-
[css] 可折叠的标题自动编号
2025-06-21 14:05感谢佬的代码,不过代码在我的电脑上没有正确生效,所有的一级标题的编号都是 1,所以使用 ai 修改了一下代码,代码如下:
/* ================= 标题自动编号模块 ================= */ body { counter-reset: h1-count; } h1, .h1 { counter-increment: h1-count; counter-reset: h2-count; } h2, .h2 { counter-increment: h2-count; counter-reset: h3-count; } h3, .h3 { counter-increment: h3-count; counter-reset: h4-count; } h4, .h4 { counter-increment: h4-count; counter-reset: h5-count; } h5, .h5 { counter-increment: h5-count; counter-reset: h6-count; } /* 通用计数器样式 */ .protyle-wysiwyg [data-node-id][class^="h"] div:first-child:before, .b3-typography h1:before, .b3-typography h2:before, .b3-typography h3:before, .b3-typography h4:before, .b3-typography h5:before, .b3-typography h6:before { display: inline-block !important; float: none; margin-right: 8px; font-size: 100%; opacity: 1 !important; /* 强制显示防止折叠隐藏 */ } /* 层级式编号生成规则 */ .protyle-wysiwyg [data-node-id].h1 div:first-child:before, .b3-typography h1:before { content: counter(h1-count) "\00A0"; } .protyle-wysiwyg [data-node-id].h2 div:first-child:before, .b3-typography h2:before { content: counter(h1-count) "." counter(h2-count) "\00A0"; } .protyle-wysiwyg [data-node-id].h3 div:first-child:before, .b3-typography h3:before { content: counter(h1-count) "." counter(h2-count) "." counter(h3-count) "\00A0"; } .protyle-wysiwyg [data-node-id].h4 div:first-child:before, .b3-typography h4:before { content: counter(h1-count) "." counter(h2-count) "." counter(h3-count) "." counter(h4-count) "\00A0"; } .protyle-wysiwyg [data-node-id].h5 div:first-child:before, .b3-typography h5:before { content: counter(h1-count) "." counter(h2-count) "." counter(h3-count) "." counter(h4-count) "." counter(h5-count) "\00A0"; font-size: 90% !important; } .protyle-wysiwyg [data-node-id].h6 div:first-child:before, .b3-typography h6:before { content: counter(h1-count) "." counter(h2-count) "." counter(h3-count) "." counter(h4-count) "." counter(h5-count) "." counter(h6-count) "\00A0"; font-size: 85% !important; } /* ================= 标题视觉标识模块 ================= */ /* 标题颜色分级系统 */ [data-type="NodeHeading"].h1 { color: #d40045 !important; } [data-type="NodeHeading"].h2 { color: #ff7f00 !important; } [data-type="NodeHeading"].h3 { color: #66b82b !important; } [data-type="NodeHeading"].h4 { color: #093f86 !important; } [data-type="NodeHeading"].h5 { color: #340c81 !important; } /* ================= 折叠状态适配模块 ================= */ .protyle-wysiwyg [data-fold="1"] [data-node-id][class^="h"] { position: relative; padding-right: 4em !important; /* 为折叠标记留出空间 */ } -
请教有没有转换块类型的公开 API?
2024-11-11 02:54再次感谢大佬,目前我的想法是
- 通过
sql获取当前文档所有 H3 块的 blockID - 根据 h3 的 blockID 使用
getChildBlocks获取其子项的 blockID - 在 h3 前插入一个超级块
- 通过子块 ID 和 h3 的 ID,使用
moveBlock将其全部移入到超级块内
目前卡在了插入超级块的地方,
insertBlock看文档没有超级块的说明,api 路由看不懂(原谅我,比较小白 😭 ),请问有什么方法可以做到吗,可以加我 QQ1269367656,奶茶感谢 - 通过
-
请教有没有转换块类型的公开 API?
2024-11-10 23:49感谢解惑,但是现在主要是如何找到这些块让我烦恼了,我去看了下 api 文档,没找到如何遍历的方法,是要通过 sql 吗。
select * from blocks where root_id = "{rootID}" and subtype = 'h3';查找 h3 块我知道可以用 sql 的方法,但是如何查找 h3 下面的块我就不知道了,我没有找到如何查找子块的方法。h3 查询到的信息里面,我只找到了 parent_id。
{ "alias": "", "box": "20240709122503-izci9q0", "content": "税收法律关系", "created": "20241109134252", "fcontent": "", "hash": "a9de36a", "hpath": "/税法/1 税法总则", "ial": "{: custom-riff-decks=\"20230218211946-2kw8jgx\" id=\"20241109134252-kxwej5j\" updated=\"20241110000111\"}", "id": "20241109134252-kxwej5j", "length": 6, "markdown": "### <<assets/税法+上册OCR-20241109141248-pd3t00z.pdf/20241109141355-lcdh8bv \"税收法律关系\">>", "memo": "", "name": "", "parent_id": "20241110000110-vt2vkli", "path": "/20241109000531-7qk5vun/20241109003338-82wzm2b.sy", "root_id": "20241109003338-82wzm2b", "sort": 5, "subtype": "h3", "tag": "", "type": "h", "updated": "20241110000111" }