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: Preserve code block selection when undoing Tab indentation https://github.com/siyuan-note/siyuan/issues/14722
Daniel87992cd25959
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 676ff4e90a..70a154500f 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -190,7 +190,7 @@"tabStartup": "页签","configGroupMarkdownBlockSyntax": "Markdown 块级语法","codeBlockMiddleDot": "中点代码块快捷输入",- "codeBlockMiddleDotTip": "启用后,输入 <code class='fn__code'>···</code> 并按回车或继续输入中点时将转换为代码块",+ "codeBlockMiddleDotTip": "启用后输入 <code class='fn__code'>···</code> 并按回车或继续输入中点时将转换为代码块","foldChildHeadings": "折叠/展开直接子标题","foldSiblingHeadings": "折叠/展开同级标题","copyViewMirror": "复制视图镜像",diff --git a/app/src/protyle/wysiwyg/codeBlock.ts b/app/src/protyle/wysiwyg/codeBlock.tsindex bbe542447b..4731c955af 100644--- a/app/src/protyle/wysiwyg/codeBlock.ts+++ b/app/src/protyle/wysiwyg/codeBlock.ts@@ -1,5 +1,5 @@import {getContenteditableElement} from "./getBlock";-import {focusByOffset, getSelectionOffset, setLastNodeRange} from "../util/selection";+import {focusByOffset, getSelectionOffset, getUndoFocusContext, setLastNodeRange} from "../util/selection";import {updateTransaction} from "./transaction";import {Constants} from "../../constants";import {@@ -21,6 +21,7 @@ export const tabCodeBlock = (protyle: IProtyle, nodeElement: HTMLElement,if (!editableElement) {return;}+ const undoFocusContext = getUndoFocusContext(protyle.wysiwyg.element, range, true);const tabSpace = getCodeBlockTabSpace(nodeElement);const oldHTML = nodeElement.outerHTML;if (range.collapsed) {@@ -47,7 +48,7 @@ export const tabCodeBlock = (protyle: IProtyle, nodeElement: HTMLElement,range.setStartAfter(textNode);range.collapse(true);}- updateTransaction(protyle, nodeElement, oldHTML);+ updateTransaction(protyle, nodeElement, oldHTML, undoFocusContext);return;}@@ -93,6 +94,6 @@ export const tabCodeBlock = (protyle: IProtyle, nodeElement: HTMLElement,const brElement = wbrElement.parentElement.querySelector("br");setLastNodeRange(brElement.previousSibling as Element, range, false);brElement.remove();- updateTransaction(protyle, nodeElement, oldHTML);+ updateTransaction(protyle, nodeElement, oldHTML, undoFocusContext);wbrElement.remove();};