From d9535ea5410ff0c2289b81fab6dcadc5d6919650 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 15 Jan 2026 22:36:00 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/12139 --- app/src/protyle/util/selection.ts | 1 + app/src/protyle/wysiwyg/remove.ts | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 40e505de0..ae65e2523 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -582,6 +582,7 @@ export const focusByWbr = (element: Element, range: Range) => { range.collapse(true); wbrElement.remove(); focusByRange(range); + return range; }; export const focusByRange = (range: Range) => { diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index a7018094b..a3de32fcf 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -271,14 +271,22 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang return; } - const isCallout = blockElement.parentElement.classList.contains("callout-content"); - if (!blockElement.previousElementSibling && - (blockType !== "NodeHeading" || (blockType === "NodeHeading" && type === "Delete")) && - (blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote" || isCallout)) { + let isCallout = blockElement.parentElement.classList.contains("callout-content"); + if (type === "Delete") { + const bqCaElement = hasClosestByClassName(blockElement, "bq") || hasClosestByClassName(blockElement, "callout"); + if (bqCaElement) { + isCallout = bqCaElement.classList.contains("callout"); + blockElement = isCallout ? bqCaElement.querySelector(".callout-content").firstElementChild : bqCaElement.firstElementChild; + } + } + const blockParentElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement; + if (!blockElement.previousElementSibling && (blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote" || isCallout) && ( + (type !== "Delete" && blockType !== "NodeHeading") || + (type === "Delete" && blockParentElement.parentElement.classList.contains("protyle-wysiwyg")) + )) { if (type !== "Delete") { range.insertNode(document.createElement("wbr")); } - const blockParentElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement; blockParentElement.insertAdjacentElement("beforebegin", blockElement); if (isCallout ? blockParentElement.querySelector(".callout-content").childElementCount === 0 : blockParentElement.childElementCount === 1) { @@ -327,6 +335,13 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang removeLi(protyle, blockElement, range, type === "Delete"); return; } + if (type === "Delete") { + const liElement = hasClosestByClassName(blockElement, "li"); + if (liElement) { + removeLi(protyle, liElement.firstElementChild.nextElementSibling, range, true); + return; + } + } const previousElement = getPreviousBlock(blockElement) as HTMLElement; // 设置 bq 和代码块光标 // 需放在列表处理后 https://github.com/siyuan-note/siyuan/issues/11606