langzhou / siyuan-note

思源笔记美化教程
182 stars 37 forks source link

refactor: 使用 API 操纵块 #11

Closed Zuoqiu-Yingyi closed 2 years ago

Zuoqiu-Yingyi commented 2 years ago

image

  1. 使用如下样式显示文章末各评论的时间
    .protyle-wysiwyg div[data-node-id][custom-quote-time]::before {
    content: attr(custom-quote-time);
    font-size: 12px;
    }
  2. 使用自定义块属性 custom-quote-type 的属性值区分不用元素, 在 config.js 文件中定义
    • custom-quote-type="heading": 四级标题 #### 批注
    • custom-quote-type="container": 超级块, 作为原文引用回链+同一个位置所有评论的容器
    • custom-quote-type="quote": 引述块, 含有原文引用回链
    • custom-quote-type="comment": 段落块, 表示一个评论 组合体如下所示:
      
      #### 批注
      {: id="20220317040230-qunfkb8" custom-quote-type="heading"}

{{{row

工作空间 {: id="20220317040230-jeeix7a"} {: id="20220317040230-5vt7jsh" custom-quote-id="20220317025713-ue0o3ss" custom-quote-type="quote"}

测试1 {: id="20220317040230-n318wqr" custom-quote-id="20220317025713-ue0o3ss" custom-quote-type="comment" custom-quote-time="2022-03-17 03:02:02"}

测试2 {: id="20220317040230-lq71ov8" custom-quote-id="20220317025713-ue0o3ss" custom-quote-type="comment" custom-quote-time="2022-03-17 03:02:13"}

}}} {: id="20220317040230-00ohj3s" custom-quote-id="20220317025713-ue0o3ss" custom-quote-type="container"}

{{{row

文件夹 {: id="20220317040230-nde27nx"} {: id="20220317040230-wusa12y" custom-quote-id="20220317040148-zj909c5" custom-quote-type="quote"}

测试3 {: id="20220317040230-clkp0b8" custom-quote-id="20220317040148-zj909c5" custom-quote-type="comment" custom-quote-time="2022-03-17 04:01:48"}

测试4 {: id="20220317040230-y76z60h" custom-quote-id="20220317040148-zj909c5" custom-quote-type="comment" custom-quote-time="2022-03-17 04:01:52"}

}}} {: id="20220317040230-i4jyzg7" custom-quote-id="20220317040148-zj909c5" custom-quote-type="container"}


3. 根据 D 大的建议, 不直接操纵 DOM 树, 改为使用 API 插入/删除块