mirror of
https://github.com/mathuo/dockview
synced 2025-08-14 21:26:01 +00:00
PR comments.
This commit is contained in:
parent
a6a6ffc058
commit
02af66a10f
@ -36,7 +36,6 @@ import {
|
||||
IDockviewGroupPanel,
|
||||
} from '../dockview/dockviewGroupPanel';
|
||||
import { Emitter, Event } from '../events';
|
||||
import { GroupOptions } from '../dockview/dockviewGroupPanelModel';
|
||||
import { IDockviewPanel } from '../dockview/dockviewPanel';
|
||||
import { PaneviewDropEvent } from '../paneview/draggablePaneviewPanel';
|
||||
import {
|
||||
@ -737,8 +736,8 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
|
||||
/**
|
||||
* Add a group and return the created object.
|
||||
*/
|
||||
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel {
|
||||
return this.component.addGroup(groupOptions, positionOptions);
|
||||
addGroup(options?: AddGroupOptions): DockviewGroupPanel {
|
||||
return this.component.addGroup(options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,12 +49,9 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
||||
|
||||
const group =
|
||||
options.group ??
|
||||
this.accessor.addGroup(
|
||||
undefined,
|
||||
{
|
||||
direction: positionToDirection(options.position ?? 'right'),
|
||||
}
|
||||
);
|
||||
this.accessor.addGroup({
|
||||
direction: positionToDirection(options.position ?? 'right'),
|
||||
});
|
||||
|
||||
this.accessor.moveGroupOrPanel(
|
||||
group,
|
||||
|
@ -1280,23 +1280,23 @@ export class DockviewComponent
|
||||
}
|
||||
}
|
||||
|
||||
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel {
|
||||
const group = this.createGroup(groupOptions);
|
||||
addGroup(options?: AddGroupOptions): DockviewGroupPanel {
|
||||
const group = this.createGroup(options);
|
||||
|
||||
if (positionOptions) {
|
||||
if (options) {
|
||||
let referenceGroup: DockviewGroupPanel | undefined;
|
||||
|
||||
if (isGroupOptionsWithPanel(positionOptions)) {
|
||||
if (isGroupOptionsWithPanel(options)) {
|
||||
const referencePanel =
|
||||
typeof positionOptions.referencePanel === 'string'
|
||||
typeof options.referencePanel === 'string'
|
||||
? this.panels.find(
|
||||
(panel) => panel.id === positionOptions.referencePanel
|
||||
(panel) => panel.id === options.referencePanel
|
||||
)
|
||||
: positionOptions.referencePanel;
|
||||
: options.referencePanel;
|
||||
|
||||
if (!referencePanel) {
|
||||
throw new Error(
|
||||
`reference panel ${positionOptions.referencePanel} does not exist`
|
||||
`reference panel ${options.referencePanel} does not exist`
|
||||
);
|
||||
}
|
||||
|
||||
@ -1304,28 +1304,28 @@ export class DockviewComponent
|
||||
|
||||
if (!referenceGroup) {
|
||||
throw new Error(
|
||||
`reference group for reference panel ${positionOptions.referencePanel} does not exist`
|
||||
`reference group for reference panel ${options.referencePanel} does not exist`
|
||||
);
|
||||
}
|
||||
} else if (isGroupOptionsWithGroup(positionOptions)) {
|
||||
} else if (isGroupOptionsWithGroup(options)) {
|
||||
referenceGroup =
|
||||
typeof positionOptions.referenceGroup === 'string'
|
||||
? this._groups.get(positionOptions.referenceGroup)?.value
|
||||
: positionOptions.referenceGroup;
|
||||
typeof options.referenceGroup === 'string'
|
||||
? this._groups.get(options.referenceGroup)?.value
|
||||
: options.referenceGroup;
|
||||
|
||||
if (!referenceGroup) {
|
||||
throw new Error(
|
||||
`reference group ${positionOptions.referenceGroup} does not exist`
|
||||
`reference group ${options.referenceGroup} does not exist`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const group = this.orthogonalize(
|
||||
directionToPosition(<Direction>positionOptions.direction)
|
||||
directionToPosition(<Direction>options.direction)
|
||||
);
|
||||
return group;
|
||||
}
|
||||
|
||||
const target = toTarget(<Direction>positionOptions.direction || 'within');
|
||||
const target = toTarget(<Direction>options.direction || 'within');
|
||||
|
||||
const location = getGridLocation(referenceGroup.element);
|
||||
const relativeLocation = getRelativeLocation(
|
||||
|
@ -14,6 +14,7 @@ import { ISplitviewStyles, Orientation } from '../splitview/splitview';
|
||||
import { PanelTransfer } from '../dnd/dataTransfer';
|
||||
import { IDisposable } from '../lifecycle';
|
||||
import { DroptargetOverlayModel, Position } from '../dnd/droptarget';
|
||||
import { GroupOptions } from './dockviewGroupPanelModel';
|
||||
import { IDockviewPanel } from './dockviewPanel';
|
||||
import {
|
||||
ComponentConstructor,
|
||||
@ -186,10 +187,12 @@ type AddGroupOptionsWithGroup = {
|
||||
direction?: Omit<Direction, 'within'>;
|
||||
};
|
||||
|
||||
export type AddGroupOptions =
|
||||
export type AddGroupOptions = (
|
||||
| AddGroupOptionsWithGroup
|
||||
| AddGroupOptionsWithPanel
|
||||
| AbsolutePosition;
|
||||
| AbsolutePosition
|
||||
) &
|
||||
GroupOptions;
|
||||
|
||||
export function isGroupOptionsWithPanel(
|
||||
data: AddGroupOptions
|
||||
|
Loading…
x
Reference in New Issue
Block a user