mirror of
https://github.com/mathuo/dockview
synced 2025-05-03 01:58:26 +00:00
Merge pull request #882 from mathuo/676-is-it-possiable-that-the-id-and-title-of-group-can-be-assigned
676 is it possiable that the id and title of group can be assigned
This commit is contained in:
commit
5e380affe7
@ -6729,4 +6729,51 @@ describe('dockviewComponent', () => {
|
||||
expect(api.panels.length).toBe(3);
|
||||
expect(api.groups.length).toBe(3);
|
||||
});
|
||||
|
||||
test('add group with custom group is', () => {
|
||||
const container = document.createElement('div');
|
||||
|
||||
const dockview = new DockviewComponent(container, {
|
||||
createComponent(options) {
|
||||
switch (options.name) {
|
||||
case 'default':
|
||||
return new PanelContentPartTest(
|
||||
options.id,
|
||||
options.name
|
||||
);
|
||||
default:
|
||||
throw new Error(`unsupported`);
|
||||
}
|
||||
},
|
||||
});
|
||||
const api = new DockviewApi(dockview);
|
||||
|
||||
dockview.layout(1000, 1000);
|
||||
|
||||
const panel1 = api.addPanel({
|
||||
id: 'panel_1',
|
||||
component: 'default',
|
||||
});
|
||||
|
||||
const group1 = api.addGroup({
|
||||
id: 'group_1',
|
||||
direction: 'left',
|
||||
});
|
||||
|
||||
const group2 = api.addGroup({
|
||||
id: 'group_2',
|
||||
direction: 'left',
|
||||
referencePanel: panel1,
|
||||
});
|
||||
|
||||
const group3 = api.addGroup({
|
||||
id: 'group_3',
|
||||
direction: 'left',
|
||||
referenceGroup: panel1.api.group,
|
||||
});
|
||||
|
||||
expect(group1.api.id).toBe('group_1');
|
||||
expect(group2.api.id).toBe('group_2');
|
||||
expect(group3.api.id).toBe('group_3');
|
||||
});
|
||||
});
|
||||
|
@ -1176,7 +1176,7 @@ export class DockviewComponent
|
||||
this.updateWatermark();
|
||||
}
|
||||
|
||||
private orthogonalize(position: Position): DockviewGroupPanel {
|
||||
private orthogonalize(position: Position, options?: GroupOptions): DockviewGroupPanel {
|
||||
switch (position) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
@ -1202,10 +1202,10 @@ export class DockviewComponent
|
||||
case 'top':
|
||||
case 'left':
|
||||
case 'center':
|
||||
return this.createGroupAtLocation([0]); // insert into first position
|
||||
return this.createGroupAtLocation([0], undefined, options); // insert into first position
|
||||
case 'bottom':
|
||||
case 'right':
|
||||
return this.createGroupAtLocation([this.gridview.length]); // insert into last position
|
||||
return this.createGroupAtLocation([this.gridview.length], undefined, options); // insert into last position
|
||||
default:
|
||||
throw new Error(`unsupported position ${position}`);
|
||||
}
|
||||
@ -1880,7 +1880,8 @@ export class DockviewComponent
|
||||
}
|
||||
} else {
|
||||
const group = this.orthogonalize(
|
||||
directionToPosition(<Direction>options.direction)
|
||||
directionToPosition(<Direction>options.direction),
|
||||
options
|
||||
);
|
||||
if (!options.skipSetActive) {
|
||||
this.doSetGroupAndPanelActive(group);
|
||||
@ -2548,9 +2549,10 @@ export class DockviewComponent
|
||||
|
||||
private createGroupAtLocation(
|
||||
location: number[],
|
||||
size?: number
|
||||
size?: number,
|
||||
options?: GroupOptions
|
||||
): DockviewGroupPanel {
|
||||
const group = this.createGroup();
|
||||
const group = this.createGroup(options);
|
||||
this.doAddGroup(group, location, size);
|
||||
return group;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user