From 5a635336b32daf0e0c0e3e46f2182100db7c1fa9 Mon Sep 17 00:00:00 2001 From: mathuo <6710312+mathuo@users.noreply.github.com> Date: Sun, 25 Feb 2024 16:09:48 +0000 Subject: [PATCH] handle edge drops for onWillShowOverlay --- .../src/dockview/dockviewComponent.ts | 15 ++++++++++++++- .../src/dockview/dockviewGroupPanelModel.ts | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/dockview-core/src/dockview/dockviewComponent.ts b/packages/dockview-core/src/dockview/dockviewComponent.ts index a2dd416bd..9b33959ab 100644 --- a/packages/dockview-core/src/dockview/dockviewComponent.ts +++ b/packages/dockview-core/src/dockview/dockviewComponent.ts @@ -568,6 +568,19 @@ export class DockviewComponent }); this.addDisposables( + this._rootDropTarget, + this._rootDropTarget.onWillShowOverlay((event) => { + if (this.gridview.length > 0 && event.position === 'center') { + // option only available when no panels in primary grid + return; + } + + this._onWillShowOverlay.fire( + new WillShowOverlayLocationEvent(event, { + kind: 'edge', + }) + ); + }), this._rootDropTarget.onDrop((event) => { const willDropEvent = new DockviewWillDropEvent({ nativeEvent: event.nativeEvent, @@ -576,7 +589,7 @@ export class DockviewComponent api: this._api, group: undefined, getData: getPanelData, - kind: 'content', + kind: 'edge', }); this._onWillDrop.fire(willDropEvent); diff --git a/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts b/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts index 9227b6aa3..6cad9ce71 100644 --- a/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts +++ b/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts @@ -125,7 +125,11 @@ export interface IHeader { export type DockviewGroupPanelLocked = boolean | 'no-drop-target'; -export type DockviewGroupDropLocation = 'tab' | 'header_space' | 'content'; +export type DockviewGroupDropLocation = + | 'tab' + | 'header_space' + | 'content' + | 'edge'; export interface IDockviewGroupPanelModel extends IPanel { readonly isActive: boolean;