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")});