Skip to content

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

:sparkles: Support independent desktop settings windows https://github.com/siyuan-note/siyuan/issues/20002

Daniel8bdac9df1951
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 8922c0a054..3ff05b692f 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "تعذّر حفظ التغييرات المعلّقة في المحرر. يرجى المحاولة مرة أخرى.",
"blockTypeParentChange": "سيؤدي هذا التحويل إلى تغيير بنية الكتلة الخارجية أو تخطيطها",
"attributePanelVisibility": "ظهور الحقل في لوحة الخصائص",
"alwaysShow": "إظهار دائمًا",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 8aa78a5669..cb4bca051c 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Ausstehende Änderungen im Editor konnten nicht gespeichert werden. Bitte erneut versuchen.",
"blockTypeParentChange": "Diese Umwandlung würde die Struktur oder das Layout des äußeren Blocks ändern",
"attributePanelVisibility": "Feldsichtbarkeit im Eigenschaftsbereich",
"alwaysShow": "Immer anzeigen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index eb0194c1e2..3f39d618ad 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Could not save pending editor changes. Please try again.",
"blockTypeParentChange": "This conversion would change the outer block structure or layout",
"attributePanelVisibility": "Attribute panel field visibility",
"alwaysShow": "Always show",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 3202f62f39..7d1b0b755f 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "No se pudieron guardar los cambios pendientes del editor. Inténtalo de nuevo.",
"blockTypeParentChange": "Esta conversión cambiaría la estructura o el diseño del bloque exterior",
"attributePanelVisibility": "Visibilidad del campo en el panel de propiedades",
"alwaysShow": "Mostrar siempre",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index aab8b00299..59bc3ace5b 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Impossible d'enregistrer les modifications en attente dans l'éditeur. Veuillez réessayer.",
"blockTypeParentChange": "Cette conversion modifierait la structure ou la disposition du bloc extérieur",
"attributePanelVisibility": "Visibilité du champ dans le panneau des propriétés",
"alwaysShow": "Toujours afficher",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 859cbe309b..74618b1686 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "לא ניתן לשמור את השינויים הממתינים בעורך. יש לנסות שוב.",
"blockTypeParentChange": "המרה זו תשנה את המבנה או הפריסה של הבלוק החיצוני",
"attributePanelVisibility": "נראות שדה בחלונית המאפיינים",
"alwaysShow": "הצג תמיד",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index b43e8ac5c7..06a6aa4ccc 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "संपादक में लंबित बदलाव सहेजे नहीं जा सके। कृपया दोबारा प्रयास करें।",
"blockTypeParentChange": "इस रूपांतरण से बाहरी ब्लॉक की संरचना या लेआउट बदल जाएगा",
"attributePanelVisibility": "गुण पैनल में फ़ील्ड की दृश्यता",
"alwaysShow": "हमेशा दिखाएँ",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 1e88778ca6..e304f04175 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Perubahan editor yang tertunda tidak dapat disimpan. Silakan coba lagi.",
"blockTypeParentChange": "Konversi ini akan mengubah struktur atau tata letak blok luar",
"attributePanelVisibility": "Visibilitas kolom di panel properti",
"alwaysShow": "Selalu tampilkan",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 48d845a738..0fc9b79fca 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Impossibile salvare le modifiche in sospeso nell'editor. Riprova.",
"blockTypeParentChange": "Questa conversione modificherebbe la struttura o la disposizione del blocco esterno",
"attributePanelVisibility": "Visibilità del campo nel pannello delle proprietà",
"alwaysShow": "Mostra sempre",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index def82c25a7..563b5d61cf 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "エディターの未保存の変更を保存できませんでした。もう一度お試しください。",
"blockTypeParentChange": "この変換は外側のブロックの構造やレイアウトを変更するため実行できません",
"attributePanelVisibility": "属性パネルのフィールド表示",
"alwaysShow": "常に表示",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index d705d9d407..bd3f8432f9 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "편집기의 저장 대기 중인 변경 사항을 저장할 수 없습니다. 다시 시도해 주세요.",
"blockTypeParentChange": "이 변환은 바깥쪽 블록의 구조나 레이아웃을 변경합니다",
"attributePanelVisibility": "속성 패널 필드 표시",
"alwaysShow": "항상 표시",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index db4f32851b..6f747f8144 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Niet-opgeslagen wijzigingen in de editor konden niet worden opgeslagen. Probeer het opnieuw.",
"blockTypeParentChange": "Deze conversie zou de structuur of indeling van het buitenste blok wijzigen",
"attributePanelVisibility": "Veldzichtbaarheid in het eigenschappenpaneel",
"alwaysShow": "Altijd tonen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 3a9a0bf770..a94174f99e 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Nie udało się zapisać oczekujących zmian w edytorze. Spróbuj ponownie.",
"blockTypeParentChange": "Ta konwersja zmieniłaby strukturę lub układ bloku zewnętrznego",
"attributePanelVisibility": "Widoczność pola w panelu właściwości",
"alwaysShow": "Zawsze pokazuj",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index b78a27b16d..73bd6e21ab 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Não foi possível salvar as alterações pendentes no editor. Tente novamente.",
"blockTypeParentChange": "Esta conversão alteraria a estrutura ou o layout do bloco externo",
"attributePanelVisibility": "Visibilidade do campo no painel de propriedades",
"alwaysShow": "Sempre mostrar",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 157521b4fc..58def0460e 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Не удалось сохранить ожидающие изменения в редакторе. Попробуйте ещё раз.",
"blockTypeParentChange": "Это преобразование изменит структуру или расположение внешнего блока",
"attributePanelVisibility": "Видимость поля в панели свойств",
"alwaysShow": "Всегда показывать",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index 512a87f57d..21703282c3 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Nepodarilo sa uložiť čakajúce zmeny v editore. Skúste to znova.",
"blockTypeParentChange": "Táto konverzia by zmenila štruktúru alebo rozloženie vonkajšieho bloku",
"attributePanelVisibility": "Viditeľnosť poľa na paneli vlastností",
"alwaysShow": "Vždy zobraziť",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index d4c8e65ff9..8697588553 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Није могуће сачувати промене на чекању у уређивачу. Покушајте поново.",
"blockTypeParentChange": "Ова конверзија би променила структуру или распоред спољног блока",
"attributePanelVisibility": "Видљивост поља у панелу својстава",
"alwaysShow": "Увек прикажи",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index bdec3c07ed..13b71291de 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "ไม่สามารถบันทึกการเปลี่ยนแปลงที่ค้างอยู่ในตัวแก้ไขได้ โปรดลองอีกครั้ง",
"blockTypeParentChange": "การแปลงนี้จะเปลี่ยนโครงสร้างหรือเค้าโครงของบล็อกภายนอก",
"attributePanelVisibility": "การแสดงฟิลด์ในแผงคุณสมบัติ",
"alwaysShow": "แสดงเสมอ",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index e709bdcf85..f2bea75738 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Düzenleyicide bekleyen değişiklikler kaydedilemedi. Lütfen tekrar deneyin.",
"blockTypeParentChange": "Bu dönüştürme dış bloğun yapısını veya düzenini değiştirir",
"attributePanelVisibility": "Özellik panelindeki alan görünürlüğü",
"alwaysShow": "Her zaman göster",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 3889db0582..390d52214c 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "Не вдалося зберегти зміни, що очікують у редакторі. Спробуйте ще раз.",
"blockTypeParentChange": "Це перетворення змінить структуру або розташування зовнішнього блоку",
"attributePanelVisibility": "Видимість поля в панелі властивостей",
"alwaysShow": "Завжди показувати",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 353037e7b7..724692d031 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "无法保存编辑器中尚未提交的修改,请重试。",
"blockTypeParentChange": "此转换会改变外层块的结构或布局",
"attributePanelVisibility": "属性面板字段可见性",
"alwaysShow": "始终显示",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 83915f6636..7dba9bd9ba 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,5 @@
{
+ "settingsPendingSaveError": "無法儲存編輯器中尚未提交的變更,請重試。",
"blockTypeParentChange": "此轉換會改變外層區塊的結構或版面配置",
"attributePanelVisibility": "屬性面板欄位可見性",
"alwaysShow": "始終顯示",
diff --git a/app/electron/main.js b/app/electron/main.js
index fc0380672a..ad0bd67a73 100644
--- a/app/electron/main.js
+++ b/app/electron/main.js
@@ -77,6 +77,8 @@ const {
const {dispatchWindowMessage} = require("./windowMessaging");
const {WindowWorkspaceRegistry, flushWindowWorkspaces} = require("./windowWorkspaces");
const {captureWindowGeometry, normalizeWindowGeometry, restoreWindowGeometry} = require("./windowGeometry");
+const {createSettingsWindows} = require("./settingsWindows");
+const {createSettingsTaskBridge} = require("./settingsTasks");
const windowWorkspaces = new WindowWorkspaceRegistry();
const {createNotebookSystemLock, prepareNotebookSystemLock} = require("./notebookSystemLock");
const {
@@ -125,6 +127,26 @@ const notebookSystemLock = createNotebookSystemLock({
});
const windowKernelTargets = new Map();
const initializedWindowIds = new Set();
+createSettingsTaskBridge({
+ ipcMain,
+ getTarget: id => getWindowKernelTarget(id),
+ getWindows: origin => BrowserWindow.getAllWindows().filter(win =>
+ initializedWindowIds.has(win.webContents.id) && windowKernelTargets.get(win.webContents.id)?.origin === origin),
+});
+const settingsWindowPolicy = createSettingsWindows({
+ ipcMain,
+ screen,
+ getTarget: id => getWindowKernelTarget(id),
+ show: win => showWindow(win),
+ log: message => writeLog(message),
+ initialize: (win, target) => {
+ remote.enable(win.webContents);
+ bindSpellcheckContextMenu(win.webContents);
+ rememberWindowKernelTarget(win, target);
+ win.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + win.webContents.userAgent;
+ windowNavigate(win, "settings", target.origin, target.mode === "remote");
+ },
+});
const pendingRemoteOpenURLs = [];
const blockDragSessions = new Map();
const blockDragWindowFocusOrder = new Map();
@@ -857,6 +879,7 @@ const windowNavigate = (currentWindow, windowType, kernelOrigin, remoteMode = fa
windowType === "app" && ["/stage/build/app/", "/check-auth"].includes(targetURL.pathname) ||
windowType === "app" && !remoteMode && targetURL.pathname === "/" ||
windowType === "window" && ["/stage/build/app/window.html", "/check-auth"].includes(targetURL.pathname) ||
+ windowType === "settings" && ["/stage/build/app/settings.html", "/check-auth"].includes(targetURL.pathname) ||
windowType === "export" && targetURL.pathname.startsWith("/export/temp/")
)) {
return;
@@ -1488,7 +1511,7 @@ const installRemoteFrontendProtocol = (target) => {
const isTargetOrigin = requestURL?.origin === target.origin;
const requestPathname = requestURL?.pathname || "/";
const localDocumentRequest = isTargetOrigin && (request.method === "GET" || request.method === "HEAD") &&
- ["/check-auth", "/stage/build/app/", "/stage/build/app/window.html"].includes(requestURL.pathname);
+ ["/check-auth", "/stage/build/app/", "/stage/build/app/window.html", "/stage/build/app/settings.html"].includes(requestURL.pathname);
const localResource = isTargetOrigin && (request.method === "GET" || request.method === "HEAD")
? getLocalRemoteResource(requestURL.pathname)
: undefined;
@@ -1548,7 +1571,7 @@ const installRemoteFrontendProtocol = (target) => {
}
}
if (localDocumentRequest &&
- ["/stage/build/app/", "/stage/build/app/window.html"].includes(requestURL.pathname)) {
+ ["/stage/build/app/", "/stage/build/app/window.html", "/stage/build/app/settings.html"].includes(requestURL.pathname)) {
try {
if (!await probeRemoteKernelAuthentication(net, remoteSession, requestURL.href)) {
const authURL = new URL("/check-auth", target.origin);
@@ -2258,7 +2281,7 @@ const initMainWindow = (kernel = kernelPort, remoteAuthenticated = true) => {
try {
const responseURL = new URL(details.url);
preserveRemoteDocumentCSP = responseURL.origin === kernelTarget.origin &&
- ["/check-auth", "/stage/build/app/", "/stage/build/app/window.html"].includes(responseURL.pathname);
+ ["/check-auth", "/stage/build/app/", "/stage/build/app/window.html", "/stage/build/app/settings.html"].includes(responseURL.pathname);
} catch (error) {
preserveRemoteDocumentCSP = false;
}
@@ -4524,6 +4547,10 @@ app.on("activate", () => {
app.on("web-contents-created", (webContentsCreatedEvent, contents) => {
contents.setWindowOpenHandler((details) => {
+ const settings = settingsWindowPolicy(contents, details);
+ if (settings) {
+ return settings;
+ }
const kernelTarget = getWindowKernelTarget(contents.id);
if (kernelTarget?.mode === "remote") {
openExternalURL(details.url, true);
diff --git a/app/electron/remoteKernel.js b/app/electron/remoteKernel.js
index b3478affe2..c750e84523 100644
--- a/app/electron/remoteKernel.js
+++ b/app/electron/remoteKernel.js
@@ -128,6 +128,7 @@ const localDocumentPaths = new Set([
"/check-auth",
"/stage/build/app/",
"/stage/build/app/window.html",
+ "/stage/build/app/settings.html",
]);
const webRequestDestinations = new Map([
["mainframe", "document"],
diff --git a/app/electron/settingsTasks.js b/app/electron/settingsTasks.js
new file mode 100644
index 0000000000..09b6742dc3
--- /dev/null
+++ b/app/electron/settingsTasks.js
@@ -0,0 +1,68 @@
+// 维护任务先阻塞同一内核的原生窗口并提交待保存输入,任一窗口失败时取消任务。
+const createSettingsTaskBridge = ({ipcMain, getTarget, getWindows}) => {
+ const tasks = new Map();
+ const disabled = new Map();
+ let sequence = 0;
+ const finish = task => {
+ if (!tasks.delete(task.id)) return;
+ clearTimeout(task.timer);
+ task.owner.removeListener("destroyed", task.close);
+ for (const win of task.blockedWindows) {
+ const state = disabled.get(win);
+ if (state && --state.count === 0) {
+ disabled.delete(win);
+ if (!win.isDestroyed()) win.setEnabled(state.enabled);
+ }
+ if (!win.isDestroyed()) {
+ win.webContents.send("siyuan-send-windows", {cmd: "endSettingTask", data: task.id});
+ }
+ }
+ };
+ ipcMain.on("siyuan-settings-task-ready", (event, data) => {
+ const task = tasks.get(data?.id);
+ if (!task || event.senderFrame !== event.sender.mainFrame || !task.pending.has(event.sender.id)) return;
+ if (data.saved !== true) {
+ finish(task);
+ task.reject(new Error("Could not save pending editor input"));
+ return;
+ }
+ task.pending.delete(event.sender.id);
+ if (!task.pending.size) {
+ clearTimeout(task.timer);
+ task.resolve(task.id);
+ }
+ });
+ ipcMain.handle("siyuan-settings-task-start", (event) => {
+ const target = getTarget(event.sender.id);
+ if (!target || event.senderFrame !== event.sender.mainFrame) throw new Error("Unregistered settings task sender");
+ const windows = getWindows(target.origin).filter(win => !win.isDestroyed());
+ if (!windows.some(win => win.webContents.id === event.sender.id)) throw new Error("Settings window is not initialized");
+ return new Promise((resolve, reject) => {
+ const id = "native-" + (++sequence);
+ const task = {id, owner: event.sender, blockedWindows: new Set(), pending: new Set(windows.map(win => win.webContents.id)), resolve, reject};
+ task.close = () => { finish(task); reject(new Error("Settings task owner closed")); };
+ task.timer = setTimeout(() => { finish(task); reject(new Error("Editor preparation timed out")); }, 10000);
+ tasks.set(id, task);
+ event.sender.once("destroyed", task.close);
+ try {
+ for (const win of windows) {
+ const state = disabled.get(win) || {count: 0, enabled: win.isEnabled()};
+ state.count++;
+ disabled.set(win, state);
+ task.blockedWindows.add(win);
+ win.setEnabled(false);
+ win.webContents.send("siyuan-send-windows", {cmd: "prepareSettingTask", data: id});
+ }
+ } catch (error) {
+ finish(task);
+ reject(error);
+ }
+ });
+ });
+ ipcMain.handle("siyuan-settings-task-end", (event, id) => {
+ const task = tasks.get(id);
+ if (task?.owner === event.sender && event.senderFrame === event.sender.mainFrame) finish(task);
+ });
+};
+
+module.exports = {createSettingsTaskBridge};
diff --git a/app/electron/settingsTasks.test.js b/app/electron/settingsTasks.test.js
new file mode 100644
index 0000000000..0e0a78309c
--- /dev/null
+++ b/app/electron/settingsTasks.test.js
@@ -0,0 +1,89 @@
+const assert = require("node:assert/strict");
+const {EventEmitter} = require("node:events");
+const {test} = require("node:test");
+const {createSettingsTaskBridge} = require("./settingsTasks");
+
+const setup = () => {
+ const handlers = {};
+ const windows = [1, 2].map(id => {
+ const contents = Object.assign(new EventEmitter(), {id, mainFrame: {}, sent: [],
+ send(...args) { this.sent.push(args); }});
+ let enabled = true;
+ return {webContents: contents, isDestroyed: () => false, isEnabled: () => enabled,
+ setEnabled(value) { enabled = value; }};
+ });
+ createSettingsTaskBridge({
+ ipcMain: {handle(name, handler) { handlers[name] = handler; }, on(name, handler) { handlers[name] = handler; }},
+ getTarget: id => id === 1 || id === 2 ? {origin: "https://example.com"} : undefined,
+ getWindows: () => windows,
+ });
+ const event = id => ({sender: windows[id - 1].webContents, senderFrame: windows[id - 1].webContents.mainFrame});
+ const ready = (id, task, saved = true) => handlers["siyuan-settings-task-ready"](event(id), {id: task, saved});
+ const start = id => handlers["siyuan-settings-task-start"](event(id));
+ const end = (id, task) => handlers["siyuan-settings-task-end"](event(id), task);
+ return {handlers, windows, event, ready, start, end};
+};
+
+test("maintenance waits for every registered window and rejects subframe acknowledgments", async () => {
+ const {handlers, windows, event, ready, start, end} = setup();
+ const prepared = start(1);
+ assert.equal(windows.every(win => !win.isEnabled()), true);
+ const id = windows[0].webContents.sent[0][1].data;
+ let completed = false;
+ prepared.then(() => { completed = true; });
+ ready(1, id);
+ handlers["siyuan-settings-task-ready"]({...event(2), senderFrame: {}}, {id, saved: true});
+ await Promise.resolve();
+ assert.equal(completed, false);
+ ready(2, id);
+ assert.equal(await prepared, id);
+ end(2, id);
+ assert.equal(windows.every(win => !win.isEnabled()), true);
+ end(1, id);
+ assert.equal(windows.every(win => win.isEnabled()), true);
+});
+
+test("a failed save releases only its own block while concurrent maintenance continues", async () => {
+ const {windows, ready, start, end} = setup();
+ const first = start(1);
+ const firstID = windows[0].webContents.sent[0][1].data;
+ const second = start(2);
+ const secondID = windows[0].webContents.sent[1][1].data;
+ ready(1, firstID, false);
+ await assert.rejects(first, /Could not save/);
+ assert.equal(windows.every(win => !win.isEnabled()), true);
+ ready(1, secondID);
+ ready(2, secondID);
+ await second;
+ end(2, secondID);
+ assert.equal(windows.every(win => win.isEnabled()), true);
+});
+
+test("partial preparation failure preserves blocks owned by another task and original disabled state", async () => {
+ const {windows, ready, start, end} = setup();
+ windows[1].setEnabled(false);
+ const first = start(1);
+ const id = windows[0].webContents.sent[0][1].data;
+ ready(1, id);
+ ready(2, id);
+ await first;
+ const send = windows[0].webContents.send;
+ windows[0].webContents.send = function (...args) {
+ if (args[1].cmd === "prepareSettingTask") throw new Error("Renderer unavailable");
+ send.apply(this, args);
+ };
+ await assert.rejects(start(2), /Renderer unavailable/);
+ assert.equal(windows[0].isEnabled(), false);
+ assert.equal(windows[1].isEnabled(), false);
+ end(1, id);
+ assert.equal(windows[0].isEnabled(), true);
+ assert.equal(windows[1].isEnabled(), false);
+});
+
+test("closing a maintenance owner releases windows and rejects the pending preparation", async () => {
+ const {windows, start} = setup();
+ const prepared = start(1);
+ windows[0].webContents.emit("destroyed");
+ await assert.rejects(prepared, /owner closed/);
+ assert.equal(windows.every(win => win.isEnabled()), true);
+});
diff --git a/app/electron/settingsWindows.js b/app/electron/settingsWindows.js
new file mode 100644
index 0000000000..7fe4e43276
--- /dev/null
+++ b/app/electron/settingsWindows.js
@@ -0,0 +1,138 @@
+const {normalizeWindowGeometry, captureWindowGeometry} = require("./windowGeometry");
+
+const settingsPath = "/stage/build/app/settings.html";
+
+// 只允许已登记的内核页面打开预先授权的设置页,不改变普通链接的打开规则。
+const createSettingsWindows = ({ipcMain, screen, getTarget, initialize, show, log}) => {
+ const pending = new Map();
+ const reservations = new Map();
+ const windows = new Map();
+ const release = approved => {
+ clearTimeout(approved.timer);
+ pending.delete(approved.owner.id + ":" + approved.frameName);
+ if (reservations.get(approved.key) === approved) reservations.delete(approved.key);
+ approved.owner.removeListener("destroyed", approved.cancel);
+ if (approved.created) approved.owner.removeListener("did-create-window", approved.created);
+ };
+ const cancel = approved => {
+ release(approved);
+ if (!approved.owner.isDestroyed()) approved.owner.send("siyuan-settings-closed", approved.data.token);
+ };
+ ipcMain.on("siyuan-settings-close", (event, key) => {
+ const target = getTarget(event.sender.id);
+ if (!target || event.senderFrame !== event.sender.mainFrame || typeof key !== "string" ||
+ !/^plugin-[a-zA-Z0-9-]+$/.test(key)) return;
+ const registryKey = `${target.origin}:${event.sender.id}:${key}`;
+ const reserved = reservations.get(registryKey);
+ if (reserved) cancel(reserved);
+ const win = windows.get(registryKey);
+ if (win && !win.isDestroyed()) win.close();
+ });
+ ipcMain.handle("siyuan-settings-prepare", (event, data) => {
+ const target = getTarget(event.sender.id);
+ if (!target || event.senderFrame !== event.sender.mainFrame || !data ||
+ !/^[a-zA-Z0-9-]{1,100}$/.test(data.token) ||
+ !/^(builtin|plugin-[a-zA-Z0-9-]+)$/.test(data.key)) {
+ return {create: false};
+ }
+ let ownerURL;
+ try {
+ ownerURL = new URL(event.sender.getURL());
+ } catch {
+ return {create: false};
+ }
+ if (ownerURL.origin !== target.origin ||
+ !["/stage/build/app/", "/stage/build/app/index.html", "/stage/build/app/window.html"].includes(ownerURL.pathname)) {
+ return {create: false};
+ }
+ const key = `${target.origin}:${data.key === "builtin" ? "builtin" : event.sender.id + ":" + data.key}`;
+ const existing = windows.get(key);
+ if (existing && !existing.isDestroyed()) {
+ show(existing);
+ existing.webContents.send("siyuan-settings-command", data.command);
+ return {create: false};
+ }
+ const reserved = reservations.get(key);
+ if (reserved && reserved.expires >= Date.now() && !reserved.owner.isDestroyed()) {
+ reserved.data.command = data.command;
+ return {create: false};
+ }
+ if (reserved) cancel(reserved);
+ const url = new URL(settingsPath, target.origin);
+ url.searchParams.set("token", data.token);
+ if (target.mode === "remote") {
+ url.searchParams.set("remote", "1");
+ }
+ const frameName = "siyuan-settings-" + data.token;
+ const approved = {key, target, owner: event.sender, url: url.href, frameName, data, expires: Date.now() + 60000};
+ approved.cancel = () => cancel(approved);
+ approved.timer = setTimeout(approved.cancel, 60000);
+ approved.timer.unref();
+ event.sender.once("destroyed", approved.cancel);
+ pending.set(event.sender.id + ":" + frameName, approved);
+ reservations.set(key, approved);
+ return {create: true, url: approved.url, frameName};
+ });
+ return (contents, details) => {
+ const pendingKey = contents.id + ":" + details.frameName;
+ const approved = pending.get(pendingKey);
+ if (!approved || approved.expires < Date.now() || details.url !== approved.url ||
+ details.frameName !== approved.frameName) {
+ return undefined;
+ }
+ pending.delete(pendingKey);
+ approved.created = (win, created) => {
+ if (created.url !== approved.url) return;
+ release(approved);
+ windows.set(approved.key, win);
+ initialize(win, approved.target);
+ const close = () => { if (!win.isDestroyed()) win.destroy(); };
+ contents.once("destroyed", close);
+ win.on("closed", () => {
+ windows.delete(approved.key);
+ contents.removeListener("destroyed", close);
+ if (!contents.isDestroyed()) {
+ contents.send("siyuan-settings-closed", approved.data.token);
+ }
+ });
+ const saveGeometry = () => {
+ if (!win.isDestroyed() && !contents.isDestroyed() && approved.data.key === "builtin") {
+ contents.send("siyuan-settings-geometry", captureWindowGeometry(win));
+ }
+ };
+ for (const event of ["resize", "move", "maximize", "unmaximize", "close"]) {
+ win.on(event, saveGeometry);
+ }
+ win.webContents.once("did-finish-load", () => {
+ if (approved.data.geometry?.maximized) win.maximize();
+ win.webContents.send("siyuan-settings-command", approved.data.command);
+ });
+ win.webContents.on("did-fail-load", (_event, code, description) => {
+ if (code !== -3) log("settings window failed to load: " + description);
+ });
+ };
+ contents.on("did-create-window", approved.created);
+ return {
+ action: "allow",
+ overrideBrowserWindowOptions: {
+ title: approved.data.title || "SiYuan",
+ frame: true,
+ minWidth: 493,
+ minHeight: 376,
+ width: 1000,
+ height: 760,
+ ...normalizeWindowGeometry(approved.data.geometry, screen),
+ webPreferences: {
+ contextIsolation: false,
+ nodeIntegration: true,
+ nodeIntegrationInSubFrames: false,
+ nodeIntegrationInWorker: false,
+ webviewTag: approved.target.mode !== "remote",
+ webSecurity: approved.target.mode === "remote",
+ },
+ },
+ };
+ };
+};
+
+module.exports = {createSettingsWindows};
diff --git a/app/electron/settingsWindows.test.js b/app/electron/settingsWindows.test.js
new file mode 100644
index 0000000000..e7a6aa5fb6
--- /dev/null
+++ b/app/electron/settingsWindows.test.js
@@ -0,0 +1,96 @@
+const assert = require("node:assert/strict");
+const {EventEmitter} = require("node:events");
+const {test} = require("node:test");
+const {createSettingsWindows} = require("./settingsWindows");
+
+const setup = () => {
+ let prepare;
+ let close;
+ const shown = [];
+ const initialized = [];
+ const target = {origin: "https://example.com", mode: "remote"};
+ const owner = Object.assign(new EventEmitter(), {
+ id: 1, mainFrame: {}, getURL: () => target.origin + "/stage/build/app/", isDestroyed: () => false,
+ sent: [], send(...message) { this.sent.push(message); },
+ });
+ const policy = createSettingsWindows({
+ ipcMain: {handle: (_name, callback) => { prepare = callback; }, on: (_name, callback) => { close = callback; }},
+ screen: {}, getTarget: id => id === 1 ? target : undefined,
+ initialize: (...args) => initialized.push(args), show: win => shown.push(win), log() {},
+ });
+ const event = {sender: owner, senderFrame: owner.mainFrame};
+ const open = (data = {}) => prepare(event, {key: "builtin", token: "first-token", command: {tab: "editor"}, ...data});
+ return {policy, owner, event, open, close, shown, initialized};
+};
+
+test("settings popup authorization requires the registered top-level page and exact URL and frame", () => {
+ const {policy, owner, event, open} = setup();
+ const prepared = open();
+ assert.equal(prepared.create, true);
+ assert.equal(new URL(prepared.url).pathname, "/stage/build/app/settings.html");
+ assert.equal(new URL(prepared.url).searchParams.get("remote"), "1");
+ assert.equal(policy(owner, {url: prepared.url + "x", frameName: prepared.frameName}), undefined);
+ assert.equal(policy(owner, {url: prepared.url, frameName: "other-frame"}), undefined);
+ const allowed = policy(owner, prepared);
+ assert.equal(allowed.action, "allow");
+ assert.equal(allowed.overrideBrowserWindowOptions.frame, true);
+ assert.equal(allowed.overrideBrowserWindowOptions.parent, undefined);
+ assert.equal(allowed.overrideBrowserWindowOptions.webPreferences.webSecurity, true);
+ assert.equal(policy(owner, prepared), undefined);
+ event.senderFrame = {};
+ assert.equal(open({token: "second-token"}).create, false);
+});
+
+test("settings windows reuse their workspace instance and close with the owning renderer", () => {
+ const {policy, owner, open, shown, initialized} = setup();
+ const prepared = open();
+ assert.equal(open({token: "second-token", command: {tab: "appearance"}}).create, false);
+ policy(owner, prepared);
+ const contents = Object.assign(new EventEmitter(), {sent: [], send(...message) { this.sent.push(message); }});
+ let destroyed = false;
+ const win = Object.assign(new EventEmitter(), {
+ webContents: contents, isDestroyed: () => destroyed,
+ destroy() { destroyed = true; this.emit("closed"); },
+ });
+ owner.emit("did-create-window", win, {url: prepared.url});
+ assert.equal(initialized.length, 1);
+ contents.emit("did-finish-load");
+ assert.deepEqual(contents.sent[0], ["siyuan-settings-command", {tab: "appearance"}]);
+ assert.equal(open({token: "third-token", command: {tab: "search"}}).create, false);
+ assert.equal(shown[0], win);
+ assert.deepEqual(contents.sent[1], ["siyuan-settings-command", {tab: "search"}]);
+ owner.emit("destroyed");
+ assert.equal(destroyed, true);
+ assert.deepEqual(owner.sent.at(-1), ["siyuan-settings-closed", "first-token"]);
+ assert.equal(open({token: "fourth-token"}).create, true);
+});
+
+test("plugin windows are distinct from built-in settings and reject other origins", () => {
+ const {open, owner} = setup();
+ assert.equal(open().create, true);
+ assert.equal(open({token: "plugin-token", key: "plugin-example"}).create, true);
+ owner.getURL = () => "https://attacker.example/stage/build/app/";
+ assert.equal(open({token: "other-token", key: "plugin-other"}).create, false);
+});
+
+test("simultaneous popups initialize their own windows and canceled reservations cannot open", () => {
+ const {policy, owner, event, open, close, initialized} = setup();
+ const builtin = open();
+ const plugin = open({token: "plugin-token", key: "plugin-example"});
+ policy(owner, builtin);
+ policy(owner, plugin);
+ const create = prepared => {
+ const contents = Object.assign(new EventEmitter(), {send() {}});
+ const win = Object.assign(new EventEmitter(), {webContents: contents, isDestroyed: () => false});
+ owner.emit("did-create-window", win, {url: prepared.url});
+ return win;
+ };
+ const pluginWindow = create(plugin);
+ const builtinWindow = create(builtin);
+ assert.deepEqual(initialized.map(args => args[0]), [pluginWindow, builtinWindow]);
+ const canceled = open({token: "canceled-token", key: "plugin-other"});
+ close(event, "plugin-other");
+ assert.equal(policy(owner, canceled), undefined);
+ assert.deepEqual(owner.sent.at(-1), ["siyuan-settings-closed", "canceled-token"]);
+ assert.equal(open({token: "reopened-token", key: "plugin-other"}).create, true);
+});
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100906-0u4zfq3.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100906-0u4zfq3.sy
index eada707fd8..eda825ede2 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100906-0u4zfq3.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100906-0u4zfq3.sy
@@ -6,7 +6,7 @@
"id": "20200924100906-0u4zfq3",
"title": "Window and Tab",
"type": "doc",
- "updated": "20260925230000"
+ "updated": "20260930192450"
},
"Children": [
{
@@ -1227,6 +1227,39 @@
}
]
},
+ {
+ "ID": "20260930192450-5l394sc",
+ "Type": "NodeHeading",
+ "HeadingLevel": 3,
+ "Properties": {
+ "id": "20260930192450-5l394sc",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeHeadingC8hMarker",
+ "Data": "### "
+ },
+ {
+ "Type": "NodeText",
+ "Data": "Settings window"
+ }
+ ]
+ },
+ {
+ "ID": "20260930192450-jc5b7ix",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930192450-jc5b7ix",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "The desktop client opens settings in a separate window that can be moved, resized, and minimized. You can keep it open while scrolling, switching, and editing documents. Opening settings again focuses the existing window. Setting changes synchronize with other windows in the same workspace. Bulk cleanup of unreferenced assets or databases and settings import temporarily block interaction while they run. The browser uses a settings dialog, and mobile uses a settings page. Plugins decide whether their settings use a separate window."
+ }
+ ]
+ },
{
"ID": "20260809170000-6df6960",
"Type": "NodeHeading",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200822191536-rm6hwid.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200822191536-rm6hwid.sy
index 9d963a2a9b..53e8451178 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200822191536-rm6hwid.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200822191536-rm6hwid.sy
@@ -6,7 +6,7 @@
"id": "20200822191536-rm6hwid",
"title": "窗口和页签",
"type": "doc",
- "updated": "20260925230000"
+ "updated": "20260930192450"
},
"Children": [
{
@@ -1231,6 +1231,39 @@
}
]
},
+ {
+ "ID": "20260930192450-4myh8mr",
+ "Type": "NodeHeading",
+ "HeadingLevel": 3,
+ "Properties": {
+ "id": "20260930192450-4myh8mr",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeHeadingC8hMarker",
+ "Data": "### "
+ },
+ {
+ "Type": "NodeText",
+ "Data": "设置窗口"
+ }
+ ]
+ },
+ {
+ "ID": "20260930192450-lqv7jpo",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930192450-lqv7jpo",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "桌面客户端的设置在独立窗口中打开,可以移动、调整大小和最小化。保持设置窗口打开时,仍可滚动、切换和编辑文档。再次打开设置会聚焦已有窗口。配置修改会同步到当前工作空间的其他窗口;批量清理未引用附件、清理未引用数据库和导入配置期间会临时阻塞操作。浏览器端使用设置对话框,移动端使用设置页面。插件设置是否使用独立窗口由插件决定。"
+ }
+ ]
+ },
{
"ID": "20260809170000-705decd",
"Type": "NodeHeading",
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123216-tlxw66f.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123216-tlxw66f.sy
index ba84717c78..926f8147c3 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123216-tlxw66f.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123216-tlxw66f.sy
@@ -6,7 +6,7 @@
"id": "20211226123216-tlxw66f",
"title": "視窗和分頁",
"type": "doc",
- "updated": "20260925230000"
+ "updated": "20260930192450"
},
"Children": [
{
@@ -1231,6 +1231,39 @@
}
]
},
+ {
+ "ID": "20260930192450-1xrty7u",
+ "Type": "NodeHeading",
+ "HeadingLevel": 3,
+ "Properties": {
+ "id": "20260930192450-1xrty7u",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeHeadingC8hMarker",
+ "Data": "### "
+ },
+ {
+ "Type": "NodeText",
+ "Data": "設定視窗"
+ }
+ ]
+ },
+ {
+ "ID": "20260930192450-635bol5",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930192450-635bol5",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "桌面用戶端的設定會在獨立視窗中開啟,可以移動、調整大小及最小化。保持設定視窗開啟時,仍可捲動、切換及編輯文件。再次開啟設定會聚焦已有視窗。設定變更會同步至目前工作空間的其他視窗;批次清理未引用附件、清理未引用資料庫及匯入設定期間會暫時阻擋操作。瀏覽器版使用設定對話框,行動版使用設定頁面。外掛程式決定其設定是否使用獨立視窗。"
+ }
+ ]
+ },
{
"ID": "20260809170000-c8ab2a7",
"Type": "NodeHeading",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-7yv4y5z.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-7yv4y5z.sy
index a3d755923e..147d4b6880 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-7yv4y5z.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-7yv4y5z.sy
@@ -7,7 +7,7 @@
"id": "20240530101000-7yv4y5z",
"title": "ウィンドウとタブ",
"type": "doc",
- "updated": "20260925230000"
+ "updated": "20260930192450"
},
"Children": [
{
@@ -1236,6 +1236,39 @@
}
]
},
+ {
+ "ID": "20260930192450-sbtyvdc",
+ "Type": "NodeHeading",
+ "HeadingLevel": 3,
+ "Properties": {
+ "id": "20260930192450-sbtyvdc",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeHeadingC8hMarker",
+ "Data": "### "
+ },
+ {
+ "Type": "NodeText",
+ "Data": "設定ウィンドウ"
+ }
+ ]
+ },
+ {
+ "ID": "20260930192450-wdavx3g",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930192450-wdavx3g",
+ "updated": "20260930192450"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "デスクトップクライアントでは、設定が移動、サイズ変更、最小化できる独立したウィンドウで開きます。設定を開いたまま、ドキュメントのスクロール、切り替え、編集ができます。設定を再度開くと、既存のウィンドウにフォーカスします。設定の変更は同じワークスペースのほかのウィンドウにも反映されます。未参照の添付ファイルやデータベースの一括削除、設定のインポート中は操作が一時的にブロックされます。ブラウザー版では設定ダイアログ、モバイル版では設定ページを使用します。プラグインの設定を独立したウィンドウで開くかどうかは、各プラグインが決めます。"
+ }
+ ]
+ },
{
"ID": "20260809170000-4b69882",
"Type": "NodeHeading",
diff --git a/app/src/assets/scss/component/_dialog.scss b/app/src/assets/scss/component/_dialog.scss
index 4221620d58..7b421cf839 100644
--- a/app/src/assets/scss/component/_dialog.scss
+++ b/app/src/assets/scss/component/_dialog.scss
@@ -1,4 +1,10 @@
.b3-dialog {
+ &--window {
+ & > .b3-dialog__scrim,
+ & > .b3-dialog__container > [class^="resize__"] {
+ display: none;
+ }
+ }
position: fixed;
top: 0;
left: 0;
diff --git a/app/src/assets/template/app/settings.tpl b/app/src/assets/template/app/settings.tpl
new file mode 100644
index 0000000000..61cdb9c7e7
--- /dev/null
+++ b/app/src/assets/template/app/settings.tpl
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>SiYuan</title>
+ <link id="protyleKatexStyle" rel="stylesheet" href="../../protyle/js/katex/katex.min.css?v=0.16.9">
+</head>
+<body class="fn__flex-column body--settings">
+<div id="commonMenu" class="b3-menu fn__none">
+ <div class="b3-menu__title fn__none"><svg class="b3-menu__icon"><use xlink:href="#iconLeft"></use></svg><span class="b3-menu__label"></span></div>
+ <div class="b3-menu__items"></div>
+</div>
+<div id="message" class="b3-snackbars"></div>
+<div id="tooltip" class="tooltip fn__none"></div>
+</body>
+</html>
diff --git a/app/src/boot/globalEvent/globalShortcut.test.ts b/app/src/boot/globalEvent/globalShortcut.test.ts
index 6b43bae901..11b38eb0b2 100644
--- a/app/src/boot/globalEvent/globalShortcut.test.ts
+++ b/app/src/boot/globalEvent/globalShortcut.test.ts
@@ -29,6 +29,7 @@ const setup = (detached = false) => {
const registeredCommands: ICommand[] = [];
const document = {activeElement: {matches: () => false}};
const dependencies: Record<string, unknown> = {
+ "../../config/setting/windowContext": {getSettingsWindowHost: (): undefined => undefined},
"../../constants": {Constants: {SIYUAN_HOTKEY: "siyuan-hotkey"}},
"../../util/functions": {isWindow: () => detached},
"../../util/hotKeyPolicy": {clearDisallowedTextInputHotkey},
diff --git a/app/src/boot/globalEvent/globalShortcut.ts b/app/src/boot/globalEvent/globalShortcut.ts
index 1146e5b40c..d2294e2ce2 100644
--- a/app/src/boot/globalEvent/globalShortcut.ts
+++ b/app/src/boot/globalEvent/globalShortcut.ts
@@ -4,11 +4,18 @@ import {isWindow} from "../../util/functions";
import {clearDisallowedTextInputHotkey} from "../../util/hotKeyPolicy";
import {getKeymapBindings} from "../../util/keymapBindings";
import {syncAppMenuShortcuts} from "./commonHotkey";
+import {getSettingsWindowHost} from "../../config/setting/windowContext";
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
export const sendGlobalShortcut = (app: App) => {
+ const host = getSettingsWindowHost();
+ if (host) {
+ if (document.activeElement?.matches(".config-keymap__record, #searchByKey")) host.suspendShortcuts();
+ else host.restoreShortcuts();
+ return;
+ }
/// #if !BROWSER
if (document.activeElement?.matches(".config-keymap__record, #searchByKey")) {
sendUnregisterGlobalShortcut(app);
@@ -48,6 +55,11 @@ export const sendGlobalShortcut = (app: App) => {
};
export const sendUnregisterGlobalShortcut = (app: App) => {
+ const host = getSettingsWindowHost();
+ if (host) {
+ host.suspendShortcuts();
+ return;
+ }
/// #if !BROWSER
if (app) {
syncAppMenuShortcuts(true);
diff --git a/app/src/config/assets.ts b/app/src/config/assets.ts
index feec64a567..bf920bed55 100644
--- a/app/src/config/assets.ts
+++ b/app/src/config/assets.ts
@@ -1,4 +1,5 @@
import {escapeAttr, escapeHtml} from "../util/escape";
+import {runSettingsMaintenance} from "./setting/maintenance";
import {confirmDialog} from "../dialog/confirmDialog";
import {isBrowser, isMobile} from "../util/functions";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
@@ -171,7 +172,7 @@ const assets = {
const type = target.getAttribute("data-type");
if (target.id === "removeAll") {
confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.clearAll}`, () => {
- fetchPost("/api/asset/removeUnusedAssets", {}, response => {
+ void runSettingsMaintenance(() => fetchPost("/api/asset/removeUnusedAssets", {}, response => {
/// #if !MOBILE
getAllModels().asset.forEach(item => {
if (response.data.paths.includes(item.path)) {
@@ -181,18 +182,18 @@ const assets = {
/// #endif
assetsListElement.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
clearAssetPreview();
- });
+ }));
}, undefined, true);
event.preventDefault();
event.stopPropagation();
break;
} else if (target.id === "removeAVAll") {
confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.clearAllAV}`, () => {
- fetchPost("/api/av/removeUnusedAttributeViews", {}, () => {
+ void runSettingsMaintenance(() => fetchPost("/api/av/removeUnusedAttributeViews", {}, () => {
avListElement.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
avPreviewElement.innerHTML = "";
hideMobilePreview(avListElement, avPreviewElement);
- });
+ }));
}, undefined, true);
event.preventDefault();
event.stopPropagation();
diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts
index 01a4e64c46..b34407d474 100644
--- a/app/src/config/bazaar.ts
+++ b/app/src/config/bazaar.ts
@@ -1,4 +1,4 @@
-import {normalizeBodyGradient} from "../util/bodyGradient";
+import {refreshSettingConfig} from "./setting/sync";
import {showMessage} from "../dialog/message";
import {fetchPost} from "../util/fetch";
import {ContractFormData} from "../util/contractFormData";
@@ -14,6 +14,7 @@ import {escapeAttr, escapeHtml} from "../util/escape";
import {formatCount} from "../util/number";
import {loadPlugin, unloadPlugin} from "../plugin/loader";
import {subscribeGlobalPluginState} from "../plugin/globalState";
+import {getSettingsWindowHost} from "./setting/windowContext";
import {switchSettingPanelSubTab} from "./setting/mount";
import {isThemeFrontendSupported} from "../util/themeCompatibility";
import {
@@ -1384,7 +1385,7 @@ type="checkbox">
callback();
};
if (!enabled) {
- unloadPlugin(app, item.name).then(finish);
+ (getSettingsWindowHost()?.unloadPlugin(item.name) || unloadPlugin(app, item.name)).then(finish);
return;
}
if (window.siyuan.config.bazaar.petalDisabled) {
@@ -1392,7 +1393,7 @@ type="checkbox">
finish();
return;
}
- loadPlugin(app, response.data).then(finish, (error) => {
+ (getSettingsWindowHost()?.loadPlugin(response.data) || loadPlugin(app, response.data)).then(finish, (error) => {
console.error(error);
finish();
});
@@ -1454,14 +1455,24 @@ type="checkbox">
appearance.themeDark = "midnight";
}
}
- fetchPost("/api/setting/setAppearance", appearance, response => {
+ const previous = window.siyuan.config.appearance;
+ const patch: {icon?: string; themeLight?: string; themeDark?: string; mode?: number; modeOS?: boolean} = {};
+ for (const key of ["icon", "themeLight", "themeDark", "mode", "modeOS"] as const) {
+ if (appearance[key] !== previous[key]) {
+ Object.assign(patch, {[key]: appearance[key]});
+ }
+ }
+ if (!Object.keys(patch).length) {
+ callback();
+ return;
+ }
+ fetchPost("/api/setting/patch", {appearance: patch}, response => {
if (response.code !== 0) {
showMessage(response.msg);
callback();
return;
}
- window.siyuan.config.appearance = {...response.data, lang: appearance.lang, bodyGradient: normalizeBodyGradient(response.data.bodyGradient)};
- callback();
+ void refreshSettingConfig("appearance").then(callback);
});
},
_initBazaarPanel(bazaarType: TBazaarType, panel: HTMLElement) {
diff --git a/app/src/config/index.ts b/app/src/config/index.ts
index b3c1c2ec98..804f0667b0 100644
--- a/app/src/config/index.ts
+++ b/app/src/config/index.ts
@@ -22,9 +22,14 @@ import type {App} from "../index";
import {unmountAssetsTab} from "./assets";
import {getHostCapabilities} from "../util/hostCapabilities";
import {unmountWorkspaceStorage} from "./tabs/workspaceStorage";
+/// #if !MOBILE
+import {openNativeSettings} from "./setting/nativeWindow";
+import {isSettingsWindow} from "./setting/windowContext";
+import {fitSettingsWindowDialog} from "./setting/windowDialog";
+/// #endif
/// #if !MOBILE
-const openSettingDialog = (app: App, initialTab: TSettingTab = "editor") => {
+export const openSettingDialog = (app: App, initialTab: TSettingTab = "editor") => {
window.siyuan.dialogs.find((item) => item.element.querySelector(".config__tab-container"))?.destroy();
let range: Range;
if (getSelection().rangeCount > 0) {
@@ -77,10 +82,13 @@ const openSettingDialog = (app: App, initialTab: TSettingTab = "editor") => {
if (range) {
focusByRange(range);
}
+ if (isSettingsWindow()) {
+ window.close();
+ }
},
});
settingDialogRef.element = dialog.element;
- const disposeDrag = initSettingDrag(dialog.element);
+ const disposeDrag = isSettingsWindow() ? undefined : initSettingDrag(dialog.element);
dialog.element.setAttribute("data-key", Constants.DIALOG_SETTING);
const tabWrap = dialog.element.querySelector(".config__tab-wrap") as HTMLElement;
@@ -102,10 +110,21 @@ const openSettingDialog = (app: App, initialTab: TSettingTab = "editor") => {
});
});
switchSettingTab(dialog.element, app, initialTab);
+ if (isSettingsWindow()) {
+ fitSettingsWindowDialog(dialog);
+ }
return dialog;
};
/// #endif
+export const openPluginSetting = (app: App) => {
+ /// #if MOBILE
+ openMobileSetting(app);
+ /// #else
+ return openSettingDialog(app);
+ /// #endif
+};
+
export const openSetting = (app: App, tab?: TSettingTab) => {
if (tab === "bazaar" && !isBazaarAvailable()) {
return;
@@ -116,6 +135,19 @@ export const openSetting = (app: App, tab?: TSettingTab) => {
/// #if MOBILE
openMobileSetting(app, tab);
/// #else
+ /// #if !BROWSER
+ if (!isSettingsWindow()) {
+ void openNativeSettings(app, {tab});
+ return;
+ }
+ /// #endif
+ if (isSettingsWindow()) {
+ const dialog = window.siyuan.dialogs.find(item => item.element.getAttribute("data-key") === Constants.DIALOG_SETTING);
+ if (dialog) {
+ switchSettingTab(dialog.element, app, tab || "editor");
+ return dialog;
+ }
+ }
return openSettingDialog(app, tab);
/// #endif
};
@@ -164,6 +196,12 @@ export const openBazaarReadme = async (app: App, bazaarType: TBazaarType, itemNa
return;
}
+ /// #if !BROWSER && !MOBILE
+ if (!isSettingsWindow()) {
+ await openNativeSettings(app, {tab: "bazaar", readme: {type: bazaarType, from, resource}});
+ return;
+ }
+ /// #endif
openSetting(app, "bazaar");
await withMountedBazaar(({bazaar, renderReadme}) => {
bazaar.switchBazaarTab(app, bazaarType, from);
diff --git a/app/src/config/keymapPayload.ts b/app/src/config/keymapPayload.ts
index a905705d25..6dbc148124 100644
--- a/app/src/config/keymapPayload.ts
+++ b/app/src/config/keymapPayload.ts
@@ -35,3 +35,12 @@ export const keymapPayload = (keymap: Config.IKeymap): {[key: string]: JSONValue
plugin,
};
};
+
+// 快捷键名称可以包含点号,按原始分段构造更新对象。
+export const keymapRowPatch = (path: string[], value: JSONValue): {[key: string]: JSONValue} => {
+ let patch: {[key: string]: JSONValue} = {[path[path.length - 1]]: value};
+ for (let index = path.length - 2; index >= 0; index--) {
+ patch = {[path[index]]: patch};
+ }
+ return patch;
+};
diff --git a/app/src/config/setting/maintenance.test.ts b/app/src/config/setting/maintenance.test.ts
new file mode 100644
index 0000000000..6c0200e43f
--- /dev/null
+++ b/app/src/config/setting/maintenance.test.ts
@@ -0,0 +1,25 @@
+import * as assert from "node:assert/strict";
+import {readFileSync} from "node:fs";
+import {test} from "node:test";
+import {runInNewContext} from "node:vm";
+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";
+
+for (const code of [0, -1]) {
+ test(`maintenance flushes kernel transactions before running and releases the window block (code ${code})`, async () => {
+ const compiled = transpileModule(readFileSync("src/config/setting/maintenance.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
+ }).outputText;
+ const calls: string[] = [];
+ const dependencies = {
+ ipcRenderer: {invoke: async (channel: string) => { calls.push(channel); return "native-1"; }},
+ fetchSyncPost: async (path: string) => { calls.push(path); return {code, msg: "Save failed"}; },
+ showMessage: () => { calls.push("error"); },
+ };
+ const exports = {} as {runSettingsMaintenance: (action: () => Promise<void>) => Promise<void>};
+ runInNewContext(compiled, {exports, require: () => dependencies, console: {error() {}},
+ window: {siyuan: {languages: {settingsPendingSaveError: "Save failed"}}}});
+ await exports.runSettingsMaintenance(async () => { calls.push("action"); });
+ assert.deepEqual(calls, ["siyuan-settings-task-start", "/api/sqlite/flushTransaction",
+ code === 0 ? "action" : "error", "siyuan-settings-task-end"]);
+ });
+}
diff --git a/app/src/config/setting/maintenance.ts b/app/src/config/setting/maintenance.ts
new file mode 100644
index 0000000000..82f0627808
--- /dev/null
+++ b/app/src/config/setting/maintenance.ts
@@ -0,0 +1,24 @@
+/// #if !BROWSER && !MOBILE
+import {ipcRenderer} from "electron";
+/// #endif
+import {fetchSyncPost} from "../../util/fetch";
+import {showMessage} from "../../dialog/message";
+
+export const runSettingsMaintenance = async (action: () => Promise<void>) => {
+ let id: string;
+ try {
+ /// #if !BROWSER && !MOBILE
+ id = await ipcRenderer.invoke("siyuan-settings-task-start");
+ const flushed = await fetchSyncPost("/api/sqlite/flushTransaction", {});
+ if (flushed.code !== 0) throw new Error(flushed.msg);
+ /// #endif
+ await action();
+ } catch (error) {
+ console.error("Settings maintenance preparation failed", error);
+ showMessage(window.siyuan.languages.settingsPendingSaveError, 6000, "error");
+ } finally {
+ /// #if !BROWSER && !MOBILE
+ if (id) await ipcRenderer.invoke("siyuan-settings-task-end", id);
+ /// #endif
+ }
+};
diff --git a/app/src/config/setting/mount.test.ts b/app/src/config/setting/mount.test.ts
index da9382b517..e541c3231e 100644
--- a/app/src/config/setting/mount.test.ts
+++ b/app/src/config/setting/mount.test.ts
@@ -3,13 +3,13 @@ import {readFileSync} from "node:fs";
import {resolve} from "node:path";
import {test} from "node:test";
import {runInNewContext} from "node:vm";
-import {ModuleKind, transpileModule} from "typescript";
+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";
for (const keywords of ["", "gradient"]) {
test(`remount restores scroll after asynchronous initialization and search (keywords=${keywords})`, async () => {
const source = readFileSync(resolve(process.cwd(), "src/config/setting/mount.ts"), "utf8");
const code = transpileModule(source, {compilerOptions: {module: ModuleKind.CommonJS}}).outputText;
- const root = {innerHTML: "settings", scrollTop: 235.5, scrollLeft: 12};
+ const root = {innerHTML: "settings", scrollTop: 235.5, scrollLeft: 12, contains: () => false};
const visibleItemIds = new Set(["bodyGradient"]);
const tab = {
scanSearch: () => ({visibleItemIds}),
@@ -26,7 +26,8 @@ for (const keywords of ["", "gradient"]) {
const moduleExports: {remountOpenSettingTab?: (tabId: string) => Promise<void>} = {};
runInNewContext(code, {
exports: moduleExports,
- window: {siyuan: {dialogs: [{element: {
+ document: {activeElement: null},
+ window: {siyuan: {ws: {app: {}}, dialogs: [{element: {
getAttribute: () => "settings",
querySelector: () => root,
}}]}},
@@ -48,3 +49,29 @@ for (const keywords of ["", "gradient"]) {
assert.equal(root.scrollLeft, 12);
});
}
+
+test("all settings refreshes preserve focused inputs and remount when focus leaves", async () => {
+ const code = transpileModule(readFileSync("src/config/setting/mount.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
+ }).outputText;
+ const input = {};
+ const root = {innerHTML: "settings", scrollTop: 12, scrollLeft: 0, contains: (element: unknown) => element === input};
+ let mounted = 0;
+ let focusout: () => void;
+ const timers: Array<() => void> = [];
+ const document = {activeElement: input, addEventListener: (_name: string, callback: () => void) => { focusout = callback; }};
+ const dependencies = {Constants: {DIALOG_SETTING: "settings"}, getSearchKeywordsLower: () => "",
+ getSettingTab: () => ({mount: async () => { mounted++; }})};
+ const exports = {} as {remountOpenSettingTab: (tab: string) => Promise<void>};
+ runInNewContext(code, {exports, require: () => dependencies, document,
+ setTimeout: (callback: () => void) => timers.push(callback),
+ window: {siyuan: {ws: {app: {}}, dialogs: [{element: {getAttribute: () => "settings", querySelector: () => root}}]}}});
+ await exports.remountOpenSettingTab("appearance");
+ assert.equal(mounted, 0);
+ document.activeElement = {};
+ focusout();
+ timers.forEach(callback => callback());
+ await Promise.resolve();
+ assert.equal(mounted, 1);
+ assert.equal(root.scrollTop, 12);
+});
diff --git a/app/src/config/setting/mount.ts b/app/src/config/setting/mount.ts
index ab858227c4..8c89bf0529 100644
--- a/app/src/config/setting/mount.ts
+++ b/app/src/config/setting/mount.ts
@@ -4,6 +4,9 @@ import {Constants} from "../../constants";
import type {SettingSearchUnavailableItem, SettingTabMountContext} from "./builder";
import {getSettingTab, type TSettingTab} from "./tabs";
+const deferredTabs = new Set<TSettingTab>();
+let watchingFocus = false;
+
/** 首次挂载:渲染全部注册项并执行 afterMount */
export const mountSettingTab = async (tabId: string, root: HTMLElement) => {
const {html, items} = buildGroupedItemsView(tabId);
@@ -24,6 +27,20 @@ export const remountOpenSettingTab = async (tabId: TSettingTab) => {
if (!root?.innerHTML) {
return;
}
+ if (root.contains(document.activeElement)) {
+ deferredTabs.add(tabId);
+ if (!watchingFocus) {
+ watchingFocus = true;
+ // 离开正在输入的面板后更新控件,避免替换用户尚未提交的输入。
+ document.addEventListener("focusout", () => setTimeout(() => {
+ const tabs = [...deferredTabs];
+ deferredTabs.clear();
+ tabs.forEach(tab => { void remountOpenSettingTab(tab); });
+ }, 0));
+ }
+ return;
+ }
+ deferredTabs.delete(tabId);
const search: Partial<SettingTabMountContext> = {};
const keywords = getSearchKeywordsLower(dialogElement);
const tab = getSettingTab(tabId);
@@ -36,7 +53,7 @@ export const remountOpenSettingTab = async (tabId: TSettingTab) => {
}
// 重建和异步初始化配置项会改变内容高度,完成后恢复面板的滚动位置。
const {scrollTop, scrollLeft} = root;
- await tab.mount(root, search, undefined, true);
+ await tab.mount(root, search, window.siyuan.ws.app, true);
root.scrollTop = scrollTop;
root.scrollLeft = scrollLeft;
};
diff --git a/app/src/config/setting/nativeWindow.ts b/app/src/config/setting/nativeWindow.ts
new file mode 100644
index 0000000000..2a23e3fb5f
--- /dev/null
+++ b/app/src/config/setting/nativeWindow.ts
@@ -0,0 +1,83 @@
+/// #if !BROWSER
+import {ipcRenderer} from "electron";
+/// #endif
+import {genUUID} from "../../util/genID";
+import {setStorageVal} from "../../protyle/util/compatibility";
+import {exportLayout} from "../../layout/util";
+import {exitSiYuan} from "../../dialog/processSystem";
+import {subscribeGlobalPluginState, applyPluginReload} from "../../plugin/globalState";
+import {loadPlugin, unloadPlugin} from "../../plugin/loader";
+import {sendGlobalShortcut, sendUnregisterGlobalShortcut} from "../../boot/globalEvent/globalShortcut";
+import type {App} from "../../index";
+import type {ISettingsWindowHost} from "./windowContext";
+import type {TSettingTab} from "./tabs";
+
+export interface ISettingsCommand {
+ tab?: TSettingTab;
+ readme?: {type: TBazaarType; from: "bazaar" | "downloaded"; resource: IBazaarItem};
+}
+
+const geometryKey = "settingsWindowGeometry";
+const hosts = new Map<string, {host: ISettingsWindowHost; listener: EventListener}>();
+let listening = false;
+
+export const closeNativeSettings = (key: string) => {
+ /// #if !BROWSER
+ ipcRenderer.send("siyuan-settings-close", key);
+ /// #endif
+};
+
+export const openNativeSettings = async (app: App, command: ISettingsCommand = {},
+ plugin?: ISettingsWindowHost["plugin"], key = "builtin") => {
+ /// #if !BROWSER
+ if (!listening) {
+ listening = true;
+ window.addEventListener("unload", () => {
+ hosts.forEach(entry => entry.host.plugin?.closed());
+ });
+ ipcRenderer.on("siyuan-settings-geometry", (_event, geometry) => {
+ window.siyuan.storage[geometryKey] = geometry;
+ setStorageVal(geometryKey, geometry);
+ });
+ ipcRenderer.on("siyuan-settings-closed", (_event, token: string) => {
+ const entry = hosts.get(token);
+ if (entry) {
+ window.removeEventListener("siyuan-settings-host-" + token, entry.listener);
+ entry.host.plugin?.closed();
+ entry.host.restoreShortcuts();
+ hosts.delete(token);
+ }
+ });
+ }
+ const token = genUUID();
+ const prepared = await ipcRenderer.invoke("siyuan-settings-prepare", {
+ token, key, command, title: plugin?.name || window.siyuan.languages.config,
+ geometry: key === "builtin" ? window.siyuan.storage[geometryKey] : undefined,
+ });
+ if (!prepared.create) {
+ return;
+ }
+ if (plugin && !plugin.isOpen()) {
+ closeNativeSettings(key);
+ return;
+ }
+ const host: ISettingsWindowHost = {
+ app, exportLayout, exit: exitSiYuan, plugin,
+ suspendShortcuts: () => sendUnregisterGlobalShortcut(app),
+ restoreShortcuts: () => sendGlobalShortcut(app),
+ subscribePlugins: listener => subscribeGlobalPluginState(app, listener),
+ applyPluginReload: async data => { await applyPluginReload(app, data); },
+ loadPlugin: async data => { await loadPlugin(app, data); },
+ unloadPlugin: async name => { await unloadPlugin(app, name); },
+ };
+ const listener = ((event: CustomEvent<(host: ISettingsWindowHost) => void>) => event.detail(host)) as EventListener;
+ hosts.set(token, {host, listener});
+ window.addEventListener("siyuan-settings-host-" + token, listener);
+ const child = window.open(prepared.url, prepared.frameName);
+ if (!child) {
+ window.removeEventListener("siyuan-settings-host-" + token, listener);
+ hosts.delete(token);
+ throw new Error("Could not open the settings window");
+ }
+ /// #endif
+};
diff --git a/app/src/config/setting/sync.test.ts b/app/src/config/setting/sync.test.ts
new file mode 100644
index 0000000000..63cb42c821
--- /dev/null
+++ b/app/src/config/setting/sync.test.ts
@@ -0,0 +1,25 @@
+import * as assert from "node:assert/strict";
+import {readFileSync} from "node:fs";
+import {test} from "node:test";
+import {runInNewContext} from "node:vm";
+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";
+
+test("settings notifications update runtime configuration and refresh the registered tab", async () => {
+ const compiled = transpileModule(readFileSync("src/config/setting/sync.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
+ }).outputText;
+ const remounted: string[] = [];
+ const config = {editor: {fontSize: 16}, keymap: {}, appearance: {}};
+ const dependencies = {
+ fetchSyncPost: async () => ({code: 0, data: {conf: {editor: {fontSize: 18}, keymap: {}, appearance: {}}}}),
+ systemConfig: (value: unknown) => value, objEquals: (left: unknown, right: unknown) => JSON.stringify(left) === JSON.stringify(right),
+ editorConfigApi: {apply: (value: {fontSize: number}) => { config.editor = value; }}, appearanceConfigApi: {},
+ syncSettingTasks() {}, remountOpenSettingTab: async (tab: string) => { remounted.push(tab); },
+ getSettingTabDefs: () => [{id: "editor"}],
+ };
+ const exports = {} as {refreshSettingConfig: (namespace: string) => Promise<void>};
+ runInNewContext(compiled, {exports, require: () => dependencies, window: {siyuan: {config}}, console});
+ await exports.refreshSettingConfig("editor");
+ assert.equal(config.editor.fontSize, 18);
+ assert.deepEqual(remounted, ["editor"]);
+});
diff --git a/app/src/config/setting/sync.ts b/app/src/config/setting/sync.ts
new file mode 100644
index 0000000000..06f6b52042
--- /dev/null
+++ b/app/src/config/setting/sync.ts
@@ -0,0 +1,67 @@
+import {fetchSyncPost} from "../../util/fetch";
+import {systemConfig} from "../systemConfig";
+import {editorConfigApi} from "../tabs/editorRuntime";
+import {appearanceConfigApi} from "../tabs/appearanceRuntime";
+import {objEquals} from "../../util/functions";
+import {syncSettingTasks} from "./taskBlocker";
+/// #if !MOBILE
+import {applyKeymap} from "../tabs/keymapRuntime";
+import {remountOpenSettingTab} from "./mount";
+import {getSettingTabDefs, type TSettingTab} from "./tabs";
+/// #endif
+
+let pending = new Set<string>();
+let refreshing: Promise<void>;
+
+// 合并通知并串行读取,重连也使用同一流程,避免旧响应覆盖更新后的配置。
+export const refreshSettingConfig = (namespace = "*"): Promise<void> => {
+ pending.add(namespace);
+ if (refreshing) {
+ return refreshing;
+ }
+ refreshing = (async () => {
+ while (pending.size) {
+ const namespaces = pending;
+ pending = new Set();
+ const response = await fetchSyncPost("/api/system/getConf", {});
+ if (response.code !== 0 || !window.siyuan.config) {
+ continue;
+ }
+ const next = systemConfig(response.data.conf);
+ syncSettingTasks(response.data.settingTasks);
+ const includes = (key: string) => namespaces.has("*") || namespaces.has(key);
+ if (includes("editor") && !objEquals(window.siyuan.config.editor, next.editor)) {
+ editorConfigApi.apply(next.editor);
+ }
+ if (includes("appearance") && !objEquals(window.siyuan.config.appearance, next.appearance)) {
+ appearanceConfigApi.apply(next.appearance);
+ }
+ /// #if !MOBILE
+ if (includes("keymap") && !objEquals(window.siyuan.config.keymap, next.keymap)) {
+ applyKeymap(next.keymap);
+ }
+ /// #else
+ if (includes("keymap")) {
+ window.siyuan.config.keymap = next.keymap;
+ }
+ /// #endif
+ const simple = ["ai", "export", "fileTree", "search", "flashcard", "secrets", "variables", "sync", "repo", "system", "bazaar", "publish"] as const;
+ for (const key of simple) {
+ if (includes(key)) {
+ Object.assign(window.siyuan.config, {[key]: next[key]});
+ }
+ }
+ /// #if !MOBILE
+ const tabs: Record<string, TSettingTab> = {fileTree: "file", secrets: "secretsVariables", variables: "secretsVariables", system: "app", publish: "access"};
+ for (const namespace of namespaces.has("*") ? [...simple, "editor", "keymap", "appearance"] : namespaces) {
+ const tab = getSettingTabDefs().find(definition => definition.id === (tabs[namespace] || namespace));
+ if (tab) void remountOpenSettingTab(tab.id);
+ }
+ /// #endif
+ }
+ })().catch(error => console.error("Could not refresh settings", error)).finally(() => {
+ refreshing = undefined;
+ if (pending.size) return refreshSettingConfig();
+ });
+ return refreshing;
+};
diff --git a/app/src/config/setting/taskBlocker.test.ts b/app/src/config/setting/taskBlocker.test.ts
new file mode 100644
index 0000000000..f5288804cb
--- /dev/null
+++ b/app/src/config/setting/taskBlocker.test.ts
@@ -0,0 +1,32 @@
+import * as assert from "node:assert/strict";
+import {readFileSync} from "node:fs";
+import {resolve} from "node:path";
+import {test} from "node:test";
+import {runInNewContext} from "node:vm";
+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";
+
+test("task snapshots cannot undo newer notifications and concurrent tasks remain blocked", () => {
+ const code = transpileModule(readFileSync(resolve("src/config/setting/taskBlocker.ts"), "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
+ }).outputText;
+ const active = new Set<string>();
+ const interceptors: Array<(event: Event) => void> = [];
+ const api: {applySettingTask?: (data: object) => void; syncSettingTasks?: (data: object) => void} = {};
+ runInNewContext(code, {exports: api, window: {addEventListener: (_type: string, callback: (event: Event) => void) => interceptors.push(callback)},
+ require: () => ({progressLoading: (data: {code: number}, id: string) => {
+ if (data.code === 2) active.delete(id); else active.add(id);
+ }})});
+ api.applySettingTask({id: "1", active: true, revision: 1, message: ""});
+ api.applySettingTask({id: "2", active: true, revision: 2, message: ""});
+ api.applySettingTask({id: "1", active: false, revision: 3, message: ""});
+ api.syncSettingTasks({revision: 1, tasks: [{id: "1", active: true, message: ""}]});
+ assert.deepEqual([...active], ["setting-task-2"]);
+ let blocked = false;
+ interceptors[0]({preventDefault: () => { blocked = true; }, stopImmediatePropagation() {}} as Event);
+ assert.equal(blocked, true);
+ api.syncSettingTasks({revision: 4, tasks: []});
+ assert.equal(active.size, 0);
+ blocked = false;
+ interceptors[0]({preventDefault: () => { blocked = true; }, stopImmediatePropagation() {}} as Event);
+ assert.equal(blocked, false);
+});
diff --git a/app/src/config/setting/taskBlocker.ts b/app/src/config/setting/taskBlocker.ts
new file mode 100644
index 0000000000..9d7457867a
--- /dev/null
+++ b/app/src/config/setting/taskBlocker.ts
@@ -0,0 +1,48 @@
+import {progressLoading} from "../../dialog/processSystem";
+
+const tasks = new Set<string>();
+let revision = 0;
+let intercepting = false;
+const intercept = (event: Event) => {
+ if (!tasks.size) return;
+ event.preventDefault();
+ event.stopImmediatePropagation();
+};
+
+// 批量清理和导入期间覆盖当前前端,键盘操作也要遵守任务阻塞。
+const applyTask = (data: {id: string; active: boolean; message: string}) => {
+ if (data.active) tasks.add(data.id);
+ else tasks.delete(data.id);
+ if (!intercepting) {
+ intercepting = true;
+ ["keydown", "beforeinput", "paste", "drop", "click", "pointerdown"].forEach(type => {
+ window.addEventListener(type, intercept, {capture: true});
+ });
+ }
+ progressLoading({cmd: "progress", code: data.active ? 1 : 2, msg: data.message,
+ data: {current: 1, total: 1}}, "setting-task-" + data.id);
+};
+
+export const applySettingTask = (data: {id: string; active: boolean; message: string; revision: number}) => {
+ if (data.revision < revision) return;
+ revision = data.revision;
+ applyTask(data);
+};
+
+export const resetSettingTaskRevision = () => { revision = 0; };
+
+export const syncSettingTasks = (snapshot?: {revision: number; tasks: Array<{id: string; active: boolean; message: string}>}) => {
+ if ((snapshot?.revision || 0) < revision) return;
+ revision = snapshot?.revision || 0;
+ const current = new Set(snapshot?.tasks.map(task => task.id));
+ for (const id of tasks) {
+ if (!id.startsWith("native-") && !current.has(id)) applyTask({id, active: false, message: ""});
+ }
+ snapshot?.tasks.forEach(applyTask);
+};
+
+export const setNativeSettingTask = (id: string, active: boolean) => {
+ applyTask({id, active, message: window.siyuan.languages.loading});
+};
+
+export const hasNativeSettingTasks = () => Array.from(tasks).some(id => id.startsWith("native-"));
diff --git a/app/src/config/setting/window.ts b/app/src/config/setting/window.ts
new file mode 100644
index 0000000000..5a11e58bf6
--- /dev/null
+++ b/app/src/config/setting/window.ts
@@ -0,0 +1,174 @@
+import "../../assets/scss/base.scss";
+import {ipcRenderer, webFrame} from "electron";
+import {Constants} from "../../constants";
+import {Model} from "../../layout/Model";
+import {Menus} from "../../menus";
+import {genUUID} from "../../util/genID";
+import {fetchSyncPost} from "../../util/fetch";
+import {addBaseURL, redirectToCheckAuth, setNoteBook} from "../../util/pathName";
+import {getLocalStorage, initNativeDialogOverride, initWindowOpenOverride} from "../../protyle/util/compatibility";
+import {addScriptSync} from "../../protyle/util/addScript";
+import {loadDesktopHostConnection, initDesktopHost} from "../../boot/onGetConfig";
+import {loadLanguages} from "../../boot/loadLanguages";
+import {systemConfig} from "../systemConfig";
+import {loadAssets, setInlineStyle, initAssets, reloadInlineStyles, refreshThemeStyle} from "../../util/assets";
+import {initMessage} from "../../dialog/message";
+import {progressLoading, processSync, downloadProgress} from "../../dialog/processSystem";
+import {setSettingsWindowHost, type ISettingsWindowHost} from "./windowContext";
+import {refreshSettingConfig} from "./sync";
+import {openSettingDialog} from "../index";
+import {switchSettingTab} from "../search/dialog";
+import {withMountedBazaar} from "../bazaarTab";
+import {appearanceConfigApi, refreshAppearance} from "../tabs/appearanceRuntime";
+import {Setting} from "../../plugin/Setting";
+import {bindMenuKeydown} from "../../menus/Menu";
+import {windowMouseMove} from "../../boot/globalEvent/mousemove";
+import {hideTooltip} from "../../dialog/tooltip";
+import {applyCloudUserState} from "../tabs/accountUi";
+import {updateServerAddresses} from "../tabs/accessRuntime";
+import {installPluginStorageFetchAppId} from "../../util/fetchAppId";
+import type {Dialog} from "../../dialog";
+import type {ISettingsCommand} from "./nativeWindow";
+import {getSettingTabDefs} from "./tabs";
+import {onWindowsMsg} from "../../window/onWindowsMsg";
+
+const initialize = async () => {
+ addBaseURL();
+ const token = new URLSearchParams(location.search).get("token");
+ if (!token || !window.opener || window.opener.location.origin !== location.origin) {
+ window.close();
+ return;
+ }
+ const host = await new Promise<ISettingsWindowHost>(resolve => {
+ window.opener.dispatchEvent(new CustomEvent("siyuan-settings-host-" + token, {detail: resolve}));
+ });
+ setSettingsWindowHost(host);
+ let dialog: Dialog;
+ let command: ISettingsCommand;
+ const applyCommand = async () => {
+ if (!dialog || !command || host.plugin) return;
+ const next = command;
+ command = undefined;
+ if (next.tab) {
+ switchSettingTab(dialog.element, host.app, next.tab);
+ const url = new URL(location.href);
+ url.searchParams.set("tab", next.tab);
+ history.replaceState(null, "", url);
+ }
+ if (next.readme) {
+ const {type, from, resource} = next.readme;
+ await withMountedBazaar(({bazaar, renderReadme}) => {
+ bazaar.switchBazaarTab(host.app, type, from);
+ renderReadme(type, from, resource);
+ });
+ }
+ };
+ ipcRenderer.on("siyuan-settings-command", (_event, next: ISettingsCommand) => {
+ command = next;
+ void applyCommand();
+ });
+ const ws = new Model({app: host.app});
+ window.siyuan = {
+ zIndex: 10, isReady: false, notebooks: [], reqIds: {}, backStack: [], layout: {}, dialogs: [],
+ blockPanels: [], closedTabs: [], ctrlIsPressed: false, altIsPressed: false, ws,
+ };
+ ws.connect({id: genUUID(), type: "main", msgCallback: data => {
+ if (!data) return;
+ switch (data.cmd) {
+ case "logoutAuth": redirectToCheckAuth(); break;
+ case "settingChanged": void refreshSettingConfig(data.data.namespace); break;
+ case "setConf": void refreshSettingConfig(); break;
+ case "setAppearance": appearanceConfigApi.apply(data.data); break;
+ case "refreshAppearance": void refreshAppearance(data.data); break;
+ case "reloadInlineStyles": void reloadInlineStyles(); break;
+ case "refreshtheme": refreshThemeStyle(data.data.theme); break;
+ case "reloadPlugin": void refreshSettingConfig("bazaar"); break;
+ case "readonly": window.siyuan.config.editor.readOnly = data.data; break;
+ case "progress": progressLoading(data); break;
+ case "downloadProgress": downloadProgress(data.data); break;
+ case "syncing": processSync(data); break;
+ case "setCloudUser": applyCloudUserState(data.data.user, data.data.userName); break;
+ case "setServerAddrs": updateServerAddresses(data.data); break;
+ case "setLocalStorageVal": window.siyuan.storage[data.data.key] = data.data.val; break;
+ case "setLocalStorageVals": Object.assign(window.siyuan.storage, data.data.keyVals); break;
+ case "removeLocalStorageVal": delete window.siyuan.storage[data.data.key]; break;
+ case "removeLocalStorageVals": data.data.keys.forEach((key: string) => delete window.siyuan.storage[key]); break;
+ }
+ }});
+ const response = await fetchSyncPost("/api/system/getConf", {});
+ if (response.code !== 0) {
+ window.close();
+ return;
+ }
+ window.siyuan.config = systemConfig(response.data.conf);
+ window.siyuan.isPublish = response.data.isPublish;
+ await loadDesktopHostConnection();
+ await Promise.all([
+ setNoteBook(),
+ new Promise<void>(resolve => getLocalStorage(resolve)),
+ addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"),
+ ]);
+ await addScriptSync(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
+ await new Promise<void>(resolve => {
+ void loadLanguages(window.siyuan.config.appearance.lang, Constants.SIYUAN_VERSION, languages => {
+ window.siyuan.languages = languages;
+ resolve();
+ });
+ });
+ window.siyuan.menus = new Menus(host.app);
+ await initDesktopHost();
+ ipcRenderer.on(Constants.SIYUAN_SEND_WINDOWS, (_event, data: IWebSocketData) => onWindowsMsg(data));
+ webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
+ const user = await fetchSyncPost("/api/setting/getCloudUser", {cached: true});
+ window.siyuan.user = user.data && "userId" in user.data ? user.data : null;
+ const emoji = await fetchSyncPost("/api/system/getEmojiConf", {});
+ if (Array.isArray(emoji.data)) {
+ window.siyuan.emojis = emoji.data;
+ }
+ await loadAssets(window.siyuan.config.appearance);
+ await setInlineStyle();
+ initAssets();
+ initMessage();
+ initNativeDialogOverride();
+ initWindowOpenOverride(host.app);
+ document.title = host.plugin?.name || window.siyuan.languages.config;
+ if (host.plugin) {
+ host.plugin.mount(options => {
+ const setting = new Setting(options);
+ options.items.forEach(item => setting.addItem(item));
+ setting.open(host.plugin.name);
+ return setting.dialog;
+ });
+ } else {
+ const tab = getSettingTabDefs().find(def => def.id === new URLSearchParams(location.search).get("tab"))?.id;
+ dialog = openSettingDialog(host.app, tab);
+ dialog.element.querySelectorAll(".config__side .b3-list-item").forEach(item => {
+ item.addEventListener("click", () => {
+ const url = new URL(location.href);
+ url.searchParams.set("tab", item.getAttribute("data-name"));
+ history.replaceState(null, "", url);
+ });
+ });
+ }
+ document.addEventListener("keydown", event => {
+ if (!window.siyuan.menus.menu.element.classList.contains("fn__none") && bindMenuKeydown(event)) return;
+ if (event.key === "Escape" && !event.isComposing && !event.repeat) {
+ window.siyuan.dialogs[window.siyuan.dialogs.length - 1]?.destroy();
+ event.preventDefault();
+ }
+ });
+ window.addEventListener("mousemove", windowMouseMove);
+ window.addEventListener("blur", hideTooltip);
+ window.addEventListener("resize", () => window.siyuan.menus.menu.resetPosition());
+ window.addEventListener("unload", () => {
+ ws.ws.onclose = null;
+ ws.ws.close();
+ host.plugin?.closed();
+ });
+ window.siyuan.isReady = true;
+ ws.flushMainMessages();
+ await applyCommand();
+};
+
+installPluginStorageFetchAppId(window, Constants.SIYUAN_APPID, window.location.href);
+void initialize().catch(error => console.error("Could not initialize the settings window", error));
diff --git a/app/src/config/setting/windowContext.ts b/app/src/config/setting/windowContext.ts
new file mode 100644
index 0000000000..b5c58cb968
--- /dev/null
+++ b/app/src/config/setting/windowContext.ts
@@ -0,0 +1,28 @@
+import type {App} from "../../index";
+import type {Dialog} from "../../dialog";
+import type {IPluginReloadData} from "../../plugin/loader";
+import type {IGlobalPluginStateSnapshot} from "../../plugin/globalStateCoordinator";
+
+export interface ISettingsWindowHost {
+ app: App;
+ exportLayout: (options: {cb: () => void; errorExit: boolean}) => Promise<void>;
+ exit: (setCurrentWorkspace?: boolean) => Promise<void>;
+ subscribePlugins: (listener: (state: IGlobalPluginStateSnapshot) => void) => () => void;
+ applyPluginReload: (data: IPluginReloadData) => Promise<void>;
+ loadPlugin: (data: IPluginData) => Promise<void>;
+ unloadPlugin: (name: string) => Promise<void>;
+ suspendShortcuts: () => void;
+ restoreShortcuts: () => void;
+ plugin?: {
+ name: string;
+ isOpen: () => boolean;
+ mount: (create: (options: {width: string; height: string; items: IPluginSettingOption[];
+ confirmCallback: () => void; destroyCallback: () => void}) => Dialog) => void;
+ closed: () => void;
+ };
+}
+
+let host: ISettingsWindowHost;
+export const setSettingsWindowHost = (value: ISettingsWindowHost) => { host = value; };
+export const getSettingsWindowHost = () => host;
+export const isSettingsWindow = () => typeof document !== "undefined" && document.body.classList.contains("body--settings");
diff --git a/app/src/config/setting/windowDialog.ts b/app/src/config/setting/windowDialog.ts
new file mode 100644
index 0000000000..226ddb9a67
--- /dev/null
+++ b/app/src/config/setting/windowDialog.ts
@@ -0,0 +1,14 @@
+import type {Dialog} from "../../dialog";
+
+// 页面铺满原生窗口,内部确认框仍使用普通 Dialog 的覆盖范围和焦点管理。
+export const fitSettingsWindowDialog = (dialog: Dialog) => {
+ dialog.element.querySelector(".b3-dialog").classList.add("b3-dialog--window");
+ const container = dialog.element.querySelector<HTMLElement>(".b3-dialog__container");
+ container.style.width = "100%";
+ container.style.height = "100%";
+ container.style.maxWidth = "none";
+ container.style.left = "auto";
+ container.style.top = "auto";
+ container.setAttribute("aria-modal", "false");
+ dialog.element.querySelectorAll(".resize__move").forEach(element => element.classList.remove("resize__move"));
+};
diff --git a/app/src/config/tabs/appTab.ts b/app/src/config/tabs/appTab.ts
index baf57665bd..77bae7a05f 100644
--- a/app/src/config/tabs/appTab.ts
+++ b/app/src/config/tabs/appTab.ts
@@ -3,6 +3,7 @@ import {ipcRenderer} from "electron";
import * as path from "path";
/// #endif
import type {SettingTabBuilder} from "../setting/builder";
+import {runSettingsMaintenance} from "../setting/maintenance";
import {Constants} from "../../constants";
import {fetchPost} from "../../util/fetch";
import {ContractFormData} from "../../util/contractFormData";
@@ -453,7 +454,7 @@ const registerAppDataGroup = (tab: SettingTabBuilder) => {
root.querySelector("#importConf")?.addEventListener("change", (event: Event) => {
const target = event.target as HTMLInputElement;
const formData = new ContractFormData({file: [target.files[0]]});
- fetchPost("/api/system/importConf", formData, (response) => {
+ void runSettingsMaintenance(() => fetchPost("/api/system/importConf", formData, (response) => {
if (response.code !== 0) {
showMessage(response.msg);
return;
@@ -467,7 +468,7 @@ const registerAppDataGroup = (tab: SettingTabBuilder) => {
cb: exitSiYuan,
});
/// #endif
- });
+ }));
});
},
});
diff --git a/app/src/config/tabs/appearanceRuntime.ts b/app/src/config/tabs/appearanceRuntime.ts
index 7b0816b53e..b3ee3ccc50 100644
--- a/app/src/config/tabs/appearanceRuntime.ts
+++ b/app/src/config/tabs/appearanceRuntime.ts
@@ -22,6 +22,7 @@ import {remountOpenSettingTab} from "../setting/mount";
import {createConfigNamespaceApi} from "../util/namespaceApi";
import {syncBodyGradient} from "./bodyGradient";
import {refreshDynamicIcons} from "../../emoji/dynamicIcon";
+import {isSettingsWindow} from "../setting/windowContext";
/** 主题模式下拉框初值:合并 mode / modeOS */
export const appearanceThemeModeValue = (): number =>
@@ -30,11 +31,10 @@ export const appearanceThemeModeValue = (): number =>
/** 主题模式选择:合并 mode / modeOS 后提交 */
export const saveThemeMode = (value: number) => {
const OSThemeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? 1 : 0;
- fetchPost("/api/setting/setAppearance", {
- ...window.siyuan.config.appearance,
+ fetchPost("/api/setting/patch", {appearance: {
mode: (value === 2 ? OSThemeMode : value) as Config.IAppearance["mode"],
modeOS: value === 2,
- });
+ }});
};
/// #if MOBILE
@@ -55,6 +55,10 @@ interface IAppearanceRefresh {
const applyAppearanceConfig = async (data: Config.IAppearance, refresh?: IAppearanceRefresh) => {
if (data.lang !== window.siyuan.config.appearance.lang) {
+ if (isSettingsWindow()) {
+ window.location.reload();
+ return;
+ }
markAppearanceReloadPending();
/// #if MOBILE
void reloadUI();
@@ -104,13 +108,15 @@ const applyAppearanceConfig = async (data: Config.IAppearance, refresh?: IAppear
document.getElementById("status")?.classList.toggle("fn__none", data.hideStatusBar);
/// #if !MOBILE
- if (data.hideStatusBar !== prevAppearance.hideStatusBar) {
+ if (!isSettingsWindow() && data.hideStatusBar !== prevAppearance.hideStatusBar) {
adjustDockPadding();
}
- if (data.hideToolbar !== prevAppearance.hideToolbar) {
+ if (!isSettingsWindow() && data.hideToolbar !== prevAppearance.hideToolbar) {
syncHideToolbarLayout();
}
- updateBarModeIcon();
+ if (!isSettingsWindow()) {
+ updateBarModeIcon();
+ }
/// #endif
await loadAssets(data);
diff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.ts
index a97cbb80db..90bef7085a 100644
--- a/app/src/config/tabs/appearanceTab.ts
+++ b/app/src/config/tabs/appearanceTab.ts
@@ -1,5 +1,3 @@
-import {normalizeAssetOpenConfig} from "../../editor/assetOpen";
-import {normalizeBodyGradient} from "../../util/bodyGradient";
/// #if !BROWSER
import * as path from "path";
import {useShell} from "../../util/pathName";
@@ -336,22 +334,9 @@ const mountAppearanceFontFamily = (root: HTMLElement, configKey: FontFamiliesCon
refreshOpenMenu?.();
};
if (globalFont) {
- const appearance = {
- ...window.siyuan.config.appearance,
- globalFontFamilies: configuredFonts,
- };
- fetchPost("/api/setting/setAppearance", appearance, response => {
- appearanceConfigApi.apply({...response.data, lang: appearance.lang, bodyGradient: normalizeBodyGradient(response.data.bodyGradient)});
- refreshFonts();
- });
+ void appearanceConfigApi.patch("globalFontFamilies", configuredFonts, refreshFonts);
} else {
- fetchPost("/api/setting/setEditor", {
- ...window.siyuan.config.editor,
- [configKey]: configuredFonts,
- }, response => {
- editorConfigApi.apply({...response.data, assetOpen: normalizeAssetOpenConfig(response.data.assetOpen)});
- refreshFonts();
- });
+ void editorConfigApi.patch(configKey, configuredFonts, refreshFonts);
}
};
bindSelectedFontList(selectedListElement, () => selectedFonts, persistFonts, (chip, index, event) => {
@@ -1166,10 +1151,7 @@ const mountAppearanceSetStatusBar = (root: HTMLElement) => {
if (objEquals(statusBar, window.siyuan.config.appearance.statusBar)) {
return;
}
- fetchPost("/api/setting/setAppearance", {
- ...window.siyuan.config.appearance,
- statusBar
- });
+ void appearanceConfigApi.patch("statusBar", statusBar);
}
});
});
@@ -1227,10 +1209,7 @@ const mountAppearanceSetNotifications = (root: HTMLElement) => {
if (objEquals(notifications, window.siyuan.config.appearance.notifications)) {
return;
}
- fetchPost("/api/setting/setAppearance", {
- ...window.siyuan.config.appearance,
- notifications
- });
+ void appearanceConfigApi.patch("notifications", notifications);
}
});
});
diff --git a/app/src/config/tabs/keymapRuntime.ts b/app/src/config/tabs/keymapRuntime.ts
new file mode 100644
index 0000000000..032c2d0d7b
--- /dev/null
+++ b/app/src/config/tabs/keymapRuntime.ts
@@ -0,0 +1,20 @@
+import {sendGlobalShortcut, sendUnregisterGlobalShortcut} from "../../boot/globalEvent/globalShortcut";
+import {updateDockHotkeys} from "../../layout/dock/util";
+import {syncAppMenuShortcuts} from "../../boot/globalEvent/commonHotkey";
+import {isSettingsWindow} from "../setting/windowContext";
+
+export const applyKeymap = (data: Config.IKeymap) => {
+ window.siyuan.config.keymap = data;
+ if (isSettingsWindow()) {
+ return;
+ }
+ sendUnregisterGlobalShortcut(window.siyuan.ws.app);
+ window.siyuan.ws.app.plugins.forEach(plugin => {
+ plugin.commands.forEach(command => {
+ command.customHotkey = data.plugin?.[plugin.name]?.[command.langKey]?.custom || "";
+ });
+ });
+ updateDockHotkeys();
+ sendGlobalShortcut(window.siyuan.ws.app);
+ syncAppMenuShortcuts(Boolean(document.activeElement?.matches(".config-keymap__record, #searchByKey")));
+};
diff --git a/app/src/config/tabs/keymapUi.ts b/app/src/config/tabs/keymapUi.ts
index dee960a410..9b590ec804 100644
--- a/app/src/config/tabs/keymapUi.ts
+++ b/app/src/config/tabs/keymapUi.ts
@@ -1,14 +1,13 @@
-import {keymapPayload} from "../keymapPayload";
+import {keymapPayload, keymapRowPatch} from "../keymapPayload";
import {isMac, updateHotkeyTip} from "../../protyle/util/compatibility";
import {matchHotKey} from "../../protyle/util/hotKey";
import {Constants} from "../../constants";
import {hideMessage, showMessage} from "../../dialog/message";
import {fetchSyncPost} from "../../util/fetch";
import {exportLayout} from "../../layout/util";
-import {updateDockHotkeys} from "../../layout/dock/util";
+import {applyKeymap} from "./keymapRuntime";
import {confirmDialog} from "../../dialog/confirmDialog";
import {sendGlobalShortcut, sendUnregisterGlobalShortcut} from "../../boot/globalEvent/globalShortcut";
-import {syncAppMenuShortcuts} from "../../boot/globalEvent/commonHotkey";
import {normalizeSearchText} from "../search/normalize";
import {genButtonRowHtml, genConfigGroup} from "../render/render";
import type {Plugin} from "../../plugin";
@@ -19,6 +18,7 @@ import {getKeymapBindings, getKeymapItem, setKeymapBindings, normalizeShortcutKe
import {genKeymapRowHtml, getRowBindings, renderRowBindings} from "./keymapRow";
import {escapeHtml} from "../../util/escape";
import {Menu} from "../../plugin/Menu";
+import {refreshSettingConfig} from "../setting/sync";
const keymapToolbarSearchStrings = (): string[] => [
window.siyuan.languages.keymapTip,
@@ -717,19 +717,6 @@ let keymapSaveQueue = Promise.resolve();
let keymapRevision = 0;
let savedKeymap: Config.IKeymap | undefined;
-const applyKeymap = (data: Config.IKeymap) => {
- sendUnregisterGlobalShortcut(window.siyuan.ws.app);
- window.siyuan.config.keymap = data;
- window.siyuan.ws.app.plugins.forEach(plugin => {
- plugin.commands.forEach(command => {
- command.customHotkey = data.plugin?.[plugin.name]?.[command.langKey]?.custom || "";
- });
- });
- updateDockHotkeys();
- sendGlobalShortcut(window.siyuan.ws.app);
- syncAppMenuShortcuts(Boolean(document.activeElement?.matches(".config-keymap__record, #searchByKey")));
-};
-
const saveKeymapRow = (root: HTMLElement, row: HTMLElement, keys: string[], change?: (data: Config.IKeymap) => void) => {
savedKeymap ||= JSON.parse(JSON.stringify(window.siyuan.config.keymap));
const data: Config.IKeymap = JSON.parse(JSON.stringify(window.siyuan.config.keymap));
@@ -743,11 +730,16 @@ const saveKeymapRow = (root: HTMLElement, row: HTMLElement, keys: string[], chan
const revision = ++keymapRevision;
keymapSaveQueue = keymapSaveQueue.then(async () => {
try {
- const response = await fetchSyncPost("/api/setting/setKeymap", {data: keymapPayload(data)});
+ const response = await fetchSyncPost("/api/setting/patch", {
+ keymap: keymapRowPatch(row.dataset.key.split(Constants.ZWSP), {
+ ...item, bindings: item.bindings ? {...item.bindings, priority: item.bindings.priority || null} : undefined,
+ }),
+ });
if (response.code !== 0) {
throw new Error(response.msg);
}
- savedKeymap = data;
+ await refreshSettingConfig("keymap");
+ savedKeymap = JSON.parse(JSON.stringify(window.siyuan.config.keymap));
} catch (error) {
console.error("Could not save shortcuts:", error);
if (revision !== keymapRevision) {
diff --git a/app/src/config/util/namespaceApi.ts b/app/src/config/util/namespaceApi.ts
index 3af366668d..4623f13239 100644
--- a/app/src/config/util/namespaceApi.ts
+++ b/app/src/config/util/namespaceApi.ts
@@ -1,5 +1,7 @@
-import {fetchPost} from "../../util/fetch";
+import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {createNamespacePatchQueue} from "./namespacePatchQueue";
+import {mergeRecordByDottedPath} from "./dotPath";
+import {refreshSettingConfig} from "../setting/sync";
export function createConfigNamespaceApi<TData>(options: {
namespace: string;
@@ -33,7 +35,16 @@ export function createConfigNamespaceApi<TData>(options: {
}
});
});
- const patch = createNamespacePatchQueue({namespace, getConfig, submit});
+ const patch = createNamespacePatchQueue({namespace, getConfig, submit, submitPatch: async (path, value) => {
+ const response = await fetchSyncPost("/api/setting/patch", {
+ [namespace]: mergeRecordByDottedPath({}, path, value),
+ });
+ if (response.code !== 0) {
+ return undefined;
+ }
+ await refreshSettingConfig(namespace);
+ return getConfig();
+ }});
return {
patch,
diff --git a/app/src/config/util/namespacePatchQueue.test.ts b/app/src/config/util/namespacePatchQueue.test.ts
index 3afeefa1a2..ad3b40cfd7 100644
--- a/app/src/config/util/namespacePatchQueue.test.ts
+++ b/app/src/config/util/namespacePatchQueue.test.ts
@@ -4,6 +4,20 @@ import {createNamespacePatchQueue} from "./namespacePatchQueue";
const nextTask = () => new Promise<void>((resolve) => setTimeout(resolve, 0));
+test("field submission sends only changed paths in order, without submitting stale local configuration", async () => {
+ const submitted: Array<[string, unknown]> = [];
+ const patch = createNamespacePatchQueue({
+ namespace: "editor", getConfig: () => ({fontSize: 16, fullWidth: false}),
+ submit: async () => { throw new Error("full configuration must not be submitted"); },
+ submitPatch: async (path, value) => {
+ submitted.push([path, value]);
+ return {fontSize: 20, fullWidth: true};
+ },
+ });
+ await Promise.all([patch("editor.fontSize", 20), patch("fullWidth", true)]);
+ assert.deepEqual(submitted, [["fontSize", 20], ["fullWidth", true]]);
+});
+
test("namespace patches are serialized against the latest server response", async () => {
type TestConfig = {
approval: {
diff --git a/app/src/config/util/namespacePatchQueue.ts b/app/src/config/util/namespacePatchQueue.ts
index 9e3ad7ae78..cd96a3d526 100644
--- a/app/src/config/util/namespacePatchQueue.ts
+++ b/app/src/config/util/namespacePatchQueue.ts
@@ -4,6 +4,7 @@ export const createNamespacePatchQueue = <TData>(options: {
namespace: string;
getConfig: () => TData;
submit: (payload: TData) => Promise<TData | undefined>;
+ submitPatch?: (path: string, value: unknown) => Promise<TData | undefined>;
}) => {
const prefix = `${options.namespace}.`;
let queue = Promise.resolve();
@@ -14,9 +15,9 @@ export const createNamespacePatchQueue = <TData>(options: {
return Promise.resolve();
}
queue = queue.then(async () => {
- const prev = options.getConfig() as unknown as Record<string, unknown>;
- const payload = mergeRecordByDottedPath(prev, rel, value) as unknown as TData;
- const data = await options.submit(payload);
+ const data = options.submitPatch ? await options.submitPatch(rel, value) : await options.submit(
+ mergeRecordByDottedPath(options.getConfig() as unknown as Record<string, unknown>, rel, value) as unknown as TData
+ );
if (data !== undefined) {
onApplied?.(data);
}
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 4704608624..b9469c4339 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -1,4 +1,5 @@
import {Constants} from "../constants";
+import {getSettingsWindowHost} from "../config/setting/windowContext";
import {fetchPost} from "../util/fetch";
/// #if !MOBILE
import {exportLayout} from "../layout/util";
@@ -208,6 +209,11 @@ const installNewVersion = (installPkgPath: string, setCurrentWorkspace: boolean)
};
export const exitSiYuan = async (setCurrentWorkspace = true) => {
+ const host = getSettingsWindowHost();
+ if (host) {
+ await host.exit(setCurrentWorkspace);
+ return;
+ }
hideAllElements(["util"]);
/// #if !BROWSER
try {
diff --git a/app/src/index.ts b/app/src/index.ts
index 0ae421e797..27d6ae8e3c 100644
--- a/app/src/index.ts
+++ b/app/src/index.ts
@@ -1,4 +1,5 @@
import {Constants} from "./constants";
+import {refreshSettingConfig} from "./config/setting/sync";
import {closeNotebookHistoryDialogs} from "./history/notebookDialogs";
import {systemConfig} from "./config/systemConfig";
import {openStandaloneDatabaseItemByURI} from "./protyle/render/av/openStandaloneDatabaseItem";
@@ -94,6 +95,9 @@ export class App {
case "setAppearance":
appearanceConfigApi.apply(data.data);
break;
+ case "settingChanged":
+ void refreshSettingConfig(data.data.namespace);
+ break;
case "refreshAppearance":
void refreshAppearance(data.data);
break;
diff --git a/app/src/layout/Model.ts b/app/src/layout/Model.ts
index fb7d17094a..68fef166dc 100644
--- a/app/src/layout/Model.ts
+++ b/app/src/layout/Model.ts
@@ -50,12 +50,22 @@ export class Model {
console.error("Failed to process queued WebSocket message:", error);
}
});
+ if (window.siyuan.isReady) {
+ const {refreshSettingConfig}: typeof import("../config/setting/sync") = require("../config/setting/sync");
+ void refreshSettingConfig();
+ }
}
public connect(options: IConnectOptions) {
const websocketURL = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/ws`;
const ws = new WebSocket(`${websocketURL}?app=${Constants.SIYUAN_APPID}&id=${options.id}${options.type ? "&type=" + options.type : ""}`);
ws.onopen = () => {
+ if (options.type === "main" && window.siyuan.isReady) {
+ const {resetSettingTaskRevision}: typeof import("../config/setting/taskBlocker") = require("../config/setting/taskBlocker");
+ resetSettingTaskRevision();
+ const {refreshSettingConfig}: typeof import("../config/setting/sync") = require("../config/setting/sync");
+ void refreshSettingConfig();
+ }
if (options.callback) {
options.callback.call(this);
}
@@ -96,11 +106,7 @@ export class Model {
if (0 > ev.reason.indexOf("close websocket")) {
console.warn("WebSocket is closed. Reconnect will be attempted in 3 second.", ev);
setTimeout(() => {
- this.connect({
- id: options.id,
- type: options.type,
- msgCallback: options.msgCallback
- });
+ this.connect(options);
}, 3000);
}
};
diff --git a/app/src/layout/dock/BacklinkContent.ts b/app/src/layout/dock/BacklinkContent.ts
index dd2765be2a..b233246042 100644
--- a/app/src/layout/dock/BacklinkContent.ts
+++ b/app/src/layout/dock/BacklinkContent.ts
@@ -1,4 +1,3 @@
-import {normalizeAssetOpenConfig} from "../../editor/assetOpen";
import {GlobalBacklinkList} from "./GlobalBacklinkList";
import {bindPanelSearch} from "./panelSearch";
import type {Tab} from "../Tab";
@@ -789,9 +788,8 @@ export class BacklinkContent extends Model {
} else {
window.siyuan.config.editor.backmentionSort = sortValue;
}
- fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
- window.siyuan.config.editor = {...response.data, assetOpen: normalizeAssetOpenConfig(response.data.assetOpen)};
- });
+ fetchPost("/api/setting/patch", {editor: type === "sort" ?
+ {backlinkSort: sortValue, backlinkGlobalSort: 0} : {backmentionSort: sortValue}});
this.searchBacklinks();
};
window.siyuan.menus.menu.remove();
@@ -883,9 +881,7 @@ export class BacklinkContent extends Model {
click: () => {
window.siyuan.config.editor.backlinkBlockSort = mode;
window.siyuan.config.editor.backlinkGlobalSort = 0;
- fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
- window.siyuan.config.editor = {...response.data, assetOpen: normalizeAssetOpenConfig(response.data.assetOpen)};
- });
+ fetchPost("/api/setting/patch", {editor: {backlinkBlockSort: mode, backlinkGlobalSort: 0}});
this.cancelContextRequests(this.tree.element, false);
if (this.globalList) {
this.searchBacklinks(true);
@@ -904,7 +900,7 @@ export class BacklinkContent extends Model {
label, iconHTML: "", checked: globalSort === index + 1,
click: () => {
window.siyuan.config.editor.backlinkGlobalSort = index + 1;
- fetchPost("/api/setting/setEditor", window.siyuan.config.editor);
+ fetchPost("/api/setting/patch", {editor: {backlinkGlobalSort: index + 1}});
this.searchBacklinks();
},
}).element);
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index c61c2b427f..ad30c2d195 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -23,6 +23,7 @@ import {saveScroll} from "../protyle/scroll/saveScroll";
import {Backlink} from "./dock/Backlink";
import {openFileById} from "../editor/util";
import {isWindow} from "../util/functions";
+import {getSettingsWindowHost} from "../config/setting/windowContext";
import {showMessage} from "../dialog/message";
import {isEncryptedBox, parseUriInfo} from "../util/pathName";
import {Custom} from "./dock/Custom";
@@ -232,6 +233,11 @@ export const exportLayout = async (options: {
cb: () => void,
errorExit: boolean
}) => {
+ const host = getSettingsWindowHost();
+ if (host) {
+ await host.exportLayout(options);
+ return;
+ }
const editors = getAllEditor();
await withFetchTimeout(async (signal) => {
for (let i = 0; i < editors.length; i++) {
diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.ts
index f850c75ec8..edf4db405b 100644
--- a/app/src/mobile/util/onMessage.ts
+++ b/app/src/mobile/util/onMessage.ts
@@ -1,4 +1,5 @@
import {openMobileFileById} from "../editor";
+import {refreshSettingConfig} from "../../config/setting/sync";
import {closeNotebookHistoryDialogs} from "../../history/notebookDialogs";
import {MOBILE_BARS_CONFIG_KEY} from "./mobileBarsConfig";
import {showMobileBars} from "./mobileBars";
@@ -74,6 +75,9 @@ export const onMessage = (app: App, data: IWebSocketData) => {
case "setAppearance":
appearanceConfigApi.apply(data.data);
break;
+ case "settingChanged":
+ void refreshSettingConfig(data.data.namespace);
+ break;
case "refreshAppearance":
void refreshAppearance(data.data);
break;
diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts
index 263e98bb1c..863564958f 100644
--- a/app/src/plugin/API.ts
+++ b/app/src/plugin/API.ts
@@ -26,7 +26,7 @@ import {getAllModels, getAllTabs} from "../layout/getAll";
import {exportLayout} from "../layout/util";
/// #endif
import {getAllEditor} from "../layout/getAll";
-import {openSetting} from "../config";
+import {openPluginSetting} from "../config";
import {openAttr, openFileAttr} from "../menus/commonMenuItem";
import {globalCommand} from "../boot/globalEvent/command/global";
import {saveScroll} from "../protyle/scroll/saveScroll";
@@ -430,7 +430,7 @@ const createAPI = () => ({
/// #endif
getActiveEditor,
platformUtils,
- openSetting,
+ openSetting: openPluginSetting,
openAttributePanel,
saveLayout,
globalCommand,
diff --git a/app/src/plugin/Setting.ts b/app/src/plugin/Setting.ts
index 40a732a38e..f900d863fe 100644
--- a/app/src/plugin/Setting.ts
+++ b/app/src/plugin/Setting.ts
@@ -1,5 +1,9 @@
-import {isMobile} from "../util/functions";
+import {getFrontend, isMobile} from "../util/functions";
import {Dialog} from "../dialog";
+import {closeNativeSettings, openNativeSettings} from "../config/setting/nativeWindow";
+import {isSettingsWindow} from "../config/setting/windowContext";
+import {fitSettingsWindowDialog} from "../config/setting/windowDialog";
+import {genUUID} from "../util/genID";
export class Setting {
private items: IPluginSettingOption[] = [];
@@ -7,6 +11,11 @@ export class Setting {
private destroyCallback: () => void;
private width: string;
private height: string;
+ private openInWindow: boolean;
+ private windowKey = "plugin-" + genUUID();
+ private windowOpen = false;
+ private closeWindowCallback: () => void;
+ private windowSession = 0;
public dialog:Dialog;
constructor(options: {
@@ -14,11 +23,13 @@ export class Setting {
width?: string,
destroyCallback?: () => void
confirmCallback?: () => void
+ openInWindow?: boolean
}) {
this.confirmCallback = options.confirmCallback;
this.destroyCallback = options.destroyCallback;
this.width = options.width || (isMobile() ? "92vw" : "768px");
this.height = options.height || "80vh";
+ this.openInWindow = options.openInWindow === true;
}
public addItem(options: IPluginSettingOption) {
@@ -26,6 +37,36 @@ export class Setting {
}
public open(name: string) {
+ if (this.openInWindow && getFrontend().startsWith("desktop") && !isSettingsWindow()) {
+ if (!this.windowOpen) {
+ this.windowOpen = true;
+ this.windowSession++;
+ }
+ const session = this.windowSession;
+ const closed = () => {
+ if (!this.windowOpen || session !== this.windowSession) return;
+ this.windowOpen = false;
+ this.dialog = undefined;
+ this.items.forEach(item => {
+ if (item.actionElement && item.actionElement.ownerDocument !== document) {
+ document.adoptNode(item.actionElement);
+ }
+ });
+ this.destroyCallback?.();
+ };
+ this.closeWindowCallback = closed;
+ void openNativeSettings(window.siyuan.ws.app, {}, {
+ name, closed, isOpen: () => this.windowOpen && session === this.windowSession,
+ mount: create => {
+ this.dialog = create({width: this.width, height: this.height, items: this.items,
+ confirmCallback: this.confirmCallback, destroyCallback: closed});
+ },
+ }, this.windowKey).catch(error => {
+ closed();
+ console.error(error);
+ });
+ return;
+ }
const dialog = new Dialog({
title: name,
content: `<div class="b3-dialog__content">
@@ -41,6 +82,9 @@ export class Setting {
if (this.destroyCallback) {
this.destroyCallback();
}
+ if (isSettingsWindow()) {
+ window.close();
+ }
}
});
const contentElement = dialog.element.querySelector(".b3-dialog__content");
@@ -103,5 +147,17 @@ export class Setting {
dialog.destroy();
});
this.dialog = dialog;
+ if (isSettingsWindow()) {
+ fitSettingsWindowDialog(dialog);
+ }
+ }
+
+ public close() {
+ if (this.windowOpen) {
+ closeNativeSettings(this.windowKey);
+ this.closeWindowCallback?.();
+ } else {
+ this.dialog?.destroy();
+ }
}
}
diff --git a/app/src/plugin/globalState.ts b/app/src/plugin/globalState.ts
index 6f108208b5..0ea77a8f7c 100644
--- a/app/src/plugin/globalState.ts
+++ b/app/src/plugin/globalState.ts
@@ -6,6 +6,7 @@ import {
type IGlobalPluginStateSnapshot,
} from "./globalStateCoordinator";
import {type IPluginReloadData, reloadPlugin} from "./loader";
+import {getSettingsWindowHost} from "../config/setting/windowContext";
type TGlobalPluginReloadData = IPluginReloadData & IGlobalPluginStatePayload;
@@ -34,6 +35,10 @@ const isGlobalPluginState = (data: IPluginReloadData): data is TGlobalPluginRelo
typeof data.globalPetalChanged === "boolean";
export const applyPluginReload = (app: App, data: IPluginReloadData = {}) => {
+ const host = getSettingsWindowHost();
+ if (host) {
+ return host.applyPluginReload(data);
+ }
if (!isGlobalPluginState(data)) {
return reloadPlugin(app, data);
}
@@ -45,7 +50,7 @@ export const syncGlobalPluginConfig = (app: App, petalDisabled: boolean) => {
};
export const subscribeGlobalPluginState = (app: App, listener: (state: IGlobalPluginStateSnapshot) => void) =>
- getCoordinator(app).subscribe(listener);
+ getSettingsWindowHost()?.subscribePlugins(listener) || getCoordinator(app).subscribe(listener);
export const setGlobalPluginsDisabled = async (app: App, petalDisabled: boolean) => {
const response = await fetchSyncPost("/api/setting/setBazaarPetalDisabled", {petalDisabled});
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 79ac2110fb..d2e3d20dd1 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -104,6 +104,7 @@ const getLifecycleManager = (app: App) => {
shouldReloadOnDataChange: (plugin) => plugin.onDataChanged === Plugin.prototype.onDataChanged,
onDataChanged: (plugin, reason) => plugin.onDataChanged(reason),
onunload: (plugin) => {
+ plugin.setting?.close();
deactivateCustomBlockPlugin(plugin.name);
beginPluginTeardown(plugin);
return plugin.onunload();
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 2887dc616d..0c701e1810 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -208,13 +208,11 @@ const showSelectAllTip = () => {
selectAllTipShown = true;
document.querySelector(`#message [data-id="${messageId}"] button`)?.addEventListener("click", () => {
hideMessage(messageId);
- fetchPost("/api/setting/setAppearance", {
- ...window.siyuan.config.appearance,
+ fetchPost("/api/setting/patch", {appearance: {
notifications: {
- ...window.siyuan.config.appearance.notifications,
selectAllTip: false,
}
- });
+ }});
});
};
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index 933e3e9dc6..dbce06aced 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -1478,6 +1478,8 @@ export type PandocData = { "path": string; };
export type PandocRequestInput = { "args": Array<string>; "dir"?: string | null; };
+export type PatchSettingRequestInput = { "ai"?: SettingAIInput | null; "appearance"?: SettingAppearanceInput | null; "editor"?: SettingEditorInput | null; "export"?: SettingExportInput | null; "fileTree"?: SettingFileTreeInput | null; "flashcard"?: SettingFlashcardInput | null; "keymap"?: { [key: string]: JSONValue }; "search"?: SettingSearchInput | null; "secrets"?: SettingSecretsInput | null; "variables"?: SettingVariablesInput | null; };
+
export type PerformSyncRequestInput = { "mobileSwitch"?: boolean | null; "upload"?: boolean; };
export type PerformTransactionsRequestInput = { "app"?: string; "reqId": number; "session"?: string; "transactions": Array<TransactionInput | null>; };
@@ -1824,6 +1826,8 @@ export type SetVariablesRequestInput = { "items"?: Array<SettingVariableInput |
export type SettingAI = { "agent": SettingAgent | null; "decision": SettingDecision | null; "editing": SettingEditing | null; "embedding": SettingEmbedding | null; "imageGeneration": SettingImageGeneration | null; "mcp": SettingMCP | null; "providers": Array<SettingProvider | null> | null; "rerank": SettingRerank | null; };
+export type SettingAIInput = { "agent"?: SettingAgentInput | null; "decision"?: SettingDecisionInput | null; "editing"?: SettingEditingInput | null; "embedding"?: SettingEmbeddingInput | null; "imageGeneration"?: SettingImageGenerationInput | null; "mcp"?: SettingMCPInput | null; "providers"?: Array<SettingProviderInput | null> | null; "rerank"?: SettingRerankInput | null; };
+
export type SettingAgent = { "approvalPolicy": SettingApprovalPolicy | null; "capabilityPolicy": SettingCapabilityPolicy | null; "confirmTimeout": number; "maxCompletionTokens": number; "maxRetries": number; "maxToolCallRounds": number; "modelId": string; "sessionTimeout": number; "skills": SettingAgentSkills | null; "streamIdleTimeout": number; "temperature": number; };
export type SettingAgentInput = { "approvalPolicy"?: SettingApprovalPolicyInput | null; "capabilityPolicy"?: SettingCapabilityPolicyInput | null; "confirmTimeout"?: number | null; "maxCompletionTokens"?: number | null; "maxRetries"?: number | null; "maxToolCallRounds"?: number | null; "modelId"?: string | null; "sessionTimeout"?: number | null; "skills"?: SettingAgentSkillsInput | null; "streamIdleTimeout"?: number | null; "temperature"?: number | null; };
@@ -1838,6 +1842,8 @@ export type SettingAppearanceIcon = { "label": string; "name": string; };
export type SettingAppearanceIconInput = { "label"?: string | null; "name"?: string | null; };
+export type SettingAppearanceInput = { "bodyGradient"?: SettingBodyGradientInput | null; "closeButtonBehavior"?: number | null; "codeBlockThemeDark"?: string | null; "codeBlockThemeLight"?: string | null; "darkThemes"?: Array<SettingAppearanceThemeInput | null> | null; "entryVisibility"?: SettingEntryVisibilityInput | null; "globalFontFamilies"?: Array<SettingEditorFontInput | null> | null; "hideStatusBar"?: boolean | null; "hideToolbar"?: boolean | null; "icon"?: string | null; "iconVer"?: string | null; "icons"?: Array<SettingAppearanceIconInput | null> | null; "lang"?: string | null; "lightThemes"?: Array<SettingAppearanceThemeInput | null> | null; "mode"?: number | null; "modeOS"?: boolean | null; "notifications"?: SettingNotificationsInput | null; "statusBar"?: SettingStatusBarInput | null; "themeDark"?: string | null; "themeJS"?: boolean | null; "themeLight"?: string | null; "themeVer"?: string | null; };
+
export type SettingAppearanceTheme = { "frontends"?: Array<string>; "label": string; "name": string; };
export type SettingAppearanceThemeInput = { "frontends"?: Array<string> | null; "label"?: string | null; "name"?: string | null; };
@@ -1906,6 +1912,8 @@ export type SettingEditorFont = { "displayName": string; "family": string; "weig
export type SettingEditorFontInput = { "displayName"?: string | null; "family"?: string | null; "weight"?: number | null; };
+export type SettingEditorInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
+
export type SettingEmbedding = { "apiKey": string; "baseURL": string; "dimensions": number; "enabled": boolean; "id": string; "name": string; "timeout": number; };
export type SettingEmbeddingInput = { "apiKey"?: string | null; "baseURL"?: string | null; "dimensions"?: number | null; "enabled"?: boolean | null; "id"?: string | null; "name"?: string | null; "timeout"?: number | null; };
@@ -1922,10 +1930,16 @@ export type SettingEntryVisibilityProfileInput = { "entries"?: Record<string, bo
export type SettingExport = { "addTitle": boolean; "blockEmbedMode": number; "blockRefMode": number; "blockRefTextLeft": string; "blockRefTextRight": string; "docxTemplate": string; "fileAnnotationRefMode": number; "imageWatermarkDesc": string; "imageWatermarkStr": string; "includeRelatedDocs": boolean; "includeSubDocs": boolean; "inlineMemo": boolean; "markdownYFM": boolean; "pandocBin": string; "pandocParams": string; "paragraphBeginningSpace": boolean; "pdfFooter": string; "pdfWatermarkDesc": string; "pdfWatermarkStr": string; "removeAssetsID": boolean; "tagCloseMarker": string; "tagOpenMarker": string; };
+export type SettingExportInput = { "addTitle"?: boolean | null; "blockEmbedMode"?: number | null; "blockRefMode"?: number | null; "blockRefTextLeft"?: string | null; "blockRefTextRight"?: string | null; "docxTemplate"?: string | null; "fileAnnotationRefMode"?: number | null; "imageWatermarkDesc"?: string | null; "imageWatermarkStr"?: string | null; "includeRelatedDocs"?: boolean | null; "includeSubDocs"?: boolean | null; "inlineMemo"?: boolean | null; "markdownYFM"?: boolean | null; "pandocBin"?: string | null; "pandocParams"?: string | null; "paragraphBeginningSpace"?: boolean | null; "pdfFooter"?: string | null; "pdfWatermarkDesc"?: string | null; "pdfWatermarkStr"?: string | null; "removeAssetsID"?: boolean | null; "tagCloseMarker"?: string | null; "tagOpenMarker"?: string | null; };
+
export type SettingFileTree = { "allowCreateDeeper": boolean; "alwaysSelectOpenedFile": boolean; "boxDocEnabled": boolean | null; "closeTabOnDoubleClick": boolean; "closeTabsOnStart": boolean; "createDocAtTop": boolean | null; "docCreateSaveBox": string; "docCreateSavePath": string; "docCreateTemplatePath": string; "docIconClickExpand": boolean; "largeFileWarningSize": number; "maxListCount": number; "maxOpenTabCount": number; "noSplitScreenWhenOpenTab": boolean; "openFilesUseCurrentTab": boolean; "parentDocClickExpand": boolean; "recentDocsMaxListCount": number; "refCreateSaveBox": string; "refCreateSavePath": string; "removeDocWithoutConfirm": boolean; "shorthandSaveBox": string; "shorthandSavePath": string; "sort": number; "tabStartupMode": number | null; "useSVGDefaultIcon": boolean | null; "useSingleLineSave": boolean; };
+export type SettingFileTreeInput = { "allowCreateDeeper"?: boolean | null; "alwaysSelectOpenedFile"?: boolean | null; "boxDocEnabled"?: boolean | null; "closeTabOnDoubleClick"?: boolean | null; "closeTabsOnStart"?: boolean | null; "createDocAtTop"?: boolean | null; "docCreateSaveBox"?: string | null; "docCreateSavePath"?: string | null; "docCreateTemplatePath"?: string | null; "docIconClickExpand"?: boolean | null; "largeFileWarningSize"?: number | null; "maxListCount"?: number | null; "maxOpenTabCount"?: number | null; "noSplitScreenWhenOpenTab"?: boolean | null; "openFilesUseCurrentTab"?: boolean | null; "parentDocClickExpand"?: boolean | null; "recentDocsMaxListCount"?: number | null; "refCreateSaveBox"?: string | null; "refCreateSavePath"?: string | null; "removeDocWithoutConfirm"?: boolean | null; "shorthandSaveBox"?: string | null; "shorthandSavePath"?: string | null; "sort"?: number | null; "tabStartupMode"?: number | null; "useSVGDefaultIcon"?: boolean | null; "useSingleLineSave"?: boolean | null; };
+
export type SettingFlashcard = { "blockquote": boolean; "callout": boolean; "deck": boolean; "heading": boolean; "list": boolean; "mark": boolean; "maximumInterval": number; "newCardLimit": number; "requestRetention": number; "reviewCardLimit": number; "reviewMode": number; "superBlock": boolean; "weights": string; };
+export type SettingFlashcardInput = { "blockquote"?: boolean | null; "callout"?: boolean | null; "deck"?: boolean | null; "heading"?: boolean | null; "list"?: boolean | null; "mark"?: boolean | null; "maximumInterval"?: number | null; "newCardLimit"?: number | null; "requestRetention"?: number | null; "reviewCardLimit"?: number | null; "reviewMode"?: number | null; "superBlock"?: boolean | null; "weights"?: string | null; };
+
export type SettingIconRequestInput = { "icon": string; };
export type SettingImageGeneration = { "modelId": string; "outputFormat": string; "quality": string; "requestTimeout": number; "size": string; };
@@ -1974,18 +1988,26 @@ export type SettingRerankInput = { "apiKey"?: string | null; "candidateCount"?:
export type SettingSearch = { "alias": boolean; "audioBlock": boolean; "backlinkMentionAlias": boolean; "backlinkMentionAnchor": boolean; "backlinkMentionDoc": boolean; "backlinkMentionKeywordsLimit": number; "backlinkMentionName": boolean; "blockquote": boolean; "callout": boolean; "caseSensitive": boolean; "codeBlock": boolean; "customBlock": boolean | null; "databaseBlock": boolean; "document": boolean; "embedBlock": boolean; "hanSensitive": boolean | null; "heading": boolean; "htmlBlock": boolean; "ial": boolean; "iframeBlock": boolean; "indexAssetPath": boolean; "limit": number; "list": boolean; "listItem": boolean; "mathBlock": boolean; "memo": boolean; "mindmap": boolean | null; "mindmapItem": boolean | null; "name": boolean; "paragraph": boolean; "superBlock": boolean; "tabItem": boolean; "table": boolean; "tabs": boolean; "videoBlock": boolean; "virtualRefAlias": boolean; "virtualRefAnchor": boolean; "virtualRefDoc": boolean; "virtualRefName": boolean; "widgetBlock": boolean; };
+export type SettingSearchInput = { "alias"?: boolean | null; "audioBlock"?: boolean | null; "backlinkMentionAlias"?: boolean | null; "backlinkMentionAnchor"?: boolean | null; "backlinkMentionDoc"?: boolean | null; "backlinkMentionKeywordsLimit"?: number | null; "backlinkMentionName"?: boolean | null; "blockquote"?: boolean | null; "callout"?: boolean | null; "caseSensitive"?: boolean | null; "codeBlock"?: boolean | null; "customBlock"?: boolean | null; "databaseBlock"?: boolean | null; "document"?: boolean | null; "embedBlock"?: boolean | null; "hanSensitive"?: boolean | null; "heading"?: boolean | null; "htmlBlock"?: boolean | null; "ial"?: boolean | null; "iframeBlock"?: boolean | null; "indexAssetPath"?: boolean | null; "limit"?: number | null; "list"?: boolean | null; "listItem"?: boolean | null; "mathBlock"?: boolean | null; "memo"?: boolean | null; "mindmap"?: boolean | null; "mindmapItem"?: boolean | null; "name"?: boolean | null; "paragraph"?: boolean | null; "superBlock"?: boolean | null; "tabItem"?: boolean | null; "table"?: boolean | null; "tabs"?: boolean | null; "videoBlock"?: boolean | null; "virtualRefAlias"?: boolean | null; "virtualRefAnchor"?: boolean | null; "virtualRefDoc"?: boolean | null; "virtualRefName"?: boolean | null; "widgetBlock"?: boolean | null; };
+
export type SettingSecret = { "allowedHosts": Array<string> | null; "name": string; "value": string; };
export type SettingSecretInput = { "allowedHosts"?: Array<string> | null; "name"?: string | null; "value"?: string | null; };
export type SettingSecrets = { "items": Array<SettingSecret | null> | null; };
+export type SettingSecretsInput = { "items"?: Array<SettingSecretInput | null> | null; };
+
export type SettingSnpt = { "enabledCSS": boolean; "enabledJS": boolean; };
export type SettingStatusBar = { "msgDataSyncDisabled": boolean; "msgTaskAssetDatabaseIndexCommitDisabled": boolean; "msgTaskDatabaseIndexCommitDisabled": boolean; "msgTaskHistoryDatabaseIndexCommitDisabled": boolean; "msgTaskHistoryGenerateFileDisabled": boolean; "version": number; };
export type SettingStatusBarInput = { "msgDataSyncDisabled"?: boolean | null; "msgTaskAssetDatabaseIndexCommitDisabled"?: boolean | null; "msgTaskDatabaseIndexCommitDisabled"?: boolean | null; "msgTaskHistoryDatabaseIndexCommitDisabled"?: boolean | null; "msgTaskHistoryGenerateFileDisabled"?: boolean | null; "version"?: number | null; };
+export type SettingTask = { "active": boolean; "id": string; "message": string; "revision": number; };
+
+export type SettingTaskState = { "revision": number; "tasks": Array<SettingTask> | null; };
+
export type SettingThemeRequestInput = { "appearanceMode"?: string | null; "modes"?: Array<number> | null; "theme"?: string | null; };
export type SettingUser = { "userAvatarURL": string; "userCreateTime": string; "userHomeBImgURL": string; "userId": string; "userIntro": string; "userName": string; "userNickname": string; "userSiYuanAssetSize": number; "userSiYuanOneTimePayStatus": number; "userSiYuanPointExchangeRepoSize": number; "userSiYuanProExpireTime": number; "userSiYuanRepoSize": number; "userSiYuanSubscriptionPlan": number; "userSiYuanSubscriptionStatus": number; "userSiYuanSubscriptionType": number; "userTitles": Array<SettingUserTitle | null> | null; "userToken": string; "userTokenExpireTime": string; "userTrafficAPIGet": number; "userTrafficAPIPut": number; "userTrafficDownload": number; "userTrafficTime": number; "userTrafficUpload": number; };
@@ -1998,6 +2020,8 @@ export type SettingVariableInput = { "name"?: string | null; "value"?: string |
export type SettingVariables = { "items": Array<SettingVariable | null> | null; };
+export type SettingVariablesInput = { "items"?: Array<SettingVariableInput | null> | null; };
+
export type Shorthand = { "hCreated": string; "oId": string; "shorthandContent": string; "shorthandDesc": string; "shorthandFrom": number; "shorthandMd": string; "shorthandTitle": string; "shorthandURL": string; };
export type ShorthandPage = { "pagination": ShorthandPagination; "shorthands": Array<Shorthand | null>; };
@@ -2094,7 +2118,7 @@ export type SystemChangelogRequestInput = { "force"?: boolean | null; };
export type SystemCheckUpdateRequestInput = { "showMsg": boolean; };
-export type SystemConfData = { "conf": SystemAppConf | null; "isPublish": boolean; "start": boolean; };
+export type SystemConfData = { "conf": SystemAppConf | null; "isPublish": boolean; "settingTasks"?: SettingTaskState; "start": boolean; };
export type SystemCustomEmojiRequestInput = { "file"?: Blob; "name"?: string; "url"?: string; };
@@ -4975,6 +4999,11 @@ export interface APIPOSTRoutes {
response: { "code": 0; "data": null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
body: "none";
};
+ "/api/setting/patch": {
+ request: PatchSettingRequestInput;
+ response: { "code": 0; "data": null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
"/api/setting/refreshVirtualBlockRef": {
request: EmptyRequestInput;
response: { "code": 0; "data": null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts
index b1a68bfe65..94d7176df2 100644
--- a/app/src/util/assets.ts
+++ b/app/src/util/assets.ts
@@ -417,11 +417,10 @@ export const setMode = (modeElementValue: number) => {
mode = 0;
}
}
- fetchPost("/api/setting/setAppearance", {
- ...window.siyuan.config.appearance,
+ fetchPost("/api/setting/patch", {appearance: {
mode,
modeOS: modeElementValue === 2,
- });
+ }});
/// #endif
};
diff --git a/app/src/util/processMessage.ts b/app/src/util/processMessage.ts
index 9db901d49b..26bd07f78f 100644
--- a/app/src/util/processMessage.ts
+++ b/app/src/util/processMessage.ts
@@ -6,8 +6,13 @@ import {setStorageVal} from "../protyle/util/compatibility";
import {Constants} from "../constants";
import {fetchPost} from "./fetch";
import {isBrowser} from "./functions";
+import {applySettingTask} from "../config/setting/taskBlocker";
export const processMessage = (response: IWebSocketData) => {
+ if (response.cmd === "settingTask") {
+ applySettingTask(response.data);
+ return false;
+ }
if ("msg" === response.cmd) {
const id = showMessage(response.msg, response.data.closeTimeout, response.code === 0 ? "info" : "error", response.data.id);
document.querySelector("#message #addMicrosoftDefenderExclusion")?.addEventListener("click", (event) => {
diff --git a/app/src/window/index.ts b/app/src/window/index.ts
index 680d1ea720..4e76608be9 100644
--- a/app/src/window/index.ts
+++ b/app/src/window/index.ts
@@ -1,6 +1,7 @@
import {onWindowWorkspaceStorageChanged} from "./workspace";
import {closeNotebookHistoryDialogs} from "../history/notebookDialogs";
import {Constants} from "../constants";
+import {refreshSettingConfig} from "../config/setting/sync";
import {systemConfig} from "../config/systemConfig";
import {Menus} from "../menus";
import {Model} from "../layout/Model";
@@ -67,6 +68,9 @@ class App {
case "setAppearance":
appearanceConfigApi.apply(data.data);
break;
+ case "settingChanged":
+ void refreshSettingConfig(data.data.namespace);
+ break;
case "refreshAppearance":
void refreshAppearance(data.data);
break;
diff --git a/app/src/window/onWindowsMsg.test.ts b/app/src/window/onWindowsMsg.test.ts
index 185b923743..a2e70e93eb 100644
--- a/app/src/window/onWindowsMsg.test.ts
+++ b/app/src/window/onWindowsMsg.test.ts
@@ -29,3 +29,30 @@ test("system lock acknowledges only after all editor input has been submitted",
await new Promise(resolve => setImmediate(resolve));
assert.deepEqual(sent, [{channel: "siyuan-notebook-system-lock-ready", id: 42}]);
});
+
+test("maintenance acknowledges save failure and restores shortcuts only after the final task", async () => {
+ const compiled = transpileModule(readFileSync("src/window/onWindowsMsg.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
+ }).outputText;
+ const tasks = new Set<string>();
+ const messages: Array<{channel: string; data: {id: string; saved: boolean}}> = [];
+ let restored = 0;
+ const dependencies = {
+ Constants: {}, getAllEditor: () => [{protyle: {wysiwyg: {}}, flushPendingTransactions: () => Promise.reject()}],
+ setNativeSettingTask: (id: string, active: boolean) => active ? tasks.add(id) : tasks.delete(id),
+ hasNativeSettingTasks: () => tasks.size > 0, sendUnregisterGlobalShortcut() {},
+ sendGlobalShortcut: () => { restored++; },
+ ipcRenderer: {send: (channel: string, data: {id: string; saved: boolean}) => messages.push({channel, data})},
+ };
+ const exports = {} as {onWindowsMsg: (message: {cmd: string; data: string}) => void};
+ runInNewContext(compiled, {exports, require: () => dependencies, window: {siyuan: {ws: {app: {}}}}, console});
+ exports.onWindowsMsg({cmd: "prepareSettingTask", data: "native-1"});
+ exports.onWindowsMsg({cmd: "prepareSettingTask", data: "native-2"});
+ await new Promise(resolve => setImmediate(resolve));
+ assert.equal(messages.length, 2);
+ assert.equal(messages.every(message => message.channel === "siyuan-settings-task-ready" && !message.data.saved), true);
+ exports.onWindowsMsg({cmd: "endSettingTask", data: "native-1"});
+ assert.equal(restored, 0);
+ exports.onWindowsMsg({cmd: "endSettingTask", data: "native-2"});
+ assert.equal(restored, 1);
+});
diff --git a/app/src/window/onWindowsMsg.ts b/app/src/window/onWindowsMsg.ts
index 6677000e8f..03da302696 100644
--- a/app/src/window/onWindowsMsg.ts
+++ b/app/src/window/onWindowsMsg.ts
@@ -6,6 +6,8 @@ import {getAllEditor} from "../layout/getAll";
import {ipcRenderer} from "electron";
import {Constants} from "../constants";
import {flushWindowWorkspace} from "./workspace";
+import {hasNativeSettingTasks, setNativeSettingTask} from "../config/setting/taskBlocker";
+import {sendGlobalShortcut, sendUnregisterGlobalShortcut} from "../boot/globalEvent/globalShortcut";
const closeTab = (ipcData: IWebSocketData) => {
const tab = getInstanceById(ipcData.data);
@@ -15,6 +17,18 @@ const closeTab = (ipcData: IWebSocketData) => {
};
export const onWindowsMsg = (ipcData: IWebSocketData) => {
switch (ipcData.cmd) {
+ case "prepareSettingTask":
+ setNativeSettingTask(ipcData.data, true);
+ sendUnregisterGlobalShortcut(window.siyuan.ws.app);
+ void Promise.all(getAllEditor().filter(editor => editor?.protyle?.wysiwyg)
+ .map(editor => editor.flushPendingTransactions())).then(() => {
+ ipcRenderer.send("siyuan-settings-task-ready", {id: ipcData.data, saved: true});
+ }).catch(() => ipcRenderer.send("siyuan-settings-task-ready", {id: ipcData.data, saved: false}));
+ break;
+ case "endSettingTask":
+ setNativeSettingTask(ipcData.data, false);
+ if (!hasNativeSettingTasks()) sendGlobalShortcut(window.siyuan.ws.app);
+ break;
case Constants.SIYUAN_WINDOW_WORKSPACE_FLUSH:
void flushWindowWorkspace().then(saved => {
ipcRenderer.send(Constants.SIYUAN_WINDOW_WORKSPACE_SAVED, {id: ipcData.data, saved});
diff --git a/app/tests/settingsWindow.test.js b/app/tests/settingsWindow.test.js
new file mode 100644
index 0000000000..a1dca6fe17
--- /dev/null
+++ b/app/tests/settingsWindow.test.js
@@ -0,0 +1,190 @@
+const assert = require("node:assert/strict");
+const fs = require("node:fs");
+const os = require("node:os");
+const path = require("node:path");
+
+const loadRendererModule = (source, modules) => {
+ const exports = {};
+ new Function("require", "exports", source)(name => {
+ if (!modules[name]) throw new Error("unexpected module: " + name);
+ return modules[name];
+ }, exports);
+ return exports;
+};
+
+const rendererModules = (sources) => {
+ let sequence = 0;
+ window.siyuan = {dialogs: [], zIndex: 1, storage: {}, languages: {cancel: "Cancel", save: "Save", config: "Settings"},
+ menus: {menu: {element: document.createElement("div"), remove() {}}}, ws: {app: {plugins: [], appId: "test"}}};
+ const genUUID = () => "test-" + (++sequence);
+ const {Dialog} = loadRendererModule(sources.dialog, {
+ "../util/genID": {genUUID}, "../util/zIndex": {isAbove: () => false}, "./moveResize": {moveResize() {}},
+ "../util/functions": {isMobile: () => false}, "../protyle/util/compatibility": {isNotCtrl: () => true},
+ "../constants": {Constants: {TIMEOUT_OPENDIALOG: 0, TIMEOUT_DBLCLICK: 0}},
+ });
+ const context = {isSettingsWindow: () => document.body.classList.contains("body--settings")};
+ const fit = loadRendererModule(sources.fit, {});
+ return {Dialog, genUUID, context, fit};
+};
+
+const bootChild = async (sources) => {
+ const {Dialog, genUUID, context, fit} = rendererModules(sources);
+ const host = await new Promise(resolve => {
+ const token = new URLSearchParams(location.search).get("token");
+ window.opener.dispatchEvent(new CustomEvent("siyuan-settings-host-" + token, {detail: resolve}));
+ });
+ if (host.plugin) {
+ const {Setting} = loadRendererModule(sources.setting, {
+ "../util/functions": {isMobile: () => false, getFrontend: () => "desktop-window"},
+ "../dialog": {Dialog}, "../config/setting/nativeWindow": {},
+ "../config/setting/windowContext": context, "../config/setting/windowDialog": fit,
+ "../util/genID": {genUUID},
+ });
+ host.plugin.mount(options => {
+ const setting = new Setting(options);
+ options.items.forEach(item => setting.addItem(item));
+ setting.open(host.plugin.name);
+ return setting.dialog;
+ });
+ window.addEventListener("unload", () => host.plugin.closed());
+ }
+ require("electron").ipcRenderer.send("test-settings-ready");
+};
+
+const runCases = async (sources) => {
+ const assert = require("node:assert/strict");
+ const {ipcRenderer} = require("electron");
+ const {Dialog, genUUID, context, fit} = rendererModules(sources);
+ const native = loadRendererModule(sources.native, {
+ electron: {ipcRenderer}, "../../util/genID": {genUUID}, "../../protyle/util/compatibility": {setStorageVal() {}},
+ "../../layout/util": {exportLayout: async options => options.cb()}, "../../dialog/processSystem": {exitSiYuan: async () => {}},
+ "../../plugin/globalState": {subscribeGlobalPluginState: () => () => {}, applyPluginReload: async () => {}},
+ "../../plugin/loader": {loadPlugin: async () => {}, unloadPlugin: async () => {}},
+ "../../boot/globalEvent/globalShortcut": {sendGlobalShortcut() {}, sendUnregisterGlobalShortcut() {}},
+ });
+ const {Setting} = loadRendererModule(sources.setting, {
+ "../util/functions": {isMobile: () => false, getFrontend: () => "desktop"}, "../dialog": {Dialog},
+ "../config/setting/nativeWindow": native, "../config/setting/windowContext": context,
+ "../config/setting/windowDialog": fit, "../util/genID": {genUUID},
+ });
+ const wait = () => new Promise(resolve => setTimeout(resolve, 50));
+ const legacy = new Setting({});
+ legacy.open("Legacy");
+ assert.equal(legacy.dialog.element.ownerDocument, document);
+ legacy.dialog.destroy();
+ await wait();
+
+ let confirmed = 0;
+ let destroyed = 0;
+ let created = 0;
+ const control = document.createElement("input");
+ control.value = "original";
+ const setting = new Setting({openInWindow: true, confirmCallback: () => {
+ assert.equal(control.value, "changed");
+ confirmed++;
+ }, destroyCallback: () => destroyed++});
+ setting.addItem({title: "Control", createActionElement: () => { created++; return control; }});
+ setting.open("Plugin");
+ await ipcRenderer.invoke("test-settings-wait");
+ assert.equal(created, 1);
+ assert.notEqual(control.ownerDocument, document);
+ assert.equal(setting.dialog.element.querySelector("input"), control);
+ setting.open("Plugin");
+ await wait();
+ assert.equal(created, 1);
+ control.value = "changed";
+ setting.dialog.element.querySelectorAll(".b3-dialog__action button")[1].click();
+ await wait();
+ assert.equal(confirmed, 1);
+ assert.equal(destroyed, 1);
+ assert.equal(setting.dialog, undefined);
+
+ setting.open("Plugin");
+ await ipcRenderer.invoke("test-settings-wait");
+ setting.close();
+ await wait();
+ assert.equal(confirmed, 1);
+ assert.equal(destroyed, 2);
+ await native.openNativeSettings(window.siyuan.ws.app, {tab: "appearance"});
+ await ipcRenderer.invoke("test-settings-wait");
+ await native.openNativeSettings(window.siyuan.ws.app, {tab: "editor"});
+ assert.equal(await ipcRenderer.invoke("test-settings-window-count"), 1);
+};
+
+if (process.versions.electron && process.type === "browser") {
+ const {app, BrowserWindow, ipcMain, screen} = require("electron");
+ const {createServer} = require("node:http");
+ const {createSettingsWindows} = require("../electron/settingsWindows");
+ app.setPath("userData", process.argv[2]);
+ app.whenReady().then(async () => {
+ let owner;
+ let code = 0;
+ let ready = 0;
+ let waiting;
+ const children = new Set();
+ const ts = require("typescript");
+ const sources = {};
+ for (const [key, file] of Object.entries({dialog: "dialog/index.ts", setting: "plugin/Setting.ts",
+ native: "config/setting/nativeWindow.ts", fit: "config/setting/windowDialog.ts"})) {
+ sources[key] = ts.transpileModule(fs.readFileSync(path.join(__dirname, "../src", file), "utf8"), {
+ compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2021},
+ }).outputText;
+ }
+ const server = createServer((request, response) => {
+ response.setHeader("Content-Type", "text/html; charset=utf-8");
+ const child = request.url.startsWith("/stage/build/app/settings.html");
+ response.end(`<html><body class="${child ? "body--settings" : ""}">${child ?
+ `<script>const loadRendererModule = ${loadRendererModule.toString()}; const rendererModules = ${rendererModules.toString()}; (${bootChild.toString()})(${JSON.stringify(sources)});</script>` : ""}</body></html>`);
+ });
+ await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
+ const origin = "http://127.0.0.1:" + server.address().port;
+ const policy = createSettingsWindows({ipcMain, screen, getTarget: id => owner?.webContents.id === id ? {origin, mode: "local"} : undefined,
+ initialize: win => {
+ children.add(win);
+ assert.equal(win.getParentWindow(), null);
+ assert.equal(win.isModal(), false);
+ win.on("closed", () => children.delete(win));
+ }, show() {}, log() {}});
+ ipcMain.on("test-settings-ready", () => {
+ if (waiting) { waiting(); waiting = undefined; } else ready++;
+ });
+ ipcMain.handle("test-settings-wait", () => ready ? (--ready, Promise.resolve()) : new Promise(resolve => { waiting = resolve; }));
+ ipcMain.handle("test-settings-window-count", () => children.size);
+ try {
+ owner = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false, offscreen: true}});
+ owner.webContents.setWindowOpenHandler(details => {
+ const result = policy(owner.webContents, details);
+ return result ? {...result, overrideBrowserWindowOptions: {...result.overrideBrowserWindowOptions, show: false}} : {action: "deny"};
+ });
+ await owner.loadURL(origin + "/stage/build/app/");
+ await owner.webContents.executeJavaScript(`const loadRendererModule = ${loadRendererModule.toString()}; const rendererModules = ${rendererModules.toString()}; (${runCases.toString()})(${JSON.stringify(sources)})`);
+ const closed = [...children].map(child => new Promise(resolve => child.once("closed", resolve)));
+ owner.destroy();
+ await Promise.all(closed);
+ assert.equal(children.size, 0);
+ } catch (error) {
+ console.error(error);
+ code = 1;
+ } finally {
+ for (const child of children) child.destroy();
+ if (owner && !owner.isDestroyed()) owner.destroy();
+ server.close();
+ app.exit(code);
+ }
+ });
+} else {
+ const {test} = require("node:test");
+ const {execFile} = require("node:child_process");
+ const {promisify} = require("node:util");
+ test("native settings preserve plugin controls, callbacks, default dialogs and owning-window lifecycle", async () => {
+ const profile = fs.mkdtempSync(path.join(os.tmpdir(), "siyuan-settings-window-"));
+ const env = {...process.env};
+ delete env.ELECTRON_RUN_AS_NODE;
+ try {
+ await promisify(execFile)(require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 30000});
+ } finally {
+ assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));
+ fs.rmSync(profile, {recursive: true, force: true, maxRetries: 5, retryDelay: 100});
+ }
+ });
+}
diff --git a/app/webpack.config.js b/app/webpack.config.js
index d65f483279..5b9f03c233 100644
--- a/app/webpack.config.js
+++ b/app/webpack.config.js
@@ -21,6 +21,7 @@ module.exports = (env, argv) => {
entry: {
"main": "./src/index.ts",
"window": "./src/window/index.ts",
+ "settings": "./src/config/setting/window.ts",
},
resolve: {
extensions: [".ts", ".js", ".tpl", ".scss", ".png", ".svg"],
@@ -72,7 +73,8 @@ module.exports = (env, argv) => {
test: /\.tpl/,
include: [
path.resolve(__dirname, "src/assets/template/app/index.tpl"),
- path.resolve(__dirname, "src/assets/template/app/window.tpl")],
+ path.resolve(__dirname, "src/assets/template/app/window.tpl"),
+ path.resolve(__dirname, "src/assets/template/app/settings.tpl")],
loader: "html-loader",
options: {
sources: false,
@@ -162,6 +164,12 @@ module.exports = (env, argv) => {
filename: "window.html",
template: "src/assets/template/app/window.tpl",
}),
+ new HtmlWebpackPlugin({
+ inject: "head",
+ chunks: ["settings"],
+ filename: "settings.html",
+ template: "src/assets/template/app/settings.tpl",
+ }),
],
};
};
diff --git a/kernel/api/asset.go b/kernel/api/asset.go
index 96414a68be..ef5fd8494c 100644
--- a/kernel/api/asset.go
+++ b/kernel/api/asset.go
@@ -341,6 +341,7 @@ var removeUnusedAsset = contractHandler(apicontract.RemoveUnusedAsset, func(c *g
})
var removeUnusedAssets = contractHandler(apicontract.RemoveUnusedAssets, func(c *gin.Context, request apicontract.EmptyRequest) apicontract.Response[apicontract.AssetPathsData] {
+ defer beginSettingTask("clearAll")()
paths, err := model.RemoveUnusedAssets()
if err != nil {
diff --git a/kernel/api/av.go b/kernel/api/av.go
index d774ec0ac8..a7a7518d85 100644
--- a/kernel/api/av.go
+++ b/kernel/api/av.go
@@ -43,6 +43,7 @@ var removeUnusedAttributeView = contractHandler(apicontract.RemoveUnusedAttribut
})
var removeUnusedAttributeViews = contractHandler(apicontract.RemoveUnusedAttributeViews, func(c *gin.Context, request apicontract.EmptyRequest) apicontract.Response[apicontract.AVPathsData] {
+ defer beginSettingTask("clearAllAV")()
return apicontract.Success(apicontract.AVPathsData{Paths: model.RemoveUnusedAttributeViews()})
})
diff --git a/kernel/api/contract.go b/kernel/api/contract.go
index 660efa32f0..89c9dc1b9b 100644
--- a/kernel/api/contract.go
+++ b/kernel/api/contract.go
@@ -42,6 +42,17 @@ func notebookConfContract(value *conf.BoxConf) *apicontract.NotebookConf {
// contractHandler 将请求绑定和响应类型与注册契约关联,业务入口继续使用现有中间件。
func contractHandler[Request, Data any](endpoint apicontract.Endpoint[Request, Data],
handler func(*gin.Context, Request) apicontract.Response[Data], beforeDecode ...func(*gin.Context) *apicontract.Response[Data]) gin.HandlerFunc {
+ if namespace := additionalSettingNamespace(endpoint.Definition().Path); namespace != "" {
+ handler = serializeSetting(namespace, handler)
+ }
+ if endpoint.Definition().Path == "/api/system/getConf" {
+ read := handler
+ handler = func(c *gin.Context, request Request) apicontract.Response[Data] {
+ settingMutationMu.Lock()
+ defer settingMutationMu.Unlock()
+ return read(c, request)
+ }
+ }
return func(c *gin.Context) {
writeResponse := func(response apicontract.Response[Data]) {
if after := response.AfterWrite(); after != nil {
diff --git a/kernel/api/router.go b/kernel/api/router.go
index ebce067bfa..48a9653679 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -488,6 +488,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/transactions/redo", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, performRedo)
ginServer.Handle("POST", "/api/transactions/clearHistory", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, clearHistory)
+ ginServer.Handle("POST", "/api/setting/patch", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, patchSetting)
ginServer.Handle("POST", "/api/setting/setEditor", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setEditor)
ginServer.Handle("POST", "/api/setting/setExport", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setExport)
ginServer.Handle("POST", "/api/setting/getPandocBin", model.CheckAuth, model.CheckAdminRole, getPandocBin)
diff --git a/kernel/api/setting.go b/kernel/api/setting.go
index 6f7735eced..c9bc239d95 100644
--- a/kernel/api/setting.go
+++ b/kernel/api/setting.go
@@ -169,7 +169,9 @@ func setKernelPluginsEnabled(enabled bool) {
}
}
-var setAI = contractHandler(apicontract.SetAI, func(c *gin.Context, request apicontract.SetAIRequest) (ret apicontract.Response[*apicontract.SettingAI]) {
+var setAI = contractHandler(apicontract.SetAI, serializeSetting("ai", applyAISetting))
+
+func applyAISetting(c *gin.Context, request apicontract.SetAIRequest) (ret apicontract.Response[*apicontract.SettingAI]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingAI](-1, err.Error())
}
@@ -242,7 +244,7 @@ var setAI = contractHandler(apicontract.SetAI, func(c *gin.Context, request apic
ret = apicontract.Success(settingAIPayload(model.Conf.AI))
return
-})
+}
func preserveMCPServerIDs(oldServers, newServers []conf.MCPServer) {
oldIDsByName := make(map[string]string, len(oldServers))
@@ -256,7 +258,9 @@ func preserveMCPServerIDs(oldServers, newServers []conf.MCPServer) {
}
}
-var setSecrets = contractHandler(apicontract.SetSecrets, func(c *gin.Context, request apicontract.SetSecretsRequest) (ret apicontract.Response[*apicontract.SettingSecrets]) {
+var setSecrets = contractHandler(apicontract.SetSecrets, serializeSetting("secrets", applySecretsSetting))
+
+func applySecretsSetting(c *gin.Context, request apicontract.SetSecretsRequest) (ret apicontract.Response[*apicontract.SettingSecrets]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingSecrets](-1, err.Error())
}
@@ -277,9 +281,11 @@ var setSecrets = contractHandler(apicontract.SetSecrets, func(c *gin.Context, re
ret = apicontract.Success(settingSecretsPayload(model.Conf.Secrets))
return
-})
+}
-var setVariables = contractHandler(apicontract.SetVariables, func(c *gin.Context, request apicontract.SetVariablesRequest) (ret apicontract.Response[*apicontract.SettingVariables]) {
+var setVariables = contractHandler(apicontract.SetVariables, serializeSetting("variables", applyVariablesSetting))
+
+func applyVariablesSetting(c *gin.Context, request apicontract.SetVariablesRequest) (ret apicontract.Response[*apicontract.SettingVariables]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingVariables](-1, err.Error())
}
@@ -300,7 +306,7 @@ var setVariables = contractHandler(apicontract.SetVariables, func(c *gin.Context
ret = apicontract.Success(settingVariablesPayload(model.Conf.Variables))
return
-})
+}
func reconnectStdioMCPWithEnvironment() {
if model.Conf.AI == nil || model.Conf.AI.MCP == nil {
@@ -322,7 +328,9 @@ func stdioMCPServerIDsWithEnvironment(servers []conf.MCPServer) []string {
return serverIDs
}
-var setFlashcard = contractHandler(apicontract.SetFlashcard, func(c *gin.Context, request apicontract.SetFlashcardRequest) (ret apicontract.Response[*apicontract.SettingFlashcard]) {
+var setFlashcard = contractHandler(apicontract.SetFlashcard, serializeSetting("flashcard", applyFlashcardSetting))
+
+func applyFlashcardSetting(c *gin.Context, request apicontract.SetFlashcardRequest) (ret apicontract.Response[*apicontract.SettingFlashcard]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingFlashcard](-1, err.Error())
}
@@ -350,9 +358,11 @@ var setFlashcard = contractHandler(apicontract.SetFlashcard, func(c *gin.Context
ret = apicontract.Success(settingFlashcardPayload(flashcard))
return
-})
+}
-var setEditor = contractHandler(apicontract.SetEditor, func(c *gin.Context, request apicontract.SetEditorRequest) (ret apicontract.Response[*apicontract.SettingEditor]) {
+var setEditor = contractHandler(apicontract.SetEditor, serializeSetting("editor", applyEditorSetting))
+
+func applyEditorSetting(c *gin.Context, request apicontract.SetEditorRequest) (ret apicontract.Response[*apicontract.SettingEditor]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingEditor](-1, err.Error())
}
@@ -434,9 +444,11 @@ var setEditor = contractHandler(apicontract.SetEditor, func(c *gin.Context, requ
ret = apicontract.Success(settingEditorPayload(model.Conf.Editor))
return
-})
+}
-var setExport = contractHandler(apicontract.SetExport, func(c *gin.Context, request apicontract.SetExportRequest) (ret apicontract.Response[*apicontract.SettingExport]) {
+var setExport = contractHandler(apicontract.SetExport, serializeSetting("export", applyExportSetting))
+
+func applyExportSetting(c *gin.Context, request apicontract.SetExportRequest) (ret apicontract.Response[*apicontract.SettingExport]) {
if err := request.ConfigError(); err != nil {
return apicontract.FailureWithTimeout[*apicontract.SettingExport](-1, err.Error(), 5000)
}
@@ -467,7 +479,7 @@ var setExport = contractHandler(apicontract.SetExport, func(c *gin.Context, requ
ret = apicontract.Success(settingExportPayload(model.Conf.Export))
return
-})
+}
var getPandocBin = contractHandler(apicontract.GetPandocBin, func(c *gin.Context, request apicontract.EmptyRequest) apicontract.Response[string] {
pandocRuntime := util.GetPandocRuntime()
@@ -481,7 +493,9 @@ var getPandocBin = contractHandler(apicontract.GetPandocBin, func(c *gin.Context
return apicontract.Success(pandocRuntime.BinPath)
})
-var setFiletree = contractHandler(apicontract.SetFiletree, func(c *gin.Context, request apicontract.SetFiletreeRequest) (ret apicontract.Response[*apicontract.SettingFileTree]) {
+var setFiletree = contractHandler(apicontract.SetFiletree, serializeSetting("fileTree", applyFiletreeSetting))
+
+func applyFiletreeSetting(c *gin.Context, request apicontract.SetFiletreeRequest) (ret apicontract.Response[*apicontract.SettingFileTree]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingFileTree](-1, err.Error())
}
@@ -564,9 +578,11 @@ var setFiletree = contractHandler(apicontract.SetFiletree, func(c *gin.Context,
ret = apicontract.Success(settingFileTreePayload(model.Conf.FileTree))
return
-})
+}
-var setSearch = contractHandler(apicontract.SetSearch, func(c *gin.Context, request apicontract.SetSearchRequest) (ret apicontract.Response[*apicontract.SettingSearch]) {
+var setSearch = contractHandler(apicontract.SetSearch, serializeSetting("search", applySearchSetting))
+
+func applySearchSetting(c *gin.Context, request apicontract.SetSearchRequest) (ret apicontract.Response[*apicontract.SettingSearch]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingSearch](-1, err.Error())
}
@@ -630,9 +646,11 @@ var setSearch = contractHandler(apicontract.SetSearch, func(c *gin.Context, requ
}
ret = apicontract.Success(settingSearchPayload(s))
return
-})
+}
+
+var setKeymap = contractHandler(apicontract.SetKeymap, applyKeymapSetting)
-var setKeymap = contractHandler(apicontract.SetKeymap, func(c *gin.Context, request apicontract.SettingKeymapRequest) apicontract.Response[apicontract.Null] {
+func applyKeymapSetting(c *gin.Context, request apicontract.SettingKeymapRequest) apicontract.Response[apicontract.Null] {
param, err := gulu.JSON.MarshalJSON(request.Data)
if err != nil {
return apicontract.Failure[apicontract.Null](-1, err.Error())
@@ -644,9 +662,11 @@ var setKeymap = contractHandler(apicontract.SetKeymap, func(c *gin.Context, requ
model.Conf.Keymap = keymap
model.Conf.Save()
return apicontract.Success(apicontract.Null{})
-})
+}
-var setAppearance = contractHandler(apicontract.SetAppearance, func(c *gin.Context, request apicontract.SetAppearanceRequest) (ret apicontract.Response[*apicontract.SettingAppearance]) {
+var setAppearance = contractHandler(apicontract.SetAppearance, serializeSetting("appearance", applyAppearanceSetting))
+
+func applyAppearanceSetting(c *gin.Context, request apicontract.SetAppearanceRequest) (ret apicontract.Response[*apicontract.SettingAppearance]) {
if err := request.ConfigError(); err != nil {
return apicontract.Failure[*apicontract.SettingAppearance](-1, err.Error())
}
@@ -688,7 +708,7 @@ var setAppearance = contractHandler(apicontract.SetAppearance, func(c *gin.Conte
ret = apicontract.Success(settingAppearancePayload(model.Conf.Appearance))
util.BroadcastByType("main", "setAppearance", 0, "", model.Conf.Appearance)
return
-})
+}
var getBootAppearances = contractHandler(apicontract.GetBootAppearances, func(c *gin.Context, request apicontract.EmptyRequest) apicontract.Response[apicontract.SettingBootAppearancesData] {
appearances := model.GetBootAppearances()
diff --git a/kernel/api/setting_patch.go b/kernel/api/setting_patch.go
new file mode 100644
index 0000000000..22a681a91f
--- /dev/null
+++ b/kernel/api/setting_patch.go
@@ -0,0 +1,192 @@
+package api
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "sort"
+ "strings"
+ "sync"
+ "sync/atomic"
+
+ "github.com/gin-gonic/gin"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
+ "github.com/siyuan-note/siyuan/kernel/conf"
+ "github.com/siyuan-note/siyuan/kernel/model"
+ "github.com/siyuan-note/siyuan/kernel/util"
+)
+
+// 配置更新按内核接受顺序提交,旧接口与字段更新共用互斥,通知只携带配置域和顺序号。
+var settingMutationMu sync.Mutex
+var settingRevision uint64
+var settingTaskID atomic.Uint64
+var settingTasksMu sync.Mutex
+var settingTasks = map[string]apicontract.SettingTask{}
+var settingTaskRevision uint64
+
+func activeSettingTasks() *apicontract.SettingTaskState {
+ settingTasksMu.Lock()
+ defer settingTasksMu.Unlock()
+ tasks := make([]apicontract.SettingTask, 0, len(settingTasks))
+ for _, task := range settingTasks {
+ tasks = append(tasks, task)
+ }
+ sort.Slice(tasks, func(i, j int) bool { return tasks[i].ID < tasks[j].ID })
+ return &apicontract.SettingTaskState{Revision: settingTaskRevision, Tasks: tasks}
+}
+
+// 每个任务独立结束通知,避免一个任务结束时取消另一个任务的遮罩。
+func beginSettingTask(messageKey string) func() {
+ id := fmt.Sprint(settingTaskID.Add(1))
+ message := util.I18nTerm(model.Conf.Lang, messageKey)
+ notify := func(active bool) {
+ settingTasksMu.Lock()
+ settingTaskRevision++
+ task := apicontract.SettingTask{ID: id, Active: active, Message: message, Revision: settingTaskRevision}
+ if active {
+ settingTasks[id] = task
+ } else {
+ delete(settingTasks, id)
+ }
+ util.BroadcastByType("main", "settingTask", 0, "", task)
+ settingTasksMu.Unlock()
+ }
+ notify(true)
+ return func() { notify(false) }
+}
+
+// 单项设置接口沿用原请求和返回值,成功后通知其他前端重新读取配置。
+func additionalSettingNamespace(path string) string {
+ switch path {
+ case "/api/setting/setKeymap":
+ return "keymap"
+ case "/api/setting/setBazaar":
+ return "bazaar"
+ case "/api/setting/setPublish":
+ return "publish"
+ case "/api/system/importConf":
+ return "*"
+ case "/api/system/setAutoLaunch", "/api/system/setFollowSystemLockScreen",
+ "/api/system/setDownloadInstallPkg", "/api/system/setUpdateChannel", "/api/system/setNetworkProxy",
+ "/api/system/setAPIToken", "/api/system/setAccessAuthCode", "/api/system/setOIDC":
+ return "system"
+ }
+ if strings.HasPrefix(path, "/api/sync/set") {
+ return "sync"
+ }
+ if strings.HasPrefix(path, "/api/repo/set") {
+ return "repo"
+ }
+ if strings.HasPrefix(path, "/api/sync/importSyncProvider") {
+ return "sync"
+ }
+ return ""
+}
+
+func notifySettingChanged(namespace string) {
+ settingRevision++
+ util.BroadcastByType("main", "settingChanged", 0, "", struct {
+ Namespace string `json:"namespace"`
+ Revision uint64 `json:"revision"`
+ }{namespace, settingRevision})
+}
+
+func serializeSetting[Request, Data any](namespace string,
+ apply func(*gin.Context, Request) apicontract.Response[Data]) func(*gin.Context, Request) apicontract.Response[Data] {
+ return func(c *gin.Context, request Request) apicontract.Response[Data] {
+ settingMutationMu.Lock()
+ defer settingMutationMu.Unlock()
+ response := apply(c, request)
+ if response.Code() == 0 {
+ notifySettingChanged(namespace)
+ }
+ return response
+ }
+}
+
+func mergeSettingJSON(base, patch []byte) ([]byte, error) {
+ var current, changes map[string]json.RawMessage
+ if err := json.Unmarshal(base, &current); err != nil {
+ return nil, err
+ }
+ if err := json.Unmarshal(patch, &changes); err != nil {
+ return nil, err
+ }
+ if current == nil {
+ current = map[string]json.RawMessage{}
+ }
+ for key, value := range changes {
+ if bytes.HasPrefix(bytes.TrimSpace(value), []byte("{")) && bytes.HasPrefix(bytes.TrimSpace(current[key]), []byte("{")) {
+ merged, err := mergeSettingJSON(current[key], value)
+ if err != nil {
+ return nil, err
+ }
+ current[key] = merged
+ } else {
+ current[key] = value
+ }
+ }
+ return json.Marshal(current)
+}
+
+func applySettingPatch[Request, Data, Config any](c *gin.Context, patch []byte, config Config,
+ endpoint apicontract.Endpoint[Request, Data], apply func(*gin.Context, Request) apicontract.Response[Data]) apicontract.Response[apicontract.Null] {
+ base, err := json.Marshal(config)
+ if err != nil {
+ return apicontract.Failure[apicontract.Null](-1, err.Error())
+ }
+ merged, err := mergeSettingJSON(base, patch)
+ if err != nil {
+ return apicontract.Failure[apicontract.Null](-1, err.Error())
+ }
+ request, err := endpoint.Decode(bytes.NewReader(merged))
+ if err != nil {
+ return apicontract.Failure[apicontract.Null](-1, err.Error())
+ }
+ response := apply(c, request)
+ if response.Code() != 0 {
+ return apicontract.Failure[apicontract.Null](response.Code(), response.Message())
+ }
+ return apicontract.Success(apicontract.Null{})
+}
+
+var patchSetting = contractHandler(apicontract.PatchSetting, func(c *gin.Context, request apicontract.PatchSettingRequest) apicontract.Response[apicontract.Null] {
+ settingMutationMu.Lock()
+ defer settingMutationMu.Unlock()
+ patch := request.PatchJSON()
+ var response apicontract.Response[apicontract.Null]
+ switch request.Namespace() {
+ case "editor":
+ response = applySettingPatch(c, patch, model.Conf.Editor, apicontract.SetEditor, applyEditorSetting)
+ case "export":
+ response = applySettingPatch(c, patch, model.Conf.Export, apicontract.SetExport, applyExportSetting)
+ case "fileTree":
+ response = applySettingPatch(c, patch, model.Conf.FileTree, apicontract.SetFiletree, applyFiletreeSetting)
+ case "search":
+ response = applySettingPatch(c, patch, model.Conf.Search, apicontract.SetSearch, applySearchSetting)
+ case "appearance":
+ response = applySettingPatch(c, patch, model.Conf.Appearance, apicontract.SetAppearance, applyAppearanceSetting)
+ case "flashcard":
+ response = applySettingPatch(c, patch, model.Conf.Flashcard, apicontract.SetFlashcard, applyFlashcardSetting)
+ case "secrets":
+ response = applySettingPatch(c, patch, model.Conf.Secrets, apicontract.SetSecrets, applySecretsSetting)
+ case "variables":
+ response = applySettingPatch(c, patch, model.Conf.Variables, apicontract.SetVariables, applyVariablesSetting)
+ case "keymap":
+ response = applySettingPatch(c, append(append([]byte(`{"data":`), patch...), '}'),
+ struct {
+ Data *conf.Keymap `json:"data"`
+ }{model.Conf.Keymap}, apicontract.SetKeymap, applyKeymapSetting)
+ case "ai":
+ if util.IsDisabledFeature("ai") {
+ return apicontract.Failure[apicontract.Null](-1, util.I18nTerm(model.Conf.Lang, "agentCapabilitiesUnavailable"))
+ }
+ response = applySettingPatch(c, patch, model.Conf.AI, apicontract.SetAI, applyAISetting)
+ default:
+ return apicontract.Failure[apicontract.Null](-1, fmt.Sprintf("unsupported settings namespace: %s", request.Namespace()))
+ }
+ if response.Code() == 0 {
+ notifySettingChanged(request.Namespace())
+ }
+ return response
+})
diff --git a/kernel/api/setting_patch_test.go b/kernel/api/setting_patch_test.go
new file mode 100644
index 0000000000..4aec9f38c9
--- /dev/null
+++ b/kernel/api/setting_patch_test.go
@@ -0,0 +1,85 @@
+package api
+
+import (
+ "encoding/json"
+ "sync"
+ "testing"
+
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
+ "github.com/siyuan-note/siyuan/kernel/conf"
+ "github.com/siyuan-note/siyuan/kernel/model"
+ "github.com/siyuan-note/siyuan/kernel/util"
+)
+
+func TestAPIContractSettingPatchConcurrentFields(t *testing.T) {
+ previousConf, previousReadOnly, previousMarkdown := model.Conf, util.ReadOnly, util.MarkdownSettings
+ model.Conf = model.NewAppConf()
+ model.Conf.Editor = conf.NewEditor()
+ util.ReadOnly = true
+ t.Cleanup(func() {
+ model.Conf, util.ReadOnly, util.MarkdownSettings = previousConf, previousReadOnly, previousMarkdown
+ })
+ fontSize := model.Conf.Editor.FontSize
+ var group sync.WaitGroup
+ for _, body := range []string{`{"editor":{"displayImgName":true}}`, `{"editor":{"displayImgAlt":true}}`} {
+ group.Add(1)
+ go func() {
+ defer group.Done()
+ code, message, _ := settingContractRequest(t, "patch", patchSetting, body)
+ if code != 0 {
+ t.Errorf("patch failed: %d %s", code, message)
+ }
+ }()
+ }
+ group.Wait()
+ if !model.Conf.Editor.DisplayImgName || !model.Conf.Editor.DisplayImgAlt || model.Conf.Editor.FontSize != fontSize {
+ t.Fatal("independent settings updates must preserve each other and omitted fields")
+ }
+ before := settingRevision
+ code, _, _ := settingContractRequest(t, "patch", patchSetting, `{"editor":{"fontSize":"bad"}}`)
+ if code == 0 || settingRevision != before || model.Conf.Editor.FontSize != fontSize {
+ t.Fatal("failed patches must not modify configuration or publish a change")
+ }
+}
+
+func TestAPIContractSettingPatchRecursiveMerge(t *testing.T) {
+ merged, err := mergeSettingJSON([]byte(`{"object":{"left":1,"right":2},"array":[1,2],"keep":true}`),
+ []byte(`{"object":{"right":3},"array":[],"null":null}`))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var value map[string]json.RawMessage
+ if err = json.Unmarshal(merged, &value); err != nil {
+ t.Fatal(err)
+ }
+ if string(value["object"]) != `{"left":1,"right":3}` || string(value["array"]) != "[]" ||
+ string(value["keep"]) != "true" || string(value["null"]) != "null" {
+ t.Fatalf("unexpected merged settings: %s", merged)
+ }
+}
+
+func TestAPIContractSettingTaskSnapshots(t *testing.T) {
+ previousConf, previousTasks, previousRevision := model.Conf, settingTasks, settingTaskRevision
+ model.Conf = model.NewAppConf()
+ settingTasks = map[string]apicontract.SettingTask{}
+ settingTaskRevision = 0
+ t.Cleanup(func() {
+ model.Conf, settingTasks, settingTaskRevision = previousConf, previousTasks, previousRevision
+ })
+ endFirst := beginSettingTask("loading")
+ firstID := activeSettingTasks().Tasks[0].ID
+ endSecond := beginSettingTask("loading")
+ initial := activeSettingTasks()
+ if len(initial.Tasks) != 2 || initial.Revision != 2 {
+ t.Fatal("both concurrent tasks must appear in the snapshot")
+ }
+ endFirst()
+ next := activeSettingTasks()
+ if len(next.Tasks) != 1 || next.Revision != 3 || next.Tasks[0].ID == firstID {
+ t.Fatal("ending one task must preserve the other task and advance the snapshot")
+ }
+ endSecond()
+ if final := activeSettingTasks(); len(final.Tasks) != 0 || final.Revision != 4 {
+ t.Fatal("the final snapshot must release all tasks")
+ }
+}
diff --git a/kernel/api/system.go b/kernel/api/system.go
index 3520fc03bd..3354acc67d 100644
--- a/kernel/api/system.go
+++ b/kernel/api/system.go
@@ -581,6 +581,7 @@ var exportConf = contractHandler(apicontract.SystemExportConf, func(c *gin.Conte
})
var importConf = contractHandler(apicontract.SystemImportConf, func(c *gin.Context, request apicontract.SystemImportConfRequest) (ret apicontract.Response[apicontract.Null]) {
+ defer beginSettingTask("importConf")()
ret = apicontract.Success(apicontract.Null{})
logging.LogInfof("importing conf...")
@@ -787,7 +788,8 @@ var getConf = contractHandler(apicontract.SystemGetConf, func(c *gin.Context, re
if err != nil {
return apicontract.Failure[apicontract.SystemConfData](-1, "get conf failed: "+err.Error())
}
- ret = apicontract.Success(apicontract.SystemConfData{Conf: config, Start: !util.IsUILoaded.Load(), IsPublish: isPublish})
+ ret = apicontract.Success(apicontract.SystemConfData{Conf: config, Start: !util.IsUILoaded.Load(), IsPublish: isPublish,
+ SettingTasks: activeSettingTasks()})
return
})
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index d934a221d5..d0beec481e 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -877,6 +877,9 @@ var SetSecrets = define[SetSecretsRequest, *SettingSecrets]("setSecrets", "/api/
var SetVariables = define[SetVariablesRequest, *SettingVariables]("setVariables", "/api/setting/setVariables", JSONBody, ResponseOptions{}, "POST")
var SetFlashcard = define[SetFlashcardRequest, *SettingFlashcard]("setFlashcard", "/api/setting/setFlashcard", JSONBody, ResponseOptions{}, "POST")
var SetEditor = define[SetEditorRequest, *SettingEditor]("setEditor", "/api/setting/setEditor", JSONBody, ResponseOptions{}, "POST")
+
+// PatchSetting 保留省略字段,成功后客户端重新读取配置;通知不包含密码或密钥。
+var PatchSetting = define[PatchSettingRequest, Null]("patchSetting", "/api/setting/patch", JSONBody, ResponseOptions{}, "POST")
var SetExport = define[SetExportRequest, *SettingExport]("setExport", "/api/setting/setExport", JSONBody, ResponseOptions{}, "POST")
var SetFiletree = define[SetFiletreeRequest, *SettingFileTree]("setFiletree", "/api/setting/setFiletree", JSONBody, ResponseOptions{}, "POST")
var SetSearch = define[SetSearchRequest, *SettingSearch]("setSearch", "/api/setting/setSearch", JSONBody, ResponseOptions{}, "POST")
diff --git a/kernel/apicontract/response.go b/kernel/apicontract/response.go
index 0bdc331055..06a70357a0 100644
--- a/kernel/apicontract/response.go
+++ b/kernel/apicontract/response.go
@@ -170,6 +170,9 @@ func WithAfterWrite[Data any](response Response[Data], after func()) Response[Da
func (r Response[Data]) AfterWrite() func() { return r.afterWrite }
+func (r Response[Data]) Code() int { return r.code }
+func (r Response[Data]) Message() string { return r.msg }
+
// WithHTTPStatus 只为声明过的业务错误保留额外 HTTP 状态。
func (e Endpoint[Request, Data]) WithHTTPStatus(response Response[Data], status int) Response[Data] {
response.httpStatus = status
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 477226c864..43f9d97cea 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -33246,6 +33246,108 @@
],
"additionalProperties": false
},
+ "PatchSettingRequestInput": {
+ "type": "object",
+ "properties": {
+ "ai": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAIInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "appearance": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAppearanceInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "editor": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEditorInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "export": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingExportInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fileTree": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingFileTreeInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "flashcard": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingFlashcardInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "keymap": {
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#/$defs/JSONValue"
+ }
+ },
+ "search": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingSearchInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "secrets": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingSecretsInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "variables": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingVariablesInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"PerformSyncRequestInput": {
"type": "object",
"properties": {
@@ -40519,6 +40621,102 @@
],
"additionalProperties": false
},
+ "SettingAIInput": {
+ "type": "object",
+ "properties": {
+ "agent": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAgentInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "decision": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingDecisionInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "editing": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEditingInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "embedding": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEmbeddingInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "imageGeneration": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingImageGenerationInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mcp": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingMCPInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "providers": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingProviderInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "rerank": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingRerankInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"SettingAgent": {
"type": "object",
"properties": {
@@ -40983,6 +41181,272 @@
},
"additionalProperties": false
},
+ "SettingAppearanceInput": {
+ "type": "object",
+ "properties": {
+ "bodyGradient": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingBodyGradientInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "closeButtonBehavior": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeBlockThemeDark": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeBlockThemeLight": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "darkThemes": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAppearanceThemeInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "entryVisibility": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEntryVisibilityInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "globalFontFamilies": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEditorFontInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "hideStatusBar": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "hideToolbar": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "icon": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "iconVer": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "icons": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAppearanceIconInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "lang": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "lightThemes": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAppearanceThemeInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "modeOS": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "notifications": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingNotificationsInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "statusBar": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingStatusBarInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "themeDark": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "themeJS": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "themeLight": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "themeVer": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"SettingAppearanceTheme": {
"type": "object",
"properties": {
@@ -42348,46 +42812,1570 @@
},
"additionalProperties": false
},
+ "SettingEditorInput": {
+ "type": "object",
+ "properties": {
+ "allowHTMLBLockScript": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "allowSVGScript": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "assetOpen": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingAssetOpenInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "autoDirection": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkBlockSort": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkContainChildren": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkExpandCount": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkGlobalSort": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkHideReference": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkMentionExclude": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkShowBottom": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkSort": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backmentionExpandCount": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backmentionSort": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "blockRefDynamicAnchorTextMaxLen": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "checkBlockRef": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeFontFamilies": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEditorFontInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeLigatures": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeLineWrap": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeSyntaxHighlightLineNum": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeTabSpaces": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "cursorSurroundingLines": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "databaseAttrClickMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "databaseAttrHideEmpty": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "databaseAttrShow": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "databaseAttrUseTabs": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "databaseAttrViewMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "displayBookmarkIcon": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "displayImgAlt": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "displayImgName": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "displayNetImgMark": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dragHTMLFileToIframe": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dynamicLoadBlocks": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "embedBlockBreadcrumb": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "emoji": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "floatWindowDelay": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "floatWindowMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fontFamilies": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEditorFontInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fontFamily": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fontFamilyDisplay": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fontSize": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fontSizeScrollZoom": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fontWeight": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fullWidth": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "generateHistoryInterval": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "hashTagSearch": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "headingEmbedMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "headingNumber": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "headingNumberFormat": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "historyRetentionDays": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "justify": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "katexMacros": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "keepLoadedContent": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "listItemDotNumberClickFocus": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "listLogicalOutdent": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "markdown": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingMarkdownInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "onlySearchForDoc": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pasteURLAutoConvert": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "plantUMLServePath": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "readOnly": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "rtl": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "spellcheck": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "spellcheckLanguages": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualBlockRef": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualBlockRefExclude": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualBlockRefInclude": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"SettingEmbedding": {
"type": "object",
"properties": {
- "apiKey": {
+ "apiKey": {
+ "type": "string"
+ },
+ "baseURL": {
+ "type": "string"
+ },
+ "dimensions": {
+ "type": "integer"
+ },
+ "enabled": {
+ "type": "boolean"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "timeout": {
+ "type": "integer"
+ }
+ },
+ "required": [
+ "apiKey",
+ "baseURL",
+ "dimensions",
+ "enabled",
+ "id",
+ "name",
+ "timeout"
+ ],
+ "additionalProperties": false
+ },
+ "SettingEmbeddingInput": {
+ "type": "object",
+ "properties": {
+ "apiKey": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "baseURL": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "dimensions": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "enabled": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "name": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "timeout": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
+ "SettingEmojiRequestInput": {
+ "type": "object",
+ "properties": {
+ "emoji": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "emoji"
+ ],
+ "additionalProperties": false
+ },
+ "SettingEntryVisibility": {
+ "type": "object",
+ "properties": {
+ "active": {
+ "type": "string"
+ },
+ "profiles": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEntryVisibilityProfile"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "version": {
+ "type": "integer"
+ }
+ },
+ "required": [
+ "active",
+ "profiles",
+ "version"
+ ],
+ "additionalProperties": false
+ },
+ "SettingEntryVisibilityInput": {
+ "type": "object",
+ "properties": {
+ "active": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "profiles": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingEntryVisibilityProfileInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "version": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
+ "SettingEntryVisibilityProfile": {
+ "type": "object",
+ "properties": {
+ "entries": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "type": "boolean"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "orders": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": [
+ "entries",
+ "id",
+ "name",
+ "orders"
+ ],
+ "additionalProperties": false
+ },
+ "SettingEntryVisibilityProfileInput": {
+ "type": "object",
+ "properties": {
+ "entries": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "type": "boolean"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "name": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "orders": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
+ "SettingExport": {
+ "type": "object",
+ "properties": {
+ "addTitle": {
+ "type": "boolean"
+ },
+ "blockEmbedMode": {
+ "type": "integer"
+ },
+ "blockRefMode": {
+ "type": "integer"
+ },
+ "blockRefTextLeft": {
+ "type": "string"
+ },
+ "blockRefTextRight": {
+ "type": "string"
+ },
+ "docxTemplate": {
+ "type": "string"
+ },
+ "fileAnnotationRefMode": {
+ "type": "integer"
+ },
+ "imageWatermarkDesc": {
+ "type": "string"
+ },
+ "imageWatermarkStr": {
+ "type": "string"
+ },
+ "includeRelatedDocs": {
+ "type": "boolean"
+ },
+ "includeSubDocs": {
+ "type": "boolean"
+ },
+ "inlineMemo": {
+ "type": "boolean"
+ },
+ "markdownYFM": {
+ "type": "boolean"
+ },
+ "pandocBin": {
+ "type": "string"
+ },
+ "pandocParams": {
+ "type": "string"
+ },
+ "paragraphBeginningSpace": {
+ "type": "boolean"
+ },
+ "pdfFooter": {
+ "type": "string"
+ },
+ "pdfWatermarkDesc": {
+ "type": "string"
+ },
+ "pdfWatermarkStr": {
+ "type": "string"
+ },
+ "removeAssetsID": {
+ "type": "boolean"
+ },
+ "tagCloseMarker": {
+ "type": "string"
+ },
+ "tagOpenMarker": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "addTitle",
+ "blockEmbedMode",
+ "blockRefMode",
+ "blockRefTextLeft",
+ "blockRefTextRight",
+ "docxTemplate",
+ "fileAnnotationRefMode",
+ "imageWatermarkDesc",
+ "imageWatermarkStr",
+ "includeRelatedDocs",
+ "includeSubDocs",
+ "inlineMemo",
+ "markdownYFM",
+ "pandocBin",
+ "pandocParams",
+ "paragraphBeginningSpace",
+ "pdfFooter",
+ "pdfWatermarkDesc",
+ "pdfWatermarkStr",
+ "removeAssetsID",
+ "tagCloseMarker",
+ "tagOpenMarker"
+ ],
+ "additionalProperties": false
+ },
+ "SettingExportInput": {
+ "type": "object",
+ "properties": {
+ "addTitle": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "blockEmbedMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "blockRefMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "blockRefTextLeft": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "blockRefTextRight": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "docxTemplate": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "fileAnnotationRefMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "imageWatermarkDesc": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "imageWatermarkStr": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "includeRelatedDocs": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "includeSubDocs": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "inlineMemo": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "markdownYFM": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pandocBin": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pandocParams": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "paragraphBeginningSpace": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pdfFooter": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pdfWatermarkDesc": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "pdfWatermarkStr": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "removeAssetsID": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tagCloseMarker": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tagOpenMarker": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
+ "SettingFileTree": {
+ "type": "object",
+ "properties": {
+ "allowCreateDeeper": {
+ "type": "boolean"
+ },
+ "alwaysSelectOpenedFile": {
+ "type": "boolean"
+ },
+ "boxDocEnabled": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "closeTabOnDoubleClick": {
+ "type": "boolean"
+ },
+ "closeTabsOnStart": {
+ "type": "boolean"
+ },
+ "createDocAtTop": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "docCreateSaveBox": {
"type": "string"
},
- "baseURL": {
+ "docCreateSavePath": {
"type": "string"
},
- "dimensions": {
+ "docCreateTemplatePath": {
+ "type": "string"
+ },
+ "docIconClickExpand": {
+ "type": "boolean"
+ },
+ "largeFileWarningSize": {
"type": "integer"
},
- "enabled": {
+ "maxListCount": {
+ "type": "integer"
+ },
+ "maxOpenTabCount": {
+ "type": "integer"
+ },
+ "noSplitScreenWhenOpenTab": {
"type": "boolean"
},
- "id": {
+ "openFilesUseCurrentTab": {
+ "type": "boolean"
+ },
+ "parentDocClickExpand": {
+ "type": "boolean"
+ },
+ "recentDocsMaxListCount": {
+ "type": "integer"
+ },
+ "refCreateSaveBox": {
"type": "string"
},
- "name": {
+ "refCreateSavePath": {
"type": "string"
},
- "timeout": {
+ "removeDocWithoutConfirm": {
+ "type": "boolean"
+ },
+ "shorthandSaveBox": {
+ "type": "string"
+ },
+ "shorthandSavePath": {
+ "type": "string"
+ },
+ "sort": {
"type": "integer"
+ },
+ "tabStartupMode": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "useSVGDefaultIcon": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "useSingleLineSave": {
+ "type": "boolean"
}
},
"required": [
- "apiKey",
- "baseURL",
- "dimensions",
- "enabled",
- "id",
- "name",
- "timeout"
+ "allowCreateDeeper",
+ "alwaysSelectOpenedFile",
+ "boxDocEnabled",
+ "closeTabOnDoubleClick",
+ "closeTabsOnStart",
+ "createDocAtTop",
+ "docCreateSaveBox",
+ "docCreateSavePath",
+ "docCreateTemplatePath",
+ "docIconClickExpand",
+ "largeFileWarningSize",
+ "maxListCount",
+ "maxOpenTabCount",
+ "noSplitScreenWhenOpenTab",
+ "openFilesUseCurrentTab",
+ "parentDocClickExpand",
+ "recentDocsMaxListCount",
+ "refCreateSaveBox",
+ "refCreateSavePath",
+ "removeDocWithoutConfirm",
+ "shorthandSaveBox",
+ "shorthandSavePath",
+ "sort",
+ "tabStartupMode",
+ "useSVGDefaultIcon",
+ "useSingleLineSave"
],
"additionalProperties": false
},
- "SettingEmbeddingInput": {
+ "SettingFileTreeInput": {
"type": "object",
"properties": {
- "apiKey": {
+ "allowCreateDeeper": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "alwaysSelectOpenedFile": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "boxDocEnabled": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "closeTabOnDoubleClick": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "closeTabsOnStart": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "createDocAtTop": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "docCreateSaveBox": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "docCreateSavePath": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "docCreateTemplatePath": {
"anyOf": [
{
"type": "string"
@@ -42397,17 +44385,17 @@
}
]
},
- "baseURL": {
+ "docIconClickExpand": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
]
},
- "dimensions": {
+ "largeFileWarningSize": {
"anyOf": [
{
"type": "integer"
@@ -42417,254 +44405,150 @@
}
]
},
- "enabled": {
+ "maxListCount": {
"anyOf": [
{
- "type": "boolean"
+ "type": "integer"
},
{
"type": "null"
}
]
},
- "id": {
+ "maxOpenTabCount": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
]
},
- "name": {
+ "noSplitScreenWhenOpenTab": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
]
},
- "timeout": {
+ "openFilesUseCurrentTab": {
"anyOf": [
{
- "type": "integer"
+ "type": "boolean"
},
{
"type": "null"
}
]
- }
- },
- "additionalProperties": false
- },
- "SettingEmojiRequestInput": {
- "type": "object",
- "properties": {
- "emoji": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- },
- "required": [
- "emoji"
- ],
- "additionalProperties": false
- },
- "SettingEntryVisibility": {
- "type": "object",
- "properties": {
- "active": {
- "type": "string"
},
- "profiles": {
+ "parentDocClickExpand": {
"anyOf": [
{
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/SettingEntryVisibilityProfile"
- },
- {
- "type": "null"
- }
- ]
- }
+ "type": "boolean"
},
{
"type": "null"
}
]
},
- "version": {
- "type": "integer"
- }
- },
- "required": [
- "active",
- "profiles",
- "version"
- ],
- "additionalProperties": false
- },
- "SettingEntryVisibilityInput": {
- "type": "object",
- "properties": {
- "active": {
+ "recentDocsMaxListCount": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
]
},
- "profiles": {
+ "refCreateSaveBox": {
"anyOf": [
{
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/SettingEntryVisibilityProfileInput"
- },
- {
- "type": "null"
- }
- ]
- }
+ "type": "string"
},
{
"type": "null"
}
]
},
- "version": {
+ "refCreateSavePath": {
"anyOf": [
{
- "type": "integer"
+ "type": "string"
},
{
"type": "null"
}
]
- }
- },
- "additionalProperties": false
- },
- "SettingEntryVisibilityProfile": {
- "type": "object",
- "properties": {
- "entries": {
+ },
+ "removeDocWithoutConfirm": {
"anyOf": [
{
- "type": "object",
- "additionalProperties": {
- "type": "boolean"
- }
+ "type": "boolean"
},
{
"type": "null"
}
]
},
- "id": {
- "type": "string"
- },
- "name": {
- "type": "string"
+ "shorthandSaveBox": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
- "orders": {
+ "shorthandSavePath": {
"anyOf": [
{
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "null"
- }
- ]
- }
+ "type": "string"
},
{
"type": "null"
}
]
- }
- },
- "required": [
- "entries",
- "id",
- "name",
- "orders"
- ],
- "additionalProperties": false
- },
- "SettingEntryVisibilityProfileInput": {
- "type": "object",
- "properties": {
- "entries": {
+ },
+ "sort": {
"anyOf": [
{
- "type": "object",
- "additionalProperties": {
- "type": "boolean"
- }
+ "type": "integer"
},
{
"type": "null"
}
]
},
- "id": {
+ "tabStartupMode": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
]
},
- "name": {
+ "useSVGDefaultIcon": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
]
},
- "orders": {
+ "useSingleLineSave": {
"anyOf": [
{
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "null"
- }
- ]
- }
+ "type": "boolean"
},
{
"type": "null"
@@ -42674,112 +44558,70 @@
},
"additionalProperties": false
},
- "SettingExport": {
+ "SettingFlashcard": {
"type": "object",
"properties": {
- "addTitle": {
+ "blockquote": {
"type": "boolean"
},
- "blockEmbedMode": {
- "type": "integer"
- },
- "blockRefMode": {
- "type": "integer"
- },
- "blockRefTextLeft": {
- "type": "string"
- },
- "blockRefTextRight": {
- "type": "string"
- },
- "docxTemplate": {
- "type": "string"
- },
- "fileAnnotationRefMode": {
- "type": "integer"
- },
- "imageWatermarkDesc": {
- "type": "string"
- },
- "imageWatermarkStr": {
- "type": "string"
- },
- "includeRelatedDocs": {
+ "callout": {
"type": "boolean"
},
- "includeSubDocs": {
+ "deck": {
"type": "boolean"
},
- "inlineMemo": {
+ "heading": {
"type": "boolean"
},
- "markdownYFM": {
+ "list": {
"type": "boolean"
},
- "pandocBin": {
- "type": "string"
+ "mark": {
+ "type": "boolean"
},
- "pandocParams": {
- "type": "string"
+ "maximumInterval": {
+ "type": "integer"
},
- "paragraphBeginningSpace": {
- "type": "boolean"
+ "newCardLimit": {
+ "type": "integer"
},
- "pdfFooter": {
- "type": "string"
+ "requestRetention": {
+ "type": "number"
},
- "pdfWatermarkDesc": {
- "type": "string"
+ "reviewCardLimit": {
+ "type": "integer"
},
- "pdfWatermarkStr": {
- "type": "string"
+ "reviewMode": {
+ "type": "integer"
},
- "removeAssetsID": {
+ "superBlock": {
"type": "boolean"
},
- "tagCloseMarker": {
- "type": "string"
- },
- "tagOpenMarker": {
+ "weights": {
"type": "string"
}
},
"required": [
- "addTitle",
- "blockEmbedMode",
- "blockRefMode",
- "blockRefTextLeft",
- "blockRefTextRight",
- "docxTemplate",
- "fileAnnotationRefMode",
- "imageWatermarkDesc",
- "imageWatermarkStr",
- "includeRelatedDocs",
- "includeSubDocs",
- "inlineMemo",
- "markdownYFM",
- "pandocBin",
- "pandocParams",
- "paragraphBeginningSpace",
- "pdfFooter",
- "pdfWatermarkDesc",
- "pdfWatermarkStr",
- "removeAssetsID",
- "tagCloseMarker",
- "tagOpenMarker"
+ "blockquote",
+ "callout",
+ "deck",
+ "heading",
+ "list",
+ "mark",
+ "maximumInterval",
+ "newCardLimit",
+ "requestRetention",
+ "reviewCardLimit",
+ "reviewMode",
+ "superBlock",
+ "weights"
],
"additionalProperties": false
},
- "SettingFileTree": {
+ "SettingFlashcardInput": {
"type": "object",
"properties": {
- "allowCreateDeeper": {
- "type": "boolean"
- },
- "alwaysSelectOpenedFile": {
- "type": "boolean"
- },
- "boxDocEnabled": {
+ "blockquote": {
"anyOf": [
{
"type": "boolean"
@@ -42789,13 +44631,7 @@
}
]
},
- "closeTabOnDoubleClick": {
- "type": "boolean"
- },
- "closeTabsOnStart": {
- "type": "boolean"
- },
- "createDocAtTop": {
+ "callout": {
"anyOf": [
{
"type": "boolean"
@@ -42805,68 +44641,17 @@
}
]
},
- "docCreateSaveBox": {
- "type": "string"
- },
- "docCreateSavePath": {
- "type": "string"
- },
- "docCreateTemplatePath": {
- "type": "string"
- },
- "docIconClickExpand": {
- "type": "boolean"
- },
- "largeFileWarningSize": {
- "type": "integer"
- },
- "maxListCount": {
- "type": "integer"
- },
- "maxOpenTabCount": {
- "type": "integer"
- },
- "noSplitScreenWhenOpenTab": {
- "type": "boolean"
- },
- "openFilesUseCurrentTab": {
- "type": "boolean"
- },
- "parentDocClickExpand": {
- "type": "boolean"
- },
- "recentDocsMaxListCount": {
- "type": "integer"
- },
- "refCreateSaveBox": {
- "type": "string"
- },
- "refCreateSavePath": {
- "type": "string"
- },
- "removeDocWithoutConfirm": {
- "type": "boolean"
- },
- "shorthandSaveBox": {
- "type": "string"
- },
- "shorthandSavePath": {
- "type": "string"
- },
- "sort": {
- "type": "integer"
- },
- "tabStartupMode": {
+ "deck": {
"anyOf": [
{
- "type": "integer"
+ "type": "boolean"
},
{
"type": "null"
}
]
},
- "useSVGDefaultIcon": {
+ "heading": {
"anyOf": [
{
"type": "boolean"
@@ -42876,98 +44661,97 @@
}
]
},
- "useSingleLineSave": {
- "type": "boolean"
- }
- },
- "required": [
- "allowCreateDeeper",
- "alwaysSelectOpenedFile",
- "boxDocEnabled",
- "closeTabOnDoubleClick",
- "closeTabsOnStart",
- "createDocAtTop",
- "docCreateSaveBox",
- "docCreateSavePath",
- "docCreateTemplatePath",
- "docIconClickExpand",
- "largeFileWarningSize",
- "maxListCount",
- "maxOpenTabCount",
- "noSplitScreenWhenOpenTab",
- "openFilesUseCurrentTab",
- "parentDocClickExpand",
- "recentDocsMaxListCount",
- "refCreateSaveBox",
- "refCreateSavePath",
- "removeDocWithoutConfirm",
- "shorthandSaveBox",
- "shorthandSavePath",
- "sort",
- "tabStartupMode",
- "useSVGDefaultIcon",
- "useSingleLineSave"
- ],
- "additionalProperties": false
- },
- "SettingFlashcard": {
- "type": "object",
- "properties": {
- "blockquote": {
- "type": "boolean"
- },
- "callout": {
- "type": "boolean"
- },
- "deck": {
- "type": "boolean"
- },
- "heading": {
- "type": "boolean"
- },
"list": {
- "type": "boolean"
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"mark": {
- "type": "boolean"
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"maximumInterval": {
- "type": "integer"
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"newCardLimit": {
- "type": "integer"
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"requestRetention": {
- "type": "number"
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"reviewCardLimit": {
- "type": "integer"
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"reviewMode": {
- "type": "integer"
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"superBlock": {
- "type": "boolean"
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"weights": {
- "type": "string"
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
}
},
- "required": [
- "blockquote",
- "callout",
- "deck",
- "heading",
- "list",
- "mark",
- "maximumInterval",
- "newCardLimit",
- "requestRetention",
- "reviewCardLimit",
- "reviewMode",
- "superBlock",
- "weights"
- ],
"additionalProperties": false
},
"SettingIconRequestInput": {
@@ -44418,6 +46202,412 @@
],
"additionalProperties": false
},
+ "SettingSearchInput": {
+ "type": "object",
+ "properties": {
+ "alias": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "audioBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkMentionAlias": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkMentionAnchor": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkMentionDoc": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkMentionKeywordsLimit": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "backlinkMentionName": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "blockquote": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "callout": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "caseSensitive": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "codeBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "customBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "databaseBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "document": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "embedBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "hanSensitive": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "heading": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "htmlBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "ial": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "iframeBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "indexAssetPath": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "limit": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "list": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "listItem": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mathBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "memo": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mindmap": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "mindmapItem": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "name": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "paragraph": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "superBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tabItem": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "table": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tabs": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "videoBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualRefAlias": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualRefAnchor": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualRefDoc": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "virtualRefName": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "widgetBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"SettingSecret": {
"type": "object",
"properties": {
@@ -44516,6 +46706,32 @@
],
"additionalProperties": false
},
+ "SettingSecretsInput": {
+ "type": "object",
+ "properties": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingSecretInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"SettingSnpt": {
"type": "object",
"properties": {
@@ -44630,6 +46846,56 @@
},
"additionalProperties": false
},
+ "SettingTask": {
+ "type": "object",
+ "properties": {
+ "active": {
+ "type": "boolean"
+ },
+ "id": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ },
+ "revision": {
+ "type": "integer"
+ }
+ },
+ "required": [
+ "active",
+ "id",
+ "message",
+ "revision"
+ ],
+ "additionalProperties": false
+ },
+ "SettingTaskState": {
+ "type": "object",
+ "properties": {
+ "revision": {
+ "type": "integer"
+ },
+ "tasks": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/SettingTask"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": [
+ "revision",
+ "tasks"
+ ],
+ "additionalProperties": false
+ },
"SettingThemeRequestInput": {
"type": "object",
"properties": {
@@ -44877,6 +47143,32 @@
],
"additionalProperties": false
},
+ "SettingVariablesInput": {
+ "type": "object",
+ "properties": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingVariableInput"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"Shorthand": {
"type": "object",
"properties": {
@@ -46383,6 +48675,9 @@
"isPublish": {
"type": "boolean"
},
+ "settingTasks": {
+ "$ref": "#/$defs/SettingTaskState"
+ },
"start": {
"type": "boolean"
}
@@ -142459,11 +144754,243 @@
},
{
"method": "POST",
- "path": "/api/notebook/lockNotebook",
- "handler": "lockNotebook",
+ "path": "/api/notebook/lockNotebook",
+ "handler": "lockNotebook",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/NotebookIDRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "type": "null"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/notebook/lsNotebooks",
+ "handler": "lsNotebooks",
+ "body": "legacyOptional",
+ "request": {
+ "$ref": "#/$defs/ListNotebooksRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ListNotebooksData"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/notebook/openNotebook",
+ "handler": "openNotebook",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/OpenNotebookRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "type": "null"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/notebook/prepareNotebookArchive",
+ "handler": "prepareNotebookArchive",
"body": "json",
"request": {
- "$ref": "#/$defs/NotebookIDRequestInput"
+ "$ref": "#/$defs/PrepareNotebookArchiveRequestInput"
},
"response": {
"anyOf": [
@@ -142477,7 +145004,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/NotebookArchiveData"
},
"msg": {
"type": "string"
@@ -142534,11 +145061,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/lsNotebooks",
- "handler": "lsNotebooks",
- "body": "legacyOptional",
+ "path": "/api/notebook/removeNotebook",
+ "handler": "removeNotebook",
+ "body": "json",
"request": {
- "$ref": "#/$defs/ListNotebooksRequestInput"
+ "$ref": "#/$defs/NotebookIDRequestInput"
},
"response": {
"anyOf": [
@@ -142552,14 +145079,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/ListNotebooksData"
- },
- {
- "type": "null"
- }
- ]
+ "type": "null"
},
"msg": {
"type": "string"
@@ -142616,11 +145136,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/openNotebook",
- "handler": "openNotebook",
+ "path": "/api/notebook/renameNotebook",
+ "handler": "renameNotebook",
"body": "json",
"request": {
- "$ref": "#/$defs/OpenNotebookRequestInput"
+ "$ref": "#/$defs/RenameNotebookRequestInput"
},
"response": {
"anyOf": [
@@ -142691,11 +145211,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/prepareNotebookArchive",
- "handler": "prepareNotebookArchive",
- "body": "json",
+ "path": "/api/notebook/reorder",
+ "handler": "reorderNotebooks",
+ "body": "structJSON",
"request": {
- "$ref": "#/$defs/PrepareNotebookArchiveRequestInput"
+ "$ref": "#/$defs/ReorderNotebooksRequestInput"
},
"response": {
"anyOf": [
@@ -142708,42 +145228,10 @@
0
]
},
- "data": {
- "$ref": "#/$defs/NotebookArchiveData"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
- },
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- -1
- ]
- },
"data": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "closeTimeout": {
- "type": "number"
- }
- },
- "required": [
- "closeTimeout"
- ],
- "additionalProperties": false
+ "$ref": "#/$defs/ReorderData"
},
{
"type": "null"
@@ -142759,42 +145247,6 @@
"msg",
"data"
],
- "additionalProperties": true
- }
- ]
- }
- },
- {
- "method": "POST",
- "path": "/api/notebook/removeNotebook",
- "handler": "removeNotebook",
- "body": "json",
- "request": {
- "$ref": "#/$defs/NotebookIDRequestInput"
- },
- "response": {
- "anyOf": [
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
- ]
- },
- "data": {
- "type": "null"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
"additionalProperties": false
},
{
@@ -142822,6 +145274,16 @@
},
{
"type": "null"
+ },
+ {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReorderData"
+ },
+ {
+ "type": "null"
+ }
+ ]
}
]
},
@@ -142841,11 +145303,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/renameNotebook",
- "handler": "renameNotebook",
+ "path": "/api/notebook/setEncryptedNotebookFollowSystemLock",
+ "handler": "setEncryptedNotebookFollowSystemLock",
"body": "json",
"request": {
- "$ref": "#/$defs/RenameNotebookRequestInput"
+ "$ref": "#/$defs/EncryptedNotebookFollowSystemLockRequestInput"
},
"response": {
"anyOf": [
@@ -142916,11 +145378,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/reorder",
- "handler": "reorderNotebooks",
- "body": "structJSON",
+ "path": "/api/notebook/setNotebookConf",
+ "handler": "setNotebookConf",
+ "body": "json",
"request": {
- "$ref": "#/$defs/ReorderNotebooksRequestInput"
+ "$ref": "#/$defs/SetNotebookConfRequestInput"
},
"response": {
"anyOf": [
@@ -142936,7 +145398,7 @@
"data": {
"anyOf": [
{
- "$ref": "#/$defs/ReorderData"
+ "$ref": "#/$defs/NotebookConf"
},
{
"type": "null"
@@ -142979,16 +145441,6 @@
},
{
"type": "null"
- },
- {
- "anyOf": [
- {
- "$ref": "#/$defs/ReorderData"
- },
- {
- "type": "null"
- }
- ]
}
]
},
@@ -143008,11 +145460,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/setEncryptedNotebookFollowSystemLock",
- "handler": "setEncryptedNotebookFollowSystemLock",
+ "path": "/api/notebook/setNotebookCryptoAutoLock",
+ "handler": "setNotebookCryptoAutoLock",
"body": "json",
"request": {
- "$ref": "#/$defs/EncryptedNotebookFollowSystemLockRequestInput"
+ "$ref": "#/$defs/NotebookCryptoAutoLockRequestInput"
},
"response": {
"anyOf": [
@@ -143083,93 +145535,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/setNotebookConf",
- "handler": "setNotebookConf",
- "body": "json",
- "request": {
- "$ref": "#/$defs/SetNotebookConfRequestInput"
- },
- "response": {
- "anyOf": [
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
- ]
- },
- "data": {
- "anyOf": [
- {
- "$ref": "#/$defs/NotebookConf"
- },
- {
- "type": "null"
- }
- ]
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
- },
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- -1
- ]
- },
- "data": {
- "anyOf": [
- {
- "type": "object",
- "properties": {
- "closeTimeout": {
- "type": "number"
- }
- },
- "required": [
- "closeTimeout"
- ],
- "additionalProperties": false
- },
- {
- "type": "null"
- }
- ]
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": true
- }
- ]
- }
- },
- {
- "method": "POST",
- "path": "/api/notebook/setNotebookCryptoAutoLock",
- "handler": "setNotebookCryptoAutoLock",
+ "path": "/api/notebook/setNotebookIcon",
+ "handler": "setNotebookIcon",
"body": "json",
"request": {
- "$ref": "#/$defs/NotebookCryptoAutoLockRequestInput"
+ "$ref": "#/$defs/SetNotebookIconRequestInput"
},
"response": {
"anyOf": [
@@ -143240,11 +145610,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/setNotebookIcon",
- "handler": "setNotebookIcon",
- "body": "json",
+ "path": "/api/notebook/touchEncryptedNotebooks",
+ "handler": "touchEncryptedNotebooks",
+ "body": "none",
"request": {
- "$ref": "#/$defs/SetNotebookIconRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -143315,11 +145685,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/touchEncryptedNotebooks",
- "handler": "touchEncryptedNotebooks",
- "body": "none",
+ "path": "/api/notebook/unlockAndOpenNotebook",
+ "handler": "unlockAndOpenNotebook",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/UnlockNotebookRequestInput"
},
"response": {
"anyOf": [
@@ -143390,8 +145760,8 @@
},
{
"method": "POST",
- "path": "/api/notebook/unlockAndOpenNotebook",
- "handler": "unlockAndOpenNotebook",
+ "path": "/api/notebook/unlockNotebook",
+ "handler": "unlockNotebook",
"body": "json",
"request": {
"$ref": "#/$defs/UnlockNotebookRequestInput"
@@ -143465,11 +145835,11 @@
},
{
"method": "POST",
- "path": "/api/notebook/unlockNotebook",
- "handler": "unlockNotebook",
+ "path": "/api/notification/pushErrMsg",
+ "handler": "pushErrMsg",
"body": "json",
"request": {
- "$ref": "#/$defs/UnlockNotebookRequestInput"
+ "$ref": "#/$defs/NotificationRequestInput"
},
"response": {
"anyOf": [
@@ -143483,7 +145853,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/NotificationData"
},
"msg": {
"type": "string"
@@ -143540,8 +145910,8 @@
},
{
"method": "POST",
- "path": "/api/notification/pushErrMsg",
- "handler": "pushErrMsg",
+ "path": "/api/notification/pushMsg",
+ "handler": "pushMsg",
"body": "json",
"request": {
"$ref": "#/$defs/NotificationRequestInput"
@@ -143615,11 +145985,11 @@
},
{
"method": "POST",
- "path": "/api/notification/pushMsg",
- "handler": "pushMsg",
+ "path": "/api/outline/getDocHeadingNumbers",
+ "handler": "getDocHeadingNumbers",
"body": "json",
"request": {
- "$ref": "#/$defs/NotificationRequestInput"
+ "$ref": "#/$defs/HeadingNumbersRequestInput"
},
"response": {
"anyOf": [
@@ -143633,7 +146003,17 @@
]
},
"data": {
- "$ref": "#/$defs/NotificationData"
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -143652,7 +146032,8 @@
"code": {
"type": "integer",
"enum": [
- -1
+ -1,
+ 1
]
},
"data": {
@@ -143690,11 +146071,11 @@
},
{
"method": "POST",
- "path": "/api/outline/getDocHeadingNumbers",
- "handler": "getDocHeadingNumbers",
+ "path": "/api/outline/getDocOutline",
+ "handler": "getDocOutline",
"body": "json",
"request": {
- "$ref": "#/$defs/HeadingNumbersRequestInput"
+ "$ref": "#/$defs/OutlineRequestInput"
},
"response": {
"anyOf": [
@@ -143710,9 +146091,16 @@
"data": {
"anyOf": [
{
- "type": "object",
- "additionalProperties": {
- "type": "string"
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchPath"
+ },
+ {
+ "type": "null"
+ }
+ ]
}
},
{
@@ -143776,11 +146164,89 @@
},
{
"method": "POST",
- "path": "/api/outline/getDocOutline",
- "handler": "getDocOutline",
+ "path": "/api/petal/getPluginPublishInfo",
+ "handler": "getPluginPublishInfo",
"body": "json",
"request": {
- "$ref": "#/$defs/OutlineRequestInput"
+ "$ref": "#/$defs/PluginPublishRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "$ref": "#/$defs/PluginPublishInfo"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1,
+ 400,
+ 403,
+ 500
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/petal/loadPetals",
+ "handler": "loadPetals",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/LoadPetalsRequestInput"
},
"response": {
"anyOf": [
@@ -143800,7 +146266,7 @@
"items": {
"anyOf": [
{
- "$ref": "#/$defs/SearchPath"
+ "$ref": "#/$defs/Petal"
},
{
"type": "null"
@@ -143830,8 +146296,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 1
+ -1
]
},
"data": {
@@ -143869,8 +146334,8 @@
},
{
"method": "POST",
- "path": "/api/petal/getPluginPublishInfo",
- "handler": "getPluginPublishInfo",
+ "path": "/api/petal/loadPluginPublishData",
+ "handler": "loadPluginPublishData",
"body": "json",
"request": {
"$ref": "#/$defs/PluginPublishRequestInput"
@@ -143887,7 +146352,23 @@
]
},
"data": {
- "$ref": "#/$defs/PluginPublishInfo"
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ {
+ "type": "null"
+ },
+ {
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ }
+ ]
+ }
},
"msg": {
"type": "string"
@@ -143909,6 +146390,7 @@
-1,
400,
403,
+ 404,
500
]
},
@@ -143947,11 +146429,89 @@
},
{
"method": "POST",
- "path": "/api/petal/loadPetals",
- "handler": "loadPetals",
+ "path": "/api/petal/savePluginPublishData",
+ "handler": "savePluginPublishData",
"body": "json",
"request": {
- "$ref": "#/$defs/LoadPetalsRequestInput"
+ "$ref": "#/$defs/SavePluginPublishDataRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "type": "null"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1,
+ 400,
+ 403,
+ 500
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/petal/setPetalEnabled",
+ "handler": "setPetalEnabled",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/SetPetalEnabledRequestInput"
},
"response": {
"anyOf": [
@@ -143967,17 +146527,7 @@
"data": {
"anyOf": [
{
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/Petal"
- },
- {
- "type": "null"
- }
- ]
- }
+ "$ref": "#/$defs/Petal"
},
{
"type": "null"
@@ -144039,11 +146589,11 @@
},
{
"method": "POST",
- "path": "/api/petal/loadPluginPublishData",
- "handler": "loadPluginPublishData",
+ "path": "/api/petal/setPetalPublishEnabled",
+ "handler": "setPetalPublishEnabled",
"body": "json",
"request": {
- "$ref": "#/$defs/PluginPublishRequestInput"
+ "$ref": "#/$defs/SetPetalPublishEnabledRequestInput"
},
"response": {
"anyOf": [
@@ -144057,23 +146607,14 @@
]
},
"data": {
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- {
- "type": "null"
- },
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "boolean"
- }
- ]
- }
+ "anyOf": [
+ {
+ "$ref": "#/$defs/Petal"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -144092,11 +146633,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 400,
- 403,
- 404,
- 500
+ -1
]
},
"data": {
@@ -144134,11 +146671,11 @@
},
{
"method": "POST",
- "path": "/api/petal/savePluginPublishData",
- "handler": "savePluginPublishData",
+ "path": "/api/petal/setPluginPublishDataGrant",
+ "handler": "setPluginPublishDataGrant",
"body": "json",
"request": {
- "$ref": "#/$defs/SavePluginPublishDataRequestInput"
+ "$ref": "#/$defs/SetPluginPublishDataGrantRequestInput"
},
"response": {
"anyOf": [
@@ -144212,11 +146749,11 @@
},
{
"method": "POST",
- "path": "/api/petal/setPetalEnabled",
- "handler": "setPetalEnabled",
+ "path": "/api/plugin/getLoadedPlugin",
+ "handler": "getLoadedPlugin",
"body": "json",
"request": {
- "$ref": "#/$defs/SetPetalEnabledRequestInput"
+ "$ref": "#/$defs/LoadedPluginRequestInput"
},
"response": {
"anyOf": [
@@ -144232,7 +146769,7 @@
"data": {
"anyOf": [
{
- "$ref": "#/$defs/Petal"
+ "$ref": "#/$defs/LoadedPlugin"
},
{
"type": "null"
@@ -144256,7 +146793,11 @@
"code": {
"type": "integer",
"enum": [
- -1
+ -1,
+ 1,
+ 2,
+ 3,
+ 4
]
},
"data": {
@@ -144294,11 +146835,11 @@
},
{
"method": "POST",
- "path": "/api/petal/setPetalPublishEnabled",
- "handler": "setPetalPublishEnabled",
- "body": "json",
+ "path": "/api/plugin/listLoadedPlugins",
+ "handler": "listLoadedPlugins",
+ "body": "none",
"request": {
- "$ref": "#/$defs/SetPetalPublishEnabledRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -144314,7 +146855,17 @@
"data": {
"anyOf": [
{
- "$ref": "#/$defs/Petal"
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/LoadedPlugin"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
},
{
"type": "null"
@@ -144376,36 +146927,52 @@
},
{
"method": "POST",
- "path": "/api/petal/setPluginPublishDataGrant",
- "handler": "setPluginPublishDataGrant",
+ "path": "/api/plugin/rpc",
+ "handler": "pluginJsonRpcHttp",
"body": "json",
"request": {
- "$ref": "#/$defs/SetPluginPublishDataGrantRequestInput"
+ "anyOf": [
+ {
+ "$ref": "#/$defs/PluginRPCRequestFieldsInput"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/PluginRPCRequestFieldsInput"
+ },
+ "minItems": 1
+ }
+ ]
},
"response": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/PluginRPCSuccess"
+ },
+ {
+ "$ref": "#/$defs/PluginRPCFailure"
+ }
]
},
- "data": {
- "type": "null"
- },
- "msg": {
- "type": "string"
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/PluginRPCSuccess"
+ },
+ {
+ "$ref": "#/$defs/PluginRPCFailure"
+ }
+ ]
+ },
+ "minItems": 1
}
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
+ ]
},
{
"type": "object",
@@ -144413,10 +146980,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 400,
- 403,
- 500
+ -1
]
},
"data": {
@@ -144450,47 +147014,58 @@
"additionalProperties": true
}
]
- }
+ },
+ "output": "directJSON",
+ "noContent": true
},
{
"method": "POST",
- "path": "/api/plugin/getLoadedPlugin",
- "handler": "getLoadedPlugin",
+ "path": "/api/plugin/rpc/:name",
+ "handler": "pluginJsonRpcHttpByName",
"body": "json",
"request": {
- "$ref": "#/$defs/LoadedPluginRequestInput"
+ "anyOf": [
+ {
+ "$ref": "#/$defs/PluginRPCRequestFieldsInput"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/PluginRPCRequestFieldsInput"
+ },
+ "minItems": 1
+ }
+ ]
},
"response": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
- ]
- },
- "data": {
+ "anyOf": [
+ {
"anyOf": [
{
- "$ref": "#/$defs/LoadedPlugin"
+ "$ref": "#/$defs/PluginRPCSuccess"
},
{
- "type": "null"
+ "$ref": "#/$defs/PluginRPCFailure"
}
]
},
- "msg": {
- "type": "string"
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/PluginRPCSuccess"
+ },
+ {
+ "$ref": "#/$defs/PluginRPCFailure"
+ }
+ ]
+ },
+ "minItems": 1
}
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
+ ]
},
{
"type": "object",
@@ -144498,11 +147073,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 1,
- 2,
- 3,
- 4
+ -1
]
},
"data": {
@@ -144536,15 +147107,17 @@
"additionalProperties": true
}
]
- }
+ },
+ "output": "directJSON",
+ "noContent": true
},
{
"method": "POST",
- "path": "/api/plugin/listLoadedPlugins",
- "handler": "listLoadedPlugins",
- "body": "none",
+ "path": "/api/query/sql",
+ "handler": "SQL",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/SQLQueryRequestInput"
},
"response": {
"anyOf": [
@@ -144558,33 +147131,50 @@
]
},
"data": {
- "anyOf": [
- {
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/LoadedPlugin"
- },
- {
- "type": "null"
- }
- ]
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ {
+ "type": "null"
+ },
+ {
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
}
- },
- {
- "type": "null"
- }
- ]
+ ]
+ }
+ },
+ "limit": {
+ "type": "integer"
},
"msg": {
"type": "string"
+ },
+ "truncated": {
+ "type": "boolean"
}
},
"required": [
"code",
"msg",
- "data"
+ "data",
+ "limit",
+ "truncated"
],
"additionalProperties": false
},
@@ -144594,7 +147184,8 @@
"code": {
"type": "integer",
"enum": [
- -1
+ -1,
+ 1
]
},
"data": {
@@ -144632,75 +147223,30 @@
},
{
"method": "POST",
- "path": "/api/plugin/rpc",
- "handler": "pluginJsonRpcHttp",
+ "path": "/api/ref/getBacklink2",
+ "handler": "getBacklink2",
"body": "json",
"request": {
- "anyOf": [
- {
- "$ref": "#/$defs/PluginRPCRequestFieldsInput"
- },
- {
- "type": "array",
- "items": {
- "$ref": "#/$defs/PluginRPCRequestFieldsInput"
- },
- "minItems": 1
- }
- ]
+ "$ref": "#/$defs/BacklinkListRequestInput"
},
"response": {
"anyOf": [
- {
- "anyOf": [
- {
- "anyOf": [
- {
- "$ref": "#/$defs/PluginRPCSuccess"
- },
- {
- "$ref": "#/$defs/PluginRPCFailure"
- }
- ]
- },
- {
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/PluginRPCSuccess"
- },
- {
- "$ref": "#/$defs/PluginRPCFailure"
- }
- ]
- },
- "minItems": 1
- }
- ]
- },
{
"type": "object",
"properties": {
"code": {
"type": "integer",
"enum": [
- -1
+ 0
]
},
"data": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "closeTimeout": {
- "type": "number"
- }
- },
- "required": [
- "closeTimeout"
- ],
- "additionalProperties": false
+ "$ref": "#/$defs/BacklinkList"
+ },
+ {
+ "$ref": "#/$defs/BacklinkRefDefs"
},
{
"type": "null"
@@ -144716,61 +147262,7 @@
"msg",
"data"
],
- "additionalProperties": true
- }
- ]
- },
- "output": "directJSON",
- "noContent": true
- },
- {
- "method": "POST",
- "path": "/api/plugin/rpc/:name",
- "handler": "pluginJsonRpcHttpByName",
- "body": "json",
- "request": {
- "anyOf": [
- {
- "$ref": "#/$defs/PluginRPCRequestFieldsInput"
- },
- {
- "type": "array",
- "items": {
- "$ref": "#/$defs/PluginRPCRequestFieldsInput"
- },
- "minItems": 1
- }
- ]
- },
- "response": {
- "anyOf": [
- {
- "anyOf": [
- {
- "anyOf": [
- {
- "$ref": "#/$defs/PluginRPCSuccess"
- },
- {
- "$ref": "#/$defs/PluginRPCFailure"
- }
- ]
- },
- {
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/PluginRPCSuccess"
- },
- {
- "$ref": "#/$defs/PluginRPCFailure"
- }
- ]
- },
- "minItems": 1
- }
- ]
+ "additionalProperties": false
},
{
"type": "object",
@@ -144778,7 +147270,8 @@
"code": {
"type": "integer",
"enum": [
- -1
+ -1,
+ 1
]
},
"data": {
@@ -144797,6 +147290,19 @@
},
{
"type": "null"
+ },
+ {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/BacklinkList"
+ },
+ {
+ "$ref": "#/$defs/BacklinkRefDefs"
+ },
+ {
+ "type": "null"
+ }
+ ]
}
]
},
@@ -144812,17 +147318,15 @@
"additionalProperties": true
}
]
- },
- "output": "directJSON",
- "noContent": true
+ }
},
{
"method": "POST",
- "path": "/api/query/sql",
- "handler": "SQL",
+ "path": "/api/ref/getBacklinkDoc",
+ "handler": "getBacklinkDoc",
"body": "json",
"request": {
- "$ref": "#/$defs/SQLQueryRequestInput"
+ "$ref": "#/$defs/BacklinkDocumentRequestInput"
},
"response": {
"anyOf": [
@@ -144836,50 +147340,16 @@
]
},
"data": {
- "type": "array",
- "items": {
- "anyOf": [
- {
- "type": "object",
- "additionalProperties": {
- "anyOf": [
- {
- "type": "null"
- },
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "boolean"
- }
- ]
- }
- },
- {
- "type": "null"
- }
- ]
- }
- },
- "limit": {
- "type": "integer"
+ "$ref": "#/$defs/BacklinkContextData"
},
"msg": {
"type": "string"
- },
- "truncated": {
- "type": "boolean"
}
},
"required": [
"code",
"msg",
- "data",
- "limit",
- "truncated"
+ "data"
],
"additionalProperties": false
},
@@ -144928,11 +147398,11 @@
},
{
"method": "POST",
- "path": "/api/ref/getBacklink2",
- "handler": "getBacklink2",
+ "path": "/api/ref/getBackmentionDoc",
+ "handler": "getBackmentionDoc",
"body": "json",
"request": {
- "$ref": "#/$defs/BacklinkListRequestInput"
+ "$ref": "#/$defs/BackmentionDocumentRequestInput"
},
"response": {
"anyOf": [
@@ -144946,17 +147416,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/BacklinkList"
- },
- {
- "$ref": "#/$defs/BacklinkRefDefs"
- },
- {
- "type": "null"
- }
- ]
+ "$ref": "#/$defs/BacklinkContextData"
},
"msg": {
"type": "string"
@@ -144995,19 +147455,6 @@
},
{
"type": "null"
- },
- {
- "anyOf": [
- {
- "$ref": "#/$defs/BacklinkList"
- },
- {
- "$ref": "#/$defs/BacklinkRefDefs"
- },
- {
- "type": "null"
- }
- ]
}
]
},
@@ -145027,11 +147474,11 @@
},
{
"method": "POST",
- "path": "/api/ref/getBacklinkDoc",
- "handler": "getBacklinkDoc",
+ "path": "/api/ref/getGlobalBacklinkContexts",
+ "handler": "getGlobalBacklinkContexts",
"body": "json",
"request": {
- "$ref": "#/$defs/BacklinkDocumentRequestInput"
+ "$ref": "#/$defs/GlobalBacklinkContextRequestInput"
},
"response": {
"anyOf": [
@@ -145045,7 +147492,7 @@
]
},
"data": {
- "$ref": "#/$defs/BacklinkContextData"
+ "$ref": "#/$defs/GlobalBacklinkContextData"
},
"msg": {
"type": "string"
@@ -145103,11 +147550,11 @@
},
{
"method": "POST",
- "path": "/api/ref/getBackmentionDoc",
- "handler": "getBackmentionDoc",
+ "path": "/api/ref/getGlobalBacklinks",
+ "handler": "getGlobalBacklinks",
"body": "json",
"request": {
- "$ref": "#/$defs/BackmentionDocumentRequestInput"
+ "$ref": "#/$defs/GlobalBacklinkListRequestInput"
},
"response": {
"anyOf": [
@@ -145121,7 +147568,7 @@
]
},
"data": {
- "$ref": "#/$defs/BacklinkContextData"
+ "$ref": "#/$defs/GlobalBacklinkListData"
},
"msg": {
"type": "string"
@@ -145179,11 +147626,11 @@
},
{
"method": "POST",
- "path": "/api/ref/getGlobalBacklinkContexts",
- "handler": "getGlobalBacklinkContexts",
+ "path": "/api/ref/refreshBacklink",
+ "handler": "refreshBacklink",
"body": "json",
"request": {
- "$ref": "#/$defs/GlobalBacklinkContextRequestInput"
+ "$ref": "#/$defs/RefreshBacklinkRequestInput"
},
"response": {
"anyOf": [
@@ -145197,7 +147644,7 @@
]
},
"data": {
- "$ref": "#/$defs/GlobalBacklinkContextData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -145216,8 +147663,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 1
+ -1
]
},
"data": {
@@ -145255,11 +147701,11 @@
},
{
"method": "POST",
- "path": "/api/ref/getGlobalBacklinks",
- "handler": "getGlobalBacklinks",
- "body": "json",
+ "path": "/api/repo/checkSnapshot",
+ "handler": "checkSnapshot",
+ "body": "none",
"request": {
- "$ref": "#/$defs/GlobalBacklinkListRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -145273,7 +147719,7 @@
]
},
"data": {
- "$ref": "#/$defs/GlobalBacklinkListData"
+ "$ref": "#/$defs/CheckSnapshotData"
},
"msg": {
"type": "string"
@@ -145292,8 +147738,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 1
+ -1
]
},
"data": {
@@ -145331,11 +147776,11 @@
},
{
"method": "POST",
- "path": "/api/ref/refreshBacklink",
- "handler": "refreshBacklink",
+ "path": "/api/repo/checkoutRepo",
+ "handler": "checkoutRepo",
"body": "json",
"request": {
- "$ref": "#/$defs/RefreshBacklinkRequestInput"
+ "$ref": "#/$defs/CheckoutRepoRequestInput"
},
"response": {
"anyOf": [
@@ -145406,11 +147851,11 @@
},
{
"method": "POST",
- "path": "/api/repo/checkSnapshot",
- "handler": "checkSnapshot",
- "body": "none",
+ "path": "/api/repo/createSnapshot",
+ "handler": "createSnapshot",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/CreateSnapshotRequestInput"
},
"response": {
"anyOf": [
@@ -145424,7 +147869,7 @@
]
},
"data": {
- "$ref": "#/$defs/CheckSnapshotData"
+ "$ref": "#/$defs/CreateSnapshotData"
},
"msg": {
"type": "string"
@@ -145481,11 +147926,11 @@
},
{
"method": "POST",
- "path": "/api/repo/checkoutRepo",
- "handler": "checkoutRepo",
+ "path": "/api/repo/diffRepoSnapshots",
+ "handler": "diffRepoSnapshots",
"body": "json",
"request": {
- "$ref": "#/$defs/CheckoutRepoRequestInput"
+ "$ref": "#/$defs/DiffRepoSnapshotsRequestInput"
},
"response": {
"anyOf": [
@@ -145499,7 +147944,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/RepoDiffData"
},
"msg": {
"type": "string"
@@ -145556,11 +148001,11 @@
},
{
"method": "POST",
- "path": "/api/repo/createSnapshot",
- "handler": "createSnapshot",
+ "path": "/api/repo/downloadCloudSnapshot",
+ "handler": "downloadCloudSnapshot",
"body": "json",
"request": {
- "$ref": "#/$defs/CreateSnapshotRequestInput"
+ "$ref": "#/$defs/DownloadCloudSnapshotRequestInput"
},
"response": {
"anyOf": [
@@ -145574,7 +148019,7 @@
]
},
"data": {
- "$ref": "#/$defs/CreateSnapshotData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -145631,11 +148076,11 @@
},
{
"method": "POST",
- "path": "/api/repo/diffRepoSnapshots",
- "handler": "diffRepoSnapshots",
+ "path": "/api/repo/exportRepoFile",
+ "handler": "exportRepoFile",
"body": "json",
"request": {
- "$ref": "#/$defs/DiffRepoSnapshotsRequestInput"
+ "$ref": "#/$defs/ExportRepoFileRequestInput"
},
"response": {
"anyOf": [
@@ -145649,7 +148094,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoDiffData"
+ "$ref": "#/$defs/RepoExportData"
},
"msg": {
"type": "string"
@@ -145706,11 +148151,11 @@
},
{
"method": "POST",
- "path": "/api/repo/downloadCloudSnapshot",
- "handler": "downloadCloudSnapshot",
+ "path": "/api/repo/getCloudRepoSnapshots",
+ "handler": "getCloudRepoSnapshots",
"body": "json",
"request": {
- "$ref": "#/$defs/DownloadCloudSnapshotRequestInput"
+ "$ref": "#/$defs/GetCloudRepoSnapshotsRequestInput"
},
"response": {
"anyOf": [
@@ -145724,7 +148169,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/RepoCloudSnapshotsData"
},
"msg": {
"type": "string"
@@ -145781,11 +148226,11 @@
},
{
"method": "POST",
- "path": "/api/repo/exportRepoFile",
- "handler": "exportRepoFile",
- "body": "json",
+ "path": "/api/repo/getCloudRepoTagSnapshots",
+ "handler": "getCloudRepoTagSnapshots",
+ "body": "none",
"request": {
- "$ref": "#/$defs/ExportRepoFileRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -145799,7 +148244,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoExportData"
+ "$ref": "#/$defs/RepoCloudTagsData"
},
"msg": {
"type": "string"
@@ -145856,11 +148301,11 @@
},
{
"method": "POST",
- "path": "/api/repo/getCloudRepoSnapshots",
- "handler": "getCloudRepoSnapshots",
+ "path": "/api/repo/getRepoDocHistory",
+ "handler": "getRepoDocHistory",
"body": "json",
"request": {
- "$ref": "#/$defs/GetCloudRepoSnapshotsRequestInput"
+ "$ref": "#/$defs/GetRepoDocHistoryRequestInput"
},
"response": {
"anyOf": [
@@ -145874,7 +148319,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoCloudSnapshotsData"
+ "$ref": "#/$defs/RepoDocHistoryData"
},
"msg": {
"type": "string"
@@ -145931,11 +148376,69 @@
},
{
"method": "POST",
- "path": "/api/repo/getCloudRepoTagSnapshots",
- "handler": "getCloudRepoTagSnapshots",
- "body": "none",
+ "path": "/api/repo/getRepoFile",
+ "handler": "getRepoFile",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/GetRepoFileRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "string",
+ "format": "binary"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ },
+ "output": "binary",
+ "errorStatus": 200
+ },
+ {
+ "method": "POST",
+ "path": "/api/repo/getRepoSnapshots",
+ "handler": "getRepoSnapshots",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/GetRepoSnapshotsRequestInput"
},
"response": {
"anyOf": [
@@ -145949,7 +148452,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoCloudTagsData"
+ "$ref": "#/$defs/RepoSnapshotsData"
},
"msg": {
"type": "string"
@@ -146006,11 +148509,11 @@
},
{
"method": "POST",
- "path": "/api/repo/getRepoDocHistory",
- "handler": "getRepoDocHistory",
- "body": "json",
+ "path": "/api/repo/getRepoTagSnapshots",
+ "handler": "getRepoTagSnapshots",
+ "body": "none",
"request": {
- "$ref": "#/$defs/GetRepoDocHistoryRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -146024,7 +148527,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoDocHistoryData"
+ "$ref": "#/$defs/RepoTagsData"
},
"msg": {
"type": "string"
@@ -146081,17 +148584,36 @@
},
{
"method": "POST",
- "path": "/api/repo/getRepoFile",
- "handler": "getRepoFile",
+ "path": "/api/repo/importRepoKey",
+ "handler": "importRepoKey",
"body": "json",
"request": {
- "$ref": "#/$defs/GetRepoFileRequestInput"
+ "$ref": "#/$defs/ImportRepoKeyRequestInput"
},
"response": {
"anyOf": [
{
- "type": "string",
- "format": "binary"
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "$ref": "#/$defs/RepoKeyData"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
},
{
"type": "object",
@@ -146133,17 +148655,15 @@
"additionalProperties": true
}
]
- },
- "output": "binary",
- "errorStatus": 200
+ }
},
{
"method": "POST",
- "path": "/api/repo/getRepoSnapshots",
- "handler": "getRepoSnapshots",
- "body": "json",
+ "path": "/api/repo/initRepoKey",
+ "handler": "initRepoKey",
+ "body": "none",
"request": {
- "$ref": "#/$defs/GetRepoSnapshotsRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -146157,7 +148677,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoSnapshotsData"
+ "$ref": "#/$defs/RepoKeyData"
},
"msg": {
"type": "string"
@@ -146214,11 +148734,11 @@
},
{
"method": "POST",
- "path": "/api/repo/getRepoTagSnapshots",
- "handler": "getRepoTagSnapshots",
- "body": "none",
+ "path": "/api/repo/initRepoKeyFromPassphrase",
+ "handler": "initRepoKeyFromPassphrase",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/InitRepoKeyFromPassphraseRequestInput"
},
"response": {
"anyOf": [
@@ -146232,7 +148752,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoTagsData"
+ "$ref": "#/$defs/RepoKeyData"
},
"msg": {
"type": "string"
@@ -146289,11 +148809,11 @@
},
{
"method": "POST",
- "path": "/api/repo/importRepoKey",
- "handler": "importRepoKey",
+ "path": "/api/repo/openRepoSnapshotFile",
+ "handler": "openRepoSnapshotFile",
"body": "json",
"request": {
- "$ref": "#/$defs/ImportRepoKeyRequestInput"
+ "$ref": "#/$defs/OpenRepoSnapshotFileRequestInput"
},
"response": {
"anyOf": [
@@ -146307,7 +148827,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoKeyData"
+ "$ref": "#/$defs/RepoOpenFileData"
},
"msg": {
"type": "string"
@@ -146364,8 +148884,8 @@
},
{
"method": "POST",
- "path": "/api/repo/initRepoKey",
- "handler": "initRepoKey",
+ "path": "/api/repo/purgeCloudRepo",
+ "handler": "purgeCloudRepo",
"body": "none",
"request": {
"$ref": "#/$defs/EmptyRequestInput"
@@ -146382,7 +148902,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoKeyData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -146439,11 +148959,11 @@
},
{
"method": "POST",
- "path": "/api/repo/initRepoKeyFromPassphrase",
- "handler": "initRepoKeyFromPassphrase",
- "body": "json",
+ "path": "/api/repo/purgeRepo",
+ "handler": "purgeRepo",
+ "body": "none",
"request": {
- "$ref": "#/$defs/InitRepoKeyFromPassphraseRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -146457,7 +148977,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoKeyData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -146514,11 +149034,11 @@
},
{
"method": "POST",
- "path": "/api/repo/openRepoSnapshotFile",
- "handler": "openRepoSnapshotFile",
+ "path": "/api/repo/removeCloudRepoTagSnapshot",
+ "handler": "removeCloudRepoTagSnapshot",
"body": "json",
"request": {
- "$ref": "#/$defs/OpenRepoSnapshotFileRequestInput"
+ "$ref": "#/$defs/RemoveCloudRepoTagSnapshotRequestInput"
},
"response": {
"anyOf": [
@@ -146532,7 +149052,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoOpenFileData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -146589,11 +149109,11 @@
},
{
"method": "POST",
- "path": "/api/repo/purgeCloudRepo",
- "handler": "purgeCloudRepo",
- "body": "none",
+ "path": "/api/repo/removeRepoTagSnapshot",
+ "handler": "removeRepoTagSnapshot",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/RemoveRepoTagSnapshotRequestInput"
},
"response": {
"anyOf": [
@@ -146664,8 +149184,8 @@
},
{
"method": "POST",
- "path": "/api/repo/purgeRepo",
- "handler": "purgeRepo",
+ "path": "/api/repo/resetRepo",
+ "handler": "resetRepo",
"body": "none",
"request": {
"$ref": "#/$defs/EmptyRequestInput"
@@ -146739,11 +149259,11 @@
},
{
"method": "POST",
- "path": "/api/repo/removeCloudRepoTagSnapshot",
- "handler": "removeCloudRepoTagSnapshot",
+ "path": "/api/repo/rollbackRepoSnapshotFile",
+ "handler": "rollbackRepoSnapshotFile",
"body": "json",
"request": {
- "$ref": "#/$defs/RemoveCloudRepoTagSnapshotRequestInput"
+ "$ref": "#/$defs/RollbackRepoSnapshotFileRequestInput"
},
"response": {
"anyOf": [
@@ -146814,11 +149334,11 @@
},
{
"method": "POST",
- "path": "/api/repo/removeRepoTagSnapshot",
- "handler": "removeRepoTagSnapshot",
+ "path": "/api/repo/searchRepoFile",
+ "handler": "searchRepoFile",
"body": "json",
"request": {
- "$ref": "#/$defs/RemoveRepoTagSnapshotRequestInput"
+ "$ref": "#/$defs/SearchRepoFileRequestInput"
},
"response": {
"anyOf": [
@@ -146832,7 +149352,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/RepoSearchData"
},
"msg": {
"type": "string"
@@ -146889,11 +149409,11 @@
},
{
"method": "POST",
- "path": "/api/repo/resetRepo",
- "handler": "resetRepo",
- "body": "none",
+ "path": "/api/repo/setRepoIndexRetentionDays",
+ "handler": "setRepoIndexRetentionDays",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/SetRepoIndexRetentionDaysRequestInput"
},
"response": {
"anyOf": [
@@ -146964,11 +149484,11 @@
},
{
"method": "POST",
- "path": "/api/repo/rollbackRepoSnapshotFile",
- "handler": "rollbackRepoSnapshotFile",
+ "path": "/api/repo/setRetentionIndexesDaily",
+ "handler": "setRetentionIndexesDaily",
"body": "json",
"request": {
- "$ref": "#/$defs/RollbackRepoSnapshotFileRequestInput"
+ "$ref": "#/$defs/SetRetentionIndexesDailyRequestInput"
},
"response": {
"anyOf": [
@@ -147039,11 +149559,11 @@
},
{
"method": "POST",
- "path": "/api/repo/searchRepoFile",
- "handler": "searchRepoFile",
+ "path": "/api/repo/setSnapshotMemo",
+ "handler": "setSnapshotMemo",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchRepoFileRequestInput"
+ "$ref": "#/$defs/SetSnapshotMemoRequestInput"
},
"response": {
"anyOf": [
@@ -147057,7 +149577,7 @@
]
},
"data": {
- "$ref": "#/$defs/RepoSearchData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -147114,11 +149634,11 @@
},
{
"method": "POST",
- "path": "/api/repo/setRepoIndexRetentionDays",
- "handler": "setRepoIndexRetentionDays",
+ "path": "/api/repo/tagSnapshot",
+ "handler": "tagSnapshot",
"body": "json",
"request": {
- "$ref": "#/$defs/SetRepoIndexRetentionDaysRequestInput"
+ "$ref": "#/$defs/TagSnapshotRequestInput"
},
"response": {
"anyOf": [
@@ -147189,11 +149709,11 @@
},
{
"method": "POST",
- "path": "/api/repo/setRetentionIndexesDaily",
- "handler": "setRetentionIndexesDaily",
+ "path": "/api/repo/uploadCloudSnapshot",
+ "handler": "uploadCloudSnapshot",
"body": "json",
"request": {
- "$ref": "#/$defs/SetRetentionIndexesDailyRequestInput"
+ "$ref": "#/$defs/UploadCloudSnapshotRequestInput"
},
"response": {
"anyOf": [
@@ -147264,11 +149784,11 @@
},
{
"method": "POST",
- "path": "/api/repo/setSnapshotMemo",
- "handler": "setSnapshotMemo",
+ "path": "/api/riff/addRiffCards",
+ "handler": "addRiffCards",
"body": "json",
"request": {
- "$ref": "#/$defs/SetSnapshotMemoRequestInput"
+ "$ref": "#/$defs/RiffDeckCardsRequestInput"
},
"response": {
"anyOf": [
@@ -147282,7 +149802,14 @@
]
},
"data": {
- "type": "null"
+ "anyOf": [
+ {
+ "$ref": "#/$defs/RiffDeck"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -147339,11 +149866,11 @@
},
{
"method": "POST",
- "path": "/api/repo/tagSnapshot",
- "handler": "tagSnapshot",
+ "path": "/api/riff/batchSetRiffCardsDueTime",
+ "handler": "batchSetRiffCardsDueTime",
"body": "json",
"request": {
- "$ref": "#/$defs/TagSnapshotRequestInput"
+ "$ref": "#/$defs/SetRiffCardsDueRequestInput"
},
"response": {
"anyOf": [
@@ -147414,11 +149941,11 @@
},
{
"method": "POST",
- "path": "/api/repo/uploadCloudSnapshot",
- "handler": "uploadCloudSnapshot",
+ "path": "/api/riff/createRiffDeck",
+ "handler": "createRiffDeck",
"body": "json",
"request": {
- "$ref": "#/$defs/UploadCloudSnapshotRequestInput"
+ "$ref": "#/$defs/CreateRiffDeckRequestInput"
},
"response": {
"anyOf": [
@@ -147432,7 +149959,14 @@
]
},
"data": {
- "type": "null"
+ "anyOf": [
+ {
+ "$ref": "#/$defs/RiffDeck"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -147489,11 +150023,11 @@
},
{
"method": "POST",
- "path": "/api/riff/addRiffCards",
- "handler": "addRiffCards",
+ "path": "/api/riff/getNotebookRiffCards",
+ "handler": "getNotebookRiffCards",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffDeckCardsRequestInput"
+ "$ref": "#/$defs/RiffCardsRequestInput"
},
"response": {
"anyOf": [
@@ -147507,14 +150041,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/RiffDeck"
- },
- {
- "type": "null"
- }
- ]
+ "$ref": "#/$defs/RiffCardsData"
},
"msg": {
"type": "string"
@@ -147571,11 +150098,11 @@
},
{
"method": "POST",
- "path": "/api/riff/batchSetRiffCardsDueTime",
- "handler": "batchSetRiffCardsDueTime",
+ "path": "/api/riff/getNotebookRiffDueCards",
+ "handler": "getNotebookRiffDueCards",
"body": "json",
"request": {
- "$ref": "#/$defs/SetRiffCardsDueRequestInput"
+ "$ref": "#/$defs/RiffNotebookDueCardsRequestInput"
},
"response": {
"anyOf": [
@@ -147589,7 +150116,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/RiffDueCardsData"
},
"msg": {
"type": "string"
@@ -147646,11 +150173,11 @@
},
{
"method": "POST",
- "path": "/api/riff/createRiffDeck",
- "handler": "createRiffDeck",
+ "path": "/api/riff/getRiffCards",
+ "handler": "getRiffCards",
"body": "json",
"request": {
- "$ref": "#/$defs/CreateRiffDeckRequestInput"
+ "$ref": "#/$defs/RiffCardsRequestInput"
},
"response": {
"anyOf": [
@@ -147663,10 +150190,42 @@
0
]
},
+ "data": {
+ "$ref": "#/$defs/RiffCardsData"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
"data": {
"anyOf": [
{
- "$ref": "#/$defs/RiffDeck"
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
},
{
"type": "null"
@@ -147682,6 +150241,42 @@
"msg",
"data"
],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/riff/getRiffCardsByBlockIDs",
+ "handler": "getRiffCardsByBlockIDs",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/RiffBlockIDsRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "$ref": "#/$defs/RiffBlocksData"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
"additionalProperties": false
},
{
@@ -147728,11 +150323,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getNotebookRiffCards",
- "handler": "getNotebookRiffCards",
- "body": "json",
+ "path": "/api/riff/getRiffDecks",
+ "handler": "getRiffDecks",
+ "body": "none",
"request": {
- "$ref": "#/$defs/RiffCardsRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -147746,7 +150341,17 @@
]
},
"data": {
- "$ref": "#/$defs/RiffCardsData"
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/RiffDeck"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
},
"msg": {
"type": "string"
@@ -147803,11 +150408,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getNotebookRiffDueCards",
- "handler": "getNotebookRiffDueCards",
+ "path": "/api/riff/getRiffDueCards",
+ "handler": "getRiffDueCards",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffNotebookDueCardsRequestInput"
+ "$ref": "#/$defs/RiffDueCardsRequestInput"
},
"response": {
"anyOf": [
@@ -147878,8 +150483,8 @@
},
{
"method": "POST",
- "path": "/api/riff/getRiffCards",
- "handler": "getRiffCards",
+ "path": "/api/riff/getTreeRiffCards",
+ "handler": "getTreeRiffCards",
"body": "json",
"request": {
"$ref": "#/$defs/RiffCardsRequestInput"
@@ -147953,11 +150558,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getRiffCardsByBlockIDs",
- "handler": "getRiffCardsByBlockIDs",
+ "path": "/api/riff/getTreeRiffDueCards",
+ "handler": "getTreeRiffDueCards",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffBlockIDsRequestInput"
+ "$ref": "#/$defs/RiffTreeDueCardsRequestInput"
},
"response": {
"anyOf": [
@@ -147971,7 +150576,7 @@
]
},
"data": {
- "$ref": "#/$defs/RiffBlocksData"
+ "$ref": "#/$defs/RiffDueCardsData"
},
"msg": {
"type": "string"
@@ -148028,11 +150633,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getRiffDecks",
- "handler": "getRiffDecks",
- "body": "none",
+ "path": "/api/riff/removeRiffCards",
+ "handler": "removeRiffCards",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/RiffDeckCardsRequestInput"
},
"response": {
"anyOf": [
@@ -148046,17 +150651,14 @@
]
},
"data": {
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/RiffDeck"
- },
- {
- "type": "null"
- }
- ]
- }
+ "anyOf": [
+ {
+ "$ref": "#/$defs/RiffDeck"
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -148113,11 +150715,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getRiffDueCards",
- "handler": "getRiffDueCards",
+ "path": "/api/riff/removeRiffDeck",
+ "handler": "removeRiffDeck",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffDueCardsRequestInput"
+ "$ref": "#/$defs/RiffDeckRequestInput"
},
"response": {
"anyOf": [
@@ -148131,7 +150733,7 @@
]
},
"data": {
- "$ref": "#/$defs/RiffDueCardsData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -148188,11 +150790,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getTreeRiffCards",
- "handler": "getTreeRiffCards",
+ "path": "/api/riff/renameRiffDeck",
+ "handler": "renameRiffDeck",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffCardsRequestInput"
+ "$ref": "#/$defs/RenameRiffDeckRequestInput"
},
"response": {
"anyOf": [
@@ -148206,7 +150808,7 @@
]
},
"data": {
- "$ref": "#/$defs/RiffCardsData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -148263,11 +150865,11 @@
},
{
"method": "POST",
- "path": "/api/riff/getTreeRiffDueCards",
- "handler": "getTreeRiffDueCards",
+ "path": "/api/riff/resetRiffCards",
+ "handler": "resetRiffCards",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffTreeDueCardsRequestInput"
+ "$ref": "#/$defs/ResetRiffCardsRequestInput"
},
"response": {
"anyOf": [
@@ -148281,7 +150883,7 @@
]
},
"data": {
- "$ref": "#/$defs/RiffDueCardsData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -148338,11 +150940,11 @@
},
{
"method": "POST",
- "path": "/api/riff/removeRiffCards",
- "handler": "removeRiffCards",
+ "path": "/api/riff/reviewRiffCard",
+ "handler": "reviewRiffCard",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffDeckCardsRequestInput"
+ "$ref": "#/$defs/ReviewRiffCardRequestInput"
},
"response": {
"anyOf": [
@@ -148356,14 +150958,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/RiffDeck"
- },
- {
- "type": "null"
- }
- ]
+ "type": "null"
},
"msg": {
"type": "string"
@@ -148420,11 +151015,11 @@
},
{
"method": "POST",
- "path": "/api/riff/removeRiffDeck",
- "handler": "removeRiffDeck",
+ "path": "/api/riff/skipReviewRiffCard",
+ "handler": "skipReviewRiffCard",
"body": "json",
"request": {
- "$ref": "#/$defs/RiffDeckRequestInput"
+ "$ref": "#/$defs/RiffCardRequestInput"
},
"response": {
"anyOf": [
@@ -148495,11 +151090,11 @@
},
{
"method": "POST",
- "path": "/api/riff/renameRiffDeck",
- "handler": "renameRiffDeck",
+ "path": "/api/search/findReplace",
+ "handler": "findReplace",
"body": "json",
"request": {
- "$ref": "#/$defs/RenameRiffDeckRequestInput"
+ "$ref": "#/$defs/FindReplaceRequestInput"
},
"response": {
"anyOf": [
@@ -148532,7 +151127,8 @@
"code": {
"type": "integer",
"enum": [
- -1
+ -1,
+ 1
]
},
"data": {
@@ -148570,11 +151166,11 @@
},
{
"method": "POST",
- "path": "/api/riff/resetRiffCards",
- "handler": "resetRiffCards",
+ "path": "/api/search/fullTextSearchAssetContent",
+ "handler": "fullTextSearchAssetContent",
"body": "json",
"request": {
- "$ref": "#/$defs/ResetRiffCardsRequestInput"
+ "$ref": "#/$defs/SearchAssetContentRequestInput"
},
"response": {
"anyOf": [
@@ -148588,7 +151184,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/SearchAssetContentData"
},
"msg": {
"type": "string"
@@ -148645,11 +151241,11 @@
},
{
"method": "POST",
- "path": "/api/riff/reviewRiffCard",
- "handler": "reviewRiffCard",
+ "path": "/api/search/fullTextSearchBlock",
+ "handler": "fullTextSearchBlock",
"body": "json",
"request": {
- "$ref": "#/$defs/ReviewRiffCardRequestInput"
+ "$ref": "#/$defs/FullTextSearchBlockRequestInput"
},
"response": {
"anyOf": [
@@ -148662,42 +151258,10 @@
0
]
},
- "data": {
- "type": "null"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
- },
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- -1
- ]
- },
"data": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "closeTimeout": {
- "type": "number"
- }
- },
- "required": [
- "closeTimeout"
- ],
- "additionalProperties": false
+ "$ref": "#/$defs/FullTextSearchBlockData"
},
{
"type": "null"
@@ -148713,42 +151277,6 @@
"msg",
"data"
],
- "additionalProperties": true
- }
- ]
- }
- },
- {
- "method": "POST",
- "path": "/api/riff/skipReviewRiffCard",
- "handler": "skipReviewRiffCard",
- "body": "json",
- "request": {
- "$ref": "#/$defs/RiffCardRequestInput"
- },
- "response": {
- "anyOf": [
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
- ]
- },
- "data": {
- "type": "null"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
"additionalProperties": false
},
{
@@ -148795,11 +151323,11 @@
},
{
"method": "POST",
- "path": "/api/search/findReplace",
- "handler": "findReplace",
+ "path": "/api/search/getAssetContent",
+ "handler": "getAssetContent",
"body": "json",
"request": {
- "$ref": "#/$defs/FindReplaceRequestInput"
+ "$ref": "#/$defs/AssetContentRequestInput"
},
"response": {
"anyOf": [
@@ -148813,7 +151341,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/AssetContentData"
},
"msg": {
"type": "string"
@@ -148832,8 +151360,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 1
+ -1
]
},
"data": {
@@ -148871,11 +151398,11 @@
},
{
"method": "POST",
- "path": "/api/search/fullTextSearchAssetContent",
- "handler": "fullTextSearchAssetContent",
+ "path": "/api/search/getAssetContentByPath",
+ "handler": "getAssetContentByPath",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchAssetContentRequestInput"
+ "$ref": "#/$defs/SearchPathRequestInput"
},
"response": {
"anyOf": [
@@ -148889,7 +151416,7 @@
]
},
"data": {
- "$ref": "#/$defs/SearchAssetContentData"
+ "$ref": "#/$defs/AssetContentData"
},
"msg": {
"type": "string"
@@ -148946,11 +151473,11 @@
},
{
"method": "POST",
- "path": "/api/search/fullTextSearchBlock",
- "handler": "fullTextSearchBlock",
+ "path": "/api/search/getEmbedBlock",
+ "handler": "getEmbedBlock",
"body": "json",
"request": {
- "$ref": "#/$defs/FullTextSearchBlockRequestInput"
+ "$ref": "#/$defs/GetEmbedBlockRequestInput"
},
"response": {
"anyOf": [
@@ -148964,14 +151491,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/FullTextSearchBlockData"
- },
- {
- "type": "null"
- }
- ]
+ "$ref": "#/$defs/EmbedBlocksData"
},
"msg": {
"type": "string"
@@ -149028,11 +151548,11 @@
},
{
"method": "POST",
- "path": "/api/search/getAssetContent",
- "handler": "getAssetContent",
+ "path": "/api/search/listInvalidBlockRefs",
+ "handler": "listInvalidBlockRefs",
"body": "json",
"request": {
- "$ref": "#/$defs/AssetContentRequestInput"
+ "$ref": "#/$defs/SearchPageRequestInput"
},
"response": {
"anyOf": [
@@ -149046,7 +151566,7 @@
]
},
"data": {
- "$ref": "#/$defs/AssetContentData"
+ "$ref": "#/$defs/SearchBlocksData"
},
"msg": {
"type": "string"
@@ -149103,8 +151623,8 @@
},
{
"method": "POST",
- "path": "/api/search/getAssetContentByPath",
- "handler": "getAssetContentByPath",
+ "path": "/api/search/removeTemplate",
+ "handler": "removeTemplate",
"body": "json",
"request": {
"$ref": "#/$defs/SearchPathRequestInput"
@@ -149121,7 +151641,7 @@
]
},
"data": {
- "$ref": "#/$defs/AssetContentData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -149178,11 +151698,11 @@
},
{
"method": "POST",
- "path": "/api/search/getEmbedBlock",
- "handler": "getEmbedBlock",
+ "path": "/api/search/searchAsset",
+ "handler": "searchAsset",
"body": "json",
"request": {
- "$ref": "#/$defs/GetEmbedBlockRequestInput"
+ "$ref": "#/$defs/SearchAssetRequestInput"
},
"response": {
"anyOf": [
@@ -149196,7 +151716,24 @@
]
},
"data": {
- "$ref": "#/$defs/EmbedBlocksData"
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchAsset"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -149253,11 +151790,11 @@
},
{
"method": "POST",
- "path": "/api/search/listInvalidBlockRefs",
- "handler": "listInvalidBlockRefs",
+ "path": "/api/search/searchEmbedBlock",
+ "handler": "searchEmbedBlock",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchPageRequestInput"
+ "$ref": "#/$defs/SearchEmbedBlockRequestInput"
},
"response": {
"anyOf": [
@@ -149271,7 +151808,7 @@
]
},
"data": {
- "$ref": "#/$defs/SearchBlocksData"
+ "$ref": "#/$defs/EmbedBlocksData"
},
"msg": {
"type": "string"
@@ -149328,11 +151865,11 @@
},
{
"method": "POST",
- "path": "/api/search/removeTemplate",
- "handler": "removeTemplate",
+ "path": "/api/search/searchRefBlock",
+ "handler": "searchRefBlock",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchPathRequestInput"
+ "$ref": "#/$defs/SearchRefBlockRequestInput"
},
"response": {
"anyOf": [
@@ -149346,7 +151883,14 @@
]
},
"data": {
- "type": "null"
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchRefResult"
+ },
+ {
+ "$ref": "#/$defs/SearchRefCorrelation"
+ }
+ ]
},
"msg": {
"type": "string"
@@ -149384,6 +151928,16 @@
},
{
"type": "null"
+ },
+ {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchRefResult"
+ },
+ {
+ "$ref": "#/$defs/SearchRefCorrelation"
+ }
+ ]
}
]
},
@@ -149403,11 +151957,11 @@
},
{
"method": "POST",
- "path": "/api/search/searchAsset",
- "handler": "searchAsset",
+ "path": "/api/search/searchTag",
+ "handler": "searchTag",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchAssetRequestInput"
+ "$ref": "#/$defs/SearchTagRequestInput"
},
"response": {
"anyOf": [
@@ -149421,24 +151975,7 @@
]
},
"data": {
- "anyOf": [
- {
- "type": "array",
- "items": {
- "anyOf": [
- {
- "$ref": "#/$defs/SearchAsset"
- },
- {
- "type": "null"
- }
- ]
- }
- },
- {
- "type": "null"
- }
- ]
+ "$ref": "#/$defs/SearchTagData"
},
"msg": {
"type": "string"
@@ -149495,11 +152032,11 @@
},
{
"method": "POST",
- "path": "/api/search/searchEmbedBlock",
- "handler": "searchEmbedBlock",
+ "path": "/api/search/searchTemplate",
+ "handler": "searchTemplate",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchEmbedBlockRequestInput"
+ "$ref": "#/$defs/SearchKeywordRequestInput"
},
"response": {
"anyOf": [
@@ -149513,7 +152050,7 @@
]
},
"data": {
- "$ref": "#/$defs/EmbedBlocksData"
+ "$ref": "#/$defs/SearchTemplateData"
},
"msg": {
"type": "string"
@@ -149570,11 +152107,11 @@
},
{
"method": "POST",
- "path": "/api/search/searchRefBlock",
- "handler": "searchRefBlock",
+ "path": "/api/search/searchWidget",
+ "handler": "searchWidget",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchRefBlockRequestInput"
+ "$ref": "#/$defs/SearchKeywordRequestInput"
},
"response": {
"anyOf": [
@@ -149588,14 +152125,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/SearchRefResult"
- },
- {
- "$ref": "#/$defs/SearchRefCorrelation"
- }
- ]
+ "$ref": "#/$defs/SearchWidgetData"
},
"msg": {
"type": "string"
@@ -149633,16 +152163,6 @@
},
{
"type": "null"
- },
- {
- "anyOf": [
- {
- "$ref": "#/$defs/SearchRefResult"
- },
- {
- "$ref": "#/$defs/SearchRefCorrelation"
- }
- ]
}
]
},
@@ -149662,11 +152182,11 @@
},
{
"method": "POST",
- "path": "/api/search/searchTag",
- "handler": "searchTag",
+ "path": "/api/search/semanticSearchBlock",
+ "handler": "semanticSearchBlock",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchTagRequestInput"
+ "$ref": "#/$defs/SearchBlockRequestInput"
},
"response": {
"anyOf": [
@@ -149680,7 +152200,7 @@
]
},
"data": {
- "$ref": "#/$defs/SearchTagData"
+ "$ref": "#/$defs/SearchBlocksData"
},
"msg": {
"type": "string"
@@ -149737,11 +152257,11 @@
},
{
"method": "POST",
- "path": "/api/search/searchTemplate",
- "handler": "searchTemplate",
+ "path": "/api/search/updateEmbedBlock",
+ "handler": "updateEmbedBlock",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchKeywordRequestInput"
+ "$ref": "#/$defs/UpdateEmbedBlockRequestInput"
},
"response": {
"anyOf": [
@@ -149755,7 +152275,7 @@
]
},
"data": {
- "$ref": "#/$defs/SearchTemplateData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -149812,11 +152332,11 @@
},
{
"method": "POST",
- "path": "/api/search/searchWidget",
- "handler": "searchWidget",
+ "path": "/api/setting/addVirtualBlockRefExclude",
+ "handler": "addVirtualBlockRefExclude",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchKeywordRequestInput"
+ "$ref": "#/$defs/VirtualBlockRefRequestInput"
},
"response": {
"anyOf": [
@@ -149830,7 +152350,7 @@
]
},
"data": {
- "$ref": "#/$defs/SearchWidgetData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -149887,11 +152407,11 @@
},
{
"method": "POST",
- "path": "/api/search/semanticSearchBlock",
- "handler": "semanticSearchBlock",
+ "path": "/api/setting/addVirtualBlockRefInclude",
+ "handler": "addVirtualBlockRefInclude",
"body": "json",
"request": {
- "$ref": "#/$defs/SearchBlockRequestInput"
+ "$ref": "#/$defs/VirtualBlockRefRequestInput"
},
"response": {
"anyOf": [
@@ -149905,7 +152425,7 @@
]
},
"data": {
- "$ref": "#/$defs/SearchBlocksData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -149962,11 +152482,11 @@
},
{
"method": "POST",
- "path": "/api/search/updateEmbedBlock",
- "handler": "updateEmbedBlock",
- "body": "json",
+ "path": "/api/setting/getBootAppearances",
+ "handler": "getBootAppearances",
+ "body": "none",
"request": {
- "$ref": "#/$defs/UpdateEmbedBlockRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -149980,7 +152500,7 @@
]
},
"data": {
- "type": "null"
+ "$ref": "#/$defs/SettingBootAppearancesData"
},
"msg": {
"type": "string"
@@ -150037,11 +152557,11 @@
},
{
"method": "POST",
- "path": "/api/setting/addVirtualBlockRefExclude",
- "handler": "addVirtualBlockRefExclude",
+ "path": "/api/setting/getCloudUser",
+ "handler": "getCloudUser",
"body": "json",
"request": {
- "$ref": "#/$defs/VirtualBlockRefRequestInput"
+ "$ref": "#/$defs/SettingCloudUserRequestInput"
},
"response": {
"anyOf": [
@@ -150054,42 +152574,10 @@
0
]
},
- "data": {
- "type": "null"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
- },
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- -1
- ]
- },
"data": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "closeTimeout": {
- "type": "number"
- }
- },
- "required": [
- "closeTimeout"
- ],
- "additionalProperties": false
+ "$ref": "#/$defs/SettingUser"
},
{
"type": "null"
@@ -150105,42 +152593,6 @@
"msg",
"data"
],
- "additionalProperties": true
- }
- ]
- }
- },
- {
- "method": "POST",
- "path": "/api/setting/addVirtualBlockRefInclude",
- "handler": "addVirtualBlockRefInclude",
- "body": "json",
- "request": {
- "$ref": "#/$defs/VirtualBlockRefRequestInput"
- },
- "response": {
- "anyOf": [
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
- ]
- },
- "data": {
- "type": "null"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
"additionalProperties": false
},
{
@@ -150149,7 +152601,9 @@
"code": {
"type": "integer",
"enum": [
- -1
+ -1,
+ 1,
+ 255
]
},
"data": {
@@ -150168,6 +152622,16 @@
},
{
"type": "null"
+ },
+ {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SettingUser"
+ },
+ {
+ "type": "null"
+ }
+ ]
}
]
},
@@ -150187,8 +152651,8 @@
},
{
"method": "POST",
- "path": "/api/setting/getBootAppearances",
- "handler": "getBootAppearances",
+ "path": "/api/setting/getPandocBin",
+ "handler": "getPandocBin",
"body": "none",
"request": {
"$ref": "#/$defs/EmptyRequestInput"
@@ -150205,7 +152669,7 @@
]
},
"data": {
- "$ref": "#/$defs/SettingBootAppearancesData"
+ "type": "string"
},
"msg": {
"type": "string"
@@ -150262,11 +152726,11 @@
},
{
"method": "POST",
- "path": "/api/setting/getCloudUser",
- "handler": "getCloudUser",
- "body": "json",
+ "path": "/api/setting/getPublish",
+ "handler": "getPublish",
+ "body": "none",
"request": {
- "$ref": "#/$defs/SettingCloudUserRequestInput"
+ "$ref": "#/$defs/EmptyRequestInput"
},
"response": {
"anyOf": [
@@ -150280,14 +152744,7 @@
]
},
"data": {
- "anyOf": [
- {
- "$ref": "#/$defs/SettingUser"
- },
- {
- "type": "null"
- }
- ]
+ "$ref": "#/$defs/SettingPublishData"
},
"msg": {
"type": "string"
@@ -150306,9 +152763,7 @@
"code": {
"type": "integer",
"enum": [
- -1,
- 1,
- 255
+ -1
]
},
"data": {
@@ -150327,16 +152782,6 @@
},
{
"type": "null"
- },
- {
- "anyOf": [
- {
- "$ref": "#/$defs/SettingUser"
- },
- {
- "type": "null"
- }
- ]
}
]
},
@@ -150356,36 +152801,16 @@
},
{
"method": "POST",
- "path": "/api/setting/getPandocBin",
- "handler": "getPandocBin",
- "body": "none",
+ "path": "/api/setting/login2faCloudUser",
+ "handler": "login2faCloudUser",
+ "body": "json",
"request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/SettingLogin2faRequestInput"
},
"response": {
"anyOf": [
{
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- 0
- ]
- },
- "data": {
- "type": "string"
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": false
+ "$ref": "#/$defs/Login2faEnvelope"
},
{
"type": "object",
@@ -150427,12 +152852,13 @@
"additionalProperties": true
}
]
- }
+ },
+ "output": "directJSON"
},
{
"method": "POST",
- "path": "/api/setting/getPublish",
- "handler": "getPublish",
+ "path": "/api/setting/logoutCloudUser",
+ "handler": "logoutCloudUser",
"body": "none",
"request": {
"$ref": "#/$defs/EmptyRequestInput"
@@ -150449,7 +152875,7 @@
]
},
"data": {
- "$ref": "#/$defs/SettingPublishData"
+ "type": "null"
},
"msg": {
"type": "string"
@@ -150506,67 +152932,11 @@
},
{
"method": "POST",
- "path": "/api/setting/login2faCloudUser",
- "handler": "login2faCloudUser",
+ "path": "/api/setting/patch",
+ "handler": "patchSetting",
"body": "json",
"request": {
- "$ref": "#/$defs/SettingLogin2faRequestInput"
- },
- "response": {
- "anyOf": [
- {
- "$ref": "#/$defs/Login2faEnvelope"
- },
- {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "enum": [
- -1
- ]
- },
- "data": {
- "anyOf": [
- {
- "type": "object",
- "properties": {
- "closeTimeout": {
- "type": "number"
- }
- },
- "required": [
- "closeTimeout"
- ],
- "additionalProperties": false
- },
- {
- "type": "null"
- }
- ]
- },
- "msg": {
- "type": "string"
- }
- },
- "required": [
- "code",
- "msg",
- "data"
- ],
- "additionalProperties": true
- }
- ]
- },
- "output": "directJSON"
- },
- {
- "method": "POST",
- "path": "/api/setting/logoutCloudUser",
- "handler": "logoutCloudUser",
- "body": "none",
- "request": {
- "$ref": "#/$defs/EmptyRequestInput"
+ "$ref": "#/$defs/PatchSettingRequestInput"
},
"response": {
"anyOf": [
diff --git a/kernel/apicontract/setting_patch.go b/kernel/apicontract/setting_patch.go
new file mode 100644
index 0000000000..23385ca2b0
--- /dev/null
+++ b/kernel/apicontract/setting_patch.go
@@ -0,0 +1,63 @@
+package apicontract
+
+import (
+ "encoding/json"
+ "errors"
+ "io"
+)
+
+// PatchSettingRequest 每次仅更新一个配置域。对象递归合并,数组和 null 整体替换,省略字段保留当前值。
+// 旧设置接口的整份配置提交和默认值语义不变;失败不发出配置变更通知。
+type PatchSettingRequest struct {
+ Editor *SettingEditor `json:"editor" api:"optional"`
+ Export *SettingExport `json:"export" api:"optional"`
+ FileTree *SettingFileTree `json:"fileTree" api:"optional"`
+ Search *SettingSearch `json:"search" api:"optional"`
+ Appearance *SettingAppearance `json:"appearance" api:"optional"`
+ Flashcard *SettingFlashcard `json:"flashcard" api:"optional"`
+ AI *SettingAI `json:"ai" api:"optional"`
+ Secrets *SettingSecrets `json:"secrets" api:"optional"`
+ Variables *SettingVariables `json:"variables" api:"optional"`
+ Keymap map[string]JSONValue `json:"keymap" api:"optional"`
+ namespace string
+ patch json.RawMessage
+}
+
+func (r PatchSettingRequest) Namespace() string { return r.namespace }
+func (r PatchSettingRequest) PatchJSON() []byte { return append([]byte(nil), r.patch...) }
+
+// PatchSetting 返回成功后由客户端重新读取已鉴权的配置,不在广播中携带密码或 API 密钥。
+func init() {
+ PatchSetting.decodeRequest = func(reader io.Reader) (r PatchSettingRequest, err error) {
+ var raw json.RawMessage
+ if err = json.NewDecoder(reader).Decode(&raw); err != nil {
+ return
+ }
+ if err = json.Unmarshal(raw, &r); err != nil {
+ return
+ }
+ var fields map[string]json.RawMessage
+ if err = json.Unmarshal(raw, &fields); err != nil {
+ return
+ }
+ if len(fields) != 1 {
+ return r, errors.New("exactly one settings namespace is required")
+ }
+ for namespace, patch := range fields {
+ switch namespace {
+ case "editor", "export", "fileTree", "search", "appearance", "flashcard", "ai", "secrets", "variables", "keymap":
+ default:
+ return r, errors.New("unsupported settings namespace")
+ }
+ var object map[string]json.RawMessage
+ if err = json.Unmarshal(patch, &object); err != nil {
+ return
+ }
+ if len(object) == 0 {
+ return r, errors.New("settings patch must be a nonempty object")
+ }
+ r.namespace, r.patch = namespace, patch
+ }
+ return
+ }
+}
diff --git a/kernel/apicontract/setting_patch_test.go b/kernel/apicontract/setting_patch_test.go
new file mode 100644
index 0000000000..50f5bdb8d2
--- /dev/null
+++ b/kernel/apicontract/setting_patch_test.go
@@ -0,0 +1,22 @@
+package apicontract
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestSettingPatchInput(t *testing.T) {
+ for _, body := range []string{`{"editor":{"fontSize":20}}`, `{"appearance":{"notifications":{"selectAllTip":false}}}`,
+ `{"ai":{"agent":{"maxRetries":2}}}`, `{"keymap":{"plugin":{"example.name":{"command":{"custom":""}}}}}`} {
+ request, err := PatchSetting.Decode(strings.NewReader(body))
+ if err != nil || request.Namespace() == "" || len(request.PatchJSON()) == 0 {
+ t.Fatalf("valid patch rejected: %s %v", body, err)
+ }
+ }
+ for _, body := range []string{`{}`, `null`, `[]`, `{"editor":{}}`, `{"editor":null}`, `{"editor":[]}`,
+ `{"unknown":{"value":1}}`, `{"editor":{"fontSize":"bad"}}`, `{"editor":{"fontSize":20},"search":{"limit":8}}`} {
+ if _, err := PatchSetting.Decode(strings.NewReader(body)); err == nil {
+ t.Fatalf("invalid patch accepted: %s", body)
+ }
+ }
+}
diff --git a/kernel/apicontract/system.go b/kernel/apicontract/system.go
index bedebf04e0..3f4da7eb70 100644
--- a/kernel/apicontract/system.go
+++ b/kernel/apicontract/system.go
@@ -45,6 +45,20 @@ type SystemConfData struct {
Conf *SystemAppConf `json:"conf"`
Start bool `json:"start"`
IsPublish bool `json:"isPublish"`
+ // SettingTasks 为当前仍执行的设置维护任务,前端初始化和重连时恢复任务阻塞。
+ SettingTasks *SettingTaskState `json:"settingTasks,omitempty"`
+}
+
+type SettingTask struct {
+ ID string `json:"id"`
+ Active bool `json:"active"`
+ Message string `json:"message"`
+ Revision uint64 `json:"revision"`
+}
+
+type SettingTaskState struct {
+ Revision uint64 `json:"revision"`
+ Tasks []SettingTask `json:"tasks"`
}
type SystemImportConfRequest struct {
File []*multipart.FileHeader `json:"file" api:"optional"`