mirror of
https://github.com/mathuo/dockview
synced 2025-07-21 17:36:01 +00:00
Merge branch 'master' of https://github.com/mathuo/dockview
This commit is contained in:
commit
efbe019583
@ -2295,4 +2295,91 @@ describe('dockviewComponent', () => {
|
|||||||
panels: {},
|
panels: {},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('that title and params.title do not conflict', () => {
|
||||||
|
const container = document.createElement('div');
|
||||||
|
|
||||||
|
const dockview = new DockviewComponent({
|
||||||
|
parentElement: container,
|
||||||
|
components: {
|
||||||
|
default: PanelContentPartTest,
|
||||||
|
},
|
||||||
|
tabComponents: {
|
||||||
|
test_tab_id: PanelTabPartTest,
|
||||||
|
},
|
||||||
|
orientation: Orientation.HORIZONTAL,
|
||||||
|
});
|
||||||
|
|
||||||
|
dockview.layout(100, 100);
|
||||||
|
|
||||||
|
dockview.addPanel({
|
||||||
|
id: 'panel1',
|
||||||
|
component: 'default',
|
||||||
|
title: 'Panel 1',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 1',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dockview.addPanel({
|
||||||
|
id: 'panel2',
|
||||||
|
component: 'default',
|
||||||
|
title: 'Panel 2',
|
||||||
|
});
|
||||||
|
|
||||||
|
dockview.addPanel({
|
||||||
|
id: 'panel3',
|
||||||
|
component: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 3',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(JSON.parse(JSON.stringify(dockview.toJSON()))).toEqual({
|
||||||
|
grid: {
|
||||||
|
root: {
|
||||||
|
type: 'branch',
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
type: 'leaf',
|
||||||
|
data: {
|
||||||
|
views: ['panel1', 'panel2', 'panel3'],
|
||||||
|
activeView: 'panel3',
|
||||||
|
id: '1',
|
||||||
|
},
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
size: 100,
|
||||||
|
},
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
orientation: 'HORIZONTAL',
|
||||||
|
},
|
||||||
|
panels: {
|
||||||
|
panel1: {
|
||||||
|
id: 'panel1',
|
||||||
|
contentComponent: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 1',
|
||||||
|
},
|
||||||
|
title: 'Panel 1',
|
||||||
|
},
|
||||||
|
panel2: {
|
||||||
|
id: 'panel2',
|
||||||
|
contentComponent: 'default',
|
||||||
|
title: 'Panel 2',
|
||||||
|
},
|
||||||
|
panel3: {
|
||||||
|
id: 'panel3',
|
||||||
|
contentComponent: 'default',
|
||||||
|
params: {
|
||||||
|
title: 'Panel 3',
|
||||||
|
},
|
||||||
|
title: 'panel3',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
activeGroup: '1',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,7 @@ describe('dockviewPanel', () => {
|
|||||||
latestTitle = event.title;
|
latestTitle = event.title;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(cut.title).toBe('');
|
expect(cut.title).toBeUndefined();
|
||||||
|
|
||||||
cut.init({ title: 'new title', params: {} });
|
cut.init({ title: 'new title', params: {} });
|
||||||
expect(latestTitle).toBe('new title');
|
expect(latestTitle).toBe('new title');
|
||||||
|
@ -19,7 +19,7 @@ export interface DockviewPanelApi
|
|||||||
> {
|
> {
|
||||||
readonly group: DockviewGroupPanel;
|
readonly group: DockviewGroupPanel;
|
||||||
readonly isGroupActive: boolean;
|
readonly isGroupActive: boolean;
|
||||||
readonly title: string;
|
readonly title: string | undefined;
|
||||||
readonly onDidActiveGroupChange: Event<void>;
|
readonly onDidActiveGroupChange: Event<void>;
|
||||||
readonly onDidGroupChange: Event<void>;
|
readonly onDidGroupChange: Event<void>;
|
||||||
close(): void;
|
close(): void;
|
||||||
@ -43,7 +43,7 @@ export class DockviewPanelApiImpl
|
|||||||
|
|
||||||
private readonly disposable = new MutableDisposable();
|
private readonly disposable = new MutableDisposable();
|
||||||
|
|
||||||
get title(): string {
|
get title(): string | undefined {
|
||||||
return this.panel.title;
|
return this.panel.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ export interface IDockviewPanel extends IDisposable, IPanel {
|
|||||||
readonly view: IDockviewPanelModel;
|
readonly view: IDockviewPanelModel;
|
||||||
readonly group: DockviewGroupPanel;
|
readonly group: DockviewGroupPanel;
|
||||||
readonly api: DockviewPanelApi;
|
readonly api: DockviewPanelApi;
|
||||||
readonly title: string;
|
readonly title: string | undefined;
|
||||||
readonly params: Record<string, any> | undefined;
|
readonly params: Record<string, any> | undefined;
|
||||||
updateParentGroup(group: DockviewGroupPanel, isGroupActive: boolean): void;
|
updateParentGroup(group: DockviewGroupPanel, isGroupActive: boolean): void;
|
||||||
init(params: IGroupPanelInitParameters): void;
|
init(params: IGroupPanelInitParameters): void;
|
||||||
@ -34,13 +34,13 @@ export class DockviewPanel
|
|||||||
private _group: DockviewGroupPanel;
|
private _group: DockviewGroupPanel;
|
||||||
private _params?: Parameters;
|
private _params?: Parameters;
|
||||||
|
|
||||||
private _title: string;
|
private _title: string | undefined;
|
||||||
|
|
||||||
get params(): Parameters | undefined {
|
get params(): Parameters | undefined {
|
||||||
return this._params;
|
return this._params;
|
||||||
}
|
}
|
||||||
|
|
||||||
get title(): string {
|
get title(): string | undefined {
|
||||||
return this._title;
|
return this._title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,6 @@ export class DockviewPanel
|
|||||||
readonly view: IDockviewPanelModel
|
readonly view: IDockviewPanelModel
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._title = '';
|
|
||||||
this._group = group;
|
this._group = group;
|
||||||
|
|
||||||
this.api = new DockviewPanelApiImpl(this, this._group);
|
this.api = new DockviewPanelApiImpl(this, this._group);
|
||||||
@ -76,13 +75,13 @@ export class DockviewPanel
|
|||||||
public init(params: IGroupPanelInitParameters): void {
|
public init(params: IGroupPanelInitParameters): void {
|
||||||
this._params = params.params;
|
this._params = params.params;
|
||||||
|
|
||||||
this.setTitle(params.title);
|
|
||||||
|
|
||||||
this.view.init({
|
this.view.init({
|
||||||
...params,
|
...params,
|
||||||
api: this.api,
|
api: this.api,
|
||||||
containerApi: this.containerApi,
|
containerApi: this.containerApi,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setTitle(params.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
focus(): void {
|
focus(): void {
|
||||||
@ -103,12 +102,12 @@ export class DockviewPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTitle(title: string): void {
|
setTitle(title: string): void {
|
||||||
const didTitleChange = title !== this._params?.title;
|
const didTitleChange = title !== this.title;
|
||||||
|
|
||||||
if (didTitleChange) {
|
if (didTitleChange) {
|
||||||
this._title = title;
|
this._title = title;
|
||||||
|
|
||||||
this.view?.update({
|
this.view.update({
|
||||||
params: {
|
params: {
|
||||||
params: this._params,
|
params: this._params,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
@ -128,10 +127,10 @@ export class DockviewPanel
|
|||||||
|
|
||||||
if (params.title !== this.title) {
|
if (params.title !== this.title) {
|
||||||
this._title = params.title;
|
this._title = params.title;
|
||||||
this.api._onDidTitleChange.fire({ title: this.title });
|
this.api._onDidTitleChange.fire({ title: params.title });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.view?.update({
|
this.view.update({
|
||||||
params: {
|
params: {
|
||||||
params: this._params,
|
params: this._params,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user