mirror of
https://github.com/mathuo/dockview
synced 2025-10-23 08:18:13 +00:00
Add group with options.
This commit is contained in:
parent
502a984d2b
commit
03a39507dc
@ -36,12 +36,13 @@ import {
|
|||||||
IDockviewGroupPanel,
|
IDockviewGroupPanel,
|
||||||
} from '../dockview/dockviewGroupPanel';
|
} from '../dockview/dockviewGroupPanel';
|
||||||
import { Emitter, Event } from '../events';
|
import { Emitter, Event } from '../events';
|
||||||
|
import { GroupOptions } from '../dockview/dockviewGroupPanelModel';
|
||||||
import { IDockviewPanel } from '../dockview/dockviewPanel';
|
import { IDockviewPanel } from '../dockview/dockviewPanel';
|
||||||
import { PaneviewDropEvent } from '../paneview/draggablePaneviewPanel';
|
import { PaneviewDropEvent } from '../paneview/draggablePaneviewPanel';
|
||||||
import {
|
import {
|
||||||
GroupDragEvent,
|
GroupDragEvent,
|
||||||
TabDragEvent,
|
TabDragEvent,
|
||||||
} from '../dockview/components/titlebar/tabsContainer';
|
} from '../dockview/components/titlebar/tabsContainer';
|
||||||
import { Box } from '../types';
|
import { Box } from '../types';
|
||||||
|
|
||||||
export interface CommonApi<T = any> {
|
export interface CommonApi<T = any> {
|
||||||
@ -736,8 +737,8 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
|
|||||||
/**
|
/**
|
||||||
* Add a group and return the created object.
|
* Add a group and return the created object.
|
||||||
*/
|
*/
|
||||||
addGroup(options?: AddGroupOptions): DockviewGroupPanel {
|
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel {
|
||||||
return this.component.addGroup(options);
|
return this.component.addGroup(groupOptions, positionOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,9 +49,12 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|||||||
|
|
||||||
const group =
|
const group =
|
||||||
options.group ??
|
options.group ??
|
||||||
this.accessor.addGroup({
|
this.accessor.addGroup(
|
||||||
direction: positionToDirection(options.position ?? 'right'),
|
undefined,
|
||||||
});
|
{
|
||||||
|
direction: positionToDirection(options.position ?? 'right'),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.accessor.moveGroupOrPanel(
|
this.accessor.moveGroupOrPanel(
|
||||||
group,
|
group,
|
||||||
|
@ -261,7 +261,7 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
|
|||||||
getGroupPanel: (id: string) => IDockviewPanel | undefined;
|
getGroupPanel: (id: string) => IDockviewPanel | undefined;
|
||||||
createWatermarkComponent(): IWatermarkRenderer;
|
createWatermarkComponent(): IWatermarkRenderer;
|
||||||
// lifecycle
|
// lifecycle
|
||||||
addGroup(options?: AddGroupOptions): DockviewGroupPanel;
|
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel;
|
||||||
closeAllGroups(): void;
|
closeAllGroups(): void;
|
||||||
// events
|
// events
|
||||||
moveToNext(options?: MovementOptions): void;
|
moveToNext(options?: MovementOptions): void;
|
||||||
@ -1280,23 +1280,23 @@ export class DockviewComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addGroup(options?: AddGroupOptions): DockviewGroupPanel {
|
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel {
|
||||||
const group = this.createGroup();
|
const group = this.createGroup(groupOptions);
|
||||||
|
|
||||||
if (options) {
|
if (positionOptions) {
|
||||||
let referenceGroup: DockviewGroupPanel | undefined;
|
let referenceGroup: DockviewGroupPanel | undefined;
|
||||||
|
|
||||||
if (isGroupOptionsWithPanel(options)) {
|
if (isGroupOptionsWithPanel(positionOptions)) {
|
||||||
const referencePanel =
|
const referencePanel =
|
||||||
typeof options.referencePanel === 'string'
|
typeof positionOptions.referencePanel === 'string'
|
||||||
? this.panels.find(
|
? this.panels.find(
|
||||||
(panel) => panel.id === options.referencePanel
|
(panel) => panel.id === positionOptions.referencePanel
|
||||||
)
|
)
|
||||||
: options.referencePanel;
|
: positionOptions.referencePanel;
|
||||||
|
|
||||||
if (!referencePanel) {
|
if (!referencePanel) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`reference panel ${options.referencePanel} does not exist`
|
`reference panel ${positionOptions.referencePanel} does not exist`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1304,28 +1304,28 @@ export class DockviewComponent
|
|||||||
|
|
||||||
if (!referenceGroup) {
|
if (!referenceGroup) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`reference group for reference panel ${options.referencePanel} does not exist`
|
`reference group for reference panel ${positionOptions.referencePanel} does not exist`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (isGroupOptionsWithGroup(options)) {
|
} else if (isGroupOptionsWithGroup(positionOptions)) {
|
||||||
referenceGroup =
|
referenceGroup =
|
||||||
typeof options.referenceGroup === 'string'
|
typeof positionOptions.referenceGroup === 'string'
|
||||||
? this._groups.get(options.referenceGroup)?.value
|
? this._groups.get(positionOptions.referenceGroup)?.value
|
||||||
: options.referenceGroup;
|
: positionOptions.referenceGroup;
|
||||||
|
|
||||||
if (!referenceGroup) {
|
if (!referenceGroup) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`reference group ${options.referenceGroup} does not exist`
|
`reference group ${positionOptions.referenceGroup} does not exist`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const group = this.orthogonalize(
|
const group = this.orthogonalize(
|
||||||
directionToPosition(<Direction>options.direction)
|
directionToPosition(<Direction>positionOptions.direction)
|
||||||
);
|
);
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = toTarget(<Direction>options.direction || 'within');
|
const target = toTarget(<Direction>positionOptions.direction || 'within');
|
||||||
|
|
||||||
const location = getGridLocation(referenceGroup.element);
|
const location = getGridLocation(referenceGroup.element);
|
||||||
const relativeLocation = getRelativeLocation(
|
const relativeLocation = getRelativeLocation(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user