|
3 | 3 | * @Author : Yp Z
|
4 | 4 | * @Date : 2023-07-29 15:17:15
|
5 | 5 | * @FilePath : /src/rules.ts
|
6 |
| - * @LastEditTime : 2024-06-15 15:46:33 |
| 6 | + * @LastEditTime : 2024-11-17 18:32:47 |
7 | 7 | * @Description :
|
8 | 8 | */
|
9 | 9 | import { showMessage, fetchPost } from "siyuan";
|
@@ -255,10 +255,17 @@ class DocBacklinks extends MatchRule {
|
255 | 255 | let resultIds = [];
|
256 | 256 | for (let backlink of backlinks) {
|
257 | 257 | backlink.backlinks.forEach((item) => {
|
258 |
| - if (item?.blockPaths) { |
259 |
| - const blockPaths = item.blockPaths; |
260 |
| - //这个 API 挺好的地方在于会自动处理 li&p 问题 |
261 |
| - resultIds.push(blockPaths[blockPaths.length - 1].id); |
| 258 | + // if (item?.blockPaths) { |
| 259 | + // const blockPaths = item.blockPaths; |
| 260 | + // //这个 API 挺好的地方在于会自动处理 li&p 问题 |
| 261 | + // resultIds.push(blockPaths[blockPaths.length - 1].id); |
| 262 | + // } |
| 263 | + if (item.dom) { |
| 264 | + const html = item.dom; |
| 265 | + const ele = document.createElement('div'); |
| 266 | + ele.innerHTML = html; |
| 267 | + const id = ele.firstElementChild.getAttribute('data-node-id'); |
| 268 | + resultIds.push(id); |
262 | 269 | }
|
263 | 270 | });
|
264 | 271 | }
|
@@ -307,9 +314,16 @@ class DocBackmentions extends MatchRule {
|
307 | 314 | let resultIds = [];
|
308 | 315 | for (let backmention of backmentions) {
|
309 | 316 | backmention.backmentions.forEach((item) => {
|
310 |
| - if (item?.blockPaths) { |
311 |
| - const blockPaths = item.blockPaths; |
312 |
| - resultIds.push(blockPaths[blockPaths.length - 1].id); |
| 317 | + // if (item?.blockPaths) { |
| 318 | + // const blockPaths = item.blockPaths; |
| 319 | + // resultIds.push(blockPaths[blockPaths.length - 1].id); |
| 320 | + // } |
| 321 | + if (item.dom) { |
| 322 | + const html = item.dom; |
| 323 | + const ele = document.createElement('div'); |
| 324 | + ele.innerHTML = html; |
| 325 | + const id = ele.firstElementChild.getAttribute('data-node-id'); |
| 326 | + resultIds.push(id); |
313 | 327 | }
|
314 | 328 | });
|
315 | 329 | }
|
|
0 commit comments