Skip to content

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

:sparkles: Support custom mobile plugin dock positions https://github.com/siyuan-note/siyuan/issues/14542

Danielcf7f89b6e116
diff --git a/app/src/mobile/dock/pluginDockState.test.ts b/app/src/mobile/dock/pluginDockState.test.ts
index 4cb3566cf4..cb0165d0f8 100644
--- a/app/src/mobile/dock/pluginDockState.test.ts
+++ b/app/src/mobile/dock/pluginDockState.test.ts
@@ -2,6 +2,8 @@ import * as assert from "node:assert/strict";
import {describe, it} from "node:test";
import {
getMobilePluginDock,
+ getMobilePluginDockEntries,
+ getMobilePluginDockLayouts,
getMobilePluginDockSide,
openMobilePluginDock,
removeMobilePluginDock,
@@ -17,6 +19,31 @@ describe("mobile plugin dock state", () => {
assert.equal(getMobilePluginDockSide("BottomRight"), "right");
});
+ it("builds a stable plugin dock catalog in registered index order", () => {
+ const mobileModel = () => ({}) as never;
+ const app = {
+ plugins: [{
+ docks: {
+ pluginSecond: {
+ config: {position: "BottomRight", index: 20, title: "Second", icon: "iconSecond"},
+ mobileModel,
+ },
+ pluginFirst: {
+ config: {position: "LeftBottom", index: 10, title: "First", icon: "iconFirst"},
+ mobileModel,
+ },
+ },
+ }],
+ };
+ const entries = getMobilePluginDockEntries(app as never);
+
+ assert.deepEqual(entries.map(entry => entry.type), ["pluginFirst", "pluginSecond"]);
+ assert.deepEqual(getMobilePluginDockLayouts(entries), [
+ {id: "pluginFirst", side: "left", index: 10},
+ {id: "pluginSecond", side: "right", index: 20},
+ ]);
+ });
+
it("keeps plugin docks independent and removes only the requested model", () => {
const windowDescriptor = Object.getOwnPropertyDescriptor(globalThis, "window");
const docks: Record<string, unknown> = {};
diff --git a/app/src/mobile/dock/pluginDockState.ts b/app/src/mobile/dock/pluginDockState.ts
index 6847f6105a..f4f17cbff7 100644
--- a/app/src/mobile/dock/pluginDockState.ts
+++ b/app/src/mobile/dock/pluginDockState.ts
@@ -1,4 +1,6 @@
import {MobileCustom} from "./MobileCustom";
+import type {App} from "../../index";
+import type {IMobileSidePanelPluginDock} from "../util/mobileSidePanelConfig";
export const MOBILE_PLUGIN_DOCKS_CHANGE_EVENT = "siyuan-mobile-plugin-docks-change";
@@ -8,6 +10,37 @@ export const getMobilePluginDockSide = (position: TPluginDockPosition) => {
return position === "LeftTop" || position === "LeftBottom" || position === "BottomLeft" ? "left" : "right";
};
+export interface IMobilePluginDockEntry {
+ type: string,
+ config: IPluginDockTab,
+ mobileModel: (element: Element) => MobileCustom,
+ order: number,
+}
+
+export const getMobilePluginDockEntries = (app: App = window.siyuan.ws.app) => {
+ const entries: IMobilePluginDockEntry[] = [];
+ app.plugins.forEach((plugin) => {
+ Object.entries(plugin.docks).forEach(([type, dock]) => {
+ entries.push({
+ type,
+ config: dock.config,
+ mobileModel: dock.mobileModel,
+ order: entries.length,
+ });
+ });
+ });
+ return entries.sort((first, second) =>
+ (first.config.index ?? 1000) - (second.config.index ?? 1000) || first.order - second.order);
+};
+
+export const getMobilePluginDockLayouts = (
+ entries: readonly IMobilePluginDockEntry[] = getMobilePluginDockEntries(),
+): IMobileSidePanelPluginDock[] => entries.map((entry) => ({
+ id: entry.type,
+ side: getMobilePluginDockSide(entry.config.position),
+ index: entry.config.index,
+}));
+
export const dispatchMobilePluginDocksChange = () => {
window.dispatchEvent(new CustomEvent(MOBILE_PLUGIN_DOCKS_CHANGE_EVENT));
};
diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts
index ffe12c3461..7137581ac1 100644
--- a/app/src/mobile/util/initFramework.ts
+++ b/app/src/mobile/util/initFramework.ts
@@ -28,18 +28,22 @@ import {initMobileBottomBar} from "./mobileBottomBar";
import {initMobileBars} from "./mobileBars";
import {openDock} from "../dock/util";
import {
+ MOBILE_SIDE_PANEL_DOCK_IDS,
MOBILE_SIDE_PANEL_CONFIG_CHANGE_EVENT,
+ normalizeMobileSidePanelConfig,
type IMobileSidePanelConfig,
} from "./mobileSidePanelConfig";
import {getMobileSidePanelConfig} from "./mobileSidePanelSetting";
import {
getMobilePluginDock,
+ getMobilePluginDockEntries,
+ getMobilePluginDockLayouts,
getMobilePluginDockSide,
MOBILE_PLUGIN_DOCKS_CHANGE_EVENT,
openMobilePluginDock,
removeMobilePluginDock,
+ type IMobilePluginDockEntry,
} from "../dock/pluginDockState";
-import type {MobileCustom} from "../dock/MobileCustom";
const getDockTabElement = (type: string) => {
return document.querySelector(`[data-type="${CSS.escape(`sidebar-${type}-tab`)}"]`) as HTMLElement;
@@ -60,32 +64,10 @@ const getActiveDockId = (sidePanelElement: HTMLElement) => {
return activeElement ? getDockIdFromTabElement(activeElement) : undefined;
};
-const getMobilePluginDockEntries = (app: App) => {
- const entries: Array<{
- type: string,
- config: IPluginDockTab,
- mobileModel: (element: Element) => MobileCustom,
- order: number,
- }> = [];
- app.plugins.forEach((plugin) => {
- Object.entries(plugin.docks).forEach(([type, dock]) => {
- entries.push({
- type,
- config: dock.config,
- mobileModel: dock.mobileModel,
- order: entries.length,
- });
- });
- });
- return entries.sort((first, second) =>
- (first.config.index ?? 1000) - (second.config.index ?? 1000) || first.order - second.order);
-};
-
const syncMobilePluginDockElements = (
- app: App,
+ entries: readonly IMobilePluginDockEntry[],
sidePanelElements: Record<"left" | "right", HTMLElement>,
) => {
- const entries = getMobilePluginDockEntries(app);
const entryTypes = new Set(entries.map(item => item.type));
const tabElements = new Map<string, SVGElement>();
const contentElements = new Map<string, HTMLElement>();
@@ -109,7 +91,6 @@ const syncMobilePluginDockElements = (
}
});
- const dockIds: Record<"left" | "right", string[]> = {left: [], right: []};
entries.forEach((entry) => {
const side = getMobilePluginDockSide(entry.config.position);
const sidePanelElement = sidePanelElements[side];
@@ -138,15 +119,17 @@ const syncMobilePluginDockElements = (
contentElement.dataset.mobilePluginDockContent = entry.type;
}
contentContainerElement.append(contentElement);
- dockIds[side].push(entry.type);
});
- return dockIds;
};
export const renderMobileSidePanelLayout = (
app: App,
- config: IMobileSidePanelConfig = getMobileSidePanelConfig(),
+ config?: IMobileSidePanelConfig,
) => {
+ const pluginDockEntries = getMobilePluginDockEntries(app);
+ const pluginDockLayouts = getMobilePluginDockLayouts(pluginDockEntries);
+ const resolvedConfig = normalizeMobileSidePanelConfig(
+ config || getMobileSidePanelConfig(pluginDockLayouts), pluginDockLayouts);
getDockTabElement("agent").classList.toggle("fn__none",
window.siyuan.config.readonly || window.siyuan.isPublish || isDisabledFeature("ai"));
const sidePanelElements = {
@@ -158,26 +141,39 @@ export const renderMobileSidePanelLayout = (
right: getActiveDockId(sidePanelElements.right),
};
const previouslyActive = new Set(Object.values(previousActive));
+ syncMobilePluginDockElements(pluginDockEntries, sidePanelElements);
+ const availableDockIds = new Set([
+ ...MOBILE_SIDE_PANEL_DOCK_IDS,
+ ...pluginDockEntries.map(item => item.type),
+ ]);
+ const sideDockIds: Record<"left" | "right", string[]> = {left: [], right: []};
(["left", "right"] as const).forEach(side => {
const sidePanelElement = sidePanelElements[side];
const toolbarScrollElement = sidePanelElement.firstElementChild.firstElementChild;
const contentElement = sidePanelElement.lastElementChild;
- config[side].forEach(type => {
- toolbarScrollElement.append(getDockTabElement(type));
- contentElement.append(getDockContentElement(type));
+ resolvedConfig[side].forEach(type => {
+ if (!availableDockIds.has(type)) {
+ return;
+ }
+ const tabElement = getDockTabElement(type);
+ const dockContentElement = getDockContentElement(type);
+ if (!tabElement || !dockContentElement) {
+ return;
+ }
+ toolbarScrollElement.append(tabElement);
+ contentElement.append(dockContentElement);
+ sideDockIds[side].push(type);
});
});
- const pluginDockIds = syncMobilePluginDockElements(app, sidePanelElements);
(["left", "right"] as const).forEach(side => {
const sidePanelElement = sidePanelElements[side];
- const sideDockIds = [...config[side], ...pluginDockIds[side]];
-
- const visibleDockIds = sideDockIds.filter(type => !getDockTabElement(type).classList.contains("fn__none"));
+ const visibleDockIds = sideDockIds[side].filter(type =>
+ !getDockTabElement(type).classList.contains("fn__none"));
const activeDockId = previousActive[side] && visibleDockIds.includes(previousActive[side]) ? previousActive[side] :
visibleDockIds.find(type => previouslyActive.has(type)) || visibleDockIds[0];
- sideDockIds.forEach(type => {
+ sideDockIds[side].forEach(type => {
getDockTabElement(type).classList.toggle("toolbar__icon--active", type === activeDockId);
getDockContentElement(type).classList.toggle("fn__none", type !== activeDockId);
});
diff --git a/app/src/mobile/util/mobileSidePanelConfig.test.ts b/app/src/mobile/util/mobileSidePanelConfig.test.ts
index feb6a61a75..68ff1025c2 100644
--- a/app/src/mobile/util/mobileSidePanelConfig.test.ts
+++ b/app/src/mobile/util/mobileSidePanelConfig.test.ts
@@ -8,16 +8,25 @@ import {
MOBILE_SIDE_PANEL_DOCK_IDS,
normalizeMobileSidePanelConfig,
reduceMobileSidePanelConfig,
+ type IMobileSidePanelPluginDock,
} from "./mobileSidePanelConfig";
+const pluginDocks: IMobileSidePanelPluginDock[] = [
+ {id: "pluginLeft", side: "left", index: 20},
+ {id: "pluginRight", side: "right", index: 10},
+];
+const builtInDockIds = new Set<string>(MOBILE_SIDE_PANEL_DOCK_IDS);
+
const assertCompleteConfig = (config: ReturnType<typeof normalizeMobileSidePanelConfig>) => {
const dockIds = [...config.left, ...config.right];
assert.equal(config.version, MOBILE_SIDE_PANEL_CONFIG_VERSION);
assert.equal(config.left.length > 0, true);
assert.equal(config.right.length > 0, true);
- assert.equal(dockIds.length, MOBILE_SIDE_PANEL_DOCK_IDS.length);
- assert.equal(new Set(dockIds).size, MOBILE_SIDE_PANEL_DOCK_IDS.length);
- assert.deepEqual(new Set(dockIds), new Set(MOBILE_SIDE_PANEL_DOCK_IDS));
+ assert.equal(new Set(dockIds).size, dockIds.length);
+ MOBILE_SIDE_PANEL_DOCK_IDS.forEach(id => assert.equal(dockIds.includes(id), true));
+ assert.equal(dockIds.length, MOBILE_SIDE_PANEL_DOCK_IDS.length + config.pluginDockIds.length);
+ assert.deepEqual(new Set(config.pluginDockIds),
+ new Set(dockIds.filter(id => !builtInDockIds.has(id))));
};
describe("mobile side panel config", () => {
@@ -27,12 +36,13 @@ describe("mobile side panel config", () => {
false,
"not json",
[],
- {version: 3, left: ["file"], right: ["outline"]},
- {version: MOBILE_SIDE_PANEL_CONFIG_VERSION, left: "file", right: ["outline"]},
- {version: MOBILE_SIDE_PANEL_CONFIG_VERSION, left: ["file"], right: null},
+ {version: 4, left: ["file"], right: ["outline"], pluginDockIds: []},
+ {version: MOBILE_SIDE_PANEL_CONFIG_VERSION, left: "file", right: ["outline"], pluginDockIds: []},
+ {version: MOBILE_SIDE_PANEL_CONFIG_VERSION, left: ["file"], right: null, pluginDockIds: []},
+ {version: MOBILE_SIDE_PANEL_CONFIG_VERSION, left: ["file"], right: ["outline"]},
].forEach((storedValue) => {
- const config = normalizeMobileSidePanelConfig(storedValue);
- assert.deepEqual(config, createDefaultMobileSidePanelConfig());
+ const config = normalizeMobileSidePanelConfig(storedValue, pluginDocks);
+ assert.deepEqual(config, createDefaultMobileSidePanelConfig(pluginDocks));
assert.notEqual(config.left, DEFAULT_MOBILE_SIDE_PANEL_LEFT);
assert.notEqual(config.right, DEFAULT_MOBILE_SIDE_PANEL_RIGHT);
});
@@ -41,81 +51,134 @@ describe("mobile side panel config", () => {
it("accepts a serialized config and preserves the configured order", () => {
const config = normalizeMobileSidePanelConfig(JSON.stringify({
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
- left: ["file", "tag"],
- right: ["backlink", "outline", "bookmark", "inbox"],
- }));
-
- assert.deepEqual(config.left, ["file", "tag"]);
- assert.deepEqual(config.right, ["backlink", "outline", "bookmark", "inbox", "agent"]);
+ left: ["file", "pluginRight", "tag"],
+ right: ["backlink", "outline", "bookmark", "inbox", "pluginLeft"],
+ pluginDockIds: ["pluginLeft", "pluginRight"],
+ }), pluginDocks);
+
+ assert.deepEqual(config.left, ["file", "pluginRight", "tag"]);
+ assert.deepEqual(config.right, ["backlink", "outline", "bookmark", "inbox", "pluginLeft", "agent"]);
+ assert.deepEqual(config.pluginDockIds, ["pluginRight", "pluginLeft"]);
assertCompleteConfig(config);
});
- it("removes the combined plugin dock and adds the Agent when migrating version 1 layouts", () => {
- const config = normalizeMobileSidePanelConfig({
- version: 1,
- left: ["file", "bookmark", "tag", "inbox", "plugin"],
- right: ["backlink", "outline"],
+ it("migrates version 1 and 2 layouts and adds active plugins at their registered side", () => {
+ [1, 2].forEach((version) => {
+ const config = normalizeMobileSidePanelConfig({
+ version,
+ left: ["file", "bookmark", "tag", "inbox", "plugin"],
+ right: ["backlink", "outline"],
+ }, pluginDocks);
+
+ assert.deepEqual(config.left, ["file", "bookmark", "tag", "inbox", "pluginLeft"]);
+ assert.deepEqual(config.right, ["backlink", "outline", "agent", "pluginRight"]);
+ assert.deepEqual(config.pluginDockIds, ["pluginLeft", "pluginRight"]);
+ assertCompleteConfig(config);
});
+ });
- assert.deepEqual(config.left, ["file", "bookmark", "tag", "inbox"]);
- assert.deepEqual(config.right, ["backlink", "outline", "agent"]);
+ it("orders new plugins by their registered index after built-in docks", () => {
+ const config = createDefaultMobileSidePanelConfig([
+ {id: "leftLast", side: "left", index: 30},
+ {id: "leftFirst", side: "left", index: 10},
+ {id: "right", side: "right", index: 20},
+ ]);
+
+ assert.deepEqual(config.left, [...DEFAULT_MOBILE_SIDE_PANEL_LEFT, "leftFirst", "leftLast"]);
+ assert.deepEqual(config.right, [...DEFAULT_MOBILE_SIDE_PANEL_RIGHT, "right"]);
+ assert.deepEqual(config.pluginDockIds, ["leftFirst", "leftLast", "right"]);
assertCompleteConfig(config);
});
- it("drops unknown and duplicate IDs and fills missing IDs on their default side", () => {
+ it("inserts a newly registered plugin relative to existing plugin positions", () => {
const config = normalizeMobileSidePanelConfig({
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
- left: ["tag", "unknown", "tag", "outline"],
- right: ["outline", "file", "unknown"],
- });
-
- assert.deepEqual(config.left, ["tag", "outline", "bookmark", "inbox"]);
- assert.deepEqual(config.right, ["file", "backlink", "agent"]);
+ left: ["file", "pluginLater", "bookmark", "tag", "inbox"],
+ right: ["outline", "backlink", "agent"],
+ pluginDockIds: ["pluginLater"],
+ }, [
+ {id: "pluginEarlier", side: "left", index: 10},
+ {id: "pluginLater", side: "left", index: 20},
+ ]);
+
+ assert.deepEqual(config.left, ["file", "pluginEarlier", "pluginLater", "bookmark", "tag", "inbox"]);
+ assert.deepEqual(config.pluginDockIds, ["pluginEarlier", "pluginLater"]);
assertCompleteConfig(config);
});
- it("repairs an empty left side with its default anchor", () => {
- const config = normalizeMobileSidePanelConfig({
+ it("preserves missing plugin positions and restores them when the plugin returns", () => {
+ const stored = {
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
- left: [],
- right: [...MOBILE_SIDE_PANEL_DOCK_IDS],
- });
+ left: ["file", "missingPlugin", "bookmark", "tag", "inbox"],
+ right: ["outline", "backlink", "agent"],
+ pluginDockIds: ["missingPlugin"],
+ };
+ const missing = normalizeMobileSidePanelConfig(stored);
+ const restored = normalizeMobileSidePanelConfig(stored, [
+ {id: "missingPlugin", side: "right"},
+ ]);
+
+ assert.deepEqual(missing.left, stored.left);
+ assert.deepEqual(missing.pluginDockIds, ["missingPlugin"]);
+ assert.deepEqual(restored.left, stored.left);
+ assert.deepEqual(restored.pluginDockIds, ["missingPlugin"]);
+ assertCompleteConfig(missing);
+ assertCompleteConfig(restored);
+ });
- assert.deepEqual(config.left, ["file"]);
- assert.deepEqual(config.right, ["outline", "bookmark", "tag", "backlink", "inbox", "agent"]);
+ it("drops unknown and duplicate IDs but retains registered plugin IDs", () => {
+ const config = normalizeMobileSidePanelConfig({
+ version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
+ left: ["tag", "unknown", "tag", "outline", "pluginLeft"],
+ right: ["outline", "file", "unknown", "pluginLeft"],
+ pluginDockIds: ["pluginLeft", "pluginLeft", ""],
+ }, pluginDocks);
+
+ assert.deepEqual(config.left, ["tag", "outline", "pluginLeft", "bookmark", "inbox"]);
+ assert.deepEqual(config.right, ["file", "backlink", "agent", "pluginRight"]);
+ assert.deepEqual(config.pluginDockIds, ["pluginLeft", "pluginRight"]);
assertCompleteConfig(config);
});
- it("repairs an empty right side with its default anchor", () => {
- const config = normalizeMobileSidePanelConfig({
+ it("repairs an empty side with its default anchor", () => {
+ const emptyLeft = normalizeMobileSidePanelConfig({
+ version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
+ left: [],
+ right: [...MOBILE_SIDE_PANEL_DOCK_IDS],
+ pluginDockIds: [],
+ });
+ const emptyRight = normalizeMobileSidePanelConfig({
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
left: [...MOBILE_SIDE_PANEL_DOCK_IDS],
right: [],
+ pluginDockIds: [],
});
- assert.deepEqual(config.left, ["file", "bookmark", "tag", "backlink", "inbox", "agent"]);
- assert.deepEqual(config.right, ["outline"]);
- assertCompleteConfig(config);
+ assert.deepEqual(emptyLeft.left, ["file"]);
+ assert.deepEqual(emptyRight.right, ["outline"]);
+ assertCompleteConfig(emptyLeft);
+ assertCompleteConfig(emptyRight);
});
- it("moves a dock between sides at a requested position", () => {
- const config = reduceMobileSidePanelConfig(createDefaultMobileSidePanelConfig(), {
+ it("moves a plugin between sides at a requested visible position", () => {
+ const config = reduceMobileSidePanelConfig(createDefaultMobileSidePanelConfig(pluginDocks), {
type: "move",
- id: "bookmark",
+ id: "pluginLeft",
side: "right",
index: 1,
- });
+ }, pluginDocks);
- assert.deepEqual(config.left, ["file", "tag", "inbox"]);
- assert.deepEqual(config.right, ["outline", "bookmark", "backlink", "agent"]);
+ assert.deepEqual(config.left, DEFAULT_MOBILE_SIDE_PANEL_LEFT);
+ assert.deepEqual(config.right, ["outline", "pluginLeft", "backlink", "agent", "pluginRight"]);
assertCompleteConfig(config);
});
- it("does not move the last dock away from a side", () => {
+ it("does not move the last visible dock away from a side", () => {
const state = normalizeMobileSidePanelConfig({
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
- left: ["file"],
+ left: ["file", "missingPlugin"],
right: ["outline", "bookmark", "tag", "backlink", "inbox", "agent"],
+ pluginDockIds: ["missingPlugin"],
});
const config = reduceMobileSidePanelConfig(state, {
type: "move",
@@ -127,43 +190,48 @@ describe("mobile side panel config", () => {
assertCompleteConfig(config);
});
- it("reorders docks within a side", () => {
- const config = reduceMobileSidePanelConfig(createDefaultMobileSidePanelConfig(), {
+ it("reorders visible docks across a missing plugin slot", () => {
+ const state = normalizeMobileSidePanelConfig({
+ version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
+ left: ["file", "missingPlugin", "bookmark", "tag", "inbox"],
+ right: ["outline", "backlink", "agent"],
+ pluginDockIds: ["missingPlugin"],
+ });
+ const config = reduceMobileSidePanelConfig(state, {
type: "reorder",
side: "left",
- fromIndex: 3,
- toIndex: 1,
+ fromIndex: 1,
+ toIndex: 0,
});
- assert.deepEqual(config.left, ["file", "inbox", "bookmark", "tag"]);
- assert.deepEqual(config.right, DEFAULT_MOBILE_SIDE_PANEL_RIGHT);
+ assert.deepEqual(config.left, ["bookmark", "missingPlugin", "file", "tag", "inbox"]);
assertCompleteConfig(config);
});
it("ignores invalid reorder indices", () => {
- const state = createDefaultMobileSidePanelConfig();
+ const state = createDefaultMobileSidePanelConfig(pluginDocks);
const config = reduceMobileSidePanelConfig(state, {
type: "reorder",
side: "left",
fromIndex: -1,
toIndex: 2,
- });
+ }, pluginDocks);
assert.deepEqual(config, state);
assert.notEqual(config, state);
});
- it("resets customized panels to a fresh default config", () => {
+ it("resets active plugins to registered positions and removes missing plugins", () => {
const customized = normalizeMobileSidePanelConfig({
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
- left: ["file", "outline"],
- right: ["backlink", "bookmark", "tag", "inbox"],
- });
- const config = reduceMobileSidePanelConfig(customized, {type: "reset"});
-
- assert.deepEqual(config.left, DEFAULT_MOBILE_SIDE_PANEL_LEFT);
- assert.deepEqual(config.right, DEFAULT_MOBILE_SIDE_PANEL_RIGHT);
- assert.notEqual(config.left, DEFAULT_MOBILE_SIDE_PANEL_LEFT);
- assert.notEqual(config.right, DEFAULT_MOBILE_SIDE_PANEL_RIGHT);
+ left: ["file", "outline", "missingPlugin", "pluginRight"],
+ right: ["backlink", "bookmark", "tag", "inbox", "agent", "pluginLeft"],
+ pluginDockIds: ["missingPlugin", "pluginLeft", "pluginRight"],
+ }, pluginDocks);
+ const config = reduceMobileSidePanelConfig(customized, {type: "reset"}, pluginDocks);
+
+ assert.deepEqual(config, createDefaultMobileSidePanelConfig(pluginDocks));
+ assert.equal(config.pluginDockIds.includes("missingPlugin"), false);
+ assertCompleteConfig(config);
});
});
diff --git a/app/src/mobile/util/mobileSidePanelConfig.ts b/app/src/mobile/util/mobileSidePanelConfig.ts
index 1d89c49731..93e8c0a371 100644
--- a/app/src/mobile/util/mobileSidePanelConfig.ts
+++ b/app/src/mobile/util/mobileSidePanelConfig.ts
@@ -1,4 +1,4 @@
-export const MOBILE_SIDE_PANEL_CONFIG_VERSION = 2 as const;
+export const MOBILE_SIDE_PANEL_CONFIG_VERSION = 3 as const;
export const MOBILE_SIDE_PANEL_CONFIG_CHANGE_EVENT = "siyuan-mobile-side-panel-config-change";
export const MOBILE_SIDE_PANEL_DOCK_IDS = [
@@ -11,13 +11,21 @@ export const MOBILE_SIDE_PANEL_DOCK_IDS = [
"agent",
] as const;
-export type MobileSidePanelDockId = typeof MOBILE_SIDE_PANEL_DOCK_IDS[number];
+export type MobileSidePanelBuiltInDockId = typeof MOBILE_SIDE_PANEL_DOCK_IDS[number];
+export type MobileSidePanelDockId = string;
export type MobileSidePanelSide = "left" | "right";
+export interface IMobileSidePanelPluginDock {
+ id: string,
+ side: MobileSidePanelSide,
+ index?: number,
+}
+
export interface IMobileSidePanelConfig {
version: typeof MOBILE_SIDE_PANEL_CONFIG_VERSION,
left: MobileSidePanelDockId[],
right: MobileSidePanelDockId[],
+ pluginDockIds: string[],
}
export type MobileSidePanelConfigEvent = {
@@ -34,14 +42,14 @@ export type MobileSidePanelConfigEvent = {
type: "reset",
};
-export const DEFAULT_MOBILE_SIDE_PANEL_LEFT: readonly MobileSidePanelDockId[] = [
+export const DEFAULT_MOBILE_SIDE_PANEL_LEFT: readonly MobileSidePanelBuiltInDockId[] = [
"file",
"bookmark",
"tag",
"inbox",
];
-export const DEFAULT_MOBILE_SIDE_PANEL_RIGHT: readonly MobileSidePanelDockId[] = [
+export const DEFAULT_MOBILE_SIDE_PANEL_RIGHT: readonly MobileSidePanelBuiltInDockId[] = [
"outline",
"backlink",
"agent",
@@ -51,27 +59,55 @@ export const DEFAULT_MOBILE_SIDE_PANEL_CONFIG: Readonly<IMobileSidePanelConfig>
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
left: [...DEFAULT_MOBILE_SIDE_PANEL_LEFT],
right: [...DEFAULT_MOBILE_SIDE_PANEL_RIGHT],
+ pluginDockIds: [],
};
const mobileSidePanelDockIdSet = new Set<string>(MOBILE_SIDE_PANEL_DOCK_IDS);
-export const isMobileSidePanelDockId = (value: unknown): value is MobileSidePanelDockId => {
+export const isMobileSidePanelBuiltInDockId = (value: unknown): value is MobileSidePanelBuiltInDockId => {
return typeof value === "string" && mobileSidePanelDockIdSet.has(value);
};
-export const createDefaultMobileSidePanelConfig = (): IMobileSidePanelConfig => ({
- version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
- left: [...DEFAULT_MOBILE_SIDE_PANEL_LEFT],
- right: [...DEFAULT_MOBILE_SIDE_PANEL_RIGHT],
-});
+const normalizePluginDocks = (pluginDocks: readonly IMobileSidePanelPluginDock[]) => {
+ const used = new Set<string>();
+ return pluginDocks
+ .map((dock, order) => ({...dock, order}))
+ .filter((dock) => {
+ if (!dock.id || isMobileSidePanelBuiltInDockId(dock.id) || used.has(dock.id)) {
+ return false;
+ }
+ used.add(dock.id);
+ return true;
+ })
+ .sort((first, second) =>
+ (first.index ?? 1000) - (second.index ?? 1000) || first.order - second.order);
+};
+
+export const createDefaultMobileSidePanelConfig = (
+ pluginDocks: readonly IMobileSidePanelPluginDock[] = [],
+): IMobileSidePanelConfig => {
+ const config: IMobileSidePanelConfig = {
+ version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
+ left: [...DEFAULT_MOBILE_SIDE_PANEL_LEFT],
+ right: [...DEFAULT_MOBILE_SIDE_PANEL_RIGHT],
+ pluginDockIds: [],
+ };
+ normalizePluginDocks(pluginDocks).forEach((dock) => {
+ config[dock.side].push(dock.id);
+ });
+ config.pluginDockIds = [...config.left, ...config.right].filter(id => !isMobileSidePanelBuiltInDockId(id));
+ return config;
+};
const addValidDockIds = (
target: MobileSidePanelDockId[],
values: unknown[],
+ validPluginDockIds: Set<string>,
used: Set<MobileSidePanelDockId>,
) => {
values.forEach((value) => {
- if (isMobileSidePanelDockId(value) && !used.has(value)) {
+ if (typeof value === "string" &&
+ (isMobileSidePanelBuiltInDockId(value) || validPluginDockIds.has(value)) && !used.has(value)) {
target.push(value);
used.add(value);
}
@@ -92,33 +128,49 @@ const moveDefaultDockToEmptySide = (
config[side].push(dockId);
};
-export const normalizeMobileSidePanelConfig = (storedValue: unknown): IMobileSidePanelConfig => {
+export const normalizeMobileSidePanelConfig = (
+ storedValue: unknown,
+ pluginDocks: readonly IMobileSidePanelPluginDock[] = [],
+): IMobileSidePanelConfig => {
let value = storedValue;
if (typeof value === "string") {
try {
value = JSON.parse(value);
} catch {
- return createDefaultMobileSidePanelConfig();
+ return createDefaultMobileSidePanelConfig(pluginDocks);
}
}
if (!value || typeof value !== "object" || Array.isArray(value)) {
- return createDefaultMobileSidePanelConfig();
+ return createDefaultMobileSidePanelConfig(pluginDocks);
}
const record = value as Record<string, unknown>;
- if ((record.version !== 1 && record.version !== MOBILE_SIDE_PANEL_CONFIG_VERSION) ||
- !Array.isArray(record.left) || !Array.isArray(record.right)) {
- return createDefaultMobileSidePanelConfig();
+ if ((record.version !== 1 && record.version !== 2 && record.version !== MOBILE_SIDE_PANEL_CONFIG_VERSION) ||
+ !Array.isArray(record.left) || !Array.isArray(record.right) ||
+ (record.version === MOBILE_SIDE_PANEL_CONFIG_VERSION && !Array.isArray(record.pluginDockIds))) {
+ return createDefaultMobileSidePanelConfig(pluginDocks);
}
+ const activePluginDocks = normalizePluginDocks(pluginDocks);
+ const activePluginDockIds = new Set(activePluginDocks.map(item => item.id));
+ const rememberedPluginDockIds = new Set<string>();
+ if (record.version === MOBILE_SIDE_PANEL_CONFIG_VERSION) {
+ (record.pluginDockIds as unknown[]).forEach((value) => {
+ if (typeof value === "string" && value && !isMobileSidePanelBuiltInDockId(value)) {
+ rememberedPluginDockIds.add(value);
+ }
+ });
+ }
+ const validPluginDockIds = new Set([...rememberedPluginDockIds, ...activePluginDockIds]);
const config: IMobileSidePanelConfig = {
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
left: [],
right: [],
+ pluginDockIds: [],
};
const used = new Set<MobileSidePanelDockId>();
- addValidDockIds(config.left, record.left, used);
- addValidDockIds(config.right, record.right, used);
+ addValidDockIds(config.left, record.left, validPluginDockIds, used);
+ addValidDockIds(config.right, record.right, validPluginDockIds, used);
DEFAULT_MOBILE_SIDE_PANEL_LEFT.forEach((id) => {
if (!used.has(id)) {
config.left.push(id);
@@ -131,6 +183,24 @@ export const normalizeMobileSidePanelConfig = (storedValue: unknown): IMobileSid
used.add(id);
}
});
+ activePluginDocks.forEach((dock, index) => {
+ if (!used.has(dock.id)) {
+ const sideDockIds = config[dock.side];
+ const nextDock = activePluginDocks.slice(index + 1)
+ .find(item => item.side === dock.side && sideDockIds.includes(item.id));
+ const previousDock = activePluginDocks.slice(0, index).reverse()
+ .find(item => item.side === dock.side && sideDockIds.includes(item.id));
+ if (nextDock) {
+ sideDockIds.splice(sideDockIds.indexOf(nextDock.id), 0, dock.id);
+ } else if (previousDock) {
+ sideDockIds.splice(sideDockIds.indexOf(previousDock.id) + 1, 0, dock.id);
+ } else {
+ sideDockIds.push(dock.id);
+ }
+ used.add(dock.id);
+ }
+ });
+ config.pluginDockIds = [...config.left, ...config.right].filter((id) => validPluginDockIds.has(id));
moveDefaultDockToEmptySide(config, "left");
moveDefaultDockToEmptySide(config, "right");
return config;
@@ -143,42 +213,59 @@ const clampIndex = (index: number | undefined, length: number) => {
return Math.max(0, Math.min(index, length));
};
+const getAvailableDockIds = (pluginDocks: readonly IMobileSidePanelPluginDock[]) => {
+ return new Set<string>([
+ ...MOBILE_SIDE_PANEL_DOCK_IDS,
+ ...normalizePluginDocks(pluginDocks).map(item => item.id),
+ ]);
+};
+
export const reduceMobileSidePanelConfig = (
state: IMobileSidePanelConfig,
event: MobileSidePanelConfigEvent,
+ pluginDocks: readonly IMobileSidePanelPluginDock[] = [],
): IMobileSidePanelConfig => {
if (event.type === "reset") {
- return createDefaultMobileSidePanelConfig();
+ return createDefaultMobileSidePanelConfig(pluginDocks);
}
- const currentState = normalizeMobileSidePanelConfig(state);
+ const currentState = normalizeMobileSidePanelConfig(state, pluginDocks);
const config: IMobileSidePanelConfig = {
version: MOBILE_SIDE_PANEL_CONFIG_VERSION,
left: [...currentState.left],
right: [...currentState.right],
+ pluginDockIds: [...currentState.pluginDockIds],
};
+ const availableDockIds = getAvailableDockIds(pluginDocks);
if (event.type === "reorder") {
const docks = config[event.side];
+ const visibleDocks = docks.filter(id => availableDockIds.has(id));
if (!Number.isInteger(event.fromIndex) || !Number.isInteger(event.toIndex) ||
- event.fromIndex < 0 || event.fromIndex >= docks.length ||
- event.toIndex < 0 || event.toIndex >= docks.length || event.fromIndex === event.toIndex) {
+ event.fromIndex < 0 || event.fromIndex >= visibleDocks.length ||
+ event.toIndex < 0 || event.toIndex >= visibleDocks.length || event.fromIndex === event.toIndex) {
return currentState;
}
- const [dockId] = docks.splice(event.fromIndex, 1);
- docks.splice(event.toIndex, 0, dockId);
+ const sourceIndex = docks.indexOf(visibleDocks[event.fromIndex]);
+ const targetIndex = docks.indexOf(visibleDocks[event.toIndex]);
+ [docks[sourceIndex], docks[targetIndex]] = [docks[targetIndex], docks[sourceIndex]];
return config;
}
- if (!isMobileSidePanelDockId(event.id)) {
+ const sourceSide = config.left.includes(event.id) ? "left" : config.right.includes(event.id) ? "right" : undefined;
+ if (!sourceSide || !availableDockIds.has(event.id)) {
return currentState;
}
- const sourceSide: MobileSidePanelSide = config.left.includes(event.id) ? "left" : "right";
const source = config[sourceSide];
const target = config[event.side];
- if (sourceSide !== event.side && source.length === 1) {
+ const visibleSource = source.filter(id => availableDockIds.has(id));
+ if (sourceSide !== event.side && visibleSource.length === 1) {
return currentState;
}
source.splice(source.indexOf(event.id), 1);
- target.splice(clampIndex(event.index, target.length), 0, event.id);
+ const visibleTarget = target.filter(id => availableDockIds.has(id));
+ const visibleTargetIndex = clampIndex(event.index, visibleTarget.length);
+ const targetIndex = visibleTargetIndex === visibleTarget.length ? target.length :
+ target.indexOf(visibleTarget[visibleTargetIndex]);
+ target.splice(targetIndex, 0, event.id);
return config;
};
diff --git a/app/src/mobile/util/mobileSidePanelSetting.ts b/app/src/mobile/util/mobileSidePanelSetting.ts
index ee416fb47f..14905113de 100644
--- a/app/src/mobile/util/mobileSidePanelSetting.ts
+++ b/app/src/mobile/util/mobileSidePanelSetting.ts
@@ -2,15 +2,26 @@ import {Constants} from "../../constants";
import {setStorageVal} from "../../protyle/util/compatibility";
import {escapeAttr, escapeHtml} from "../../util/escape";
import {
+ getMobilePluginDockEntries,
+ getMobilePluginDockLayouts,
+ MOBILE_PLUGIN_DOCKS_CHANGE_EVENT,
+ type IMobilePluginDockEntry,
+} from "../dock/pluginDockState";
+import {
+ isMobileSidePanelBuiltInDockId,
MOBILE_SIDE_PANEL_CONFIG_CHANGE_EVENT,
normalizeMobileSidePanelConfig,
reduceMobileSidePanelConfig,
type IMobileSidePanelConfig,
+ type IMobileSidePanelPluginDock,
+ type MobileSidePanelBuiltInDockId,
type MobileSidePanelDockId,
type MobileSidePanelSide,
} from "./mobileSidePanelConfig";
-const getDockLabel = (dockId: MobileSidePanelDockId) => {
+let pluginDocksChangeHandler: (() => void) | undefined;
+
+const getBuiltInDockLabel = (dockId: MobileSidePanelBuiltInDockId) => {
switch (dockId) {
case "file":
return window.siyuan.languages.fileTree;
@@ -29,7 +40,7 @@ const getDockLabel = (dockId: MobileSidePanelDockId) => {
}
};
-const getDockIcon = (dockId: MobileSidePanelDockId) => {
+const getBuiltInDockIcon = (dockId: MobileSidePanelBuiltInDockId) => {
switch (dockId) {
case "file":
return "iconFiles";
@@ -48,53 +59,91 @@ const getDockIcon = (dockId: MobileSidePanelDockId) => {
}
};
-export const getMobileSidePanelConfig = (): IMobileSidePanelConfig => {
- return normalizeMobileSidePanelConfig(window.siyuan.storage[Constants.LOCAL_MOBILE_SIDE_PANEL]);
+const getPluginDockContext = () => {
+ const entries = getMobilePluginDockEntries();
+ return {
+ entriesById: new Map(entries.map(entry => [entry.type, entry])),
+ layouts: getMobilePluginDockLayouts(entries),
+ };
+};
+
+export const getMobileSidePanelConfig = (
+ pluginDocks: readonly IMobileSidePanelPluginDock[] = getMobilePluginDockLayouts(),
+): IMobileSidePanelConfig => {
+ return normalizeMobileSidePanelConfig(
+ window.siyuan.storage[Constants.LOCAL_MOBILE_SIDE_PANEL], pluginDocks);
};
export const dispatchMobileSidePanelConfigChange = () => {
window.dispatchEvent(new CustomEvent(MOBILE_SIDE_PANEL_CONFIG_CHANGE_EVENT));
};
-export const saveMobileSidePanelConfig = (value: unknown): IMobileSidePanelConfig => {
- const config = normalizeMobileSidePanelConfig(value);
+export const saveMobileSidePanelConfig = (
+ value: unknown,
+ pluginDocks: readonly IMobileSidePanelPluginDock[] = getMobilePluginDockLayouts(),
+): IMobileSidePanelConfig => {
+ const config = normalizeMobileSidePanelConfig(value, pluginDocks);
window.siyuan.storage[Constants.LOCAL_MOBILE_SIDE_PANEL] = config;
setStorageVal(Constants.LOCAL_MOBILE_SIDE_PANEL, config);
dispatchMobileSidePanelConfigChange();
return config;
};
+const getVisibleDockIds = (
+ config: IMobileSidePanelConfig,
+ side: MobileSidePanelSide,
+ pluginEntriesById: ReadonlyMap<string, IMobilePluginDockEntry>,
+) => config[side].filter(id => isMobileSidePanelBuiltInDockId(id) || pluginEntriesById.has(id));
+
const genDockItemHtml = (
dockId: MobileSidePanelDockId,
side: MobileSidePanelSide,
index: number,
length: number,
+ pluginEntriesById: ReadonlyMap<string, IMobilePluginDockEntry>,
) => {
+ const pluginEntry = pluginEntriesById.get(dockId);
+ const label = isMobileSidePanelBuiltInDockId(dockId) ? getBuiltInDockLabel(dockId) : pluginEntry?.config.title;
+ const icon = isMobileSidePanelBuiltInDockId(dockId) ? getBuiltInDockIcon(dockId) : pluginEntry?.config.icon;
+ if (!label || !icon) {
+ return "";
+ }
const moveLabel = side === "left" ? window.siyuan.languages.moveToRight : window.siyuan.languages.moveToLeft;
const moveIcon = side === "left" ? "iconRight" : "iconLeft";
const disabled = window.siyuan.config.readonly || window.siyuan.isPublish;
- return `<div class="b3-list-item" data-dock-id="${dockId}">
- <svg class="b3-list-item__graphic"><use xlink:href="#${getDockIcon(dockId)}"></use></svg>
- <span class="b3-list-item__text">${escapeHtml(getDockLabel(dockId))}</span>
+ return `<div class="b3-list-item" data-dock-id="${escapeAttr(dockId)}">
+ <svg class="b3-list-item__graphic"><use xlink:href="#${escapeAttr(icon)}"></use></svg>
+ <span class="b3-list-item__text">${escapeHtml(label)}</span>
<button class="block__icon block__icon--show ariaLabel" data-action="up" data-position="north" aria-label="${escapeAttr(window.siyuan.languages.up)}" type="button"${disabled || index === 0 ? " disabled" : ""}><svg><use xlink:href="#iconUp"></use></svg></button>
<button class="block__icon block__icon--show ariaLabel" data-action="down" data-position="north" aria-label="${escapeAttr(window.siyuan.languages.down)}" type="button"${disabled || index === length - 1 ? " disabled" : ""}><svg><use xlink:href="#iconDown"></use></svg></button>
<button class="block__icon block__icon--show ariaLabel" data-action="move" data-position="north" aria-label="${escapeAttr(moveLabel)}" type="button"${disabled || length === 1 ? " disabled" : ""}><svg><use xlink:href="#${moveIcon}"></use></svg></button>
</div>`;
};
-const genSideHtml = (config: IMobileSidePanelConfig, side: MobileSidePanelSide) => {
+const genSideHtml = (
+ config: IMobileSidePanelConfig,
+ side: MobileSidePanelSide,
+ pluginEntriesById: ReadonlyMap<string, IMobilePluginDockEntry>,
+) => {
const label = side === "left" ? window.siyuan.languages.marginLeft : window.siyuan.languages.marginRight;
+ const dockIds = getVisibleDockIds(config, side, pluginEntriesById);
return `<div class="b3-label__text">${escapeHtml(label)}</div>
-<div class="b3-list b3-list--background" data-side="${side}">${config[side].map((dockId, index) =>
- genDockItemHtml(dockId, side, index, config[side].length)).join("")}</div>`;
+<div class="b3-list b3-list--background" data-side="${side}">${dockIds.map((dockId, index) =>
+ genDockItemHtml(dockId, side, index, dockIds.length, pluginEntriesById)).join("")}</div>`;
};
-const genMobileSidePanelListsHtml = (config: IMobileSidePanelConfig) => {
- return `${genSideHtml(config, "left")}<div class="fn__hr"></div>${genSideHtml(config, "right")}`;
+const genMobileSidePanelListsHtml = (
+ config: IMobileSidePanelConfig,
+ pluginEntriesById: ReadonlyMap<string, IMobilePluginDockEntry>,
+) => {
+ return `${genSideHtml(config, "left", pluginEntriesById)}<div class="fn__hr"></div>${
+ genSideHtml(config, "right", pluginEntriesById)}`;
};
export const genMobileSidePanelSettingHTML = () => {
const disabled = window.siyuan.config.readonly || window.siyuan.isPublish ? " disabled" : "";
+ const pluginDockContext = getPluginDockContext();
+ const config = getMobileSidePanelConfig(pluginDockContext.layouts);
return `<div id="mobileSidePanelSetting" class="b3-label config-item">
<div class="fn__flex">
<div class="fn__flex-1 config-item__main"><div class="config-name">${escapeHtml(window.siyuan.languages.leftRightLayout)}</div></div>
@@ -103,7 +152,7 @@ export const genMobileSidePanelSettingHTML = () => {
</button>
</div>
<div class="fn__hr"></div>
- <div data-type="side-panel-lists">${genMobileSidePanelListsHtml(getMobileSidePanelConfig())}</div>
+ <div data-type="side-panel-lists">${genMobileSidePanelListsHtml(config, pluginDockContext.entriesById)}</div>
</div>`;
};
@@ -113,26 +162,31 @@ export const mountMobileSidePanelSetting = (root: HTMLElement) => {
if (!settingElement || !listsElement) {
return;
}
- let config = getMobileSidePanelConfig();
+ let pluginDockContext = getPluginDockContext();
+ let config = getMobileSidePanelConfig(pluginDockContext.layouts);
const render = () => {
- listsElement.innerHTML = genMobileSidePanelListsHtml(config);
+ listsElement.innerHTML = genMobileSidePanelListsHtml(config, pluginDockContext.entriesById);
};
+ render();
settingElement.addEventListener("click", (event) => {
const actionElement = (event.target as HTMLElement).closest<HTMLButtonElement>("[data-action]");
if (!actionElement || actionElement.disabled) {
return;
}
if (actionElement.dataset.action === "reset") {
- config = saveMobileSidePanelConfig(reduceMobileSidePanelConfig(config, {type: "reset"}));
+ config = saveMobileSidePanelConfig(
+ reduceMobileSidePanelConfig(config, {type: "reset"}, pluginDockContext.layouts),
+ pluginDockContext.layouts);
render();
return;
}
const itemElement = actionElement.closest<HTMLElement>("[data-dock-id]");
const sideElement = actionElement.closest<HTMLElement>("[data-side]");
- const dockId = itemElement?.dataset.dockId as MobileSidePanelDockId;
+ const dockId = itemElement?.dataset.dockId;
const side = sideElement?.dataset.side as MobileSidePanelSide;
- const index = config[side]?.indexOf(dockId);
- if (index === undefined || index < 0) {
+ const visibleDockIds = config[side] ? getVisibleDockIds(config, side, pluginDockContext.entriesById) : [];
+ const index = dockId ? visibleDockIds.indexOf(dockId) : -1;
+ if (!dockId || index < 0) {
return;
}
if (actionElement.dataset.action === "move") {
@@ -140,18 +194,35 @@ export const mountMobileSidePanelSetting = (root: HTMLElement) => {
type: "move",
id: dockId,
side: side === "left" ? "right" : "left",
- });
+ }, pluginDockContext.layouts);
} else if (actionElement.dataset.action === "up" || actionElement.dataset.action === "down") {
config = reduceMobileSidePanelConfig(config, {
type: "reorder",
side,
fromIndex: index,
toIndex: index + (actionElement.dataset.action === "up" ? -1 : 1),
- });
+ }, pluginDockContext.layouts);
} else {
return;
}
- config = saveMobileSidePanelConfig(config);
+ config = saveMobileSidePanelConfig(config, pluginDockContext.layouts);
render();
});
+ const onPluginDocksChange = () => {
+ if (!settingElement.isConnected) {
+ window.removeEventListener(MOBILE_PLUGIN_DOCKS_CHANGE_EVENT, onPluginDocksChange);
+ if (pluginDocksChangeHandler === onPluginDocksChange) {
+ pluginDocksChangeHandler = undefined;
+ }
+ return;
+ }
+ pluginDockContext = getPluginDockContext();
+ config = getMobileSidePanelConfig(pluginDockContext.layouts);
+ render();
+ };
+ if (pluginDocksChangeHandler) {
+ window.removeEventListener(MOBILE_PLUGIN_DOCKS_CHANGE_EVENT, pluginDocksChangeHandler);
+ }
+ pluginDocksChangeHandler = onPluginDocksChange;
+ window.addEventListener(MOBILE_PLUGIN_DOCKS_CHANGE_EVENT, onPluginDocksChange);
};