Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/9521

Vanessab8bd2b2059a8
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts
index 33c1d13ea2..8b0e8d2dce 100644
--- a/app/src/protyle/wysiwyg/remove.ts
+++ b/app/src/protyle/wysiwyg/remove.ts
@@ -344,12 +344,14 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
range.insertNode(document.createElement("wbr"));
}
blockParentElement.insertAdjacentElement("beforebegin", blockElement);
+ // 跳过 sb__resize 手柄取前一个块,避免超级块内引述块首删除时 previousID 为手柄导致位置错
+ const previousID = getPreviousBlockSibling(blockElement)?.getAttribute("data-node-id");
if (isCallout ? blockParentElement.querySelector(".callout-content").childElementCount === 0 :
blockParentElement.childElementCount === 1) {
transaction(protyle, [{
action: "move",
id: blockElement.getAttribute("data-node-id"),
- previousID: blockElement.previousElementSibling?.getAttribute("data-node-id"),
+ previousID,
parentID: getParentBlock(blockParentElement).getAttribute("data-node-id") || protyle.block.parentID
}, {
action: "delete",
@@ -358,7 +360,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
action: "insert",
id: blockParentElement.getAttribute("data-node-id"),
data: blockParentElement.outerHTML,
- previousID: blockElement.previousElementSibling?.getAttribute("data-node-id"),
+ previousID,
parentID: getParentBlock(blockElement).getAttribute("data-node-id") || protyle.block.parentID
}, {
action: "move",
@@ -370,7 +372,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
transaction(protyle, [{
action: "move",
id: blockElement.getAttribute("data-node-id"),
- previousID: blockElement.previousElementSibling?.getAttribute("data-node-id"),
+ previousID,
parentID: getParentBlock(blockParentElement).getAttribute("data-node-id") || protyle.block.parentID
}], [{
action: "move",
@@ -378,6 +380,11 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
parentID: blockParentElement.getAttribute("data-node-id")
}]);
}
+ // 引述块移出/删除后,若所在容器是超级块则刷新拖拽手柄(清残留)
+ const sbAncestor = getParentBlock(blockElement);
+ if (sbAncestor?.classList.contains("sb")) {
+ refreshSbResize(sbAncestor);
+ }
if (type === "Delete") {
moveToPrevious(blockElement, range, true);
} else {