From cfe11c944c1e87507f9127b4469f8bf9b43dccb5 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 31 Aug 2022 21:57:12 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5770 --- app/src/protyle/util/paste.ts | 14 ++------------ app/src/protyle/util/selection.ts | 4 +++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index ee9a2a8e9..18e9bfe98 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -178,18 +178,8 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html); focusByWbr(protyle.wysiwyg.element, range); } else { - nodeElement.insertAdjacentHTML("afterend", code); - const codeElement = nodeElement.nextElementSibling as HTMLElement; - transaction(protyle, [{ - action: "insert", - data: codeElement.outerHTML, - id: codeElement.getAttribute("data-node-id"), - previousID: id - }], [{ - action: "delete", - id: codeElement.getAttribute("data-node-id") - }]); - highlightRender(codeElement); + insertHTML(code, protyle, true); + highlightRender(protyle.wysiwyg.element); } } else { let isHTML = false; diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index a6e7e2b7f..995426bcb 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -507,7 +507,9 @@ export const focusSideBlock = (updateElement: Element) => { if (updateElement.getAttribute("data-node-id")) { let sideBlockElement; let collapse; - if (updateElement.nextElementSibling) { + if (updateElement.nextElementSibling && + !updateElement.nextElementSibling.classList.contains("protyle-attr") // 用例 https://ld246.com/article/1661928364696 + ) { collapse = true; sideBlockElement = getNextBlock(updateElement) as HTMLElement; } else if (updateElement.previousElementSibling) {