From 4806421ba524a0b20560e1982a2743149acc0f14 Mon Sep 17 00:00:00 2001 From: mathuo <6710312+mathuo@users.noreply.github.com> Date: Mon, 2 May 2022 17:12:14 +0100 Subject: [PATCH] feat: api improvements --- .../src/__tests__/api/component.api.spec.ts | 4 ---- packages/dockview/src/api/component.api.ts | 18 ------------------ .../src/gridview/baseComponentGridview.ts | 13 ------------- .../dockview/src/paneview/paneviewComponent.ts | 13 ------------- .../src/splitview/splitviewComponent.ts | 13 ------------- 5 files changed, 61 deletions(-) diff --git a/packages/dockview/src/__tests__/api/component.api.spec.ts b/packages/dockview/src/__tests__/api/component.api.spec.ts index 0430e4a6f..006e67da2 100644 --- a/packages/dockview/src/__tests__/api/component.api.spec.ts +++ b/packages/dockview/src/__tests__/api/component.api.spec.ts @@ -24,7 +24,6 @@ describe('component.api', () => { 'onDidRemoveView', 'panels', 'focus', - 'resizeToFit', 'toJSON', ]; @@ -56,7 +55,6 @@ describe('component.api', () => { 'onDidRemoveView', 'panels', 'focus', - 'resizeToFit', 'toJSON', ]; @@ -88,7 +86,6 @@ describe('component.api', () => { 'onDidLayoutChange', 'orientation', 'focus', - 'resizeToFit', 'toJSON', 'onDidActiveGroupChange', 'onDidAddGroup', @@ -130,7 +127,6 @@ describe('component.api', () => { 'activePanel', 'focus', 'closeAllGroups', - 'resizeToFit', 'toJSON', 'onDidActiveGroupChange', 'onDidAddGroup', diff --git a/packages/dockview/src/api/component.api.ts b/packages/dockview/src/api/component.api.ts index b7af71608..02755d7b4 100644 --- a/packages/dockview/src/api/component.api.ts +++ b/packages/dockview/src/api/component.api.ts @@ -41,9 +41,7 @@ export interface CommonApi { readonly onDidLayoutFromJSON: Event; focus(): void; layout(width: number, height: number): void; - resizeToFit(): void; fromJSON(data: T): void; - toJSON(): T; } @@ -126,10 +124,6 @@ export class SplitviewApi implements CommonApi { return this.component.addPanel(options); } - resizeToFit(): void { - this.component.resizeToFit(); - } - movePanel(from: number, to: number): void { this.component.movePanel(from, to); } @@ -221,10 +215,6 @@ export class PaneviewApi implements CommonApi { return this.component.addPanel(options); } - resizeToFit(): void { - this.component.resizeToFit(); - } - fromJSON(data: SerializedPaneview): void { this.component.fromJSON(data); } @@ -316,10 +306,6 @@ export class GridviewApi implements CommonApi { this.component.movePanel(panel, options); } - resizeToFit(): void { - this.component.resizeToFit(); - } - getPanel(id: string): IGridviewPanel | undefined { return this.component.getPanel(id); } @@ -476,10 +462,6 @@ export class DockviewApi implements CommonApi { this.component.removeGroup(group); } - resizeToFit(): void { - return this.component.resizeToFit(); - } - getGroup(id: string): IGroupviewPanel | undefined { return this.component.getPanel(id); } diff --git a/packages/dockview/src/gridview/baseComponentGridview.ts b/packages/dockview/src/gridview/baseComponentGridview.ts index 2e2ee9c8a..eb429bee4 100644 --- a/packages/dockview/src/gridview/baseComponentGridview.ts +++ b/packages/dockview/src/gridview/baseComponentGridview.ts @@ -62,7 +62,6 @@ export interface IBaseGrid { toJSON(): object; fromJSON(data: any): void; layout(width: number, height: number, force?: boolean): void; - resizeToFit(): void; setVisible(panel: T, visible: boolean): void; isVisible(panel: T): boolean; } @@ -299,18 +298,6 @@ export abstract class BaseGrid this.gridview.layout(width, height); } - /** - * Resize the layout to fit the parent container - */ - public resizeToFit(): void { - if (!this.element.parentElement) { - return; - } - const { width, height } = - this.element.parentElement.getBoundingClientRect(); - this.layout(width, height); - } - public dispose(): void { super.dispose(); diff --git a/packages/dockview/src/paneview/paneviewComponent.ts b/packages/dockview/src/paneview/paneviewComponent.ts index 72a7cbeb9..9ee70d861 100644 --- a/packages/dockview/src/paneview/paneviewComponent.ts +++ b/packages/dockview/src/paneview/paneviewComponent.ts @@ -108,7 +108,6 @@ export interface IPaneviewComponent extends IDisposable { layout(width: number, height: number): void; toJSON(): SerializedPaneview; fromJSON(serializedPaneview: SerializedPaneview): void; - resizeToFit(): void; focus(): void; removePanel(panel: IPaneviewPanel): void; getPanel(id: string): IPaneviewPanel | undefined; @@ -316,18 +315,6 @@ export class PaneviewComponent this.paneview.layout(size, orthogonalSize); } - /** - * Resize the layout to fit the parent container - */ - resizeToFit(): void { - if (!this.element.parentElement) { - return; - } - const { width, height } = - this.element.parentElement.getBoundingClientRect(); - this.layout(width, height); - } - toJSON(): SerializedPaneview { const maximum = (value: number) => value === Number.MAX_SAFE_INTEGER || diff --git a/packages/dockview/src/splitview/splitviewComponent.ts b/packages/dockview/src/splitview/splitviewComponent.ts index e9e7f4f85..486bfd43f 100644 --- a/packages/dockview/src/splitview/splitviewComponent.ts +++ b/packages/dockview/src/splitview/splitviewComponent.ts @@ -68,7 +68,6 @@ export interface ISplitviewComponent extends IDisposable { onDidLayoutChange: Event; toJSON(): SerializedSplitview; fromJSON(serializedSplitview: SerializedSplitview): void; - resizeToFit(): void; focus(): void; getPanel(id: string): ISplitviewPanel | undefined; setActive(view: ISplitviewPanel, skipFocus?: boolean): void; @@ -296,18 +295,6 @@ export class SplitviewComponent return view; } - /** - * Resize the layout to fit the parent container - */ - resizeToFit(): void { - if (!this.element.parentElement) { - return; - } - const { width, height } = - this.element.parentElement.getBoundingClientRect(); - this.layout(width, height); - } - layout(width: number, height: number): void { const [size, orthogonalSize] = this.splitview.orientation === Orientation.HORIZONTAL