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/15308

Vanessa4c2c4b4a7231
diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts
index 20da0f8eda..6e9670e2dd 100644
--- a/app/src/plugin/API.ts
+++ b/app/src/plugin/API.ts
@@ -27,6 +27,8 @@ import {getAllEditor} from "../layout/getAll";
import {openSetting} from "../config";
import {openAttr, openFileAttr} from "../menus/commonMenuItem";
import {globalCommand} from "../boot/globalEvent/command/global";
+import {exportLayout} from "../layout/util";
+import {saveScroll} from "../protyle/scroll/saveScroll";
let openTab;
let openWindow;
@@ -195,6 +197,21 @@ const openAttributePanel = (options: {
}
};
+const saveLayout = (cb: () => void) => {
+ /// #if MOBILE
+ if (window.siyuan.mobile.editor) {
+ const result = saveScroll(window.siyuan.mobile.editor.protyle);
+ if (cb && result instanceof Promise) {
+ result.then(() => {
+ cb();
+ });
+ }
+ }
+ /// #else
+ exportLayout({cb, errorExit: false});
+ /// #endif
+};
+
export const API = {
adaptHotkey: updateHotkeyTip,
confirm: confirmDialog,
@@ -223,5 +240,6 @@ export const API = {
platformUtils,
openSetting,
openAttributePanel,
+ saveLayout,
globalCommand,
};