From 741c1ef49d0b37e3575563f7232d0f2933749afc Mon Sep 17 00:00:00 2001 From: slavamuravey Date: Mon, 5 Aug 2024 14:59:30 +0700 Subject: [PATCH] Pass panelLock on serialization --- es/DockData.d.ts | 12 ++++++------ es/Serializer.js | 12 ++++++------ lib/DockData.d.ts | 12 ++++++------ lib/Serializer.js | 12 ++++++------ src/DockData.ts | 15 +++++++-------- src/Serializer.ts | 12 ++++++------ 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/es/DockData.d.ts b/es/DockData.d.ts index 89b1506d..b00bdf92 100644 --- a/es/DockData.d.ts +++ b/es/DockData.d.ts @@ -119,6 +119,12 @@ export interface PanelBase { w?: number; /** float mode only */ h?: number; + /** + * addition information of a panel, + * This prevents the panel from being removed when there is no tab inside + * a locked panel can not be moved to float layer either + */ + panelLock?: PanelLock; } export interface BoxBase { /** @@ -204,12 +210,6 @@ interface PanelLock { export interface PanelData extends PanelBase, BoxChild { parent?: BoxData; tabs: TabData[]; - /** - * addition information of a panel, - * This prevents the panel from being removed when there is no tab inside - * a locked panel can not be moved to float layer either - */ - panelLock?: PanelLock; } export interface TabPaneCache { id: string; diff --git a/es/Serializer.js b/es/Serializer.js index a7ba8da6..faa54791 100644 --- a/es/Serializer.js +++ b/es/Serializer.js @@ -49,14 +49,14 @@ export function saveLayoutData(layout, saveTab, afterPanelSaved) { tabs.push(savedTab); } } - let { id, size, activeId, group } = panelData; + let { id, size, activeId, group, panelLock } = panelData; let savedPanel; if (panelData.parent.mode === 'float' || panelData.parent.mode === 'window') { let { x, y, z, w, h } = panelData; - savedPanel = { id, size, tabs, group, activeId, x, y, z, w, h }; + savedPanel = { id, size, tabs, group, activeId, panelLock, x, y, z, w, h }; } else { - savedPanel = { id, size, tabs, group, activeId }; + savedPanel = { id, size, tabs, group, activeId, panelLock }; } if (afterPanelSaved) { afterPanelSaved(savedPanel, panelData); @@ -97,7 +97,7 @@ export function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLo return null; } function loadPanelData(savedPanel) { - let { id, size, activeId, x, y, z, w, h, group } = savedPanel; + let { id, size, activeId, x, y, z, w, h, group, panelLock } = savedPanel; let tabs = []; for (let savedTab of savedPanel.tabs) { let tabData = loadTabData(savedTab); @@ -107,10 +107,10 @@ export function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLo } let panelData; if (w || h || x || y || z) { - panelData = { id, size, activeId, group, x, y, z, w, h, tabs }; + panelData = { id, size, activeId, group, x, y, z, w, h, tabs, panelLock }; } else { - panelData = { id, size, activeId, group, tabs }; + panelData = { id, size, activeId, group, tabs, panelLock }; } if (savedPanel.id === maximePlaceHolderId) { panelData.panelLock = {}; diff --git a/lib/DockData.d.ts b/lib/DockData.d.ts index 89b1506d..b00bdf92 100644 --- a/lib/DockData.d.ts +++ b/lib/DockData.d.ts @@ -119,6 +119,12 @@ export interface PanelBase { w?: number; /** float mode only */ h?: number; + /** + * addition information of a panel, + * This prevents the panel from being removed when there is no tab inside + * a locked panel can not be moved to float layer either + */ + panelLock?: PanelLock; } export interface BoxBase { /** @@ -204,12 +210,6 @@ interface PanelLock { export interface PanelData extends PanelBase, BoxChild { parent?: BoxData; tabs: TabData[]; - /** - * addition information of a panel, - * This prevents the panel from being removed when there is no tab inside - * a locked panel can not be moved to float layer either - */ - panelLock?: PanelLock; } export interface TabPaneCache { id: string; diff --git a/lib/Serializer.js b/lib/Serializer.js index 93993566..236047bd 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -53,14 +53,14 @@ function saveLayoutData(layout, saveTab, afterPanelSaved) { tabs.push(savedTab); } } - let { id, size, activeId, group } = panelData; + let { id, size, activeId, group, panelLock } = panelData; let savedPanel; if (panelData.parent.mode === 'float' || panelData.parent.mode === 'window') { let { x, y, z, w, h } = panelData; - savedPanel = { id, size, tabs, group, activeId, x, y, z, w, h }; + savedPanel = { id, size, tabs, group, activeId, panelLock, x, y, z, w, h }; } else { - savedPanel = { id, size, tabs, group, activeId }; + savedPanel = { id, size, tabs, group, activeId, panelLock }; } if (afterPanelSaved) { afterPanelSaved(savedPanel, panelData); @@ -102,7 +102,7 @@ function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLoaded) { return null; } function loadPanelData(savedPanel) { - let { id, size, activeId, x, y, z, w, h, group } = savedPanel; + let { id, size, activeId, x, y, z, w, h, group, panelLock } = savedPanel; let tabs = []; for (let savedTab of savedPanel.tabs) { let tabData = loadTabData(savedTab); @@ -112,10 +112,10 @@ function loadLayoutData(savedLayout, defaultLayout, loadTab, afterPanelLoaded) { } let panelData; if (w || h || x || y || z) { - panelData = { id, size, activeId, group, x, y, z, w, h, tabs }; + panelData = { id, size, activeId, group, x, y, z, w, h, tabs, panelLock }; } else { - panelData = { id, size, activeId, group, tabs }; + panelData = { id, size, activeId, group, tabs, panelLock }; } if (savedPanel.id === DockData_1.maximePlaceHolderId) { panelData.panelLock = {}; diff --git a/src/DockData.ts b/src/DockData.ts index b71c2015..5fd285a3 100644 --- a/src/DockData.ts +++ b/src/DockData.ts @@ -141,6 +141,13 @@ export interface PanelBase { w?: number; /** float mode only */ h?: number; + + /** + * addition information of a panel, + * This prevents the panel from being removed when there is no tab inside + * a locked panel can not be moved to float layer either + */ + panelLock?: PanelLock; // if not null, panel won't disappear even when all children are gone } export interface BoxBase { @@ -244,14 +251,6 @@ export interface PanelData extends PanelBase, BoxChild { tabs: TabData[]; - /** - * addition information of a panel, - * This prevents the panel from being removed when there is no tab inside - * a locked panel can not be moved to float layer either - */ - panelLock?: PanelLock; // if not null, panel won't disappear even when all children are gone - - } export interface TabPaneCache { diff --git a/src/Serializer.ts b/src/Serializer.ts index 1e9d1aaf..084e922e 100644 --- a/src/Serializer.ts +++ b/src/Serializer.ts @@ -69,13 +69,13 @@ export function saveLayoutData( tabs.push(savedTab); } } - let {id, size, activeId, group} = panelData; + let {id, size, activeId, group, panelLock} = panelData; let savedPanel: PanelBase; if (panelData.parent.mode === 'float' || panelData.parent.mode === 'window') { let {x, y, z, w, h} = panelData; - savedPanel = {id, size, tabs, group, activeId, x, y, z, w, h}; + savedPanel = {id, size, tabs, group, activeId, panelLock, x, y, z, w, h}; } else { - savedPanel = {id, size, tabs, group, activeId}; + savedPanel = {id, size, tabs, group, activeId, panelLock}; } if (afterPanelSaved) { afterPanelSaved(savedPanel, panelData); @@ -124,7 +124,7 @@ export function loadLayoutData( } function loadPanelData(savedPanel: PanelBase): PanelData { - let {id, size, activeId, x, y, z, w, h, group} = savedPanel; + let {id, size, activeId, x, y, z, w, h, group, panelLock} = savedPanel; let tabs: TabData[] = []; for (let savedTab of savedPanel.tabs) { @@ -135,9 +135,9 @@ export function loadLayoutData( } let panelData: PanelData; if (w || h || x || y || z) { - panelData = {id, size, activeId, group, x, y, z, w, h, tabs}; + panelData = {id, size, activeId, group, x, y, z, w, h, tabs, panelLock}; } else { - panelData = {id, size, activeId, group, tabs}; + panelData = {id, size, activeId, group, tabs, panelLock}; } if (savedPanel.id === maximePlaceHolderId) { panelData.panelLock = {};