Skip to content

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

:bug: Restore the caret after undoing list shortcut insertion https://github.com/siyuan-note/siyuan/issues/14123

Daniela231376bdaf2
diff --git a/app/src/protyle/wysiwyg/list.ts b/app/src/protyle/wysiwyg/list.ts
index 4fa1247617..9b72337030 100644
--- a/app/src/protyle/wysiwyg/list.ts
+++ b/app/src/protyle/wysiwyg/list.ts
@@ -162,13 +162,13 @@ export const insertEmptyListItem = async (protyle: IProtyle, listItemElement: HT
const newListItemElement = genListItemElement(listItemElement, 0, true);
const id = newListItemElement.getAttribute("data-node-id");
+ const undoFocusContext = getUndoFocusContext(protyle.wysiwyg.element, range, true);
if (listElement.classList.contains("protyle-wysiwyg")) {
if (insertingFocusedListItems.has(protyle)) {
return;
}
insertingFocusedListItems.add(protyle);
try {
- const undoFocusContext = getUndoFocusContext(protyle.wysiwyg.element, range, true);
const orderOperations = await getFocusedOrderedListUpdates(protyle, listItemElement);
if (!listItemElement.isConnected) {
return;
@@ -195,7 +195,7 @@ export const insertEmptyListItem = async (protyle: IProtyle, listItemElement: HT
const oldHTML = listElement.outerHTML;
listItemElement.insertAdjacentElement("afterend", newListItemElement);
updateListOrder(listElement);
- updateTransaction(protyle, listElement, oldHTML);
+ updateTransaction(protyle, listElement, oldHTML, undoFocusContext);
focusByWbr(newListItemElement, range);
scrollCenter(protyle, newListItemElement);
};