Skip to content

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

:art: Add focus handling for paste actions in content menu and toolbar (#16190)

Jeffrey Chenaf26096dbb26
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index c02fc2dbc6..0845ca487b 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -825,6 +825,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
icon: "iconPaste",
accelerator: "⌘V",
async click() {
+ focusByRange(getEditorRange(nodeElement));
if (document.queryCommandSupported("paste")) {
document.execCommand("paste");
} else {
@@ -850,6 +851,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
id: "pasteEscaped",
label: window.siyuan.languages.pasteEscaped,
click() {
+ focusByRange(getEditorRange(nodeElement));
pasteEscaped(protyle, nodeElement);
}
}).element);
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 406f217939..7998617e60 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -1685,6 +1685,7 @@ ${item.name}
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
this.subElement.classList.add("fn__none");
} else if (action === "paste") {
+ focusByRange(getEditorRange(nodeElement));
if (document.queryCommandSupported("paste")) {
document.execCommand("paste");
} else {
@@ -1708,6 +1709,7 @@ ${item.name}
pasteAsPlainText(protyle);
this.subElement.classList.add("fn__none");
} else if (action === "pasteEscaped") {
+ focusByRange(getEditorRange(nodeElement));
pasteEscaped(protyle, nodeElement);
this.subElement.classList.add("fn__none");
} else if (action === "back") {