An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prevent repeated deletion during block merging https://github.com/siyuan-note/siyuan/issues/11248
Daniele83f674a2f04
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 996b981572..7f7293b1f1 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -273,6 +273,7 @@ const getRangeListItemElements = (editorElement: HTMLElement, range: Range) => {};export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {+ let forwardBlockRemovalPending = false;editorElement.addEventListener("keydown", async (event: KeyboardEvent & { target: HTMLElement }) => {if (event.target.localName === "protyle-html" || event.target.localName === "input") {event.stopPropagation();@@ -1223,6 +1224,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {// 不可使用 !event.shiftKey,否则 https://ld246.com/article/1666434796806if ((!event.altKey && (event.key === "Backspace" || event.key === "Delete")) ||matchHotKey("⌃D", event)) {+ if (forwardBlockRemovalPending) {+ event.stopPropagation();+ event.preventDefault();+ return;+ }const rangeCheckTargets = !range.collapsed && endElement ?getRangeBlockRefCheckTargets(protyle.wysiwyg.element, range, nodeElement, endElement, true) :{elements: [], exactIDs: [], deletedIDs: []};@@ -1382,8 +1388,20 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {(getContenteditableElement(nextBlockElement).textContent == "\n") || nextBlockElement.parentElement.classList.contains("li")))) {// 反向删除合并为一个块时,光标应保持在尾部 https://github.com/siyuan-note/siyuan/issues/14290#issuecomment-2849810529- cloneRange.insertNode(document.createElement("wbr"));- removeBlock(protyle, nextBlockElement, nextRange, "Delete");+ const caretElement = document.createElement("wbr");+ cloneRange.insertNode(caretElement);+ focusByWbr(nodeElement, cloneRange, true);+ event.stopPropagation();+ event.preventDefault();+ forwardBlockRemovalPending = true;+ try {+ await removeBlock(protyle, nextBlockElement, nextRange, "Delete");+ } finally {+ forwardBlockRemovalPending = false;+ if (caretElement.isConnected) {+ focusByWbr(nodeElement, cloneRange);+ }+ }}}event.stopPropagation();