From bfbfbaea3eaa7d26f4f1a779539dadea0d70a4d4 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 13 Dec 2023 23:15:20 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=8F=A6=E5=A4=96=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=9D=97=E7=9A=84=E8=BF=87=E7=A8=8B=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E4=BA=86=E8=A1=8C=EF=BC=8C=E5=B9=B6=E9=80=9F=E5=BA=A6?= =?UTF-8?q?=E6=AF=94=E5=AE=83=E5=BF=AB=E5=B0=B1=E4=BC=9A=E5=9C=A8=E5=89=8D?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/hint/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index a240e54e4..eba81fc0f 100644 --- a/app/src/protyle/hint/index.ts +++ b/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,