Skip to content

Commit

Permalink
🔖 v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Achuan-2 committed Nov 19, 2024
1 parent 1d52954 commit 322c3bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ TODO
- [ ] 支持数字编号
- [ ] 思路:添加一个命令,把当前文档的脚注转化为数字编号,考虑到思源的动态加载机制,应该是把当前文档导出kramdown文本,直接对kramdown进行处理。注意,导出kramdown需要用span样式(https://github.com/siyuan-note/siyuan/issues/13183)
1. 首先先用正则搜索形如`<sup>((20241118190709-lx2usll "注"))</sup>{: style="--memo: 1"}`的块引,根据搜索,获取每个被引用的块id,考虑到可能会存在重复,只考虑这个id在整个文档第一次出现的顺序进行排序。排序后将块引中的`"注"`改为单引号包裹的对应块id的序号(思源笔记kramdown语法单引号代表动态锚文本)。
2. 然后用设置属性api,添加命名,并把脚注引用变为动态锚文本(块引由原来的s改为d),应该就可以实现了
2. 把脚注引用变为动态锚文本(块引由原来的s改为d)
- [ ] 需要改进下如何做到选择同一文本,如果已经有脚注了,脚注块引应该放在最后,而不是放在最前
- [ ] 用protyle.insert 插入块引
- [ ] 用protyle.insert 插入块引(不需要了,因为插入块引不需要有选中文本,用setInlineMark就行)
- [ ] 需要获取range的位置,然后根据位置判断是否有脚注,如果有脚注,就插入在脚注后面
- [ ] 不过也可以选中全部文本,插入脚注,不过获取的selection文本需要排除已经添加的脚注,这样更简单一点,也更加自由,只需要对selection文本进行处理,这个应该是好处理的
- [ ] 如果选中的文本末尾不包含脚注,则应该新增的脚注要放在所有脚注后面,如果选中的文本末尾包含脚注,就直接放到当前选中文本的后面,这样就非常自由
- [ ] 优化导出到微信公众号
- [ ] 去除脚注块引锚文本,只保留导出
- [ ] 不导出脚注内容,只显示思源的脚注
Expand Down
4 changes: 4 additions & 0 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
![](https://fastly.jsdelivr.net/gh/Achuan-2/PicBed/assets/PixPin_2024-11-18_16-39-18-2024-11-18.png)


支持对同一个文本进行多次备注

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

## 🙏致谢

* [https://github.com/zxhd863943427/siyuan-plugin-memo](https://github.com/zxhd863943427/siyuan-plugin-memo):基于该插件进行改进,添加了更多功能和配置项
Expand Down
6 changes: 1 addition & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,8 @@ export default class PluginMemo extends Plugin {
let range = protyle.toolbar.range;

// 将range的起始点和结束点都移动到选中文本的末尾
const str = ""
const textNode = document.createTextNode(str);
range.collapse(false);
protyle.toolbar.range.insertNode(textNode);
protyle.toolbar.range.setEndAfter(textNode);
protyle.toolbar.range.setStartBefore(textNode);


// 添加块引,同时添加上标样式
protyle.toolbar.setInlineMark(protyle, "clear", "toolbar");
Expand Down

0 comments on commit 322c3bd

Please sign in to comment.