From 1a3540a767a4c5b566c54adaeaf411645f046ba7 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 2 Nov 2024 13:28:55 +0800 Subject: [PATCH] :bug: Fix HTML block pasting https://github.com/siyuan-note/siyuan/issues/12994 --- app/src/protyle/util/paste.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index 940367c48..9b4829021 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -388,7 +388,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven tempElement.querySelectorAll('[contenteditable="false"][spellcheck]').forEach((e) => { e.setAttribute("contenteditable", "true"); }); - const tempInnerHTML = tempElement.innerHTML; + let tempInnerHTML = tempElement.innerHTML; if (!nodeElement.classList.contains("av") && tempInnerHTML.startsWith("[[{") && tempInnerHTML.endsWith("}]]")) { try { const json = JSON.parse(tempInnerHTML); @@ -401,6 +401,10 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven insertHTML(tempInnerHTML, protyle, isBlock); } } else { + if (tempInnerHTML.indexOf("NodeHTMLBlock")) { + // 复制 HTML 块粘贴出来的不是 HTML 块 https://github.com/siyuan-note/siyuan/issues/12994 + tempInnerHTML = Lute.UnEscapeHTMLStr(tempInnerHTML); + } insertHTML(tempInnerHTML, protyle, isBlock, false, true); } filterClipboardHint(protyle, protyle.lute.BlockDOM2StdMd(tempInnerHTML));