Selaa lähdekoodia

:art: fix https://github.com/siyuan-note/siyuan/issues/11843

Vanessa 1 vuosi sitten
vanhempi
commit
904b9faf8c
2 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. 6 3
      app/src/layout/dock/Outline.ts
  2. 2 1
      app/src/util/Tree.ts

+ 6 - 3
app/src/layout/dock/Outline.ts

@@ -375,18 +375,21 @@ export class Outline extends Model {
         }
         }
         let needReload = false;
         let needReload = false;
         const ops = data.data.sources[0];
         const ops = data.data.sources[0];
-        ops.doOperations.forEach((item: IOperation) => {
+        ops.doOperations.find((item: IOperation) => {
             if ((item.action === "update" || item.action === "insert") &&
             if ((item.action === "update" || item.action === "insert") &&
                 (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`<div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div>`) > -1)) {
                 (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`<div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div>`) > -1)) {
                 needReload = true;
                 needReload = true;
+                return true
             } else if (item.action === "delete" || item.action === "move") {
             } else if (item.action === "delete" || item.action === "move") {
                 needReload = true;
                 needReload = true;
+                return true;
             }
             }
         });
         });
-        if (ops.undoOperations) {
-            ops.undoOperations.forEach((item: IOperation) => {
+        if (!needReload && ops.undoOperations) {
+            ops.undoOperations.find((item: IOperation) => {
                 if (item.action === "update" && item.data.indexOf('data-type="NodeHeading"') > -1) {
                 if (item.action === "update" && item.data.indexOf('data-type="NodeHeading"') > -1) {
                     needReload = true;
                     needReload = true;
+                    return true;
                 }
                 }
             });
             });
         }
         }

+ 2 - 1
app/src/util/Tree.ts

@@ -84,6 +84,7 @@ export class Tree {
                 style = `padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px`;
                 style = `padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px`;
             }
             }
             const showArrow = hasChild || (item.type === "backlink" && !isMobile());
             const showArrow = hasChild || (item.type === "backlink" && !isMobile());
+            // data-id 需要添加 item.id,否则大纲更新时 name 不一致导致 https://github.com/siyuan-note/siyuan/issues/11843
             html += `<li class="b3-list-item${isMobile() ? "" : " b3-list-item--hide-action"}" 
             html += `<li class="b3-list-item${isMobile() ? "" : " b3-list-item--hide-action"}" 
 ${item.id ? 'data-node-id="' + item.id + '"' : ""} 
 ${item.id ? 'data-node-id="' + item.id + '"' : ""} 
 ${item.box ? 'data-notebook-id="' + item.box + '"' : ""} 
 ${item.box ? 'data-notebook-id="' + item.box + '"' : ""} 
@@ -93,7 +94,7 @@ data-type="${item.nodeType}"
 data-subtype="${item.subType}" 
 data-subtype="${item.subType}" 
 ${item.label ? "data-label='" + item.label + "'" : ""}>
 ${item.label ? "data-label='" + item.label + "'" : ""}>
     <span style="${style}" class="b3-list-item__toggle${showArrow ? " b3-list-item__toggle--hl" : ""}${showArrow ? "" : " fn__hidden"}">
     <span style="${style}" class="b3-list-item__toggle${showArrow ? " b3-list-item__toggle--hl" : ""}${showArrow ? "" : " fn__hidden"}">
-        <svg data-id="${encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow${hasChild ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
+        <svg data-id="${item.id || encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow${hasChild ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
     </span>
     </span>
     ${iconHTML}
     ${iconHTML}
     <span class="b3-list-item__text ariaLabel" data-position="parentE"${titleTip}>${item.name}</span>
     <span class="b3-list-item__text ariaLabel" data-position="parentE"${titleTip}>${item.name}</span>