Skip to content

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

:bug: Preserve embed focus when undoing leading line breaks https://github.com/siyuan-note/siyuan/issues/13869

Daniel2c61b47efa09
diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts
index 2cf93a9b94..1121c95e67 100644
--- a/app/src/protyle/wysiwyg/enter.ts
+++ b/app/src/protyle/wysiwyg/enter.ts
@@ -227,6 +227,7 @@ export const enter = async (blockElement: HTMLElement, range: Range, protyle: IP
// 段首换行
if (editableElement.textContent !== "" && range.toString() === "" && position.start === 0) {
+ const undoFocusContext = getUndoFocusContext(protyle.wysiwyg.element, range);
let newElement;
const previousBlockElement = getPreviousBlockSibling(blockElement);
if (previousBlockElement?.getAttribute("data-type") === "NodeHeading" &&
@@ -246,6 +247,7 @@ export const enter = async (blockElement: HTMLElement, range: Range, protyle: IP
const undoOperations: IOperation[] = [{
action: "delete",
id: newId,
+ context: undoFocusContext,
}];
if (blockElement.parentElement.classList.contains("sb") &&
blockElement.parentElement.getAttribute("data-sb-layout") === "col") {