An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Remember mind map zoom and position https://github.com/siyuan-note/siyuan/issues/20877
Daniel6411db04edf3
diff --git a/app/src/constants.ts b/app/src/constants.tsindex da574b23f6..9956cede4d 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -226,6 +226,7 @@ export abstract class Constants {public static readonly LOCAL_CLOSED_TABS = "local-closed-tabs";public static readonly LOCAL_AV_CALENDAR_MODES = "local-av-calendar-modes";public static readonly LOCAL_TABS_READING = "local-tabs-reading";+ public static readonly LOCAL_MINDMAP_VIEWPORTS = "local-mindmap-viewports";/** @deprecated 内置偏好改用 config.appearance.compactMode,不再读取此旧键 */public static readonly LOCAL_COMPACT_MODE = "local-compact-mode";/** @deprecated 内置偏好改用 config.appearance.menuMouseScroll,不再读取此旧键 */diff --git a/app/src/protyle/render/listMindmap/arrows.test.ts b/app/src/protyle/render/listMindmap/arrows.test.tsindex 40fb18acab..00a58c1b74 100644--- a/app/src/protyle/render/listMindmap/arrows.test.ts+++ b/app/src/protyle/render/listMindmap/arrows.test.ts@@ -13,9 +13,9 @@ const source = createSourceFile("view.ts", readFileSync("src/protyle/render/listconst view = source.statements.find(item => isClassDeclaration(item) && item.name?.text === "ListMindmapView");assert.ok(view && isClassDeclaration(view));const methods = view.members.filter(item => ["relationPath", "draw", "resizeViewport", "getViewportAnchorY",- "updateDocumentViewport", "findLine", "renderInspector"]+ "updateDocumentViewport", "rememberViewport", "findLine", "renderInspector"].includes(item.name?.getText(source)));-assert.equal(methods.length, 7);+assert.equal(methods.length, 8);const compiled = transpileModule(`class View {${methods.map(item => item.getText(source)).join("\n")}}diff --git a/app/src/protyle/render/listMindmap/fullscreen.test.ts b/app/src/protyle/render/listMindmap/fullscreen.test.tsindex 356d71cb2a..ab132ed51b 100644--- a/app/src/protyle/render/listMindmap/fullscreen.test.ts+++ b/app/src/protyle/render/listMindmap/fullscreen.test.ts@@ -45,7 +45,12 @@ const browserCases = async (source: string, css: string) => {Array.from({length: 12}, (_, index) => ` - Node ${index}\n`).join(""));const list = holder.firstElementChild;const originalSource = list.outerHTML;- const view = new api.ListMindmapView({host, model: api.readListMindmap(list), onExit: () => {}});+ let remembered: {scale: number, center: {x: number, y: number}};+ const remember = (state: typeof remembered) => {+ remembered = {scale: state.scale, center: {...state.center}};+ };+ const view = new api.ListMindmapView({host, model: api.readListMindmap(list),+ onViewportChange: remember, onExit: () => {}});await settle();const viewport = host.querySelector<HTMLElement>(".mindmap-view__viewport");const center = () => [(viewport.clientWidth / 2 - view.offsetX) / view.scale,@@ -258,9 +263,11 @@ const browserCases = async (source: string, css: string) => {await settle();checkFrame();const beforePrint = [view.scale, view.offsetX, view.offsetY];+ const rememberedBeforePrint = JSON.stringify(remembered);window.dispatchEvent(new Event("beforeprint"));await require("electron").ipcRenderer.invoke("mindmap-fullscreen-media", "print");check.equal(getComputedStyle(preview).display, "none", "layout guides are excluded from printing");+ check.equal(JSON.stringify(remembered), rememberedBeforePrint, "print fitting does not overwrite the saved view");await require("electron").ipcRenderer.invoke("mindmap-fullscreen-media", "");window.dispatchEvent(new Event("afterprint"));await settle();@@ -270,6 +277,8 @@ const browserCases = async (source: string, css: string) => {button("exitFullscreen").click();await settle();checkApplied(editedLayout);+ check.equal(remembered.scale, view.scale, "explicit fullscreen layout saves the applied document zoom");+ check.deepEqual([remembered.center.x, remembered.center.y], center());check.equal(view.getContentHost(view.model.root.id).textContent, "Edited in document layout");// 画布锁定会取消未应用的布局,不能借助模式切换改写锁定视角。@@ -491,19 +500,28 @@ const browserCases = async (source: string, css: string) => {await settle();equalCenter(beforeLock);check.equal(view.scale, beforeLockScale, "locking in fullscreen does not replace the saved document view");+ check.equal(remembered.scale, beforeLockScale);+ check.deepEqual([remembered.center.x, remembered.center.y], beforeLock);button("fullscreen").click();await settle();view.destroy();check.equal(host.parentElement, parent);check.equal(host.classList.contains("fullscreen"), false);check.equal(Array.from(parent.childNodes).some(node => node.nodeType === Node.COMMENT_NODE), false);- const initializing = new api.ListMindmapView({host, model: api.readListMindmap(list), onExit: () => {}});+ const initializing = new api.ListMindmapView({host, model: api.readListMindmap(list),+ viewport: remembered, onViewportChange: remember, onExit: () => {}});button("fullscreen").click();button("exitFullscreen").click();await settle();check.equal(initializing.initialFit, false, "an early round trip still completes the initial document layout");check.equal(host.parentElement, parent);check.ok(Number.isFinite(initializing.offsetX) && Number.isFinite(initializing.offsetY));+ check.equal(initializing.scale, beforeLockScale, "reopening restores zoom instead of fitting");+ const reopenedViewport = host.querySelector<HTMLElement>(".mindmap-view__viewport");+ const reopenedCenter = [(reopenedViewport.clientWidth / 2 - initializing.offsetX) / initializing.scale,+ (reopenedViewport.clientHeight / 2 - initializing.offsetY) / initializing.scale];+ reopenedCenter.forEach((value, index) => check.ok(Math.abs(value - beforeLock[index]) < 1e-8,+ "reopening restores the document center"));initializing.destroy();parent.remove();}diff --git a/app/src/protyle/render/listMindmap/index.ts b/app/src/protyle/render/listMindmap/index.tsindex b2dd943691..4d117988a9 100644--- a/app/src/protyle/render/listMindmap/index.ts+++ b/app/src/protyle/render/listMindmap/index.ts@@ -36,6 +36,7 @@ import {syncListMindmapHeight} from "./height";import {bindListMindmapResize} from "./resize";import {setBlockHeight} from "../../gutter/height";import {ListMindmapView} from "./view";+import {flushListMindmapViewports, getListMindmapViewport, saveListMindmapViewport} from "./viewport";import {getListMindmapLineColors, getListMindmapNodeColors, getListMindmapNodeColorMenu} from "./colors";import {openListMindmapEditor} from "./editor";import {focusListMindmap} from "./create";@@ -238,6 +239,8 @@ class ListMindmapController {list.appendChild(this.host);let restoreFullscreenChrome: () => void;this.view = new ListMindmapView({+ viewport: getListMindmapViewport(owner, list),+ onViewportChange: state => saveListMindmapViewport(owner, list, state),host: this.host, model: this.model, labels: window.siyuan.languages,onOpenLink: (href, event) => openLink(owner.app, href, event, event.ctrlKey || event.metaKey),onPreviewImage: (src, video) => previewDocImage(src, owner.block.rootID, video),@@ -1055,6 +1058,7 @@ class ListMindmapController {this.resize.destroy();this.unregisterVisible?.();this.view.destroy();+ flushListMindmapViewports();this.host.remove();this.list.removeAttribute("data-mindmap-view-rendered");if (restoreFocus) {diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex dfe38e1760..8ac4efe5ed 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -389,6 +389,8 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,CUSTOM_SY_LIST_MINDMAP: "custom-sy-list-mindmap", CUSTOM_SY_LIST_MINDMAP_DATA: "custom-sy-list-mindmap-data"},isProtyleListItemFragment: () => false, isHiddenTabContent: () => false,isMobile: () => mobile, waitForPendingTransactions: async () => {},+ isEncryptedBox: () => false,+ setStorageVal: () => check.fail("Embedded previews cannot persist viewport positions"),fetchSyncPost: async () => ({code: 0, data: {dom: full}}),normalizeHTMLAssetIFrameBlockDOM: (html: string) => html,cleanHeadingNumberHTML: (html: string) => html, cleanTableCellRichHTML: (html: string) => html,@@ -5504,7 +5506,7 @@ test("list mindmap mutations preserve block data in the real DOM and Lute", {readFileSync(path.join(__dirname, "../../wysiwyg/transaction.ts"), "utf8"), typescript.ScriptTarget.Latest, true);const updateTransaction = transactionSource.statements.find(statement => typescript.isVariableStatement(statement) &&statement.declarationList.declarations.some(item => item.name.getText(transactionSource) === "updateTransaction"));- const controllerSource = compile(path.join(__dirname, "foldMenu.ts")) ++ const controllerSource = compile(path.join(__dirname, "viewport.ts")) + compile(path.join(__dirname, "foldMenu.ts")) +compile(path.join(__dirname, "../../util/hasClosest.ts")) +compile(path.join(__dirname, "../../wysiwyg/getBlock.ts")) + compile(path.join(__dirname, "index.ts")) +typescript.transpileModule(updateTransaction.getText(transactionSource).replace(/^export /, ""), {diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex 5b30ef1dc1..c2eaa47455 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -24,10 +24,13 @@ import type {ListMindmapSummary, ListMindmapSummaryPosition, ListMindmapSummaryRimport {buildListMindmapConnectors, buildListMindmapSummaryConnector} from "./connectors";import {getMindmapLineColor, getMindmapTextColor, isMindmapColor, resolveListMindmapColors} from "./appearance";import {canCutMindmapBranches} from "./clipboard";+import type {ListMindmapViewport} from "./viewport";export interface ListMindmapViewOptions {host: HTMLElement;model: ListMindmapModel;+ viewport?: ListMindmapViewport;+ onViewportChange?: (state: ListMindmapViewport) => void;readOnly?: boolean;onLockChange?: (locked: boolean) => Promise<boolean>;printLayout?: boolean;@@ -1355,7 +1358,9 @@ export class ListMindmapView {this.fitPrint();} else if (this.initialFit) {this.initialFit = false;- this.fit();+ if (!this.restoreViewport()) {+ this.fit();+ }} else if (center) {this.draw();} else {@@ -2036,6 +2041,7 @@ export class ListMindmapView {const height = this.viewport.clientHeight;this.resizeViewport(width, height);this.world.style.transform = `translate(${this.offsetX}px, ${this.offsetY}px) scale(${this.scale})`;+ this.rememberViewport();this.updateDocumentViewport();this.zoomLabel.textContent = `${Math.round(this.scale * 100)}%`;this.zoomSlider.value = String(Math.round(this.scale * 100));@@ -4179,6 +4185,33 @@ export class ListMindmapView {this.documentViewport.style.transform = `translate(${x}px, ${y}px)`;}+ private restoreViewport() {+ const state = this.options.viewport;+ if (!state) {+ return false;+ }+ this.scale = state.scale;+ this.offsetX = this.viewport.clientWidth / 2 - state.center.x * this.scale;+ this.offsetY = this.getViewportAnchorY(this.viewport.clientHeight) - state.center.y * this.scale;+ this.draw();+ return true;+ }++ private rememberViewport() {+ if (!this.options.onViewportChange || this.initialFit || this.printTransform || this.options.printLayout ||+ !this.viewport.clientWidth || !this.viewport.clientHeight) {+ return;+ }+ // 全屏中的临时浏览不覆盖文档视角;显式应用布局后由文档视图的下一次绘制保存。+ this.options.onViewportChange(this.documentView || {+ scale: this.scale,+ center: {+ x: (this.viewport.clientWidth / 2 - this.offsetX) / this.scale,+ y: (this.getViewportAnchorY(this.viewport.clientHeight) - this.offsetY) / this.scale,+ },+ });+ }+private captureViewportCenter() {if (!this.initialFit && !this.viewportCenter) {this.viewportCenter = {diff --git a/app/src/protyle/render/listMindmap/viewport.test.ts b/app/src/protyle/render/listMindmap/viewport.test.tsnew file mode 100644index 0000000000..e11078c476--- /dev/null+++ b/app/src/protyle/render/listMindmap/viewport.test.ts@@ -0,0 +1,121 @@+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";+import type {ListMindmapViewport} from "./viewport";++const key = "local-mindmap-viewports";+const compiled = transpileModule(readFileSync("src/protyle/render/listMindmap/viewport.ts", "utf8"), {+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},+}).outputText;+const state: ListMindmapViewport = {scale: 1.25, center: {x: 220, y: 180}};+const fixture = (storage: Record<string, unknown> = {}) => {+ const writes: unknown[] = [];+ const timers = new Map<number, () => void>();+ let nextTimer = 0;+ const siyuan = {storage, config: {readonly: false}, isPublish: false};+ const root = {};+ const owner = {lite: false, notebookId: "ordinary", options: {action: [] as string[]}, wysiwyg: {element: root}};+ let excluded = false;+ const list = (id = "map") => ({dataset: {nodeId: id},+ closest: (selector: string) => selector === ".protyle-wysiwyg" ? root : excluded ? root : null});+ const api = {} as typeof import("./viewport");+ runInNewContext(compiled, {exports: api, window: {siyuan,+ setTimeout: (action: () => void) => { timers.set(++nextTimer, action); return nextTimer; },+ clearTimeout: (id: number) => timers.delete(id)}, require: (id: string) => {+ if (id === "../../../constants") {+ return {Constants: {LOCAL_MINDMAP_VIEWPORTS: key, CB_GET_HISTORY: "history"}};+ }+ if (id === "../../../util/pathName") {+ return {isEncryptedBox: (id: string) => id === "encrypted"};+ }+ assert.equal(id, "../../util/compatibility");+ return {setStorageVal: (name: string, value: unknown) => {+ assert.equal(name, key);+ writes.push(JSON.parse(JSON.stringify(value)));+ }};+ }});+ return {siyuan, owner, writes, timers, list, api,+ exclude: () => { excluded = true; },+ get: (id = "map") => api.getListMindmapViewport(owner as IProtyle, list(id) as unknown as HTMLElement),+ save: (value = state, id = "map") => api.saveListMindmapViewport(owner as IProtyle, list(id) as unknown as HTMLElement, value)};+};++test("mindmap viewports survive reopening and restart, independently for each block", () => {+ const f = fixture();+ f.save();+ f.save({scale: .75, center: {x: 10, y: 20}}, "other");+ assert.equal(f.writes.length, 0, "continuous changes are coalesced");+ assert.equal(f.timers.size, 1);+ assert.equal(JSON.stringify(f.get()), JSON.stringify(state));+ f.api.flushListMindmapViewports();+ assert.equal(f.writes.length, 1);+ assert.equal(f.timers.size, 0);+ const restarted = fixture({[key]: f.writes[0]});+ assert.equal(JSON.stringify(restarted.get()), JSON.stringify(state));+ assert.equal(restarted.get("other").scale, .75);+ assert.equal(restarted.get("missing"), undefined);+ restarted.get().center.x = 999;+ assert.equal(restarted.get().center.x, state.center.x, "callers cannot mutate the stored center");+ f.save();+ assert.equal(f.timers.size, 0, "unchanged drawing does not schedule another write");+});++test("encrypted, readonly and published viewports remain only in workspace session memory", () => {+ for (const mode of ["encrypted", "readonly", "publish"]) {+ const f = fixture({[key]: {map: {scale: 2, center: {x: 1, y: 2}}}});+ f.owner.notebookId = mode === "encrypted" ? "encrypted" : "ordinary";+ f.siyuan.config.readonly = mode === "readonly";+ f.siyuan.isPublish = mode === "publish";+ assert.equal(f.get(), undefined, "session-only contexts do not read persistent positions");+ f.save();+ assert.equal(JSON.stringify(f.get()), JSON.stringify(state));+ assert.equal(f.timers.size, 0);+ f.api.flushListMindmapViewports();+ assert.equal(f.writes.length, 0);+ assert.equal((f.siyuan.storage[key] as Record<string, ListMindmapViewport>).map.scale, 2);+ f.siyuan.storage = {};+ assert.equal(f.get(), undefined, "workspace sessions are isolated");+ }+});++test("history, lite editors, embedded maps and missing IDs do not read or overwrite saved positions", () => {+ for (const mode of ["history", "lite", "embedded", "missing-id"]) {+ const f = fixture({[key]: {map: state}});+ f.owner.options.action = mode === "history" ? ["history"] : [];+ f.owner.lite = mode === "lite";+ if (mode === "embedded") {+ f.exclude();+ }+ const id = mode === "missing-id" ? "" : "map";+ assert.equal(f.get(id), undefined);+ f.save(state, id);+ assert.equal(f.timers.size, 0);+ }+});++test("malformed saved viewports are ignored and invalid updates preserve existing data", () => {+ const invalidValues: unknown[] = [null, [], "invalid", {scale: 0, center: state.center},+ {scale: 3, center: state.center}, {scale: 1, center: {x: Infinity, y: 0}},+ {scale: 1, center: {x: 0, y: 1000001}}, {scale: "1", center: state.center}, {scale: 1}];+ for (const invalid of invalidValues) {+ const f = fixture({[key]: {map: invalid}});+ assert.equal(f.get(), undefined);+ f.save(invalid as ListMindmapViewport);+ assert.equal(f.siyuan.storage[key] && (f.siyuan.storage[key] as Record<string, unknown>).map, invalid);+ assert.equal(f.timers.size, 0);+ }+});++test("viewport history is bounded and retains the most recently changed maps", () => {+ const saved = Object.fromEntries(Array.from({length: 1000}, (_, index) => [`map-${index}`, state]));+ const f = fixture({[key]: saved});+ f.save({...state, scale: 2}, "map-0");+ f.save(state, "new");+ assert.equal(f.get("map-1"), undefined);+ assert.equal(f.get("map-0").scale, 2);+ assert.equal(Object.keys(f.siyuan.storage[key]).length, 1000);+ f.api.flushListMindmapViewports();+ assert.equal(f.writes.length, 1);+});diff --git a/app/src/protyle/render/listMindmap/viewport.ts b/app/src/protyle/render/listMindmap/viewport.tsnew file mode 100644index 0000000000..61a97ab7d9--- /dev/null+++ b/app/src/protyle/render/listMindmap/viewport.ts@@ -0,0 +1,80 @@+import {Constants} from "../../../constants";+import {isEncryptedBox} from "../../../util/pathName";+import {setStorageVal} from "../../util/compatibility";++export interface ListMindmapViewport {+ scale: number;+ center: {x: number, y: number};+}++const sessionViewports = new WeakMap<object, Record<string, ListMindmapViewport>>();+let saveTimer: number;++const isViewport = (value: unknown): value is ListMindmapViewport => {+ if (!value || typeof value !== "object") {+ return false;+ }+ const state = value as ListMindmapViewport;+ return Number.isFinite(state.scale) && state.scale >= .15 && state.scale <= 2.5 &&+ !!state.center && [state.center.x, state.center.y].every(value =>+ Number.isFinite(value) && Math.abs(value) <= 1000000);+};++const canRemember = (owner: IProtyle, list: HTMLElement) => !!list.dataset.nodeId && !owner.lite &&+ !owner.options.action.includes(Constants.CB_GET_HISTORY) &&+ !list.closest(".protyle-wysiwyg__embed, .mindmap-view__preview-block") &&+ list.closest(".protyle-wysiwyg") === owner.wysiwyg.element;++// 与文档阅读位置一致,加密笔记本和无写权限场景仅使用工作空间会话内存。+const isSessionOnly = (owner: IProtyle) => window.siyuan.config.readonly || window.siyuan.isPublish ||+ isEncryptedBox(owner.notebookId);++const getViewports = (owner: IProtyle): Record<string, ListMindmapViewport> => {+ const storage = window.siyuan.storage;+ if (!storage) {+ return {};+ }+ const saved = isSessionOnly(owner) ? sessionViewports.get(storage) : storage[Constants.LOCAL_MINDMAP_VIEWPORTS];+ return saved && typeof saved === "object" && !Array.isArray(saved) ? saved : {};+};++export const getListMindmapViewport = (owner: IProtyle, list: HTMLElement): ListMindmapViewport | undefined => {+ if (canRemember(owner, list)) {+ const state = getViewports(owner)[list.dataset.nodeId];+ if (isViewport(state)) {+ return {scale: state.scale, center: {...state.center}};+ }+ }+};++export const flushListMindmapViewports = () => {+ if (saveTimer === undefined) {+ return;+ }+ window.clearTimeout(saveTimer);+ saveTimer = undefined;+ void setStorageVal(Constants.LOCAL_MINDMAP_VIEWPORTS, window.siyuan.storage[Constants.LOCAL_MINDMAP_VIEWPORTS]);+};++export const saveListMindmapViewport = (owner: IProtyle, list: HTMLElement, state: ListMindmapViewport) => {+ if (!canRemember(owner, list) || !window.siyuan.storage || !isViewport(state)) {+ return;+ }+ const saved = getViewports(owner);+ const key = list.dataset.nodeId;+ const previous = saved[key];+ if (isViewport(previous) && previous.scale === state.scale &&+ previous.center.x === state.center.x && previous.center.y === state.center.y) {+ return;+ }+ const entries = Object.entries(saved).filter(([id, value]) => id !== key && isViewport(value));+ entries.push([key, {scale: state.scale, center: {...state.center}}]);+ const viewports = Object.fromEntries(entries.slice(-1000));+ if (isSessionOnly(owner)) {+ sessionViewports.set(window.siyuan.storage, viewports);+ } else {+ window.siyuan.storage[Constants.LOCAL_MINDMAP_VIEWPORTS] = viewports;+ window.clearTimeout(saveTimer);+ saveTimer = window.setTimeout(flushListMindmapViewports, 300);+ }+};diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex 674f222c05..4090181239 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -857,6 +857,7 @@ export const getLocalStorage = (cb: () => void, onError?: (error: unknown) => vodefaultStorage[Constants.LOCAL_MOVE_PATH] = {keys: [], k: ""};defaultStorage[Constants.LOCAL_AV_CALENDAR_MODES] = {};defaultStorage[Constants.LOCAL_TABS_READING] = {};+ defaultStorage[Constants.LOCAL_MINDMAP_VIEWPORTS] = {};[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_EXPORTPATH, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_BAZAAR,Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_MOBILE_TABS,@@ -867,7 +868,8 @@ export const getLocalStorage = (cb: () => void, onError?: (error: unknown) => voConstants.LOCAL_DIALOGPOSITION, Constants.LOCAL_SEARCHUNREF, Constants.LOCAL_HISTORY,Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, Constants.LOCAL_IMAGES,Constants.LOCAL_PLUGIN_DOCKS, Constants.LOCAL_EMOJIS, Constants.LOCAL_MOVE_PATH,- Constants.LOCAL_CLOSED_TABS, Constants.LOCAL_AV_CALENDAR_MODES, Constants.LOCAL_TABS_READING].forEach((key) => {+ Constants.LOCAL_CLOSED_TABS, Constants.LOCAL_AV_CALENDAR_MODES, Constants.LOCAL_TABS_READING,+ Constants.LOCAL_MINDMAP_VIEWPORTS].forEach((key) => {const value = response.data[key];if (typeof value === "string") {try {