فهرست منبع

:art: https://github.com/siyuan-note/siyuan/issues/8234

Vanessa 10 ماه پیش
والد
کامیت
7c12d293ee
2فایلهای تغییر یافته به همراه4 افزوده شده و 15 حذف شده
  1. 4 5
      app/src/dialog/processSystem.ts
  2. 0 10
      app/src/protyle/wysiwyg/transaction.ts

+ 4 - 5
app/src/dialog/processSystem.ts

@@ -151,11 +151,10 @@ export const setRefDynamicText = (data: {
     "rootID": string
     "rootID": string
 }) => {
 }) => {
     getAllEditor().forEach(item => {
     getAllEditor().forEach(item => {
-        if (item.protyle.block.rootID === data.rootID) {
-           const refElement = item.protyle.wysiwyg.element.querySelector(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`);
-           if (refElement) {
-               refElement.innerHTML = data.refText;
-           }
+        // 不能对比 rootId,否则潜入块中的锚文本无法更新
+        const refElement = item.protyle.wysiwyg.element.querySelector(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`);
+        if (refElement) {
+            refElement.innerHTML = data.refText;
         }
         }
     })
     })
 }
 }

+ 0 - 10
app/src/protyle/wysiwyg/transaction.ts

@@ -109,8 +109,6 @@ const promiseTransaction = () => {
                 }
                 }
                 // 当前编辑器中更新嵌入块
                 // 当前编辑器中更新嵌入块
                 updateEmbed(protyle, operation);
                 updateEmbed(protyle, operation);
-                // 更新块引用
-                updateRef(protyle, operation.id);
                 return;
                 return;
             }
             }
             if (operation.action === "delete" || operation.action === "append") {
             if (operation.action === "delete" || operation.action === "append") {
@@ -230,8 +228,6 @@ const promiseTransaction = () => {
                 //         blockRender(protyle, item);
                 //         blockRender(protyle, item);
                 //     }
                 //     }
                 // });
                 // });
-                // 更新块引用
-                updateRef(protyle, operation.id);
             }
             }
         });
         });
 
 
@@ -328,8 +324,6 @@ const updateBlock = (updateElements: Element[], protyle: IProtyle, operation: IO
     blockRender(protyle, updateElements.length === 1 ? updateElements[0] : protyle.wysiwyg.element);
     blockRender(protyle, updateElements.length === 1 ? updateElements[0] : protyle.wysiwyg.element);
     // 更新 ws 嵌入块
     // 更新 ws 嵌入块
     updateEmbed(protyle, operation);
     updateEmbed(protyle, operation);
-    // 更新 ws 块引用
-    updateRef(protyle, operation.id);
 };
 };
 
 
 // 用于推送和撤销
 // 用于推送和撤销
@@ -433,8 +427,6 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
         } else { // updateElements 没有包含嵌入块,在悬浮层编辑嵌入块时,嵌入块也需要更新
         } else { // updateElements 没有包含嵌入块,在悬浮层编辑嵌入块时,嵌入块也需要更新
             // 更新 ws 嵌入块
             // 更新 ws 嵌入块
             updateEmbed(protyle, operation);
             updateEmbed(protyle, operation);
-            // 更新 ws 块引用
-            updateRef(protyle, operation.id);
         }
         }
         return;
         return;
     }
     }
@@ -691,8 +683,6 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
                 wbrElement.remove();
                 wbrElement.remove();
             }
             }
         });
         });
-        // 更新 ws 块引用
-        updateRef(protyle, operation.id);
         return;
         return;
     }
     }
     if (operation.action === "append") {
     if (operation.action === "append") {