Skip to content

Commit

Permalink
🔖v1.0.4 / 2024.11.20
Browse files Browse the repository at this point in the history
- ✨ 脚注内容默认模板完善,用kramdown语法设置边框样式
    ```markdown
    {{{row
    > ${selection}

    ${content}
    }}}
    {: style="border: 2px dashed var(--b3-theme-on-background);"}
    ```
- ✨脚注块引默认模板完善,从“注”改为“[注]”
- 📝完善文档
  • Loading branch information
Achuan-2 committed Nov 20, 2024
1 parent ad6bb06 commit 46465c9
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 39 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ TODO
- [ ] 自定义选中文本的样式
- [ ] 参考<https://github.com/zxhd863943427/siyuan-plugin-memo>,添加css样式


## v1.0.4 / 2024.11.20
- ✨ 脚注内容默认模板完善,用kramdown语法设置边框样式
```markdown
{{{row
> ${selection}

${content}
}}}
{: style="border: 2px dashed var(--b3-theme-on-background);"}
```
- ✨脚注块引默认模板完善,从“注”改为“[注]”
- 📝完善文档

## v1.0.3 / 2024.11.19

- ✨ 脚注块引用自定义属性custom-footnote实现,不用style
Expand Down
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@

## ✨Features

Implement footnotes and remarks using SiYuan's blockref.
Implement footnotes and remarks function using SiYuan's blockref.

![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/思源笔记脚注插件2-2024-11-18.gif)
![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/%E6%80%9D%E6%BA%90%E7%AC%94%E8%AE%B0%E8%84%9A%E6%B3%A8%E6%8F%92%E4%BB%B62-2024-11-18.gif)

> Using the Tsundoku theme for demonstration, the style of nested blockquote has been optimized.
## 📝Usage Instructions

The requirement of SiYuan minAppVersion:v3.1.12
> The minimum required version of Siyuan Notes for this plugin is v3.1.12.
**Settings**

- **Footnote Location**: You can set the storage location to be in the current document or a specified document. The default is `Current Document`.
- **Selected Text Style**: You can choose styles such as bold, highlight, italic, or underline for the selected text. The default style is `None`.
- **Order of Inserting Footnotes**: ascending or descending order. The default is `ascending `.
- **Order of Inserting Footnotes**: ascending or descending order. The default is `Ascending` .
- **Footnote Title**: Set the title for storing footnotes. The default is `Footnote`.
- **Footnote Anchor Text**: Set the anchor text for footnote references. The default is `Footnote`.
- **Footnote Template**: Set the template for footnotes. It is recommended to use a blockquote or superblock combination to ensure the input content belongs to the same block. `${selection}` represents the content of the selected text, and `${content}` represents the placeholder for footnote content.
- **Footnote Anchor Text**: Set the anchor text for footnote references. The default is `[Footnote]`.
- **Footnote Template**: Set the template for footnotes. It is recommended to use a blockquote or superblock combination to ensure the input content belongs to the same block. `${selection}` represents the content of the selected text, and `${content}` represents the placeholder for footnote content. And you can use kramdown syntax to define block styles.

- **Nested Quote Block Template**

```markdown
Expand All @@ -35,22 +35,30 @@ The requirement of SiYuan minAppVersion:v3.1.12

${content}
}}}
{: style="border: 2px dashed var(--b3-theme-on-background);"}
```





![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/PixPin_2024-11-18_16-23-41-2024-11-18.png)

To simultaneously delete footnote references and footnote content, you can right-click on the footnote reference and select [Plugin - Delete Footnote] from the menu.
![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/PixPin_2024-11-18_16-24-25-2024-11-18.png)
To simultaneously delete footnote references and footnote content, you can right-click on the footnote reference and select `[Plugin -> Delete Footnote]` from the menu.

![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/PixPin_2024-11-18_16-24-25-2024-11-18.png)

## 🙏 Acknowledge
## 📝CHANGELOG

- https://github.com/zxhd863943427/siyuan-plugin-memo
- https://github.com/siyuan-note/plugin-sample-vite-svelte
See [CHANGELOG.md](CHANGELOG.md)

## 🙏 Acknowledge

- [https://github.com/zxhd863943427/siyuan-plugin-memo](https://github.com/zxhd863943427/siyuan-plugin-memo)
- [https://github.com/siyuan-note/plugin-sample-vite-svelte](https://github.com/siyuan-note/plugin-sample-vite-svelte)

## ❤️ Donation

A poor graduate student in the process of studying. If you like my plugin, feel free to buy me a pack of spicy strips. This will motivate me to continue improving this plugin and developing new ones.

![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/20241118182532-2024-11-18.png)
16 changes: 10 additions & 6 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
## 📝使用介绍

思源笔记最低版本要求:v3.1.12
> 思源笔记使用本插件的版本要求:>v3.1.12
**本插件支持高度自定义化,支持的设置如下:**

- **脚注存放位置**:可以设置存放在当前文档或者指定文档,默认为`当前文档`
- **选中文本的样式**:可以为选中文本添加加粗、高亮、斜体、下划线样式,默认:`无样式`
- **插入脚注的顺序**:顺序或者倒序,默认:`顺序`
- **脚注标题**:设置存放脚注的标题名,默认:`脚注`
- **脚注块引锚文本**:设置脚注引用的锚文本,默认:``
- **脚注内容模板**:设置脚注的模板,推荐使用引述块或超级块组合,保证脚注内容属于同一个块,`${selection}`表示选中文本的内容,`${content}`代表脚注内容占位
- **脚注标题名**:设置存放脚注的标题名,默认:`脚注`
- **脚注块引锚文本**:设置脚注引用的锚文本,默认:`[注]`
- **脚注内容模板**:设置脚注的模板,推荐使用引述块或超级块组合,保证脚注内容属于同一个块,`${selection}`表示选中文本的内容,`${content}`代表脚注内容占位。可以使用kramdown语法设置块样式。

- 嵌套引述块模板

Expand All @@ -26,15 +26,15 @@
>>
> 💡${content}
```

- 竖向超级块组合模板
- 竖向超级块组合模板,添加虚线框样式

```markdown
{{{row
> ${selection}

${content}
}}}
{: style="border: 2px dashed var(--b3-theme-on-background);"}
```

![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/PixPin_2024-11-18_16-46-42-2024-11-18.png)
Expand All @@ -48,6 +48,10 @@

![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/思源笔记脚注插件支持对同一个文本进行多次备注-2024-11-19.gif)

## 📝更新日志

见[CHANGELOG.md](CHANGELOG.md)

## 🙏致谢

* [https://github.com/zxhd863943427/siyuan-plugin-memo](https://github.com/zxhd863943427/siyuan-plugin-memo):基于该插件进行改进,添加了更多功能和配置项
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "siyuan-plugin-blockref-footnote",
"author": "Achuan-2",
"url": "https://github.com/Achuan-2/siyuan-plugin-blockref-footnote",
"version": "1.0.3",
"version": "1.0.4",
"minAppVersion": "3.1.12",
"backends": [
"windows",
Expand Down
4 changes: 2 additions & 2 deletions public/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"footnoteBlockref": {
"title": "Footnote Blockref Anchor Text",
"description": "Custom anchor text",
"value": "Footnote"
"value": "[Footnote]"
},
"template": {
"title": "Footnote Template",
"description": "<code>${selection}</code> for selected text, <code>${content}</code> for footnote content"
"description": "<code>${selection}</code> for selected text, <code>${content}</code> for footnote content, You can use kramdown syntax to define block styles."
}
},
"deleteFootnote": "Delete Footnote",
Expand Down
6 changes: 3 additions & 3 deletions public/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"desc": "逆序"
},
"footnoteTitle":{
"title": "脚注标题",
"title": "脚注标题名",
"description": "脚注会存放在h2标题下",
"value": "脚注"

},
"footnoteBlockref": {
"title": "脚注块引锚文本",
"description": "自定义锚文本",
"value": ""
"value": "[注]"
},
"template": {
"title": "脚注内容模版",
"description": "<code>${selection}</code>为选中文本的内容,<code>${content}</code>为脚注内容占位"
"description": "<code>${selection}</code>为选中文本的内容,<code>${content}</code>为脚注内容占位,可以使用kramdown语法设置块样式"
}
},
"deleteFootnote": "删除脚注",
Expand Down
27 changes: 13 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ export default class PluginFootnote extends Plugin {
});
this.settingUtils.addItem({
key: "templates",
value: `{{{ row
value: `{{{row
> \${selection}
>
💡\${content}
}}}`,
\${content}
}}}
{: style="border: 2px dashed var(--b3-theme-on-background);"}}`,
type: "textarea",
title: this.i18n.settings.template.title,
description: this.i18n.settings.template.description,
Expand All @@ -166,11 +167,6 @@ export default class PluginFootnote extends Plugin {
await this.settingUtils.load(); //导入配置并合并


// const frontEnd = getFrontend();

// this.isMobile = frontEnd === "mobile" || frontEnd === "browser-mobile";


this.eventBus.on("open-menu-blockref", this.deleteMemo.bind(this)); // 注意:事件回调函数中的 this 指向发生了改变。需要bind
}

Expand Down Expand Up @@ -263,7 +259,7 @@ export default class PluginFootnote extends Plugin {
if (this.settingUtils.get("save_location") == 2) {
// 获取当前文档的标题
let currentDocTitle = (await sql(`SELECT * FROM blocks AS b WHERE id = '${protyle.block.id}' limit 1`))[0].content;
footnoteTitle = currentDocTitle +" "+ footnoteTitle;
footnoteTitle = currentDocTitle + " " + footnoteTitle;
}
headingID = (await appendBlock("markdown", `
## ${footnoteTitle}`, docID))[0].doOperations[0].id;
Expand All @@ -277,20 +273,19 @@ export default class PluginFootnote extends Plugin {
// 获取当前文档的标题
let currentDocTitle = (await sql(`SELECT * FROM blocks AS b WHERE id = '${protyle.block.id}' limit 1`))[0].content;
// updateBlock for h2
await updateBlock("markdown", "## "+currentDocTitle + " " + this.settingUtils.get("footnoteTitle"), headingID);
await updateBlock("markdown", "## " + currentDocTitle + " " + this.settingUtils.get("footnoteTitle"), headingID);
await setBlockAttrs(headingID, { "custom-plugin-footnote-parent": protyle.block.id })

}

}


// 获取脚注模板并替换为具体变量值
// 获取脚注模板并替换为具体变量值
const selection = await navigator.clipboard.readText(); // 获取选中文本
// 过滤掉脚注文本 <sup>((id "text"))</sup>
const cleanSelection = selection.replace(/<sup>\(\([^)]+\)\)<\/sup>/g, '');
console.log(cleanSelection);
// console.log(cleanSelection);
let templates = this.settingUtils.get("templates");
templates = templates.replace(/\$\{selection\}/g, cleanSelection);
templates = templates.replace(/\$\{content\}/g, zeroWhite);
Expand All @@ -304,6 +299,7 @@ export default class PluginFootnote extends Plugin {
back = await appendBlock("markdown", templates, headingID);
break;
default:
// 默认顺序插入
if (children.length > 0) {
// 在最后一个子块后面添加(使用 insertBlock 并指定 previousID)
back = await insertBlock(
Expand Down Expand Up @@ -342,10 +338,13 @@ export default class PluginFootnote extends Plugin {
memoELement.setAttribute("custom-footnote", "true");
}

// 保存
// 保存脚注块引添加的自定义属性值
saveViaTransaction(memoELement)

// 关闭工具栏
protyle.toolbar.element.classList.add("fn__none")

// 显示块引浮窗,来填写内容
this.addFloatLayer({
ids: [newBlockId],
defIds: [],
Expand Down
2 changes: 1 addition & 1 deletion src/libs/setting-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class SettingUtils {
case 'textarea':
let textareaElement: HTMLTextAreaElement = document.createElement('textarea');
textareaElement.className = "b3-text-field fn__block";
textareaElement.rows = 5;
textareaElement.rows = 6;
textareaElement.value = item.value;
textareaElement.onchange = item.action?.callback ?? (() => { });
itemElement = textareaElement;
Expand Down

0 comments on commit 46465c9

Please sign in to comment.