From e2d89fa2b47fc87abfaee78b82f68e15c90b1819 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 25 Jun 2024 16:23:10 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/11732 --- app/src/protyle/wysiwyg/remove.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index 86b94464e..ade0cfeba 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -246,8 +246,24 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran // 设置 bq 和代码块光标 // 需放在列表处理后 https://github.com/siyuan-note/siyuan/issues/11606 if (["NodeCodeBlock", "NodeTable", "NodeAttributeView"].includes(blockType)) { - if (blockElement.previousElementSibling) { - focusBlock(blockElement.previousElementSibling, undefined, false); + const previousElement = getPreviousBlock(blockElement) + if (previousElement) { + if (previousElement.classList.contains("p") && getContenteditableElement(previousElement).textContent === "") { + const ppElement = getPreviousBlock(previousElement) + transaction(protyle, [{ + action: "delete", + id: previousElement.getAttribute("data-node-id"), + }], [{ + action: "insert", + data: previousElement.outerHTML, + id: previousElement.getAttribute("data-node-id"), + parentID: protyle.block.parentID, + previousID: ppElement ? ppElement.getAttribute("data-node-id") : undefined + }]); + previousElement.remove(); + } else { + focusBlock(previousElement, undefined, false); + } } return; }