Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/15483

Vanessa1edd35029ec3
diff --git a/app/src/boot/globalEvent/command/panel.ts b/app/src/boot/globalEvent/command/panel.ts
index 0ffef3b531..a98bea2f38 100644
--- a/app/src/boot/globalEvent/command/panel.ts
+++ b/app/src/boot/globalEvent/command/panel.ts
@@ -23,6 +23,7 @@ import {globalCommand} from "./global";
import {getDisplayName, getNotebookName, getTopPaths, movePathTo, moveToPath, pathPosix} from "../../../util/pathName";
import {hintMoveBlock} from "../../../protyle/hint/extend";
import {fetchSyncPost} from "../../../util/fetch";
+import {focusByRange} from "../../../protyle/util/selection";
export const commandPanel = (app: App) => {
const range = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : undefined;
@@ -41,7 +42,12 @@ export const commandPanel = (app: App) => {
<kbd>${window.siyuan.languages.enterKey}/${window.siyuan.languages.click}</kbd> ${window.siyuan.languages.confirm}
<kbd>Esc</kbd> ${window.siyuan.languages.close}
</div>
-</div>`
+</div>`,
+ destroyCallback() {
+ if (range) {
+ focusByRange(range);
+ }
+ },
});
dialog.element.setAttribute("data-key", Constants.DIALOG_COMMANDPANEL);
const listElement = dialog.element.querySelector("#commands");
diff --git a/app/src/config/index.ts b/app/src/config/index.ts
index 0f372ab87c..84c82e3671 100644
--- a/app/src/config/index.ts
+++ b/app/src/config/index.ts
@@ -20,6 +20,7 @@ import {publish} from "./publish";
import {App} from "../index";
import {isHuawei, isInHarmony} from "../protyle/util/compatibility";
import {Constants} from "../constants";
+import {focusByRange} from "../protyle/util/selection";
/// #endif
export const genItemPanel = (type: string, containerElement: Element, app: App) => {
@@ -107,6 +108,10 @@ export const openSetting = (app: App) => {
if (exitDialog) {
return exitDialog;
}
+ let range: Range;
+ if (getSelection().rangeCount > 0) {
+ range = getSelection().getRangeAt(0);
+ }
const dialog = new Dialog({
content: `<div class="fn__flex-1 fn__flex config__panel" style="overflow: hidden;position: relative">
<ul class="b3-tab-bar b3-list b3-list--background">
@@ -152,6 +157,11 @@ export const openSetting = (app: App) => {
</div>`,
width: "90vw",
height: "90vh",
+ destroyCallback() {
+ if (range) {
+ focusByRange(range);
+ }
+ },
});
dialog.element.setAttribute("data-key", Constants.DIALOG_SETTING);