PR comments.

This commit is contained in:
NaNgets 2024-01-21 22:51:19 +02:00
parent a6a6ffc058
commit 02af66a10f
No known key found for this signature in database
GPG Key ID: E3F583B7BB2DAA82
4 changed files with 26 additions and 27 deletions

View File

@ -36,7 +36,6 @@ 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 {
@ -737,8 +736,8 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
/** /**
* Add a group and return the created object. * Add a group and return the created object.
*/ */
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel { addGroup(options?: AddGroupOptions): DockviewGroupPanel {
return this.component.addGroup(groupOptions, positionOptions); return this.component.addGroup(options);
} }
/** /**

View File

@ -49,12 +49,9 @@ export class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
const group = const group =
options.group ?? options.group ??
this.accessor.addGroup( this.accessor.addGroup({
undefined, direction: positionToDirection(options.position ?? 'right'),
{ });
direction: positionToDirection(options.position ?? 'right'),
}
);
this.accessor.moveGroupOrPanel( this.accessor.moveGroupOrPanel(
group, group,

View File

@ -1280,23 +1280,23 @@ export class DockviewComponent
} }
} }
addGroup(groupOptions?: GroupOptions, positionOptions?: AddGroupOptions): DockviewGroupPanel { addGroup(options?: AddGroupOptions): DockviewGroupPanel {
const group = this.createGroup(groupOptions); const group = this.createGroup(options);
if (positionOptions) { if (options) {
let referenceGroup: DockviewGroupPanel | undefined; let referenceGroup: DockviewGroupPanel | undefined;
if (isGroupOptionsWithPanel(positionOptions)) { if (isGroupOptionsWithPanel(options)) {
const referencePanel = const referencePanel =
typeof positionOptions.referencePanel === 'string' typeof options.referencePanel === 'string'
? this.panels.find( ? this.panels.find(
(panel) => panel.id === positionOptions.referencePanel (panel) => panel.id === options.referencePanel
) )
: positionOptions.referencePanel; : options.referencePanel;
if (!referencePanel) { if (!referencePanel) {
throw new Error( 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) { if (!referenceGroup) {
throw new Error( 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 = referenceGroup =
typeof positionOptions.referenceGroup === 'string' typeof options.referenceGroup === 'string'
? this._groups.get(positionOptions.referenceGroup)?.value ? this._groups.get(options.referenceGroup)?.value
: positionOptions.referenceGroup; : options.referenceGroup;
if (!referenceGroup) { if (!referenceGroup) {
throw new Error( throw new Error(
`reference group ${positionOptions.referenceGroup} does not exist` `reference group ${options.referenceGroup} does not exist`
); );
} }
} else { } else {
const group = this.orthogonalize( const group = this.orthogonalize(
directionToPosition(<Direction>positionOptions.direction) directionToPosition(<Direction>options.direction)
); );
return group; return group;
} }
const target = toTarget(<Direction>positionOptions.direction || 'within'); const target = toTarget(<Direction>options.direction || 'within');
const location = getGridLocation(referenceGroup.element); const location = getGridLocation(referenceGroup.element);
const relativeLocation = getRelativeLocation( const relativeLocation = getRelativeLocation(

View File

@ -14,6 +14,7 @@ import { ISplitviewStyles, Orientation } from '../splitview/splitview';
import { PanelTransfer } from '../dnd/dataTransfer'; import { PanelTransfer } from '../dnd/dataTransfer';
import { IDisposable } from '../lifecycle'; import { IDisposable } from '../lifecycle';
import { DroptargetOverlayModel, Position } from '../dnd/droptarget'; import { DroptargetOverlayModel, Position } from '../dnd/droptarget';
import { GroupOptions } from './dockviewGroupPanelModel';
import { IDockviewPanel } from './dockviewPanel'; import { IDockviewPanel } from './dockviewPanel';
import { import {
ComponentConstructor, ComponentConstructor,
@ -186,10 +187,12 @@ type AddGroupOptionsWithGroup = {
direction?: Omit<Direction, 'within'>; direction?: Omit<Direction, 'within'>;
}; };
export type AddGroupOptions = export type AddGroupOptions = (
| AddGroupOptionsWithGroup | AddGroupOptionsWithGroup
| AddGroupOptionsWithPanel | AddGroupOptionsWithPanel
| AbsolutePosition; | AbsolutePosition
) &
GroupOptions;
export function isGroupOptionsWithPanel( export function isGroupOptionsWithPanel(
data: AddGroupOptions data: AddGroupOptions