dockview-core 6.3.0 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cjs/dnd/backend.d.ts +70 -0
- package/dist/cjs/dnd/backend.js +171 -0
- package/dist/cjs/dnd/dropOverlay.d.ts +20 -0
- package/dist/cjs/dnd/dropOverlay.js +197 -0
- package/dist/cjs/dnd/droptarget.d.ts +20 -6
- package/dist/cjs/dnd/droptarget.js +14 -208
- package/dist/cjs/dnd/pointer/index.d.ts +11 -0
- package/dist/cjs/dnd/pointer/index.js +13 -0
- package/dist/cjs/dnd/pointer/longPress.d.ts +32 -0
- package/dist/cjs/dnd/pointer/longPress.js +151 -0
- package/dist/cjs/dnd/pointer/pointerDragController.d.ts +60 -0
- package/dist/cjs/dnd/pointer/pointerDragController.js +241 -0
- package/dist/cjs/dnd/pointer/pointerDragSource.d.ts +61 -0
- package/dist/cjs/dnd/pointer/pointerDragSource.js +195 -0
- package/dist/cjs/dnd/pointer/pointerDropTarget.d.ts +39 -0
- package/dist/cjs/dnd/pointer/pointerDropTarget.js +198 -0
- package/dist/cjs/dnd/pointer/pointerGhost.d.ts +30 -0
- package/dist/cjs/dnd/pointer/pointerGhost.js +44 -0
- package/dist/cjs/dnd/pointer/types.d.ts +16 -0
- package/dist/cjs/dnd/pointer/types.js +2 -0
- package/dist/cjs/dockview/components/panel/content.d.ts +3 -1
- package/dist/cjs/dockview/components/panel/content.js +33 -16
- package/dist/cjs/dockview/components/popupService.js +34 -0
- package/dist/cjs/dockview/components/tab/tab.d.ts +11 -3
- package/dist/cjs/dockview/components/tab/tab.js +151 -117
- package/dist/cjs/dockview/components/titlebar/tabGroupChip.d.ts +9 -2
- package/dist/cjs/dockview/components/titlebar/tabGroupChip.js +15 -6
- package/dist/cjs/dockview/components/titlebar/tabGroups.d.ts +33 -5
- package/dist/cjs/dockview/components/titlebar/tabGroups.js +231 -40
- package/dist/cjs/dockview/components/titlebar/tabs.d.ts +38 -1
- package/dist/cjs/dockview/components/titlebar/tabs.js +372 -251
- package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +5 -3
- package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +6 -2
- package/dist/cjs/dockview/components/titlebar/voidContainer.js +189 -27
- package/dist/cjs/dockview/contextMenu.js +19 -4
- package/dist/cjs/dockview/dndCapabilities.d.ts +19 -0
- package/dist/cjs/dockview/dndCapabilities.js +39 -0
- package/dist/cjs/dockview/dockviewComponent.d.ts +1 -0
- package/dist/cjs/dockview/dockviewComponent.js +54 -33
- package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +9 -5
- package/dist/cjs/dockview/dockviewGroupPanelModel.js +25 -11
- package/dist/cjs/dockview/events.d.ts +2 -1
- package/dist/cjs/dockview/events.js +1 -0
- package/dist/cjs/dockview/options.d.ts +18 -3
- package/dist/cjs/dockview/options.js +1 -0
- package/dist/cjs/dom.js +7 -3
- package/dist/cjs/overlay/overlay.d.ts +12 -0
- package/dist/cjs/overlay/overlay.js +84 -16
- package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +3 -1
- package/dist/cjs/paneview/draggablePaneviewPanel.js +27 -26
- package/dist/cjs/paneview/options.d.ts +4 -3
- package/dist/dockview-core.js +2199 -834
- package/dist/dockview-core.min.js +2 -2
- package/dist/dockview-core.min.js.map +1 -1
- package/dist/dockview-core.min.noStyle.js +2 -2
- package/dist/dockview-core.min.noStyle.js.map +1 -1
- package/dist/dockview-core.noStyle.js +2202 -837
- package/dist/esm/dnd/backend.d.ts +70 -0
- package/dist/esm/dnd/backend.js +148 -0
- package/dist/esm/dnd/dropOverlay.d.ts +20 -0
- package/dist/esm/dnd/dropOverlay.js +192 -0
- package/dist/esm/dnd/droptarget.d.ts +20 -6
- package/dist/esm/dnd/droptarget.js +16 -210
- package/dist/esm/dnd/pointer/index.d.ts +11 -0
- package/dist/esm/dnd/pointer/index.js +5 -0
- package/dist/esm/dnd/pointer/longPress.d.ts +32 -0
- package/dist/esm/dnd/pointer/longPress.js +127 -0
- package/dist/esm/dnd/pointer/pointerDragController.d.ts +60 -0
- package/dist/esm/dnd/pointer/pointerDragController.js +191 -0
- package/dist/esm/dnd/pointer/pointerDragSource.d.ts +61 -0
- package/dist/esm/dnd/pointer/pointerDragSource.js +171 -0
- package/dist/esm/dnd/pointer/pointerDropTarget.d.ts +39 -0
- package/dist/esm/dnd/pointer/pointerDropTarget.js +168 -0
- package/dist/esm/dnd/pointer/pointerGhost.d.ts +30 -0
- package/dist/esm/dnd/pointer/pointerGhost.js +39 -0
- package/dist/esm/dnd/pointer/types.d.ts +16 -0
- package/dist/esm/dnd/pointer/types.js +1 -0
- package/dist/esm/dockview/components/panel/content.d.ts +3 -1
- package/dist/esm/dockview/components/panel/content.js +33 -16
- package/dist/esm/dockview/components/popupService.js +34 -0
- package/dist/esm/dockview/components/tab/tab.d.ts +11 -3
- package/dist/esm/dockview/components/tab/tab.js +139 -114
- package/dist/esm/dockview/components/titlebar/tabGroupChip.d.ts +9 -2
- package/dist/esm/dockview/components/titlebar/tabGroupChip.js +15 -6
- package/dist/esm/dockview/components/titlebar/tabGroups.d.ts +33 -5
- package/dist/esm/dockview/components/titlebar/tabGroups.js +177 -12
- package/dist/esm/dockview/components/titlebar/tabs.d.ts +38 -1
- package/dist/esm/dockview/components/titlebar/tabs.js +348 -227
- package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +5 -3
- package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +6 -2
- package/dist/esm/dockview/components/titlebar/voidContainer.js +179 -31
- package/dist/esm/dockview/contextMenu.js +19 -4
- package/dist/esm/dockview/dndCapabilities.d.ts +19 -0
- package/dist/esm/dockview/dndCapabilities.js +36 -0
- package/dist/esm/dockview/dockviewComponent.d.ts +1 -0
- package/dist/esm/dockview/dockviewComponent.js +55 -34
- package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +9 -5
- package/dist/esm/dockview/dockviewGroupPanelModel.js +24 -11
- package/dist/esm/dockview/events.d.ts +2 -1
- package/dist/esm/dockview/events.js +1 -0
- package/dist/esm/dockview/options.d.ts +18 -3
- package/dist/esm/dockview/options.js +1 -0
- package/dist/esm/dom.js +7 -3
- package/dist/esm/overlay/overlay.d.ts +12 -0
- package/dist/esm/overlay/overlay.js +85 -17
- package/dist/esm/paneview/draggablePaneviewPanel.d.ts +3 -1
- package/dist/esm/paneview/draggablePaneviewPanel.js +26 -20
- package/dist/esm/paneview/options.d.ts +4 -3
- package/dist/package/main.cjs.js +2202 -837
- package/dist/package/main.cjs.min.js +2 -2
- package/dist/package/main.esm.min.mjs +2 -2
- package/dist/package/main.esm.mjs +2202 -837
- package/dist/styles/dockview.css +117 -1
- package/package.json +3 -1
- package/dist/cjs/dnd/abstractDragHandler.d.ts +0 -14
- package/dist/cjs/dnd/abstractDragHandler.js +0 -86
- package/dist/cjs/dnd/groupDragHandler.d.ts +0 -12
- package/dist/cjs/dnd/groupDragHandler.js +0 -104
- package/dist/esm/dnd/abstractDragHandler.d.ts +0 -14
- package/dist/esm/dnd/abstractDragHandler.js +0 -63
- package/dist/esm/dnd/groupDragHandler.d.ts +0 -12
- package/dist/esm/dnd/groupDragHandler.js +0 -81
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IDragSource } from '../../../dnd/backend';
|
|
1
2
|
import { IDisposable, IValueDisposable } from '../../../lifecycle';
|
|
2
3
|
import { DockviewComponent } from '../../dockviewComponent';
|
|
3
4
|
import { DockviewGroupPanel } from '../../dockviewGroupPanel';
|
|
@@ -5,6 +6,7 @@ import { DockviewHeaderDirection } from '../../options';
|
|
|
5
6
|
import { Tab } from '../tab/tab';
|
|
6
7
|
import { ITabGroup } from '../../tabGroup';
|
|
7
8
|
import { ITabGroupChipRenderer } from '../../framework';
|
|
9
|
+
import { Droptarget, DroptargetEvent } from '../../../dnd/droptarget';
|
|
8
10
|
export interface TabGroupManagerContext {
|
|
9
11
|
readonly group: DockviewGroupPanel;
|
|
10
12
|
readonly accessor: DockviewComponent;
|
|
@@ -15,7 +17,21 @@ export interface TabGroupManagerContext {
|
|
|
15
17
|
}
|
|
16
18
|
export interface TabGroupManagerCallbacks {
|
|
17
19
|
onChipContextMenu(tabGroup: ITabGroup, event: MouseEvent): void;
|
|
18
|
-
onChipDragStart(tabGroup: ITabGroup, chip: ITabGroupChipRenderer, event: DragEvent): void;
|
|
20
|
+
onChipDragStart(tabGroup: ITabGroup, chip: ITabGroupChipRenderer, event: DragEvent | PointerEvent): void;
|
|
21
|
+
/**
|
|
22
|
+
* HTML5 chip dragend only. Pointer dragend is handled centrally via
|
|
23
|
+
* `PointerDragController.onDragEnd` in `tabs.ts`.
|
|
24
|
+
*/
|
|
25
|
+
onChipDragEnd?(tabGroup: ITabGroup, chip: ITabGroupChipRenderer, event: DragEvent | PointerEvent): void;
|
|
26
|
+
onChipDrop(tabGroup: ITabGroup, event: DroptargetEvent): void;
|
|
27
|
+
}
|
|
28
|
+
interface ChipRendererEntry {
|
|
29
|
+
chip: ITabGroupChipRenderer;
|
|
30
|
+
/** Created by the manager so it can be toggled live on strategy changes. */
|
|
31
|
+
html5DragSource: IDragSource;
|
|
32
|
+
pointerDragSource: IDragSource;
|
|
33
|
+
disposable: IDisposable;
|
|
34
|
+
dropTarget: Droptarget;
|
|
19
35
|
}
|
|
20
36
|
export declare class TabGroupManager {
|
|
21
37
|
private readonly _ctx;
|
|
@@ -24,10 +40,7 @@ export declare class TabGroupManager {
|
|
|
24
40
|
private _indicator;
|
|
25
41
|
private _skipNextCollapseAnimation;
|
|
26
42
|
private readonly _pendingTransitionCleanups;
|
|
27
|
-
get chipRenderers(): ReadonlyMap<string,
|
|
28
|
-
chip: ITabGroupChipRenderer;
|
|
29
|
-
disposable: IDisposable;
|
|
30
|
-
}>;
|
|
43
|
+
get chipRenderers(): ReadonlyMap<string, ChipRendererEntry>;
|
|
31
44
|
get groupUnderlines(): ReadonlyMap<string, HTMLElement>;
|
|
32
45
|
get skipNextCollapseAnimation(): boolean;
|
|
33
46
|
set skipNextCollapseAnimation(value: boolean);
|
|
@@ -44,14 +57,29 @@ export declare class TabGroupManager {
|
|
|
44
57
|
*/
|
|
45
58
|
refreshAccents(): void;
|
|
46
59
|
positionAllChips(): void;
|
|
60
|
+
updateDirection(): void;
|
|
47
61
|
snapshotChipWidths(): Map<string, number>;
|
|
48
62
|
positionUnderlines(): void;
|
|
49
63
|
trackUnderlines(): void;
|
|
50
64
|
setGroupDragImage(event: DragEvent, tabGroup: ITabGroup, chipEl: HTMLElement): void;
|
|
51
65
|
cleanupTransition(panelId: string): void;
|
|
66
|
+
updateDragAndDropState(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Synchronously dispose the chip drag sources for an in-flight chip
|
|
69
|
+
* drag. Called from `_commitGroupMove` so the transfer payload +
|
|
70
|
+
* iframe shield are released BEFORE the cross-group move detaches
|
|
71
|
+
* the chip (chip dispose is scheduled on a microtask via
|
|
72
|
+
* `_scheduleTabGroupUpdate`, which is too late for callers that read
|
|
73
|
+
* `getPanelData()` synchronously after the move). Idempotent — the
|
|
74
|
+
* subsequent `update()` will also dispose the sources.
|
|
75
|
+
*/
|
|
76
|
+
disposeChipDrag(tabGroupId: string): void;
|
|
77
|
+
/** Cloned chip rect used as the pointer follow-finger ghost. */
|
|
78
|
+
private _buildChipGhostElement;
|
|
52
79
|
disposeAll(): void;
|
|
53
80
|
private _ensureIndicator;
|
|
54
81
|
private _ensureChipForGroup;
|
|
55
82
|
private _positionChipForGroup;
|
|
56
83
|
private _updateTabGroupClasses;
|
|
57
84
|
}
|
|
85
|
+
export {};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { toggleClass } from '../../../dom';
|
|
2
2
|
import { addDisposableListener } from '../../../events';
|
|
3
|
+
import { LocalSelectionTransfer, PanelTransfer, } from '../../../dnd/dataTransfer';
|
|
4
|
+
import { html5Backend, pointerBackend, } from '../../../dnd/backend';
|
|
5
|
+
import { LongPressDetector } from '../../../dnd/pointer/longPress';
|
|
3
6
|
import { CompositeDisposable, } from '../../../lifecycle';
|
|
7
|
+
import { resolveDndCapabilities } from '../../dndCapabilities';
|
|
4
8
|
import { applyTabGroupAccent } from '../../tabGroupAccent';
|
|
5
9
|
import { TabGroupChip } from './tabGroupChip';
|
|
10
|
+
import { Droptarget } from '../../../dnd/droptarget';
|
|
11
|
+
import { getPanelData } from '../../../dnd/dataTransfer';
|
|
6
12
|
import { NoneTabGroupIndicator, WrapTabGroupIndicator, } from './tabGroupIndicator';
|
|
7
13
|
const EMPTY_MAP = new Map();
|
|
8
14
|
export class TabGroupManager {
|
|
@@ -74,6 +80,12 @@ export class TabGroupManager {
|
|
|
74
80
|
this._positionChipForGroup(tabGroup);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
83
|
+
updateDirection() {
|
|
84
|
+
const isVertical = this._ctx.getDirection() === 'vertical';
|
|
85
|
+
for (const [, entry] of this._chipRenderers) {
|
|
86
|
+
entry.dropTarget.setTargetZones(isVertical ? ['top'] : ['left']);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
77
89
|
snapshotChipWidths() {
|
|
78
90
|
const widths = new Map();
|
|
79
91
|
for (const [groupId, entry] of this._chipRenderers) {
|
|
@@ -167,6 +179,45 @@ export class TabGroupManager {
|
|
|
167
179
|
(_a = this._pendingTransitionCleanups.get(panelId)) === null || _a === void 0 ? void 0 : _a();
|
|
168
180
|
this._pendingTransitionCleanups.delete(panelId);
|
|
169
181
|
}
|
|
182
|
+
updateDragAndDropState() {
|
|
183
|
+
const caps = resolveDndCapabilities(this._ctx.accessor.options);
|
|
184
|
+
for (const entry of this._chipRenderers.values()) {
|
|
185
|
+
entry.chip.element.draggable = caps.html5;
|
|
186
|
+
entry.html5DragSource.setDisabled(!caps.html5);
|
|
187
|
+
entry.pointerDragSource.setDisabled(!caps.pointer);
|
|
188
|
+
entry.pointerDragSource.setTouchOnly(!caps.pointerHandlesMouse);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Synchronously dispose the chip drag sources for an in-flight chip
|
|
193
|
+
* drag. Called from `_commitGroupMove` so the transfer payload +
|
|
194
|
+
* iframe shield are released BEFORE the cross-group move detaches
|
|
195
|
+
* the chip (chip dispose is scheduled on a microtask via
|
|
196
|
+
* `_scheduleTabGroupUpdate`, which is too late for callers that read
|
|
197
|
+
* `getPanelData()` synchronously after the move). Idempotent — the
|
|
198
|
+
* subsequent `update()` will also dispose the sources.
|
|
199
|
+
*/
|
|
200
|
+
disposeChipDrag(tabGroupId) {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
const entry = this._chipRenderers.get(tabGroupId);
|
|
203
|
+
if (!entry) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
// Optional-chained because tests may inject minimal entries
|
|
207
|
+
// that skip the manager's normal `_ensureChipForGroup` flow.
|
|
208
|
+
(_a = entry.html5DragSource) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
209
|
+
(_b = entry.pointerDragSource) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
210
|
+
}
|
|
211
|
+
/** Cloned chip rect used as the pointer follow-finger ghost. */
|
|
212
|
+
_buildChipGhostElement(chipEl) {
|
|
213
|
+
const style = getComputedStyle(chipEl);
|
|
214
|
+
const clone = chipEl.cloneNode(true);
|
|
215
|
+
Array.from(style).forEach((key) => {
|
|
216
|
+
clone.style.setProperty(key, style.getPropertyValue(key), style.getPropertyPriority(key));
|
|
217
|
+
});
|
|
218
|
+
clone.style.position = 'absolute';
|
|
219
|
+
return clone;
|
|
220
|
+
}
|
|
170
221
|
disposeAll() {
|
|
171
222
|
var _a;
|
|
172
223
|
(_a = this._indicator) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
@@ -212,6 +263,74 @@ export class TabGroupManager {
|
|
|
212
263
|
? createChip(tabGroup)
|
|
213
264
|
: new TabGroupChip(this._ctx.accessor.tabGroupColorPalette);
|
|
214
265
|
chip.init({ tabGroup, api: this._ctx.accessor.api });
|
|
266
|
+
const caps = resolveDndCapabilities(this._ctx.accessor.options);
|
|
267
|
+
chip.element.draggable = caps.html5;
|
|
268
|
+
const panelTransfer = LocalSelectionTransfer.getInstance();
|
|
269
|
+
// Shared `getData` for both backends. Sets a group-level
|
|
270
|
+
// PanelTransfer (panelId=null, tabGroupId identifies the group).
|
|
271
|
+
// The returned disposer clears it on drag end.
|
|
272
|
+
const getData = () => {
|
|
273
|
+
panelTransfer.setData([
|
|
274
|
+
new PanelTransfer(this._ctx.accessor.id, this._ctx.group.id, null, tabGroup.id),
|
|
275
|
+
], PanelTransfer.prototype);
|
|
276
|
+
return {
|
|
277
|
+
dispose: () => {
|
|
278
|
+
panelTransfer.clearData(PanelTransfer.prototype);
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
// The chip's HTML5 drag image is the cloned tabs list (chip only),
|
|
283
|
+
// mounted inside the dockview root for CSS-variable inheritance and
|
|
284
|
+
// positioned against the chip's in-place rect. Layout-dependent
|
|
285
|
+
// offset means we set the drag image directly in `onDragStart`
|
|
286
|
+
// (inside the dragstart handler) rather than via the generic
|
|
287
|
+
// `createGhost` factory, which only knows about ghost specs that
|
|
288
|
+
// can be appended to `document.body`.
|
|
289
|
+
const html5DragSource = html5Backend.createDragSource(chip.element, {
|
|
290
|
+
getData,
|
|
291
|
+
disabled: !caps.html5,
|
|
292
|
+
isCancelled: () => !resolveDndCapabilities(this._ctx.accessor.options).html5,
|
|
293
|
+
onDragStart: (event) => {
|
|
294
|
+
// Type guard via `dataTransfer` — `instanceof DragEvent`
|
|
295
|
+
// would throw in jsdom which doesn't ship a DragEvent
|
|
296
|
+
// constructor.
|
|
297
|
+
if ('dataTransfer' in event && event.dataTransfer) {
|
|
298
|
+
this.setGroupDragImage(event, tabGroup, chip.element);
|
|
299
|
+
}
|
|
300
|
+
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
301
|
+
},
|
|
302
|
+
onDragEnd: (event) => {
|
|
303
|
+
var _a, _b;
|
|
304
|
+
(_b = (_a = this._callbacks).onChipDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, tabGroup, chip, event);
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
// Synchronous panelTransfer cleanup directly on the chip element.
|
|
308
|
+
// `Html5DragSource`'s dragend defers data disposal via `setTimeout(0)`
|
|
309
|
+
// so drop handlers can read the payload — but a chip drag that
|
|
310
|
+
// ends via `moveGroupOrPanel` (no actual drop event) needs the
|
|
311
|
+
// singleton cleared immediately, otherwise a synchronous
|
|
312
|
+
// `getPanelData()` after the move still sees the stale chip
|
|
313
|
+
// payload. Attached directly (not via `addDisposableListener`) so
|
|
314
|
+
// the listener survives chip disposal in the detach-then-dragend
|
|
315
|
+
// cross-group path; `once: true` auto-removes after the single
|
|
316
|
+
// dragend that we care about. (#1254)
|
|
317
|
+
chip.element.addEventListener('dragend', () => {
|
|
318
|
+
panelTransfer.clearData(PanelTransfer.prototype);
|
|
319
|
+
}, { once: true });
|
|
320
|
+
const pointerDragSource = pointerBackend.createDragSource(chip.element, {
|
|
321
|
+
getData,
|
|
322
|
+
disabled: !caps.pointer,
|
|
323
|
+
touchOnly: !caps.pointerHandlesMouse,
|
|
324
|
+
isCancelled: () => !resolveDndCapabilities(this._ctx.accessor.options).pointer,
|
|
325
|
+
createGhost: () => ({
|
|
326
|
+
element: this._buildChipGhostElement(chip.element),
|
|
327
|
+
offsetX: 8,
|
|
328
|
+
offsetY: 8,
|
|
329
|
+
}),
|
|
330
|
+
onDragStart: (event) => {
|
|
331
|
+
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
332
|
+
},
|
|
333
|
+
});
|
|
215
334
|
const disposables = [
|
|
216
335
|
tabGroup.onDidChange(() => {
|
|
217
336
|
var _a;
|
|
@@ -225,24 +344,70 @@ export class TabGroupManager {
|
|
|
225
344
|
tabGroup.onDidCollapseChange(() => {
|
|
226
345
|
this._updateTabGroupClasses();
|
|
227
346
|
}),
|
|
347
|
+
html5DragSource,
|
|
348
|
+
pointerDragSource,
|
|
228
349
|
];
|
|
229
|
-
//
|
|
350
|
+
// Context menu: built-in TabGroupChip already aggregates right-click
|
|
351
|
+
// + touch long-press into `onContextMenu`. Custom chip renderers
|
|
352
|
+
// don't, so attach a long-press detector and contextmenu listener
|
|
353
|
+
// directly on their element.
|
|
354
|
+
const onContextMenu = (event) => {
|
|
355
|
+
// A long-press on a chip should preempt the in-flight pointer
|
|
356
|
+
// drag and open the menu instead.
|
|
357
|
+
pointerDragSource.cancelPending();
|
|
358
|
+
this._callbacks.onChipContextMenu(tabGroup, event);
|
|
359
|
+
};
|
|
230
360
|
if (chip instanceof TabGroupChip) {
|
|
231
|
-
disposables.push(chip.onContextMenu(
|
|
232
|
-
this._callbacks.onChipContextMenu(tabGroup, event);
|
|
233
|
-
}), chip.onDragStart((event) => {
|
|
234
|
-
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
235
|
-
}));
|
|
361
|
+
disposables.push(chip.onContextMenu(onContextMenu));
|
|
236
362
|
}
|
|
237
363
|
else {
|
|
238
|
-
disposables.push(
|
|
239
|
-
|
|
240
|
-
}), addDisposableListener(chip.element, '
|
|
241
|
-
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
242
|
-
}));
|
|
364
|
+
disposables.push(new LongPressDetector(chip.element, {
|
|
365
|
+
onLongPress: onContextMenu,
|
|
366
|
+
}), addDisposableListener(chip.element, 'contextmenu', onContextMenu));
|
|
243
367
|
}
|
|
368
|
+
// The chip sits before its group's first tab in the DOM, so it
|
|
369
|
+
// covers the "drop before the group" position. Without a drop
|
|
370
|
+
// target here, dropping a tab over the chip is a dead zone —
|
|
371
|
+
// particularly visible when the group is first in the tabs list
|
|
372
|
+
// and there's no preceding tab whose right zone covers position 0.
|
|
373
|
+
// The smooth animation path already shifts the chip's margin to
|
|
374
|
+
// open a gap, so suppress the overlay in that mode.
|
|
375
|
+
const isVertical = this._ctx.getDirection() === 'vertical';
|
|
376
|
+
const dropTarget = new Droptarget(chip.element, {
|
|
377
|
+
acceptedTargetZones: isVertical ? ['top'] : ['left'],
|
|
378
|
+
overlayModel: {
|
|
379
|
+
activationSize: { value: 100, type: 'percentage' },
|
|
380
|
+
},
|
|
381
|
+
canDisplayOverlay: (event, position) => {
|
|
382
|
+
var _a;
|
|
383
|
+
if (this._ctx.group.locked) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
if (this._ctx.accessor.options.disableDnd) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
const data = getPanelData();
|
|
390
|
+
if (data && this._ctx.accessor.id === data.viewId) {
|
|
391
|
+
if (((_a = this._ctx.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) ===
|
|
392
|
+
'smooth') {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
return this._ctx.group.model.canDisplayOverlay(event, position, 'tab');
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
disposables.push(dropTarget, dropTarget.onDrop((event) => {
|
|
401
|
+
this._callbacks.onChipDrop(tabGroup, event);
|
|
402
|
+
}));
|
|
244
403
|
const disposable = new CompositeDisposable(...disposables);
|
|
245
|
-
this._chipRenderers.set(tabGroup.id, {
|
|
404
|
+
this._chipRenderers.set(tabGroup.id, {
|
|
405
|
+
chip,
|
|
406
|
+
html5DragSource,
|
|
407
|
+
pointerDragSource,
|
|
408
|
+
disposable,
|
|
409
|
+
dropTarget,
|
|
410
|
+
});
|
|
246
411
|
// Group is born collapsed (cross-group drop, layout restore, etc.):
|
|
247
412
|
// its tabs are about to be added without the collapsed class. Skip
|
|
248
413
|
// the animation in the upcoming _updateTabGroupClasses call so they
|
|
@@ -26,7 +26,7 @@ export declare class Tabs extends CompositeDisposable {
|
|
|
26
26
|
private _voidContainer;
|
|
27
27
|
private _voidContainerListeners;
|
|
28
28
|
private _extendedDropZone;
|
|
29
|
-
private
|
|
29
|
+
private _pointerInsideTabsList;
|
|
30
30
|
private readonly _tabGroupManager;
|
|
31
31
|
private readonly _onTabDragStart;
|
|
32
32
|
readonly onTabDragStart: Event<TabDragEvent>;
|
|
@@ -72,7 +72,22 @@ export declare class Tabs extends CompositeDisposable {
|
|
|
72
72
|
*/
|
|
73
73
|
updateTabGroups(): void;
|
|
74
74
|
refreshTabGroupAccent(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Tabs-list-specific side effects of a chip drag start. The chip's
|
|
77
|
+
* drag sources (constructed by `TabGroupManager`) own the transfer
|
|
78
|
+
* payload, iframe shielding, dataTransfer setup, and the HTML5 drag
|
|
79
|
+
* image. This method just sets up the smooth-reorder anim state and
|
|
80
|
+
* collapses the source-group tabs in the tabs list.
|
|
81
|
+
*/
|
|
75
82
|
private _handleChipDragStart;
|
|
83
|
+
/**
|
|
84
|
+
* A drop on a tab group chip means "insert before this group". Resolve to
|
|
85
|
+
* the index of the group's first tab, adjusting for same-group removal
|
|
86
|
+
* (when the source tab is currently to the left of the target slot, its
|
|
87
|
+
* removal shifts the insertion index down by one). Always clears
|
|
88
|
+
* `targetTabGroupId` so the dropped tab lands outside the group.
|
|
89
|
+
*/
|
|
90
|
+
private _handleChipDrop;
|
|
76
91
|
/**
|
|
77
92
|
* Sets the broader container that is part of the same logical drop surface
|
|
78
93
|
* as this tab list (e.g. the full header element). When a dragleave from
|
|
@@ -94,6 +109,28 @@ export declare class Tabs extends CompositeDisposable {
|
|
|
94
109
|
clearExternalAnimState(): void;
|
|
95
110
|
private snapshotTabPositions;
|
|
96
111
|
private getAverageTabWidth;
|
|
112
|
+
/**
|
|
113
|
+
* Pointer-event entry point. The HTML5 path enters via the per-element
|
|
114
|
+
* `dragover` listener; this one hit-tests the global pointer-drag
|
|
115
|
+
* position against the tabs list and routes through the same shared
|
|
116
|
+
* `_processDragOver` / `_processDragLeave` helpers.
|
|
117
|
+
*/
|
|
118
|
+
private _handlePointerDragMove;
|
|
119
|
+
/**
|
|
120
|
+
* Shared body of the dragover entry point. Refreshes stale anim state
|
|
121
|
+
* for a changed drag identity, initializes anim state for incoming
|
|
122
|
+
* cross-group drags, and dispatches to the gap-following math in
|
|
123
|
+
* `handleDragOver`. Returns true when this tabs list has taken
|
|
124
|
+
* ownership of the drag — HTML5 callers use this to gate
|
|
125
|
+
* `event.preventDefault()`.
|
|
126
|
+
*/
|
|
127
|
+
private _processDragOver;
|
|
128
|
+
/**
|
|
129
|
+
* Shared body of the dragleave entry point. Preserves anim state when
|
|
130
|
+
* the drag moves between tabs-list children, into the extended drop
|
|
131
|
+
* zone, or into the void container; tears it down otherwise.
|
|
132
|
+
*/
|
|
133
|
+
private _processDragLeave;
|
|
97
134
|
private handleDragOver;
|
|
98
135
|
/**
|
|
99
136
|
* Batch-remove a CSS class from multiple elements instantly,
|