From 975775f95c14ecf96e8d3f9194b0df75956afdae Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 6 Aug 2022 09:42:11 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20```=E7=BB=A7=E7=BB=AD=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/wysiwyg/input.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts index b0ab97385..732300d5f 100644 --- a/app/src/protyle/wysiwyg/input.ts +++ b/app/src/protyle/wysiwyg/input.ts @@ -41,9 +41,10 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: } const wbrElement = document.createElement("wbr"); range.insertNode(wbrElement); + let id = blockElement.getAttribute("data-node-id"); if (type !== "NodeCodeBlock" && (editElement.innerHTML.endsWith("\n") || editElement.innerHTML.endsWith("\n\n"))) { // 软换行 - updateTransaction(protyle, blockElement.getAttribute("data-node-id"), blockElement.outerHTML, blockElement.outerHTML.replace("\n", "")); + updateTransaction(protyle, id, blockElement.outerHTML, blockElement.outerHTML.replace("\n", "")); wbrElement.remove(); return; } @@ -66,10 +67,10 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: } else if ((editElement.textContent.startsWith("```") || editElement.textContent.startsWith("···") || editElement.textContent.startsWith("~~~")) && editElement.innerHTML.indexOf("\n") === -1 && editElement.textContent.replace(/·|~/g, "`").replace(/^`{3,}/g, "").indexOf("`") === -1) { // ```test` 后续处理,```test 不处理 + updateTransaction(protyle, id, blockElement.outerHTML, protyle.wysiwyg.lastHTMLs[id]); wbrElement.remove(); return; } - let id = blockElement.getAttribute("data-node-id"); const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref"); if (refElement && refElement.getAttribute("data-subtype") === "d") { const response = await fetchSyncPost("/api/block/getRefText", {id: refElement.getAttribute("data-id")});