Parcourir la source

:bug: 另外如果绑定块的过程新建了行,并速度比它快就会在前面

Vanessa il y a 1 an
Parent
commit
bfbfbaea3e
1 fichiers modifiés avec 12 ajouts et 4 suppressions
  1. 12 4
      app/src/protyle/hint/index.ts

+ 12 - 4
app/src/protyle/hint/index.ts

@@ -414,6 +414,10 @@ ${genHintItemHTML(item)}
             if (!cellElement) {
                 return;
             }
+            const rowElement = hasClosestByClassName(cellElement, "av__row");
+            if (!rowElement) {
+                return;
+            }
             const previousID = cellElement.dataset.blockId;
             const avID = nodeElement.getAttribute("data-av-id");
             let tempElement = document.createElement("div");
@@ -422,23 +426,26 @@ ${genHintItemHTML(item)}
             if (value.startsWith("((newFile ") && value.endsWith(`${Lute.Caret}'))`)) {
                 const fileNames = value.substring(11, value.length - 4).split(`"${Constants.ZWSP}'`);
                 const realFileName = fileNames.length === 1 ? fileNames[0] : fileNames[1];
+                const newID = Lute.NewNodeID();
+                rowElement.dataset.id = newID;
                 getSavePath(protyle.path, protyle.notebookId, (pathString) => {
                     fetchPost("/api/filetree/createDocWithMd", {
                         notebook: protyle.notebookId,
                         path: pathPosix().join(pathString, realFileName),
                         parentID: protyle.block.rootID,
-                        markdown: ""
-                    }, response => {
+                        markdown: "",
+                        id: newID,
+                    }, () => {
                         transaction(protyle, [{
                             action: "replaceAttrViewBlock",
                             avID,
                             previousID,
-                            nextID: response.data,
+                            nextID: newID,
                             isDetached: false,
                         }], [{
                             action: "replaceAttrViewBlock",
                             avID,
-                            previousID: response.data,
+                            previousID: newID,
                             nextID: previousID,
                             isDetached: true,
                         }]);
@@ -446,6 +453,7 @@ ${genHintItemHTML(item)}
                 });
             } else {
                 const sourceId = tempElement.getAttribute("data-id");
+                rowElement.dataset.id = sourceId;
                 transaction(protyle, [{
                     action: "replaceAttrViewBlock",
                     avID,