An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/16051
Vanessa83fdc0f31bb7
diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex 28900f91b7..22c4d72662 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -19,7 +19,7 @@ import {Constants} from "../../constants";import {scrollCenter} from "../../util/highlightById";import {isMobile} from "../../util/functions";import {mathRender} from "../render/mathRender";-import {hasClosestByClassName} from "../util/hasClosest";+import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";import {getInstanceById} from "../../layout/util";import {Tab} from "../../layout/Tab";import {Backlink} from "../../layout/dock/Backlink";@@ -131,7 +131,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rangdata,id,previousID,- parentID: topElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID+ parentID: (hasClosestBlock(topElement.parentElement) as HTMLElement)?.getAttribute("data-node-id") || protyle.block.parentID});if (topElement.getAttribute("data-subtype") === "o" && topElement.classList.contains("li")) {listElement = topElement.parentElement;@@ -240,7 +240,8 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang}const blockParentElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement;blockParentElement.insertAdjacentElement("beforebegin", blockElement);- if (isCallout ? blockParentElement.querySelector(".callout-content").childElementCount === 0:blockParentElement.childElementCount === 1 ) {+ if (isCallout ? blockParentElement.querySelector(".callout-content").childElementCount === 0 :+ blockParentElement.childElementCount === 1) {transaction(protyle, [{action: "move",id: blockElement.getAttribute("data-node-id"),@@ -352,7 +353,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rangreturn;}- const parentElement = blockElement.parentElement;+ const parentElement = hasClosestBlock(blockElement.parentElement);const editableElement = getContenteditableElement(blockElement);const previousLastElement = getLastBlock(previousElement) as HTMLElement;if (range.toString() === "" && isMobile() && previousLastElement && previousLastElement.classList.contains("hr") && getSelectionOffset(editableElement).start === 0) {@@ -394,7 +395,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang}];blockElement.remove();// 取消超级块- if (parentElement.getAttribute("data-type") === "NodeSuperBlock" && parentElement.childElementCount === 2) {+ if (parentElement && parentElement.getAttribute("data-type") === "NodeSuperBlock" && parentElement.childElementCount === 2) {const sbData = await cancelSB(protyle, parentElement);transaction(protyle, doOperations.concat(sbData.doOperations), sbData.undoOperations.concat(undoOperations));} else {@@ -427,7 +428,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rangid: removeId,// 不能使用 previousLastElement,否则在超级块下的元素前删除撤销错误previousID: blockElement.previousElementSibling?.getAttribute("data-node-id"),- parentID: parentElement.getAttribute("data-node-id")+ parentID: parentElement ? parentElement.getAttribute("data-node-id") : protyle.block.parentID}];const doOperations: IOperation[] = [{action: "delete",@@ -502,7 +503,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rangid: previousId,});}- if (parentElement.getAttribute("data-type") === "NodeSuperBlock" && parentElement.childElementCount === 2) {+ if (parentElement && parentElement.getAttribute("data-type") === "NodeSuperBlock" && parentElement.childElementCount === 2) {const sbData = await cancelSB(protyle, parentElement);transaction(protyle, doOperations.concat(sbData.doOperations), sbData.undoOperations.concat(undoOperations));} else {