dockview-core 6.3.0 → 6.4.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
package/dist/package/main.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview-core
|
|
3
|
-
* @version 6.
|
|
3
|
+
* @version 6.4.0
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -547,7 +547,7 @@ function addTestId(element, id) {
|
|
|
547
547
|
* Should be more efficient than element.querySelectorAll("*") since there
|
|
548
548
|
* is no need to store every element in-memory using this approach
|
|
549
549
|
*/
|
|
550
|
-
function allTagsNamesInclusiveOfShadowDoms(tagNames) {
|
|
550
|
+
function allTagsNamesInclusiveOfShadowDoms(tagNames, rootNode) {
|
|
551
551
|
const iframes = [];
|
|
552
552
|
function findIframesInNode(node) {
|
|
553
553
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -562,11 +562,15 @@ function allTagsNamesInclusiveOfShadowDoms(tagNames) {
|
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
|
|
565
|
+
// Document → walk from its root element. Element → walk from itself.
|
|
566
|
+
const startEl = rootNode instanceof Document
|
|
567
|
+
? rootNode.documentElement
|
|
568
|
+
: rootNode;
|
|
569
|
+
findIframesInNode(startEl);
|
|
566
570
|
return iframes;
|
|
567
571
|
}
|
|
568
572
|
function disableIframePointEvents(rootNode = document) {
|
|
569
|
-
const iframes = allTagsNamesInclusiveOfShadowDoms(['IFRAME', 'WEBVIEW']);
|
|
573
|
+
const iframes = allTagsNamesInclusiveOfShadowDoms(['IFRAME', 'WEBVIEW'], rootNode);
|
|
570
574
|
const original = new WeakMap(); // don't hold onto HTMLElement references longer than required
|
|
571
575
|
for (const iframe of iframes) {
|
|
572
576
|
original.set(iframe, iframe.style.pointerEvents);
|
|
@@ -3986,67 +3990,6 @@ class DockviewApi {
|
|
|
3986
3990
|
}
|
|
3987
3991
|
}
|
|
3988
3992
|
|
|
3989
|
-
class DragHandler extends CompositeDisposable {
|
|
3990
|
-
constructor(el, disabled) {
|
|
3991
|
-
super();
|
|
3992
|
-
this.el = el;
|
|
3993
|
-
this.disabled = disabled;
|
|
3994
|
-
this.dataDisposable = new MutableDisposable();
|
|
3995
|
-
this.pointerEventsDisposable = new MutableDisposable();
|
|
3996
|
-
this._onDragStart = new Emitter();
|
|
3997
|
-
this.onDragStart = this._onDragStart.event;
|
|
3998
|
-
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
3999
|
-
this.configure();
|
|
4000
|
-
}
|
|
4001
|
-
setDisabled(disabled) {
|
|
4002
|
-
this.disabled = disabled;
|
|
4003
|
-
}
|
|
4004
|
-
isCancelled(_event) {
|
|
4005
|
-
return false;
|
|
4006
|
-
}
|
|
4007
|
-
configure() {
|
|
4008
|
-
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
4009
|
-
if (event.defaultPrevented ||
|
|
4010
|
-
this.isCancelled(event) ||
|
|
4011
|
-
this.disabled) {
|
|
4012
|
-
event.preventDefault();
|
|
4013
|
-
return;
|
|
4014
|
-
}
|
|
4015
|
-
const iframes = disableIframePointEvents();
|
|
4016
|
-
this.pointerEventsDisposable.value = {
|
|
4017
|
-
dispose: () => {
|
|
4018
|
-
iframes.release();
|
|
4019
|
-
},
|
|
4020
|
-
};
|
|
4021
|
-
this.el.classList.add('dv-dragged');
|
|
4022
|
-
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
4023
|
-
this.dataDisposable.value = this.getData(event);
|
|
4024
|
-
this._onDragStart.fire(event);
|
|
4025
|
-
if (event.dataTransfer) {
|
|
4026
|
-
event.dataTransfer.effectAllowed = 'move';
|
|
4027
|
-
const hasData = event.dataTransfer.items.length > 0;
|
|
4028
|
-
if (!hasData) {
|
|
4029
|
-
/**
|
|
4030
|
-
* Although this is not used by dockview many third party dnd libraries will check
|
|
4031
|
-
* dataTransfer.types to determine valid drag events.
|
|
4032
|
-
*
|
|
4033
|
-
* For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
|
|
4034
|
-
* through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
|
|
4035
|
-
* dnd logic. You can see the code at
|
|
4036
|
-
P * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
|
|
4037
|
-
*/
|
|
4038
|
-
event.dataTransfer.setData('text/plain', '');
|
|
4039
|
-
}
|
|
4040
|
-
}
|
|
4041
|
-
}), addDisposableListener(this.el, 'dragend', () => {
|
|
4042
|
-
this.pointerEventsDisposable.dispose();
|
|
4043
|
-
setTimeout(() => {
|
|
4044
|
-
this.dataDisposable.dispose(); // allow the data to be read by other handlers before disposing
|
|
4045
|
-
}, 0);
|
|
4046
|
-
}));
|
|
4047
|
-
}
|
|
4048
|
-
}
|
|
4049
|
-
|
|
4050
3993
|
class DragAndDropObserver extends CompositeDisposable {
|
|
4051
3994
|
constructor(element, callbacks) {
|
|
4052
3995
|
super();
|
|
@@ -4097,48 +4040,197 @@ class DragAndDropObserver extends CompositeDisposable {
|
|
|
4097
4040
|
}
|
|
4098
4041
|
}
|
|
4099
4042
|
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
const
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4043
|
+
// Two render paths: in-place (dropzone appended to drop element) and
|
|
4044
|
+
// anchored (overlay rendered into an external anchor container).
|
|
4045
|
+
const DEFAULT_SIZE = { value: 50, type: 'percentage' };
|
|
4046
|
+
const SMALL_WIDTH_BOUNDARY = 100;
|
|
4047
|
+
const SMALL_HEIGHT_BOUNDARY = 100;
|
|
4048
|
+
function createOverlayElements() {
|
|
4049
|
+
const dropzone = document.createElement('div');
|
|
4050
|
+
dropzone.className = 'dv-drop-target-dropzone';
|
|
4051
|
+
const selection = document.createElement('div');
|
|
4052
|
+
selection.className = 'dv-drop-target-selection';
|
|
4053
|
+
dropzone.appendChild(selection);
|
|
4054
|
+
return { dropzone, selection };
|
|
4055
|
+
}
|
|
4056
|
+
function computeOverlayShape(quadrant, width, height, overlayModel) {
|
|
4057
|
+
var _a, _b, _c;
|
|
4058
|
+
const smallWidthBoundary = (_a = overlayModel === null || overlayModel === void 0 ? void 0 : overlayModel.smallWidthBoundary) !== null && _a !== void 0 ? _a : SMALL_WIDTH_BOUNDARY;
|
|
4059
|
+
const smallHeightBoundary = (_b = overlayModel === null || overlayModel === void 0 ? void 0 : overlayModel.smallHeightBoundary) !== null && _b !== void 0 ? _b : SMALL_HEIGHT_BOUNDARY;
|
|
4060
|
+
const isSmallX = width < smallWidthBoundary;
|
|
4061
|
+
const isSmallY = height < smallHeightBoundary;
|
|
4062
|
+
const isLeft = quadrant === 'left';
|
|
4063
|
+
const isRight = quadrant === 'right';
|
|
4064
|
+
const isTop = quadrant === 'top';
|
|
4065
|
+
const isBottom = quadrant === 'bottom';
|
|
4066
|
+
const rightClass = !isSmallX && isRight;
|
|
4067
|
+
const leftClass = !isSmallX && isLeft;
|
|
4068
|
+
const topClass = !isSmallY && isTop;
|
|
4069
|
+
const bottomClass = !isSmallY && isBottom;
|
|
4070
|
+
let size = 1;
|
|
4071
|
+
const sizeOptions = (_c = overlayModel === null || overlayModel === void 0 ? void 0 : overlayModel.size) !== null && _c !== void 0 ? _c : DEFAULT_SIZE;
|
|
4072
|
+
if (sizeOptions.type === 'percentage') {
|
|
4073
|
+
size = clamp(sizeOptions.value, 0, 100) / 100;
|
|
4074
|
+
}
|
|
4075
|
+
else {
|
|
4076
|
+
if (rightClass || leftClass) {
|
|
4077
|
+
size = clamp(0, sizeOptions.value, width) / width;
|
|
4078
|
+
}
|
|
4079
|
+
if (topClass || bottomClass) {
|
|
4080
|
+
size = clamp(0, sizeOptions.value, height) / height;
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
return {
|
|
4084
|
+
isSmallX,
|
|
4085
|
+
isSmallY,
|
|
4086
|
+
isLeft,
|
|
4087
|
+
isRight,
|
|
4088
|
+
isTop,
|
|
4089
|
+
isBottom,
|
|
4090
|
+
rightClass,
|
|
4091
|
+
leftClass,
|
|
4092
|
+
topClass,
|
|
4093
|
+
bottomClass,
|
|
4094
|
+
size,
|
|
4095
|
+
};
|
|
4096
|
+
}
|
|
4097
|
+
function renderInPlaceOverlay(overlay, quadrant, width, height, overlayModel) {
|
|
4098
|
+
const shape = computeOverlayShape(quadrant, width, height, overlayModel);
|
|
4099
|
+
const { rightClass, leftClass, topClass, bottomClass, size } = shape;
|
|
4100
|
+
const box = { top: '0px', left: '0px', width: '100%', height: '100%' };
|
|
4101
|
+
if (rightClass) {
|
|
4102
|
+
box.left = `${100 * (1 - size)}%`;
|
|
4103
|
+
box.width = `${100 * size}%`;
|
|
4104
|
+
}
|
|
4105
|
+
else if (leftClass) {
|
|
4106
|
+
box.width = `${100 * size}%`;
|
|
4107
|
+
}
|
|
4108
|
+
else if (topClass) {
|
|
4109
|
+
box.height = `${100 * size}%`;
|
|
4110
|
+
}
|
|
4111
|
+
else if (bottomClass) {
|
|
4112
|
+
box.top = `${100 * (1 - size)}%`;
|
|
4113
|
+
box.height = `${100 * size}%`;
|
|
4114
|
+
}
|
|
4115
|
+
if (shape.isSmallX && shape.isLeft) {
|
|
4116
|
+
box.width = '4px';
|
|
4117
|
+
}
|
|
4118
|
+
if (shape.isSmallX && shape.isRight) {
|
|
4119
|
+
box.left = `${width - 4}px`;
|
|
4120
|
+
box.width = '4px';
|
|
4121
|
+
}
|
|
4122
|
+
if (shape.isSmallY && shape.isTop) {
|
|
4123
|
+
box.height = '4px';
|
|
4124
|
+
}
|
|
4125
|
+
if (shape.isSmallY && shape.isBottom) {
|
|
4126
|
+
box.top = `${height - 4}px`;
|
|
4127
|
+
box.height = '4px';
|
|
4128
|
+
}
|
|
4129
|
+
overlay.style.top = box.top;
|
|
4130
|
+
overlay.style.left = box.left;
|
|
4131
|
+
overlay.style.width = box.width;
|
|
4132
|
+
overlay.style.height = box.height;
|
|
4133
|
+
overlay.style.visibility = 'visible';
|
|
4134
|
+
if (!overlay.style.transform || overlay.style.transform === '') {
|
|
4135
|
+
overlay.style.transform = 'translate3d(0, 0, 0)';
|
|
4136
|
+
}
|
|
4137
|
+
const isLine = (shape.isSmallX && (shape.isLeft || shape.isRight)) ||
|
|
4138
|
+
(shape.isSmallY && (shape.isTop || shape.isBottom));
|
|
4139
|
+
toggleClass(overlay, 'dv-drop-target-small-vertical', shape.isSmallY);
|
|
4140
|
+
toggleClass(overlay, 'dv-drop-target-small-horizontal', shape.isSmallX);
|
|
4141
|
+
toggleClass(overlay, 'dv-drop-target-selection-line', isLine);
|
|
4142
|
+
toggleClass(overlay, 'dv-drop-target-left', shape.isLeft);
|
|
4143
|
+
toggleClass(overlay, 'dv-drop-target-right', shape.isRight);
|
|
4144
|
+
toggleClass(overlay, 'dv-drop-target-top', shape.isTop);
|
|
4145
|
+
toggleClass(overlay, 'dv-drop-target-bottom', shape.isBottom);
|
|
4146
|
+
toggleClass(overlay, 'dv-drop-target-center', quadrant === 'center');
|
|
4147
|
+
}
|
|
4148
|
+
function checkAnchoredBoundsChanged(overlay, bounds) {
|
|
4149
|
+
const topPx = `${Math.round(bounds.top)}px`;
|
|
4150
|
+
const leftPx = `${Math.round(bounds.left)}px`;
|
|
4151
|
+
const widthPx = `${Math.round(bounds.width)}px`;
|
|
4152
|
+
const heightPx = `${Math.round(bounds.height)}px`;
|
|
4153
|
+
return (overlay.style.top !== topPx ||
|
|
4154
|
+
overlay.style.left !== leftPx ||
|
|
4155
|
+
overlay.style.width !== widthPx ||
|
|
4156
|
+
overlay.style.height !== heightPx);
|
|
4157
|
+
}
|
|
4158
|
+
function applyAnchoredBounds(overlay, bounds) {
|
|
4159
|
+
overlay.style.top = `${Math.round(bounds.top)}px`;
|
|
4160
|
+
overlay.style.left = `${Math.round(bounds.left)}px`;
|
|
4161
|
+
overlay.style.width = `${Math.round(bounds.width)}px`;
|
|
4162
|
+
overlay.style.height = `${Math.round(bounds.height)}px`;
|
|
4163
|
+
overlay.style.visibility = 'visible';
|
|
4164
|
+
if (!overlay.style.transform || overlay.style.transform === '') {
|
|
4165
|
+
overlay.style.transform = 'translate3d(0, 0, 0)';
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
/** `boundsChanged: false` lets callers skip redundant work on tight drag loops. */
|
|
4169
|
+
function renderAnchoredOverlay(args) {
|
|
4170
|
+
const shape = computeOverlayShape(args.quadrant, args.width, args.height, args.overlayModel);
|
|
4171
|
+
const { rightClass, leftClass, topClass, bottomClass, size } = shape;
|
|
4172
|
+
const elBox = args.outlineElement.getBoundingClientRect();
|
|
4173
|
+
const ta = args.targetModel.getElements(undefined, args.outlineElement);
|
|
4174
|
+
const el = ta.root;
|
|
4175
|
+
const overlay = ta.overlay;
|
|
4176
|
+
const bigbox = el.getBoundingClientRect();
|
|
4177
|
+
const rootTop = elBox.top - bigbox.top;
|
|
4178
|
+
const rootLeft = elBox.left - bigbox.left;
|
|
4179
|
+
const box = {
|
|
4180
|
+
top: rootTop,
|
|
4181
|
+
left: rootLeft,
|
|
4182
|
+
width: args.width,
|
|
4183
|
+
height: args.height,
|
|
4184
|
+
};
|
|
4185
|
+
if (rightClass) {
|
|
4186
|
+
box.left = rootLeft + args.width * (1 - size);
|
|
4187
|
+
box.width = args.width * size;
|
|
4188
|
+
}
|
|
4189
|
+
else if (leftClass) {
|
|
4190
|
+
box.width = args.width * size;
|
|
4191
|
+
}
|
|
4192
|
+
else if (topClass) {
|
|
4193
|
+
box.height = args.height * size;
|
|
4194
|
+
}
|
|
4195
|
+
else if (bottomClass) {
|
|
4196
|
+
box.top = rootTop + args.height * (1 - size);
|
|
4197
|
+
box.height = args.height * size;
|
|
4198
|
+
}
|
|
4199
|
+
if (shape.isSmallX && shape.isLeft) {
|
|
4200
|
+
box.width = 4;
|
|
4201
|
+
}
|
|
4202
|
+
if (shape.isSmallX && shape.isRight) {
|
|
4203
|
+
box.left = rootLeft + args.width - 4;
|
|
4204
|
+
box.width = 4;
|
|
4205
|
+
}
|
|
4206
|
+
if (shape.isSmallY && shape.isTop) {
|
|
4207
|
+
box.height = 4;
|
|
4208
|
+
}
|
|
4209
|
+
if (shape.isSmallY && shape.isBottom) {
|
|
4210
|
+
box.top = rootTop + args.height - 4;
|
|
4211
|
+
box.height = 4;
|
|
4212
|
+
}
|
|
4213
|
+
if (!checkAnchoredBoundsChanged(overlay, box)) {
|
|
4214
|
+
return { boundsChanged: false, targetChanged: ta.changed };
|
|
4215
|
+
}
|
|
4216
|
+
applyAnchoredBounds(overlay, box);
|
|
4217
|
+
overlay.className = `dv-drop-target-anchor${args.className ? ` ${args.className}` : ''}`;
|
|
4218
|
+
toggleClass(overlay, 'dv-drop-target-left', shape.isLeft);
|
|
4219
|
+
toggleClass(overlay, 'dv-drop-target-right', shape.isRight);
|
|
4220
|
+
toggleClass(overlay, 'dv-drop-target-top', shape.isTop);
|
|
4221
|
+
toggleClass(overlay, 'dv-drop-target-bottom', shape.isBottom);
|
|
4222
|
+
toggleClass(overlay, 'dv-drop-target-anchor-line', (shape.isSmallX && (shape.isLeft || shape.isRight)) ||
|
|
4223
|
+
(shape.isSmallY && (shape.isTop || shape.isBottom)));
|
|
4224
|
+
toggleClass(overlay, 'dv-drop-target-center', args.quadrant === 'center');
|
|
4225
|
+
if (ta.changed) {
|
|
4226
|
+
toggleClass(overlay, 'dv-drop-target-anchor-container-changed', true);
|
|
4227
|
+
setTimeout(() => {
|
|
4228
|
+
toggleClass(overlay, 'dv-drop-target-anchor-container-changed', false);
|
|
4229
|
+
}, 10);
|
|
4230
|
+
}
|
|
4231
|
+
return { boundsChanged: true, targetChanged: ta.changed };
|
|
4141
4232
|
}
|
|
4233
|
+
|
|
4142
4234
|
class WillShowOverlayEvent extends DockviewEvent {
|
|
4143
4235
|
get nativeEvent() {
|
|
4144
4236
|
return this.options.nativeEvent;
|
|
@@ -4183,16 +4275,10 @@ function positionToDirection(position) {
|
|
|
4183
4275
|
throw new Error(`invalid position '${position}'`);
|
|
4184
4276
|
}
|
|
4185
4277
|
}
|
|
4186
|
-
const DEFAULT_ACTIVATION_SIZE = {
|
|
4278
|
+
const DEFAULT_ACTIVATION_SIZE$1 = {
|
|
4187
4279
|
value: 20,
|
|
4188
4280
|
type: 'percentage',
|
|
4189
4281
|
};
|
|
4190
|
-
const DEFAULT_SIZE = {
|
|
4191
|
-
value: 50,
|
|
4192
|
-
type: 'percentage',
|
|
4193
|
-
};
|
|
4194
|
-
const SMALL_WIDTH_BOUNDARY = 100;
|
|
4195
|
-
const SMALL_HEIGHT_BOUNDARY = 100;
|
|
4196
4282
|
class Droptarget extends CompositeDisposable {
|
|
4197
4283
|
get disabled() {
|
|
4198
4284
|
return this._disabled;
|
|
@@ -4273,20 +4359,12 @@ class Droptarget extends CompositeDisposable {
|
|
|
4273
4359
|
this.markAsUsed(e);
|
|
4274
4360
|
if (overrideTarget) ;
|
|
4275
4361
|
else if (!this.targetElement) {
|
|
4276
|
-
|
|
4277
|
-
this.targetElement
|
|
4278
|
-
this.overlayElement =
|
|
4279
|
-
this.overlayElement.className = 'dv-drop-target-selection';
|
|
4362
|
+
const els = createOverlayElements();
|
|
4363
|
+
this.targetElement = els.dropzone;
|
|
4364
|
+
this.overlayElement = els.selection;
|
|
4280
4365
|
this._state = 'center';
|
|
4281
|
-
this.targetElement.appendChild(this.overlayElement);
|
|
4282
4366
|
target.classList.add('dv-drop-target');
|
|
4283
4367
|
target.append(this.targetElement);
|
|
4284
|
-
// this.overlayElement.style.opacity = '0';
|
|
4285
|
-
// requestAnimationFrame(() => {
|
|
4286
|
-
// if (this.overlayElement) {
|
|
4287
|
-
// this.overlayElement.style.opacity = '';
|
|
4288
|
-
// }
|
|
4289
|
-
// });
|
|
4290
4368
|
}
|
|
4291
4369
|
this.toggleClasses(quadrant, width, height);
|
|
4292
4370
|
this._state = quadrant;
|
|
@@ -4356,166 +4434,29 @@ class Droptarget extends CompositeDisposable {
|
|
|
4356
4434
|
return typeof value === 'boolean' && value;
|
|
4357
4435
|
}
|
|
4358
4436
|
toggleClasses(quadrant, width, height) {
|
|
4359
|
-
var _a, _b, _c, _d, _e
|
|
4437
|
+
var _a, _b, _c, _d, _e;
|
|
4360
4438
|
const target = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4361
|
-
if (!target && !this.overlayElement) {
|
|
4362
|
-
return;
|
|
4363
|
-
}
|
|
4364
|
-
const smallWidthBoundary = (_d = (_c = this.options.overlayModel) === null || _c === void 0 ? void 0 : _c.smallWidthBoundary) !== null && _d !== void 0 ? _d : SMALL_WIDTH_BOUNDARY;
|
|
4365
|
-
const smallHeightBoundary = (_f = (_e = this.options.overlayModel) === null || _e === void 0 ? void 0 : _e.smallHeightBoundary) !== null && _f !== void 0 ? _f : SMALL_HEIGHT_BOUNDARY;
|
|
4366
|
-
const isSmallX = width < smallWidthBoundary;
|
|
4367
|
-
const isSmallY = height < smallHeightBoundary;
|
|
4368
|
-
const isLeft = quadrant === 'left';
|
|
4369
|
-
const isRight = quadrant === 'right';
|
|
4370
|
-
const isTop = quadrant === 'top';
|
|
4371
|
-
const isBottom = quadrant === 'bottom';
|
|
4372
|
-
const rightClass = !isSmallX && isRight;
|
|
4373
|
-
const leftClass = !isSmallX && isLeft;
|
|
4374
|
-
const topClass = !isSmallY && isTop;
|
|
4375
|
-
const bottomClass = !isSmallY && isBottom;
|
|
4376
|
-
let size = 1;
|
|
4377
|
-
const sizeOptions = (_h = (_g = this.options.overlayModel) === null || _g === void 0 ? void 0 : _g.size) !== null && _h !== void 0 ? _h : DEFAULT_SIZE;
|
|
4378
|
-
if (sizeOptions.type === 'percentage') {
|
|
4379
|
-
size = clamp(sizeOptions.value, 0, 100) / 100;
|
|
4380
|
-
}
|
|
4381
|
-
else {
|
|
4382
|
-
if (rightClass || leftClass) {
|
|
4383
|
-
size = clamp(0, sizeOptions.value, width) / width;
|
|
4384
|
-
}
|
|
4385
|
-
if (topClass || bottomClass) {
|
|
4386
|
-
size = clamp(0, sizeOptions.value, height) / height;
|
|
4387
|
-
}
|
|
4388
|
-
}
|
|
4389
4439
|
if (target) {
|
|
4390
|
-
const outlineEl = (
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
left: rootLeft,
|
|
4401
|
-
width: width,
|
|
4402
|
-
height: height,
|
|
4403
|
-
};
|
|
4404
|
-
if (rightClass) {
|
|
4405
|
-
box.left = rootLeft + width * (1 - size);
|
|
4406
|
-
box.width = width * size;
|
|
4407
|
-
}
|
|
4408
|
-
else if (leftClass) {
|
|
4409
|
-
box.width = width * size;
|
|
4410
|
-
}
|
|
4411
|
-
else if (topClass) {
|
|
4412
|
-
box.height = height * size;
|
|
4413
|
-
}
|
|
4414
|
-
else if (bottomClass) {
|
|
4415
|
-
box.top = rootTop + height * (1 - size);
|
|
4416
|
-
box.height = height * size;
|
|
4417
|
-
}
|
|
4418
|
-
if (isSmallX && isLeft) {
|
|
4419
|
-
box.width = 4;
|
|
4420
|
-
}
|
|
4421
|
-
if (isSmallX && isRight) {
|
|
4422
|
-
box.left = rootLeft + width - 4;
|
|
4423
|
-
box.width = 4;
|
|
4424
|
-
}
|
|
4425
|
-
if (isSmallY && isTop) {
|
|
4426
|
-
box.height = 4;
|
|
4427
|
-
}
|
|
4428
|
-
if (isSmallY && isBottom) {
|
|
4429
|
-
box.top = rootTop + height - 4;
|
|
4430
|
-
box.height = 4;
|
|
4431
|
-
}
|
|
4432
|
-
// Use GPU-optimized bounds checking and setting
|
|
4433
|
-
if (!checkBoundsChanged(overlay, box)) {
|
|
4434
|
-
return;
|
|
4435
|
-
}
|
|
4436
|
-
setGPUOptimizedBounds(overlay, box);
|
|
4437
|
-
overlay.className = `dv-drop-target-anchor${this.options.className ? ` ${this.options.className}` : ''}`;
|
|
4438
|
-
toggleClass(overlay, 'dv-drop-target-left', isLeft);
|
|
4439
|
-
toggleClass(overlay, 'dv-drop-target-right', isRight);
|
|
4440
|
-
toggleClass(overlay, 'dv-drop-target-top', isTop);
|
|
4441
|
-
toggleClass(overlay, 'dv-drop-target-bottom', isBottom);
|
|
4442
|
-
toggleClass(overlay, 'dv-drop-target-anchor-line', (isSmallX && (isLeft || isRight)) ||
|
|
4443
|
-
(isSmallY && (isTop || isBottom)));
|
|
4444
|
-
toggleClass(overlay, 'dv-drop-target-center', quadrant === 'center');
|
|
4445
|
-
if (ta.changed) {
|
|
4446
|
-
toggleClass(overlay, 'dv-drop-target-anchor-container-changed', true);
|
|
4447
|
-
setTimeout(() => {
|
|
4448
|
-
toggleClass(overlay, 'dv-drop-target-anchor-container-changed', false);
|
|
4449
|
-
}, 10);
|
|
4450
|
-
}
|
|
4440
|
+
const outlineEl = (_e = (_d = (_c = this.options).getOverlayOutline) === null || _d === void 0 ? void 0 : _d.call(_c)) !== null && _e !== void 0 ? _e : this.element;
|
|
4441
|
+
renderAnchoredOverlay({
|
|
4442
|
+
outlineElement: outlineEl,
|
|
4443
|
+
targetModel: target,
|
|
4444
|
+
quadrant,
|
|
4445
|
+
width,
|
|
4446
|
+
height,
|
|
4447
|
+
overlayModel: this.options.overlayModel,
|
|
4448
|
+
className: this.options.className,
|
|
4449
|
+
});
|
|
4451
4450
|
return;
|
|
4452
4451
|
}
|
|
4453
4452
|
if (!this.overlayElement) {
|
|
4454
4453
|
return;
|
|
4455
4454
|
}
|
|
4456
|
-
|
|
4457
|
-
/**
|
|
4458
|
-
* You can also achieve the overlay placement using the transform CSS property
|
|
4459
|
-
* to translate and scale the element however this has the undesired effect of
|
|
4460
|
-
* 'skewing' the element. Comment left here for anybody that ever revisits this.
|
|
4461
|
-
*
|
|
4462
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
|
|
4463
|
-
*
|
|
4464
|
-
* right
|
|
4465
|
-
* translateX(${100 * (1 - size) / 2}%) scaleX(${scale})
|
|
4466
|
-
*
|
|
4467
|
-
* left
|
|
4468
|
-
* translateX(-${100 * (1 - size) / 2}%) scaleX(${scale})
|
|
4469
|
-
*
|
|
4470
|
-
* top
|
|
4471
|
-
* translateY(-${100 * (1 - size) / 2}%) scaleY(${scale})
|
|
4472
|
-
*
|
|
4473
|
-
* bottom
|
|
4474
|
-
* translateY(${100 * (1 - size) / 2}%) scaleY(${scale})
|
|
4475
|
-
*/
|
|
4476
|
-
if (rightClass) {
|
|
4477
|
-
box.left = `${100 * (1 - size)}%`;
|
|
4478
|
-
box.width = `${100 * size}%`;
|
|
4479
|
-
}
|
|
4480
|
-
else if (leftClass) {
|
|
4481
|
-
box.width = `${100 * size}%`;
|
|
4482
|
-
}
|
|
4483
|
-
else if (topClass) {
|
|
4484
|
-
box.height = `${100 * size}%`;
|
|
4485
|
-
}
|
|
4486
|
-
else if (bottomClass) {
|
|
4487
|
-
box.top = `${100 * (1 - size)}%`;
|
|
4488
|
-
box.height = `${100 * size}%`;
|
|
4489
|
-
}
|
|
4490
|
-
if (isSmallX && isLeft) {
|
|
4491
|
-
box.width = '4px';
|
|
4492
|
-
}
|
|
4493
|
-
if (isSmallX && isRight) {
|
|
4494
|
-
box.left = `${width - 4}px`;
|
|
4495
|
-
box.width = '4px';
|
|
4496
|
-
}
|
|
4497
|
-
if (isSmallY && isTop) {
|
|
4498
|
-
box.height = '4px';
|
|
4499
|
-
}
|
|
4500
|
-
if (isSmallY && isBottom) {
|
|
4501
|
-
box.top = `${height - 4}px`;
|
|
4502
|
-
box.height = '4px';
|
|
4503
|
-
}
|
|
4504
|
-
setGPUOptimizedBoundsFromStrings(this.overlayElement, box);
|
|
4505
|
-
const isLine = (isSmallX && (isLeft || isRight)) ||
|
|
4506
|
-
(isSmallY && (isTop || isBottom));
|
|
4507
|
-
toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
|
|
4508
|
-
toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
|
|
4509
|
-
toggleClass(this.overlayElement, 'dv-drop-target-selection-line', isLine);
|
|
4510
|
-
toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
|
|
4511
|
-
toggleClass(this.overlayElement, 'dv-drop-target-right', isRight);
|
|
4512
|
-
toggleClass(this.overlayElement, 'dv-drop-target-top', isTop);
|
|
4513
|
-
toggleClass(this.overlayElement, 'dv-drop-target-bottom', isBottom);
|
|
4514
|
-
toggleClass(this.overlayElement, 'dv-drop-target-center', quadrant === 'center');
|
|
4455
|
+
renderInPlaceOverlay(this.overlayElement, quadrant, width, height, this.options.overlayModel);
|
|
4515
4456
|
}
|
|
4516
4457
|
calculateQuadrant(overlayType, x, y, width, height) {
|
|
4517
4458
|
var _a, _b;
|
|
4518
|
-
const activationSizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) !== null && _b !== void 0 ? _b : DEFAULT_ACTIVATION_SIZE;
|
|
4459
|
+
const activationSizeOptions = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) !== null && _b !== void 0 ? _b : DEFAULT_ACTIVATION_SIZE$1;
|
|
4519
4460
|
const isPercentage = activationSizeOptions.type === 'percentage';
|
|
4520
4461
|
if (isPercentage) {
|
|
4521
4462
|
return calculateQuadrantAsPercentage(overlayType, x, y, width, height, activationSizeOptions.value);
|
|
@@ -4573,6 +4514,723 @@ function calculateQuadrantAsPixels(overlayType, x, y, width, height, threshold)
|
|
|
4573
4514
|
return 'center';
|
|
4574
4515
|
}
|
|
4575
4516
|
|
|
4517
|
+
function addGhostImage(dataTransfer, ghostElement, options) {
|
|
4518
|
+
var _a, _b;
|
|
4519
|
+
// class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
|
|
4520
|
+
addClasses(ghostElement, 'dv-dragged');
|
|
4521
|
+
// move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
|
|
4522
|
+
ghostElement.style.top = '-9999px';
|
|
4523
|
+
document.body.appendChild(ghostElement);
|
|
4524
|
+
dataTransfer.setDragImage(ghostElement, (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0);
|
|
4525
|
+
setTimeout(() => {
|
|
4526
|
+
removeClasses(ghostElement, 'dv-dragged');
|
|
4527
|
+
ghostElement.remove();
|
|
4528
|
+
}, 0);
|
|
4529
|
+
}
|
|
4530
|
+
|
|
4531
|
+
/**
|
|
4532
|
+
* Singleton — only one pointer-driven drag active at a time.
|
|
4533
|
+
*
|
|
4534
|
+
* State is shared across every Dockview instance on the page. Targets
|
|
4535
|
+
* from instance B receive hit-tests from drags originating in instance A;
|
|
4536
|
+
* that's intentional for cross-instance drops since `LocalSelectionTransfer`
|
|
4537
|
+
* is also process-wide. The corollary is that every Tabs subscriber to
|
|
4538
|
+
* `onDragMove` fires for every pointer drag globally — each subscriber
|
|
4539
|
+
* hit-tests against its own DOM, so this is O(N) per pointermove where N
|
|
4540
|
+
* is the number of registered listeners across all instances.
|
|
4541
|
+
*/
|
|
4542
|
+
class PointerDragController extends CompositeDisposable {
|
|
4543
|
+
static getInstance() {
|
|
4544
|
+
if (!PointerDragController._instance) {
|
|
4545
|
+
PointerDragController._instance = new PointerDragController();
|
|
4546
|
+
}
|
|
4547
|
+
return PointerDragController._instance;
|
|
4548
|
+
}
|
|
4549
|
+
constructor() {
|
|
4550
|
+
super();
|
|
4551
|
+
this._targets = new Set();
|
|
4552
|
+
/** Kept in sync with `_targets` so hit-testing is allocation-free. */
|
|
4553
|
+
this._targetByElement = new Map();
|
|
4554
|
+
this._onDragStart = new Emitter();
|
|
4555
|
+
this.onDragStart = this._onDragStart.event;
|
|
4556
|
+
this._onDragMove = new Emitter();
|
|
4557
|
+
this.onDragMove = this._onDragMove.event;
|
|
4558
|
+
this._onDragEnd = new Emitter();
|
|
4559
|
+
this.onDragEnd = this._onDragEnd.event;
|
|
4560
|
+
this.addDisposables(this._onDragStart, this._onDragMove, this._onDragEnd);
|
|
4561
|
+
}
|
|
4562
|
+
get active() {
|
|
4563
|
+
return this._active;
|
|
4564
|
+
}
|
|
4565
|
+
registerTarget(target) {
|
|
4566
|
+
this._targets.add(target);
|
|
4567
|
+
this._targetByElement.set(target.element, target);
|
|
4568
|
+
return {
|
|
4569
|
+
dispose: () => {
|
|
4570
|
+
this._targets.delete(target);
|
|
4571
|
+
if (this._targetByElement.get(target.element) === target) {
|
|
4572
|
+
this._targetByElement.delete(target.element);
|
|
4573
|
+
}
|
|
4574
|
+
if (this._currentTarget === target) {
|
|
4575
|
+
this._currentTarget = undefined;
|
|
4576
|
+
}
|
|
4577
|
+
},
|
|
4578
|
+
};
|
|
4579
|
+
}
|
|
4580
|
+
beginDrag(args) {
|
|
4581
|
+
var _a, _b, _c;
|
|
4582
|
+
if (this._active) {
|
|
4583
|
+
this.cancel();
|
|
4584
|
+
}
|
|
4585
|
+
const { pointerEvent, source } = args;
|
|
4586
|
+
// Call `getData()` before mutating controller state — a throw
|
|
4587
|
+
// here would otherwise leave `_active` populated with no window
|
|
4588
|
+
// listeners installed, blocking every subsequent drag.
|
|
4589
|
+
const dataDisposable = args.getData();
|
|
4590
|
+
this._active = {
|
|
4591
|
+
pointerId: pointerEvent.pointerId,
|
|
4592
|
+
startX: pointerEvent.clientX,
|
|
4593
|
+
startY: pointerEvent.clientY,
|
|
4594
|
+
source,
|
|
4595
|
+
};
|
|
4596
|
+
this._onDragMoveCallback = args.onDragMove;
|
|
4597
|
+
this._onDragEndCallback = args.onDragEnd;
|
|
4598
|
+
this._dataDisposable = dataDisposable;
|
|
4599
|
+
this._ghost = args.ghost;
|
|
4600
|
+
// Iframes capture pointermove once the cursor crosses into them,
|
|
4601
|
+
// which would freeze the drag from the parent window's POV.
|
|
4602
|
+
this._iframeShield = disableIframePointEvents((_a = source.ownerDocument) !== null && _a !== void 0 ? _a : document);
|
|
4603
|
+
const startEvent = {
|
|
4604
|
+
clientX: pointerEvent.clientX,
|
|
4605
|
+
clientY: pointerEvent.clientY,
|
|
4606
|
+
pointerEvent,
|
|
4607
|
+
};
|
|
4608
|
+
this._onDragStart.fire(startEvent);
|
|
4609
|
+
// Source's owning window — popout drags fire on their own window,
|
|
4610
|
+
// not the main one.
|
|
4611
|
+
const targetWindow = (_c = (_b = source.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView) !== null && _c !== void 0 ? _c : window;
|
|
4612
|
+
this._moveListener = addDisposableListener(targetWindow, 'pointermove', (e) => {
|
|
4613
|
+
if (!this._active || e.pointerId !== this._active.pointerId) {
|
|
4614
|
+
return;
|
|
4615
|
+
}
|
|
4616
|
+
this._handleMove(e);
|
|
4617
|
+
});
|
|
4618
|
+
this._upListener = addDisposableListener(targetWindow, 'pointerup', (e) => {
|
|
4619
|
+
if (!this._active || e.pointerId !== this._active.pointerId) {
|
|
4620
|
+
return;
|
|
4621
|
+
}
|
|
4622
|
+
this._handleEnd(e, true);
|
|
4623
|
+
});
|
|
4624
|
+
this._cancelListener = addDisposableListener(targetWindow, 'pointercancel', (e) => {
|
|
4625
|
+
if (!this._active || e.pointerId !== this._active.pointerId) {
|
|
4626
|
+
return;
|
|
4627
|
+
}
|
|
4628
|
+
this._handleEnd(e, false);
|
|
4629
|
+
});
|
|
4630
|
+
}
|
|
4631
|
+
cancel() {
|
|
4632
|
+
var _a, _b;
|
|
4633
|
+
if (!this._active) {
|
|
4634
|
+
return;
|
|
4635
|
+
}
|
|
4636
|
+
(_a = this._currentTarget) === null || _a === void 0 ? void 0 : _a.handleDragLeave();
|
|
4637
|
+
this._teardown();
|
|
4638
|
+
(_b = this._dataDisposable) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
4639
|
+
this._dataDisposable = undefined;
|
|
4640
|
+
}
|
|
4641
|
+
_findTargetUnder(x, y) {
|
|
4642
|
+
var _a, _b;
|
|
4643
|
+
// `elementsFromPoint` is topmost-first; walk up to find the closest
|
|
4644
|
+
// registered ancestor (so a tab beats the layout-root that contains it).
|
|
4645
|
+
// Use the source's owning document so popout drags hit their own targets.
|
|
4646
|
+
const sourceDoc = (_b = (_a = this._active) === null || _a === void 0 ? void 0 : _a.source.ownerDocument) !== null && _b !== void 0 ? _b : document;
|
|
4647
|
+
const elements = sourceDoc.elementsFromPoint(x, y);
|
|
4648
|
+
for (const el of elements) {
|
|
4649
|
+
let current = el;
|
|
4650
|
+
while (current) {
|
|
4651
|
+
const target = this._targetByElement.get(current);
|
|
4652
|
+
if (target) {
|
|
4653
|
+
return target;
|
|
4654
|
+
}
|
|
4655
|
+
current = current.parentElement;
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
return undefined;
|
|
4659
|
+
}
|
|
4660
|
+
_handleMove(e) {
|
|
4661
|
+
var _a, _b, _c;
|
|
4662
|
+
(_a = this._ghost) === null || _a === void 0 ? void 0 : _a.update(e.clientX, e.clientY);
|
|
4663
|
+
const dragEvent = {
|
|
4664
|
+
clientX: e.clientX,
|
|
4665
|
+
clientY: e.clientY,
|
|
4666
|
+
pointerEvent: e,
|
|
4667
|
+
};
|
|
4668
|
+
const newTarget = this._findTargetUnder(e.clientX, e.clientY);
|
|
4669
|
+
if (newTarget !== this._currentTarget) {
|
|
4670
|
+
(_b = this._currentTarget) === null || _b === void 0 ? void 0 : _b.handleDragLeave();
|
|
4671
|
+
this._currentTarget = newTarget;
|
|
4672
|
+
}
|
|
4673
|
+
if (newTarget) {
|
|
4674
|
+
newTarget.handleDragOver(dragEvent);
|
|
4675
|
+
}
|
|
4676
|
+
(_c = this._onDragMoveCallback) === null || _c === void 0 ? void 0 : _c.call(this, dragEvent);
|
|
4677
|
+
this._onDragMove.fire(dragEvent);
|
|
4678
|
+
}
|
|
4679
|
+
_handleEnd(e, dropped) {
|
|
4680
|
+
var _a;
|
|
4681
|
+
const dragEvent = {
|
|
4682
|
+
clientX: e.clientX,
|
|
4683
|
+
clientY: e.clientY,
|
|
4684
|
+
pointerEvent: e,
|
|
4685
|
+
};
|
|
4686
|
+
if (dropped && this._currentTarget) {
|
|
4687
|
+
this._currentTarget.handleDrop(dragEvent);
|
|
4688
|
+
}
|
|
4689
|
+
else {
|
|
4690
|
+
(_a = this._currentTarget) === null || _a === void 0 ? void 0 : _a.handleDragLeave();
|
|
4691
|
+
}
|
|
4692
|
+
const onEnd = this._onDragEndCallback;
|
|
4693
|
+
const dataDisposable = this._dataDisposable;
|
|
4694
|
+
this._teardown();
|
|
4695
|
+
this._dataDisposable = undefined;
|
|
4696
|
+
// Defer disposal so drop handlers can still read the transfer data.
|
|
4697
|
+
setTimeout(() => dataDisposable === null || dataDisposable === void 0 ? void 0 : dataDisposable.dispose(), 0);
|
|
4698
|
+
onEnd === null || onEnd === void 0 ? void 0 : onEnd(dragEvent, dropped);
|
|
4699
|
+
this._onDragEnd.fire(dragEvent);
|
|
4700
|
+
}
|
|
4701
|
+
_teardown() {
|
|
4702
|
+
var _a, _b, _c, _d, _e;
|
|
4703
|
+
this._currentTarget = undefined;
|
|
4704
|
+
this._active = undefined;
|
|
4705
|
+
this._onDragMoveCallback = undefined;
|
|
4706
|
+
this._onDragEndCallback = undefined;
|
|
4707
|
+
(_a = this._ghost) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4708
|
+
this._ghost = undefined;
|
|
4709
|
+
(_b = this._iframeShield) === null || _b === void 0 ? void 0 : _b.release();
|
|
4710
|
+
this._iframeShield = undefined;
|
|
4711
|
+
(_c = this._moveListener) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
4712
|
+
(_d = this._upListener) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
4713
|
+
(_e = this._cancelListener) === null || _e === void 0 ? void 0 : _e.dispose();
|
|
4714
|
+
this._moveListener = undefined;
|
|
4715
|
+
this._upListener = undefined;
|
|
4716
|
+
this._cancelListener = undefined;
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4720
|
+
const DEFAULT_ACTIVATION_SIZE = {
|
|
4721
|
+
value: 20,
|
|
4722
|
+
type: 'percentage',
|
|
4723
|
+
};
|
|
4724
|
+
/** Pointer-driven counterpart to `Droptarget` with identical visual output. */
|
|
4725
|
+
class PointerDropTarget extends CompositeDisposable {
|
|
4726
|
+
get disabled() {
|
|
4727
|
+
return this._disabled;
|
|
4728
|
+
}
|
|
4729
|
+
set disabled(value) {
|
|
4730
|
+
this._disabled = value;
|
|
4731
|
+
if (value) {
|
|
4732
|
+
this._removeOverlay();
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
get state() {
|
|
4736
|
+
return this._state;
|
|
4737
|
+
}
|
|
4738
|
+
constructor(element, options) {
|
|
4739
|
+
super();
|
|
4740
|
+
this.element = element;
|
|
4741
|
+
this.options = options;
|
|
4742
|
+
this._onDrop = new Emitter();
|
|
4743
|
+
this.onDrop = this._onDrop.event;
|
|
4744
|
+
this._onWillShowOverlay = new Emitter();
|
|
4745
|
+
this.onWillShowOverlay = this._onWillShowOverlay.event;
|
|
4746
|
+
this._disabled = false;
|
|
4747
|
+
this._acceptedTargetZonesSet = new Set(options.acceptedTargetZones);
|
|
4748
|
+
const handle = {
|
|
4749
|
+
element: this.element,
|
|
4750
|
+
handleDragOver: (e) => this._onDragOver(e),
|
|
4751
|
+
handleDragLeave: () => this._onDragLeave(),
|
|
4752
|
+
handleDrop: (e) => this._onDropEvent(e),
|
|
4753
|
+
};
|
|
4754
|
+
this.addDisposables(this._onDrop, this._onWillShowOverlay, PointerDragController.getInstance().registerTarget(handle));
|
|
4755
|
+
}
|
|
4756
|
+
setTargetZones(zones) {
|
|
4757
|
+
this._acceptedTargetZonesSet = new Set(zones);
|
|
4758
|
+
}
|
|
4759
|
+
setOverlayModel(model) {
|
|
4760
|
+
this.options.overlayModel = model;
|
|
4761
|
+
}
|
|
4762
|
+
dispose() {
|
|
4763
|
+
this._removeOverlay();
|
|
4764
|
+
super.dispose();
|
|
4765
|
+
}
|
|
4766
|
+
_onDragOver(event) {
|
|
4767
|
+
var _a, _b, _c, _d, _e;
|
|
4768
|
+
if (this._disabled) {
|
|
4769
|
+
this._removeOverlay();
|
|
4770
|
+
return;
|
|
4771
|
+
}
|
|
4772
|
+
const overrideTarget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4773
|
+
if (this._acceptedTargetZonesSet.size === 0) {
|
|
4774
|
+
if (overrideTarget) {
|
|
4775
|
+
return;
|
|
4776
|
+
}
|
|
4777
|
+
this._removeOverlay();
|
|
4778
|
+
return;
|
|
4779
|
+
}
|
|
4780
|
+
const outlineEl = (_e = (_d = (_c = this.options).getOverlayOutline) === null || _d === void 0 ? void 0 : _d.call(_c)) !== null && _e !== void 0 ? _e : this.element;
|
|
4781
|
+
const width = outlineEl.offsetWidth;
|
|
4782
|
+
const height = outlineEl.offsetHeight;
|
|
4783
|
+
if (width === 0 || height === 0) {
|
|
4784
|
+
return;
|
|
4785
|
+
}
|
|
4786
|
+
const rect = outlineEl.getBoundingClientRect();
|
|
4787
|
+
const x = event.clientX - rect.left;
|
|
4788
|
+
const y = event.clientY - rect.top;
|
|
4789
|
+
const quadrant = this._calculateQuadrant(x, y, width, height);
|
|
4790
|
+
if (quadrant === null) {
|
|
4791
|
+
this._removeOverlay();
|
|
4792
|
+
return;
|
|
4793
|
+
}
|
|
4794
|
+
if (!this.options.canDisplayOverlay(event.pointerEvent, quadrant)) {
|
|
4795
|
+
if (overrideTarget) {
|
|
4796
|
+
return;
|
|
4797
|
+
}
|
|
4798
|
+
this._removeOverlay();
|
|
4799
|
+
return;
|
|
4800
|
+
}
|
|
4801
|
+
const willShow = new WillShowOverlayEvent({
|
|
4802
|
+
nativeEvent: event.pointerEvent,
|
|
4803
|
+
position: quadrant,
|
|
4804
|
+
});
|
|
4805
|
+
this._onWillShowOverlay.fire(willShow);
|
|
4806
|
+
if (willShow.defaultPrevented) {
|
|
4807
|
+
this._removeOverlay();
|
|
4808
|
+
return;
|
|
4809
|
+
}
|
|
4810
|
+
if (overrideTarget) {
|
|
4811
|
+
renderAnchoredOverlay({
|
|
4812
|
+
outlineElement: outlineEl,
|
|
4813
|
+
targetModel: overrideTarget,
|
|
4814
|
+
quadrant,
|
|
4815
|
+
width,
|
|
4816
|
+
height,
|
|
4817
|
+
overlayModel: this.options.overlayModel,
|
|
4818
|
+
className: this.options.className,
|
|
4819
|
+
});
|
|
4820
|
+
this._state = quadrant;
|
|
4821
|
+
return;
|
|
4822
|
+
}
|
|
4823
|
+
if (!this._targetElement) {
|
|
4824
|
+
const els = createOverlayElements();
|
|
4825
|
+
this._targetElement = els.dropzone;
|
|
4826
|
+
this._overlayElement = els.selection;
|
|
4827
|
+
this._state = 'center';
|
|
4828
|
+
this.element.classList.add('dv-drop-target');
|
|
4829
|
+
this.element.append(this._targetElement);
|
|
4830
|
+
}
|
|
4831
|
+
if (this._overlayElement) {
|
|
4832
|
+
renderInPlaceOverlay(this._overlayElement, quadrant, width, height, this.options.overlayModel);
|
|
4833
|
+
}
|
|
4834
|
+
this._state = quadrant;
|
|
4835
|
+
}
|
|
4836
|
+
_onDragLeave() {
|
|
4837
|
+
var _a, _b;
|
|
4838
|
+
const overrideTarget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4839
|
+
// Anchor target owns its own lifecycle; just clear our latched
|
|
4840
|
+
// state so a subsequent pointerup doesn't fire a stale drop.
|
|
4841
|
+
if (overrideTarget) {
|
|
4842
|
+
this._state = undefined;
|
|
4843
|
+
overrideTarget.clear();
|
|
4844
|
+
return;
|
|
4845
|
+
}
|
|
4846
|
+
this._removeOverlay();
|
|
4847
|
+
}
|
|
4848
|
+
_onDropEvent(event) {
|
|
4849
|
+
var _a, _b;
|
|
4850
|
+
const state = this._state;
|
|
4851
|
+
const overrideTarget = (_b = (_a = this.options).getOverrideTarget) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4852
|
+
this._removeOverlay();
|
|
4853
|
+
overrideTarget === null || overrideTarget === void 0 ? void 0 : overrideTarget.clear();
|
|
4854
|
+
if (state) {
|
|
4855
|
+
this._onDrop.fire({
|
|
4856
|
+
position: state,
|
|
4857
|
+
nativeEvent: event.pointerEvent,
|
|
4858
|
+
});
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
_calculateQuadrant(x, y, width, height) {
|
|
4862
|
+
var _a, _b;
|
|
4863
|
+
const activation = (_b = (_a = this.options.overlayModel) === null || _a === void 0 ? void 0 : _a.activationSize) !== null && _b !== void 0 ? _b : DEFAULT_ACTIVATION_SIZE;
|
|
4864
|
+
if (activation.type === 'percentage') {
|
|
4865
|
+
return calculateQuadrantAsPercentage(this._acceptedTargetZonesSet, x, y, width, height, activation.value);
|
|
4866
|
+
}
|
|
4867
|
+
return calculateQuadrantAsPixels(this._acceptedTargetZonesSet, x, y, width, height, activation.value);
|
|
4868
|
+
}
|
|
4869
|
+
_removeOverlay() {
|
|
4870
|
+
var _a;
|
|
4871
|
+
if (this._targetElement) {
|
|
4872
|
+
this._state = undefined;
|
|
4873
|
+
(_a = this._targetElement.parentElement) === null || _a === void 0 ? void 0 : _a.classList.remove('dv-drop-target');
|
|
4874
|
+
this._targetElement.remove();
|
|
4875
|
+
this._targetElement = undefined;
|
|
4876
|
+
this._overlayElement = undefined;
|
|
4877
|
+
}
|
|
4878
|
+
else {
|
|
4879
|
+
this._state = undefined;
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4884
|
+
const DEFAULT_THRESHOLD = 5;
|
|
4885
|
+
const DEFAULT_TOUCH_INITIATION_DELAY = 250;
|
|
4886
|
+
const DEFAULT_PRESS_TOLERANCE = 8;
|
|
4887
|
+
/**
|
|
4888
|
+
* Pointer-event drag source. Waits for movement past `threshold` (and
|
|
4889
|
+
* touch-only `touchInitiationDelay`) before promoting to a drag so taps
|
|
4890
|
+
* pass through unaffected.
|
|
4891
|
+
*/
|
|
4892
|
+
class PointerDragSource extends CompositeDisposable {
|
|
4893
|
+
constructor(element, options) {
|
|
4894
|
+
var _a;
|
|
4895
|
+
super();
|
|
4896
|
+
this.element = element;
|
|
4897
|
+
this.options = options;
|
|
4898
|
+
this._disabled = false;
|
|
4899
|
+
this._armed = false;
|
|
4900
|
+
this._startX = 0;
|
|
4901
|
+
this._startY = 0;
|
|
4902
|
+
this._touchOnly = (_a = options.touchOnly) !== null && _a !== void 0 ? _a : true;
|
|
4903
|
+
this.addDisposables(addDisposableListener(this.element, 'pointerdown', (e) => {
|
|
4904
|
+
this._onPointerDown(e);
|
|
4905
|
+
}));
|
|
4906
|
+
}
|
|
4907
|
+
setDisabled(value) {
|
|
4908
|
+
this._disabled = value;
|
|
4909
|
+
if (value) {
|
|
4910
|
+
this._cancelPending();
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
/**
|
|
4914
|
+
* `false` lets the pointer source also handle mouse pointers; used when
|
|
4915
|
+
* `dndStrategy: 'pointer'` to drive every input type through this path.
|
|
4916
|
+
*/
|
|
4917
|
+
setTouchOnly(value) {
|
|
4918
|
+
if (this._touchOnly === value) {
|
|
4919
|
+
return;
|
|
4920
|
+
}
|
|
4921
|
+
this._touchOnly = value;
|
|
4922
|
+
// A pending mouse-tracked drag should be abandoned if we re-enable
|
|
4923
|
+
// the touch-only filter mid-flight.
|
|
4924
|
+
if (value) {
|
|
4925
|
+
this._cancelPending();
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
_shouldHandle(event) {
|
|
4929
|
+
var _a, _b;
|
|
4930
|
+
if (this._disabled) {
|
|
4931
|
+
return false;
|
|
4932
|
+
}
|
|
4933
|
+
// Pointer-type filter runs before isCancelled — consumer state read
|
|
4934
|
+
// by isCancelled may not be populated for events we'll never handle.
|
|
4935
|
+
if (this._touchOnly &&
|
|
4936
|
+
event.pointerType !== 'touch' &&
|
|
4937
|
+
event.pointerType !== 'pen') {
|
|
4938
|
+
return false;
|
|
4939
|
+
}
|
|
4940
|
+
if ((_b = (_a = this.options).isCancelled) === null || _b === void 0 ? void 0 : _b.call(_a, event)) {
|
|
4941
|
+
return false;
|
|
4942
|
+
}
|
|
4943
|
+
return true;
|
|
4944
|
+
}
|
|
4945
|
+
_onPointerDown(event) {
|
|
4946
|
+
var _a, _b, _c, _d, _e;
|
|
4947
|
+
if (!this._shouldHandle(event)) {
|
|
4948
|
+
return;
|
|
4949
|
+
}
|
|
4950
|
+
// Defensive: a fresh pointerdown supersedes any in-flight tracking.
|
|
4951
|
+
this._cancelPending();
|
|
4952
|
+
this._pendingPointerId = event.pointerId;
|
|
4953
|
+
this._startX = event.clientX;
|
|
4954
|
+
this._startY = event.clientY;
|
|
4955
|
+
this._startEvent = event;
|
|
4956
|
+
const isTouch = event.pointerType === 'touch' || event.pointerType === 'pen';
|
|
4957
|
+
// Touch waits a short window so a still finger can press-and-hold
|
|
4958
|
+
// before drifting; once the timer fires, any motion past `threshold`
|
|
4959
|
+
// begins the drag.
|
|
4960
|
+
const initiationDelayOpt = this.options.touchInitiationDelay;
|
|
4961
|
+
const initiationDelay = (_a = (typeof initiationDelayOpt === 'function'
|
|
4962
|
+
? initiationDelayOpt()
|
|
4963
|
+
: initiationDelayOpt)) !== null && _a !== void 0 ? _a : DEFAULT_TOUCH_INITIATION_DELAY;
|
|
4964
|
+
this._armed = !isTouch || initiationDelay <= 0;
|
|
4965
|
+
if (isTouch && initiationDelay > 0 && isFinite(initiationDelay)) {
|
|
4966
|
+
this._armTimer = setTimeout(() => {
|
|
4967
|
+
this._armTimer = undefined;
|
|
4968
|
+
this._armed = true;
|
|
4969
|
+
}, initiationDelay);
|
|
4970
|
+
}
|
|
4971
|
+
const threshold = (_b = this.options.threshold) !== null && _b !== void 0 ? _b : DEFAULT_THRESHOLD;
|
|
4972
|
+
const pressToleranceOpt = this.options.pressTolerance;
|
|
4973
|
+
const pressTolerance = (_c = (typeof pressToleranceOpt === 'function'
|
|
4974
|
+
? pressToleranceOpt()
|
|
4975
|
+
: pressToleranceOpt)) !== null && _c !== void 0 ? _c : DEFAULT_PRESS_TOLERANCE;
|
|
4976
|
+
// Source's owning window — popout drags fire on their own window.
|
|
4977
|
+
const targetWindow = (_e = (_d = this.element.ownerDocument) === null || _d === void 0 ? void 0 : _d.defaultView) !== null && _e !== void 0 ? _e : window;
|
|
4978
|
+
this._pendingMoveListener = addDisposableListener(targetWindow, 'pointermove', (moveEvent) => {
|
|
4979
|
+
if (moveEvent.pointerId !== this._pendingPointerId) {
|
|
4980
|
+
return;
|
|
4981
|
+
}
|
|
4982
|
+
const dx = moveEvent.clientX - this._startX;
|
|
4983
|
+
const dy = moveEvent.clientY - this._startY;
|
|
4984
|
+
const distance = Math.hypot(dx, dy);
|
|
4985
|
+
if (this._armed) {
|
|
4986
|
+
if (distance >= threshold) {
|
|
4987
|
+
this._beginDrag(moveEvent);
|
|
4988
|
+
}
|
|
4989
|
+
return;
|
|
4990
|
+
}
|
|
4991
|
+
// Pre-arm phase: a flick past `pressTolerance` in any
|
|
4992
|
+
// direction is treated as drag intent. The element opts out
|
|
4993
|
+
// of native scroll via `touch-action: none`; container-level
|
|
4994
|
+
// scrolling lives on the surrounding strip's empty space.
|
|
4995
|
+
if (distance > pressTolerance) {
|
|
4996
|
+
this._beginDrag(moveEvent);
|
|
4997
|
+
}
|
|
4998
|
+
});
|
|
4999
|
+
this._pendingUpListener = addDisposableListener(targetWindow, 'pointerup', (upEvent) => {
|
|
5000
|
+
if (upEvent.pointerId !== this._pendingPointerId) {
|
|
5001
|
+
return;
|
|
5002
|
+
}
|
|
5003
|
+
this._cancelPending();
|
|
5004
|
+
});
|
|
5005
|
+
this._pendingCancelListener = addDisposableListener(targetWindow, 'pointercancel', (cancelEvent) => {
|
|
5006
|
+
if (cancelEvent.pointerId !== this._pendingPointerId) {
|
|
5007
|
+
return;
|
|
5008
|
+
}
|
|
5009
|
+
this._cancelPending();
|
|
5010
|
+
});
|
|
5011
|
+
}
|
|
5012
|
+
/** For sibling gesture detectors (e.g. LongPressDetector) to dismiss a pending drag. */
|
|
5013
|
+
cancelPending() {
|
|
5014
|
+
this._cancelPending();
|
|
5015
|
+
}
|
|
5016
|
+
_cancelPending() {
|
|
5017
|
+
var _a, _b, _c;
|
|
5018
|
+
this._pendingPointerId = undefined;
|
|
5019
|
+
if (this._armTimer !== undefined) {
|
|
5020
|
+
clearTimeout(this._armTimer);
|
|
5021
|
+
this._armTimer = undefined;
|
|
5022
|
+
}
|
|
5023
|
+
this._armed = false;
|
|
5024
|
+
(_a = this._pendingMoveListener) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
5025
|
+
(_b = this._pendingUpListener) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
5026
|
+
(_c = this._pendingCancelListener) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
5027
|
+
this._pendingMoveListener = undefined;
|
|
5028
|
+
this._pendingUpListener = undefined;
|
|
5029
|
+
this._pendingCancelListener = undefined;
|
|
5030
|
+
this._startEvent = undefined;
|
|
5031
|
+
}
|
|
5032
|
+
_beginDrag(triggerEvent) {
|
|
5033
|
+
var _a, _b, _c, _d, _e;
|
|
5034
|
+
const startEvent = (_a = this._startEvent) !== null && _a !== void 0 ? _a : triggerEvent;
|
|
5035
|
+
this._cancelPending();
|
|
5036
|
+
(_c = (_b = this.options).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, startEvent);
|
|
5037
|
+
const ghost = (_e = (_d = this.options).createGhost) === null || _e === void 0 ? void 0 : _e.call(_d, startEvent);
|
|
5038
|
+
PointerDragController.getInstance().beginDrag({
|
|
5039
|
+
pointerEvent: triggerEvent,
|
|
5040
|
+
source: this.element,
|
|
5041
|
+
getData: () => this.options.getData(startEvent),
|
|
5042
|
+
ghost,
|
|
5043
|
+
onDragMove: this.options.onDragMove,
|
|
5044
|
+
onDragEnd: this.options.onDragEnd,
|
|
5045
|
+
});
|
|
5046
|
+
}
|
|
5047
|
+
dispose() {
|
|
5048
|
+
this._cancelPending();
|
|
5049
|
+
super.dispose();
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
|
|
5053
|
+
/**
|
|
5054
|
+
* Floating clone that follows the pointer; appended to the owning
|
|
5055
|
+
* document's body with `pointer-events: none` so it doesn't intercept
|
|
5056
|
+
* hit-testing.
|
|
5057
|
+
*/
|
|
5058
|
+
class PointerGhost {
|
|
5059
|
+
constructor(opts) {
|
|
5060
|
+
var _a, _b, _c, _d, _e;
|
|
5061
|
+
this._disposed = false;
|
|
5062
|
+
this.element = opts.element;
|
|
5063
|
+
this.offsetX = (_a = opts.offsetX) !== null && _a !== void 0 ? _a : 0;
|
|
5064
|
+
this.offsetY = (_b = opts.offsetY) !== null && _b !== void 0 ? _b : 0;
|
|
5065
|
+
// Animate via transform (see update); position:fixed for scroll-independence.
|
|
5066
|
+
this.element.style.position = 'fixed';
|
|
5067
|
+
this.element.style.left = '0px';
|
|
5068
|
+
this.element.style.top = '0px';
|
|
5069
|
+
this.element.style.pointerEvents = 'none';
|
|
5070
|
+
this.element.style.zIndex = '99999';
|
|
5071
|
+
this.element.style.opacity = String((_c = opts.opacity) !== null && _c !== void 0 ? _c : 0.8);
|
|
5072
|
+
this.element.style.willChange = 'transform';
|
|
5073
|
+
this.element.style.transform = `translate3d(${opts.initialX - this.offsetX}px, ${opts.initialY - this.offsetY}px, 0)`;
|
|
5074
|
+
const ownerDocument = (_e = (_d = opts.owner) === null || _d === void 0 ? void 0 : _d.ownerDocument) !== null && _e !== void 0 ? _e : document;
|
|
5075
|
+
ownerDocument.body.appendChild(this.element);
|
|
5076
|
+
}
|
|
5077
|
+
update(clientX, clientY) {
|
|
5078
|
+
if (this._disposed) {
|
|
5079
|
+
return;
|
|
5080
|
+
}
|
|
5081
|
+
// translate3d composites on the GPU — no layout per pointermove.
|
|
5082
|
+
this.element.style.transform = `translate3d(${clientX - this.offsetX}px, ${clientY - this.offsetY}px, 0)`;
|
|
5083
|
+
}
|
|
5084
|
+
dispose() {
|
|
5085
|
+
if (this._disposed) {
|
|
5086
|
+
return;
|
|
5087
|
+
}
|
|
5088
|
+
this._disposed = true;
|
|
5089
|
+
this.element.remove();
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
|
|
5093
|
+
/**
|
|
5094
|
+
* HTML5 drag source. Listens for the native `dragstart` event, calls
|
|
5095
|
+
* `getData` to populate transfer, optionally renders the ghost via
|
|
5096
|
+
* `setDragImage`, fires `onDragStart` / `onDragEnd`, and tears down the
|
|
5097
|
+
* transfer disposer after `dragend`.
|
|
5098
|
+
*/
|
|
5099
|
+
class Html5DragSource extends CompositeDisposable {
|
|
5100
|
+
constructor(el, opts) {
|
|
5101
|
+
super();
|
|
5102
|
+
this.el = el;
|
|
5103
|
+
this.opts = opts;
|
|
5104
|
+
this._dataDisposable = new MutableDisposable();
|
|
5105
|
+
this._pointerEventsDisposable = new MutableDisposable();
|
|
5106
|
+
this._disabled = !!opts.disabled;
|
|
5107
|
+
this.addDisposables(this._dataDisposable, this._pointerEventsDisposable, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
5108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
5109
|
+
if (event.defaultPrevented ||
|
|
5110
|
+
this._disabled ||
|
|
5111
|
+
((_b = (_a = this.opts).isCancelled) === null || _b === void 0 ? void 0 : _b.call(_a, event))) {
|
|
5112
|
+
event.preventDefault();
|
|
5113
|
+
return;
|
|
5114
|
+
}
|
|
5115
|
+
// Iframes capture pointermove once the cursor enters them,
|
|
5116
|
+
// which freezes drag tracking from the parent window's
|
|
5117
|
+
// POV. Shield the source's owning document so popout-window
|
|
5118
|
+
// drags shield the popout, not the main window.
|
|
5119
|
+
const iframes = disableIframePointEvents((_c = this.el.ownerDocument) !== null && _c !== void 0 ? _c : document);
|
|
5120
|
+
this._pointerEventsDisposable.value = {
|
|
5121
|
+
dispose: () => iframes.release(),
|
|
5122
|
+
};
|
|
5123
|
+
this.el.classList.add('dv-dragged');
|
|
5124
|
+
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
5125
|
+
this._dataDisposable.value = this.opts.getData(event);
|
|
5126
|
+
const ghost = (_e = (_d = this.opts).createGhost) === null || _e === void 0 ? void 0 : _e.call(_d, event);
|
|
5127
|
+
if (ghost && event.dataTransfer) {
|
|
5128
|
+
addGhostImage(event.dataTransfer, ghost.element, {
|
|
5129
|
+
x: (_f = ghost.offsetX) !== null && _f !== void 0 ? _f : 0,
|
|
5130
|
+
y: (_g = ghost.offsetY) !== null && _g !== void 0 ? _g : 0,
|
|
5131
|
+
});
|
|
5132
|
+
if (ghost.dispose) {
|
|
5133
|
+
// addGhostImage removes the element from the DOM on
|
|
5134
|
+
// the next tick; dispose the framework renderer on
|
|
5135
|
+
// the same schedule.
|
|
5136
|
+
const disposeGhost = ghost.dispose;
|
|
5137
|
+
setTimeout(() => disposeGhost(), 0);
|
|
5138
|
+
}
|
|
5139
|
+
}
|
|
5140
|
+
if (event.dataTransfer) {
|
|
5141
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
5142
|
+
// Some third-party DnD libs (e.g. react-dnd) cancel the
|
|
5143
|
+
// dragstart when `dataTransfer.types` is empty.
|
|
5144
|
+
if (event.dataTransfer.items.length === 0) {
|
|
5145
|
+
event.dataTransfer.setData('text/plain', '');
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
(_j = (_h = this.opts).onDragStart) === null || _j === void 0 ? void 0 : _j.call(_h, event);
|
|
5149
|
+
}), addDisposableListener(this.el, 'dragend', (event) => {
|
|
5150
|
+
var _a, _b;
|
|
5151
|
+
this._pointerEventsDisposable.dispose();
|
|
5152
|
+
// Defer disposal so drop handlers can still read the
|
|
5153
|
+
// transfer payload before it clears.
|
|
5154
|
+
setTimeout(() => this._dataDisposable.dispose(), 0);
|
|
5155
|
+
(_b = (_a = this.opts).onDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
5156
|
+
}));
|
|
5157
|
+
}
|
|
5158
|
+
setDisabled(value) {
|
|
5159
|
+
this._disabled = value;
|
|
5160
|
+
}
|
|
5161
|
+
setTouchOnly(_) {
|
|
5162
|
+
// No-op — HTML5 path can't filter by pointer type.
|
|
5163
|
+
}
|
|
5164
|
+
cancelPending() {
|
|
5165
|
+
// No-op — HTML5 has no pre-arm phase to cancel.
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
class Html5DragBackend {
|
|
5169
|
+
constructor() {
|
|
5170
|
+
this.kind = 'html5';
|
|
5171
|
+
}
|
|
5172
|
+
createDropTarget(element, options) {
|
|
5173
|
+
return new Droptarget(element, options);
|
|
5174
|
+
}
|
|
5175
|
+
createDragSource(element, options) {
|
|
5176
|
+
return new Html5DragSource(element, options);
|
|
5177
|
+
}
|
|
5178
|
+
}
|
|
5179
|
+
class PointerDragBackend {
|
|
5180
|
+
constructor() {
|
|
5181
|
+
this.kind = 'pointer';
|
|
5182
|
+
}
|
|
5183
|
+
createDropTarget(element, options) {
|
|
5184
|
+
return new PointerDropTarget(element, options);
|
|
5185
|
+
}
|
|
5186
|
+
createDragSource(element, options) {
|
|
5187
|
+
const pointerCreateGhost = options.createGhost
|
|
5188
|
+
? (event) => {
|
|
5189
|
+
const spec = options.createGhost(event);
|
|
5190
|
+
if (!spec) {
|
|
5191
|
+
return undefined;
|
|
5192
|
+
}
|
|
5193
|
+
const ghost = new PointerGhost({
|
|
5194
|
+
element: spec.element,
|
|
5195
|
+
initialX: event.clientX,
|
|
5196
|
+
initialY: event.clientY,
|
|
5197
|
+
offsetX: spec.offsetX,
|
|
5198
|
+
offsetY: spec.offsetY,
|
|
5199
|
+
owner: element,
|
|
5200
|
+
});
|
|
5201
|
+
if (spec.dispose) {
|
|
5202
|
+
const baseDispose = ghost.dispose.bind(ghost);
|
|
5203
|
+
const disposeSpec = spec.dispose;
|
|
5204
|
+
ghost.dispose = () => {
|
|
5205
|
+
baseDispose();
|
|
5206
|
+
disposeSpec();
|
|
5207
|
+
};
|
|
5208
|
+
}
|
|
5209
|
+
return ghost;
|
|
5210
|
+
}
|
|
5211
|
+
: undefined;
|
|
5212
|
+
const source = new PointerDragSource(element, {
|
|
5213
|
+
getData: options.getData,
|
|
5214
|
+
isCancelled: options.isCancelled,
|
|
5215
|
+
onDragStart: options.onDragStart,
|
|
5216
|
+
onDragEnd: options.onDragEnd
|
|
5217
|
+
? (event) => options.onDragEnd(event.pointerEvent)
|
|
5218
|
+
: undefined,
|
|
5219
|
+
createGhost: pointerCreateGhost,
|
|
5220
|
+
touchOnly: options.touchOnly,
|
|
5221
|
+
touchInitiationDelay: options.touchInitiationDelay,
|
|
5222
|
+
pressTolerance: options.pressTolerance,
|
|
5223
|
+
threshold: options.threshold,
|
|
5224
|
+
});
|
|
5225
|
+
if (options.disabled) {
|
|
5226
|
+
source.setDisabled(true);
|
|
5227
|
+
}
|
|
5228
|
+
return source;
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5231
|
+
const html5Backend = new Html5DragBackend();
|
|
5232
|
+
const pointerBackend = new PointerDragBackend();
|
|
5233
|
+
|
|
4576
5234
|
const PROPERTY_KEYS_PANEVIEW = (() => {
|
|
4577
5235
|
/**
|
|
4578
5236
|
* by readong the keys from an empty value object TypeScript will error
|
|
@@ -5038,35 +5696,42 @@ class DraggablePaneviewPanel extends PaneviewPanel {
|
|
|
5038
5696
|
const id = this.id;
|
|
5039
5697
|
const accessorId = this.accessor.id;
|
|
5040
5698
|
this.header.draggable = true;
|
|
5041
|
-
|
|
5042
|
-
getData() {
|
|
5699
|
+
const sharedDragOptions = {
|
|
5700
|
+
getData: () => {
|
|
5043
5701
|
LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
|
|
5044
5702
|
return {
|
|
5045
5703
|
dispose: () => {
|
|
5046
5704
|
LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
|
|
5047
5705
|
},
|
|
5048
5706
|
};
|
|
5707
|
+
},
|
|
5708
|
+
};
|
|
5709
|
+
this.html5DragSource = html5Backend.createDragSource(this.header, sharedDragOptions);
|
|
5710
|
+
this.pointerDragSource = pointerBackend.createDragSource(this.header, sharedDragOptions);
|
|
5711
|
+
const canDisplayOverlay = (event, position) => {
|
|
5712
|
+
const data = getPaneData();
|
|
5713
|
+
if (data) {
|
|
5714
|
+
if (data.paneId !== this.id &&
|
|
5715
|
+
data.viewId === this.accessor.id) {
|
|
5716
|
+
return true;
|
|
5717
|
+
}
|
|
5049
5718
|
}
|
|
5050
|
-
|
|
5051
|
-
|
|
5719
|
+
const firedEvent = new PaneviewUnhandledDragOverEvent(event, position, getPaneData, this);
|
|
5720
|
+
this._onUnhandledDragOverEvent.fire(firedEvent);
|
|
5721
|
+
return firedEvent.isAccepted;
|
|
5722
|
+
};
|
|
5723
|
+
const dropTargetOptions = {
|
|
5052
5724
|
acceptedTargetZones: ['top', 'bottom'],
|
|
5053
5725
|
overlayModel: {
|
|
5054
5726
|
activationSize: { type: 'percentage', value: 50 },
|
|
5055
5727
|
},
|
|
5056
|
-
canDisplayOverlay
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
}
|
|
5064
|
-
const firedEvent = new PaneviewUnhandledDragOverEvent(event, position, getPaneData, this);
|
|
5065
|
-
this._onUnhandledDragOverEvent.fire(firedEvent);
|
|
5066
|
-
return firedEvent.isAccepted;
|
|
5067
|
-
},
|
|
5068
|
-
});
|
|
5069
|
-
this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
|
|
5728
|
+
canDisplayOverlay,
|
|
5729
|
+
};
|
|
5730
|
+
this.target = html5Backend.createDropTarget(this.element, dropTargetOptions);
|
|
5731
|
+
this.pointerTarget = pointerBackend.createDropTarget(this.element, dropTargetOptions);
|
|
5732
|
+
this.addDisposables(this._onDidDrop, this.html5DragSource, this.pointerDragSource, this.target, this.pointerTarget, this.target.onDrop((event) => {
|
|
5733
|
+
this.onDrop(event);
|
|
5734
|
+
}), this.pointerTarget.onDrop((event) => {
|
|
5070
5735
|
this.onDrop(event);
|
|
5071
5736
|
}));
|
|
5072
5737
|
}
|
|
@@ -5121,6 +5786,25 @@ class ContentContainer extends CompositeDisposable {
|
|
|
5121
5786
|
this._element.tabIndex = -1;
|
|
5122
5787
|
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
5123
5788
|
const target = group.dropTargetContainer;
|
|
5789
|
+
const canDisplayOverlay = (event, position) => {
|
|
5790
|
+
if (this.group.locked === 'no-drop-target' ||
|
|
5791
|
+
(this.group.locked && position === 'center')) {
|
|
5792
|
+
return false;
|
|
5793
|
+
}
|
|
5794
|
+
const data = getPanelData();
|
|
5795
|
+
if (!data &&
|
|
5796
|
+
event.shiftKey &&
|
|
5797
|
+
this.group.location.type !== 'floating') {
|
|
5798
|
+
return false;
|
|
5799
|
+
}
|
|
5800
|
+
if (data && data.viewId === this.accessor.id) {
|
|
5801
|
+
return true;
|
|
5802
|
+
}
|
|
5803
|
+
return this.group.canDisplayOverlay(event, position, 'content');
|
|
5804
|
+
};
|
|
5805
|
+
// `dropTarget` stays the concrete `Droptarget` (not via the backend
|
|
5806
|
+
// factory) because overlayRenderContainer forwards HTML5 drag events
|
|
5807
|
+
// through `dropTarget.dnd` — that field is not part of `IDropTarget`.
|
|
5124
5808
|
this.dropTarget = new Droptarget(this.element, {
|
|
5125
5809
|
getOverlayOutline: () => {
|
|
5126
5810
|
var _a;
|
|
@@ -5130,25 +5814,22 @@ class ContentContainer extends CompositeDisposable {
|
|
|
5130
5814
|
},
|
|
5131
5815
|
className: 'dv-drop-target-content',
|
|
5132
5816
|
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5133
|
-
canDisplayOverlay
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
if (data && data.viewId === this.accessor.id) {
|
|
5145
|
-
return true;
|
|
5146
|
-
}
|
|
5147
|
-
return this.group.canDisplayOverlay(event, position, 'content');
|
|
5817
|
+
canDisplayOverlay,
|
|
5818
|
+
getOverrideTarget: target ? () => target.model : undefined,
|
|
5819
|
+
});
|
|
5820
|
+
this.pointerDropTarget = pointerBackend.createDropTarget(this.element, {
|
|
5821
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5822
|
+
canDisplayOverlay,
|
|
5823
|
+
getOverlayOutline: () => {
|
|
5824
|
+
var _a;
|
|
5825
|
+
return ((_a = accessor.options.theme) === null || _a === void 0 ? void 0 : _a.dndPanelOverlay) === 'group'
|
|
5826
|
+
? this.element.parentElement
|
|
5827
|
+
: null;
|
|
5148
5828
|
},
|
|
5829
|
+
className: 'dv-drop-target-content',
|
|
5149
5830
|
getOverrideTarget: target ? () => target.model : undefined,
|
|
5150
5831
|
});
|
|
5151
|
-
this.addDisposables(this.dropTarget);
|
|
5832
|
+
this.addDisposables(this.dropTarget, this.pointerDropTarget);
|
|
5152
5833
|
}
|
|
5153
5834
|
show() {
|
|
5154
5835
|
this.element.style.display = '';
|
|
@@ -5236,37 +5917,169 @@ class ContentContainer extends CompositeDisposable {
|
|
|
5236
5917
|
}
|
|
5237
5918
|
}
|
|
5238
5919
|
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5920
|
+
const DEFAULT_DELAY = 500;
|
|
5921
|
+
const DEFAULT_TOLERANCE = 8;
|
|
5922
|
+
/**
|
|
5923
|
+
* Passive — does not consume the pointer; movement past `tolerance`
|
|
5924
|
+
* cancels silently so a sibling `PointerDragSource` can take over.
|
|
5925
|
+
*/
|
|
5926
|
+
class LongPressDetector extends CompositeDisposable {
|
|
5927
|
+
constructor(element, options) {
|
|
5928
|
+
super();
|
|
5929
|
+
this.element = element;
|
|
5930
|
+
this.options = options;
|
|
5931
|
+
this._startX = 0;
|
|
5932
|
+
this._startY = 0;
|
|
5933
|
+
this.addDisposables(addDisposableListener(this.element, 'pointerdown', (e) => {
|
|
5934
|
+
this._onPointerDown(e);
|
|
5935
|
+
}));
|
|
5936
|
+
}
|
|
5937
|
+
_onPointerDown(event) {
|
|
5938
|
+
var _a, _b, _c, _d, _e;
|
|
5939
|
+
const touchOnly = (_a = this.options.touchOnly) !== null && _a !== void 0 ? _a : true;
|
|
5940
|
+
if (touchOnly &&
|
|
5941
|
+
event.pointerType !== 'touch' &&
|
|
5942
|
+
event.pointerType !== 'pen') {
|
|
5943
|
+
return;
|
|
5944
|
+
}
|
|
5945
|
+
// Defensive — supersede any in-flight press.
|
|
5946
|
+
this._cancelPending();
|
|
5947
|
+
this._pointerId = event.pointerId;
|
|
5948
|
+
this._startX = event.clientX;
|
|
5949
|
+
this._startY = event.clientY;
|
|
5950
|
+
const delay = (_b = this.options.delay) !== null && _b !== void 0 ? _b : DEFAULT_DELAY;
|
|
5951
|
+
const tolerance = (_c = this.options.tolerance) !== null && _c !== void 0 ? _c : DEFAULT_TOLERANCE;
|
|
5952
|
+
// Source's owning window — popout drags fire on their own window.
|
|
5953
|
+
const targetWindow = (_e = (_d = this.element.ownerDocument) === null || _d === void 0 ? void 0 : _d.defaultView) !== null && _e !== void 0 ? _e : window;
|
|
5954
|
+
this._timer = setTimeout(() => {
|
|
5955
|
+
this._timer = undefined;
|
|
5956
|
+
this._cancelPending();
|
|
5957
|
+
// Touch browsers synthesize a compatibility `contextmenu` event
|
|
5958
|
+
// for long-press. preventDefault on the original pointerdown is
|
|
5959
|
+
// too late (already dispatched), so install a one-shot
|
|
5960
|
+
// capture-phase guard for the next contextmenu. Without this,
|
|
5961
|
+
// consumers that don't preventDefault inside their onLongPress
|
|
5962
|
+
// (or that early-return before doing so) leak the browser's
|
|
5963
|
+
// native menu on top of theirs.
|
|
5964
|
+
this._installContextMenuGuard(targetWindow);
|
|
5965
|
+
// Same idea for `click`: when the user releases their finger
|
|
5966
|
+
// after the long-press, touch browsers dispatch a `click` to
|
|
5967
|
+
// the element the touch ended on (the source). Consumers
|
|
5968
|
+
// typically wire click to a primary action (e.g. tab activate,
|
|
5969
|
+
// tab-group chip collapse-toggle). Without this guard, the
|
|
5970
|
+
// long-press immediately fires both the context menu AND the
|
|
5971
|
+
// primary action — and the action's side effects (e.g. a chip
|
|
5972
|
+
// collapse animation) read as a screen wobble while the menu
|
|
5973
|
+
// is supposed to be open. Scoped to the source element so
|
|
5974
|
+
// clicks on menu items elsewhere remain effective.
|
|
5975
|
+
this._installClickGuard(targetWindow);
|
|
5976
|
+
this.options.onLongPress(event);
|
|
5977
|
+
}, delay);
|
|
5978
|
+
this._moveListener = addDisposableListener(targetWindow, 'pointermove', (moveEvent) => {
|
|
5979
|
+
if (moveEvent.pointerId !== this._pointerId) {
|
|
5980
|
+
return;
|
|
5981
|
+
}
|
|
5982
|
+
const dx = moveEvent.clientX - this._startX;
|
|
5983
|
+
const dy = moveEvent.clientY - this._startY;
|
|
5984
|
+
if (Math.hypot(dx, dy) > tolerance) {
|
|
5985
|
+
this._cancelPending();
|
|
5986
|
+
}
|
|
5987
|
+
});
|
|
5988
|
+
this._upListener = addDisposableListener(targetWindow, 'pointerup', (upEvent) => {
|
|
5989
|
+
if (upEvent.pointerId !== this._pointerId) {
|
|
5990
|
+
return;
|
|
5991
|
+
}
|
|
5992
|
+
this._cancelPending();
|
|
5993
|
+
});
|
|
5994
|
+
this._cancelListener = addDisposableListener(targetWindow, 'pointercancel', (cancelEvent) => {
|
|
5995
|
+
if (cancelEvent.pointerId !== this._pointerId) {
|
|
5996
|
+
return;
|
|
5997
|
+
}
|
|
5998
|
+
this._cancelPending();
|
|
5999
|
+
});
|
|
6000
|
+
}
|
|
6001
|
+
_installContextMenuGuard(targetWindow) {
|
|
6002
|
+
let guard;
|
|
6003
|
+
const timeout = setTimeout(() => guard === null || guard === void 0 ? void 0 : guard.dispose(), 500);
|
|
6004
|
+
guard = addDisposableListener(targetWindow, 'contextmenu', (event) => {
|
|
6005
|
+
event.preventDefault();
|
|
6006
|
+
clearTimeout(timeout);
|
|
6007
|
+
guard === null || guard === void 0 ? void 0 : guard.dispose();
|
|
6008
|
+
}, { capture: true });
|
|
6009
|
+
}
|
|
6010
|
+
_installClickGuard(targetWindow) {
|
|
6011
|
+
let guard;
|
|
6012
|
+
const timeout = setTimeout(() => guard === null || guard === void 0 ? void 0 : guard.dispose(), 500);
|
|
6013
|
+
guard = addDisposableListener(targetWindow, 'click', (event) => {
|
|
6014
|
+
// Only suppress clicks targeted at the long-pressed element
|
|
6015
|
+
// or its descendants. A user tap on a context menu item (or
|
|
6016
|
+
// anywhere else) still gets through unchanged.
|
|
6017
|
+
const target = event.target;
|
|
6018
|
+
if (target && this.element.contains(target)) {
|
|
6019
|
+
event.preventDefault();
|
|
6020
|
+
event.stopPropagation();
|
|
6021
|
+
}
|
|
6022
|
+
clearTimeout(timeout);
|
|
6023
|
+
guard === null || guard === void 0 ? void 0 : guard.dispose();
|
|
6024
|
+
}, { capture: true });
|
|
6025
|
+
}
|
|
6026
|
+
_cancelPending() {
|
|
6027
|
+
var _a, _b, _c;
|
|
6028
|
+
if (this._timer !== undefined) {
|
|
6029
|
+
clearTimeout(this._timer);
|
|
6030
|
+
this._timer = undefined;
|
|
6031
|
+
}
|
|
6032
|
+
this._pointerId = undefined;
|
|
6033
|
+
(_a = this._moveListener) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
6034
|
+
(_b = this._upListener) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
6035
|
+
(_c = this._cancelListener) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
6036
|
+
this._moveListener = undefined;
|
|
6037
|
+
this._upListener = undefined;
|
|
6038
|
+
this._cancelListener = undefined;
|
|
6039
|
+
}
|
|
6040
|
+
dispose() {
|
|
6041
|
+
this._cancelPending();
|
|
6042
|
+
super.dispose();
|
|
6043
|
+
}
|
|
5251
6044
|
}
|
|
5252
6045
|
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
6046
|
+
function resolveDndCapabilities(options) {
|
|
6047
|
+
if (options.disableDnd) {
|
|
6048
|
+
return { html5: false, pointer: false, pointerHandlesMouse: false };
|
|
6049
|
+
}
|
|
6050
|
+
switch (options.dndStrategy) {
|
|
6051
|
+
case 'pointer':
|
|
6052
|
+
return { html5: false, pointer: true, pointerHandlesMouse: true };
|
|
6053
|
+
case 'html5':
|
|
6054
|
+
return { html5: true, pointer: false, pointerHandlesMouse: false };
|
|
6055
|
+
case 'auto':
|
|
6056
|
+
case undefined:
|
|
6057
|
+
default:
|
|
6058
|
+
// On touch-primary devices (phones / basic tablets) HTML5 DnD's
|
|
6059
|
+
// native long-press intercepts the gesture before our pointer
|
|
6060
|
+
// backend can react — Android Chrome launches a system drag with
|
|
6061
|
+
// its half-transparent thumbnail, and the long-press context menu
|
|
6062
|
+
// never opens. Disable HTML5 there so the pointer backend owns
|
|
6063
|
+
// every gesture. Hybrid devices (touchscreen laptops, Surface,
|
|
6064
|
+
// iPad with mouse) keep both backends — mouse uses HTML5, touch
|
|
6065
|
+
// falls back to whichever backend the underlying element wired.
|
|
6066
|
+
return isCoarsePrimaryInput$2()
|
|
6067
|
+
? { html5: false, pointer: true, pointerHandlesMouse: true }
|
|
6068
|
+
: { html5: true, pointer: true, pointerHandlesMouse: false };
|
|
5260
6069
|
}
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
5266
|
-
},
|
|
5267
|
-
};
|
|
6070
|
+
}
|
|
6071
|
+
function isCoarsePrimaryInput$2() {
|
|
6072
|
+
if (typeof window === 'undefined' || !window.matchMedia) {
|
|
6073
|
+
return false;
|
|
5268
6074
|
}
|
|
6075
|
+
// Coarse pointer without any fine pointer = phone-class device. A laptop
|
|
6076
|
+
// touchscreen reports both, and we want HTML5 to remain available there
|
|
6077
|
+
// because a real mouse is also plugged in.
|
|
6078
|
+
const coarse = window.matchMedia('(pointer: coarse)').matches;
|
|
6079
|
+
const fine = window.matchMedia('(pointer: fine)').matches;
|
|
6080
|
+
return coarse && !fine;
|
|
5269
6081
|
}
|
|
6082
|
+
|
|
5270
6083
|
class Tab extends CompositeDisposable {
|
|
5271
6084
|
get element() {
|
|
5272
6085
|
return this._element;
|
|
@@ -5277,6 +6090,7 @@ class Tab extends CompositeDisposable {
|
|
|
5277
6090
|
this.accessor = accessor;
|
|
5278
6091
|
this.group = group;
|
|
5279
6092
|
this.content = undefined;
|
|
6093
|
+
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
5280
6094
|
this._direction = 'horizontal';
|
|
5281
6095
|
this._onPointDown = new Emitter();
|
|
5282
6096
|
this.onPointerDown = this._onPointDown.event;
|
|
@@ -5288,114 +6102,106 @@ class Tab extends CompositeDisposable {
|
|
|
5288
6102
|
this.onDragStart = this._onDragStart.event;
|
|
5289
6103
|
this._onDragEnd = new Emitter();
|
|
5290
6104
|
this.onDragEnd = this._onDragEnd.event;
|
|
6105
|
+
const caps = resolveDndCapabilities(this.accessor.options);
|
|
5291
6106
|
this._element = document.createElement('div');
|
|
5292
6107
|
this._element.className = 'dv-tab';
|
|
5293
6108
|
this._element.tabIndex = 0;
|
|
5294
|
-
this._element.draggable =
|
|
6109
|
+
this._element.draggable = caps.html5;
|
|
5295
6110
|
toggleClass(this.element, 'dv-inactive-tab', true);
|
|
5296
|
-
|
|
5297
|
-
|
|
6111
|
+
const canDisplayOverlay = (event, position) => {
|
|
6112
|
+
var _a;
|
|
6113
|
+
if (this.group.locked) {
|
|
6114
|
+
return false;
|
|
6115
|
+
}
|
|
6116
|
+
const data = getPanelData();
|
|
6117
|
+
if (data && this.accessor.id === data.viewId) {
|
|
6118
|
+
// Smooth-reorder takes over the in-flight visual when active,
|
|
6119
|
+
// so individual tab overlays are suppressed for internal drags.
|
|
6120
|
+
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'smooth') {
|
|
6121
|
+
return false;
|
|
6122
|
+
}
|
|
6123
|
+
return true;
|
|
6124
|
+
}
|
|
6125
|
+
return this.group.model.canDisplayOverlay(event, position, 'tab');
|
|
6126
|
+
};
|
|
6127
|
+
this.dropTarget = html5Backend.createDropTarget(this._element, {
|
|
5298
6128
|
acceptedTargetZones: ['left', 'right'],
|
|
5299
6129
|
overlayModel: this._buildOverlayModel(),
|
|
5300
|
-
canDisplayOverlay
|
|
6130
|
+
canDisplayOverlay,
|
|
6131
|
+
getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
|
|
6132
|
+
});
|
|
6133
|
+
this.pointerDropTarget = pointerBackend.createDropTarget(this._element, {
|
|
6134
|
+
acceptedTargetZones: ['left', 'right'],
|
|
6135
|
+
overlayModel: this._buildOverlayModel(),
|
|
6136
|
+
canDisplayOverlay,
|
|
6137
|
+
getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
|
|
6138
|
+
});
|
|
6139
|
+
const sharedDragOptions = {
|
|
6140
|
+
getData: () => {
|
|
6141
|
+
this.panelTransfer.setData([
|
|
6142
|
+
new PanelTransfer(this.accessor.id, this.group.id, this.panel.id),
|
|
6143
|
+
], PanelTransfer.prototype);
|
|
6144
|
+
return {
|
|
6145
|
+
dispose: () => {
|
|
6146
|
+
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
6147
|
+
},
|
|
6148
|
+
};
|
|
6149
|
+
},
|
|
6150
|
+
// 30/-10 matches the HTML5 setDragImage offset that has been
|
|
6151
|
+
// shipped for years; pointer backend wraps in PointerGhost,
|
|
6152
|
+
// HTML5 backend feeds into setDragImage.
|
|
6153
|
+
createGhost: () => ({
|
|
6154
|
+
element: this._buildGhostElement(),
|
|
6155
|
+
offsetX: 30,
|
|
6156
|
+
offsetY: -10,
|
|
6157
|
+
}),
|
|
6158
|
+
onDragStart: (event) => {
|
|
5301
6159
|
var _a;
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
// (both same-group and cross-group) via
|
|
5311
|
-
// animation. Suppress the per-tab overlay so
|
|
5312
|
-
// the tab is dropped *beside* rather than *on*.
|
|
5313
|
-
return false;
|
|
5314
|
-
}
|
|
5315
|
-
return true;
|
|
6160
|
+
this._onDragStart.fire(event);
|
|
6161
|
+
if (!(event instanceof PointerEvent) &&
|
|
6162
|
+
((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'smooth') {
|
|
6163
|
+
// Delay collapse to next frame so the browser
|
|
6164
|
+
// captures the full drag image first.
|
|
6165
|
+
requestAnimationFrame(() => {
|
|
6166
|
+
toggleClass(this.element, 'dv-tab--dragging', true);
|
|
6167
|
+
});
|
|
5316
6168
|
}
|
|
5317
|
-
return this.group.model.canDisplayOverlay(event, position, 'tab');
|
|
5318
6169
|
},
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
6170
|
+
onDragEnd: (event) => {
|
|
6171
|
+
this._onDragEnd.fire(event);
|
|
6172
|
+
},
|
|
6173
|
+
};
|
|
6174
|
+
this.html5DragSource = html5Backend.createDragSource(this._element, Object.assign(Object.assign({}, sharedDragOptions), { disabled: !caps.html5 }));
|
|
6175
|
+
this.pointerDragSource = pointerBackend.createDragSource(this._element, Object.assign(Object.assign({}, sharedDragOptions), { disabled: !caps.pointer, touchOnly: !caps.pointerHandlesMouse, isCancelled: () => !resolveDndCapabilities(this.accessor.options).pointer }));
|
|
6176
|
+
// Both droptargets feed the same downstream stream; consumers don't
|
|
6177
|
+
// need to know which path produced the overlay.
|
|
6178
|
+
this.onWillShowOverlay = exports.DockviewEvent.any(this.dropTarget.onWillShowOverlay, this.pointerDropTarget.onWillShowOverlay);
|
|
5322
6179
|
this.addDisposables(this._onPointDown, this._onTabClick, this._onDropped, this._onDragStart, this._onDragEnd, this.accessor.onDidOptionsChange(() => {
|
|
5323
|
-
this.
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
const isVertical = this._direction === 'vertical';
|
|
5330
|
-
/**
|
|
5331
|
-
* Properties to skip when copying computed styles for a
|
|
5332
|
-
* vertical tab ghost. `writing-mode` is excluded so we
|
|
5333
|
-
* can force `horizontal-tb`. Size and margin logical
|
|
5334
|
-
* properties are excluded because their physical meaning
|
|
5335
|
-
* flips when writing-mode changes, which would produce
|
|
5336
|
-
* incorrect dimensions.
|
|
5337
|
-
*/
|
|
5338
|
-
const verticalSkip = new Set([
|
|
5339
|
-
'writing-mode',
|
|
5340
|
-
'inline-size',
|
|
5341
|
-
'block-size',
|
|
5342
|
-
'min-inline-size',
|
|
5343
|
-
'min-block-size',
|
|
5344
|
-
'max-inline-size',
|
|
5345
|
-
'max-block-size',
|
|
5346
|
-
'margin-inline',
|
|
5347
|
-
'margin-inline-start',
|
|
5348
|
-
'margin-inline-end',
|
|
5349
|
-
'margin-block',
|
|
5350
|
-
'margin-block-start',
|
|
5351
|
-
'margin-block-end',
|
|
5352
|
-
'padding-inline',
|
|
5353
|
-
'padding-inline-start',
|
|
5354
|
-
'padding-inline-end',
|
|
5355
|
-
'padding-block',
|
|
5356
|
-
'padding-block-start',
|
|
5357
|
-
'padding-block-end',
|
|
5358
|
-
]);
|
|
5359
|
-
Array.from(style).forEach((key) => {
|
|
5360
|
-
if (isVertical && verticalSkip.has(key)) {
|
|
5361
|
-
return;
|
|
5362
|
-
}
|
|
5363
|
-
newNode.style.setProperty(key, style.getPropertyValue(key), style.getPropertyPriority(key));
|
|
5364
|
-
});
|
|
5365
|
-
if (isVertical) {
|
|
5366
|
-
// Force horizontal text flow and swap the physical
|
|
5367
|
-
// dimensions so the ghost appears as a horizontal tab.
|
|
5368
|
-
newNode.style.setProperty('writing-mode', 'horizontal-tb');
|
|
5369
|
-
newNode.style.setProperty('width', style.height);
|
|
5370
|
-
newNode.style.setProperty('height', style.width);
|
|
5371
|
-
}
|
|
5372
|
-
newNode.style.position = 'absolute';
|
|
5373
|
-
newNode.classList.add('dv-tab-ghost-drag');
|
|
5374
|
-
addGhostImage(event.dataTransfer, newNode, {
|
|
5375
|
-
y: -10,
|
|
5376
|
-
x: 30,
|
|
5377
|
-
});
|
|
5378
|
-
}
|
|
5379
|
-
this._onDragStart.fire(event);
|
|
5380
|
-
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'smooth') {
|
|
5381
|
-
// Delay collapse to next frame so the browser
|
|
5382
|
-
// captures the full drag image first
|
|
5383
|
-
requestAnimationFrame(() => {
|
|
5384
|
-
toggleClass(this.element, 'dv-tab--dragging', true);
|
|
5385
|
-
});
|
|
5386
|
-
}
|
|
5387
|
-
}), addDisposableListener(this._element, 'dragend', (event) => {
|
|
6180
|
+
const model = this._buildOverlayModel();
|
|
6181
|
+
this.dropTarget.setOverlayModel(model);
|
|
6182
|
+
this.pointerDropTarget.setOverlayModel(model);
|
|
6183
|
+
}), addDisposableListener(this._element, 'dragend', () => {
|
|
6184
|
+
// The shared onDragEnd handler already fires _onDragEnd via
|
|
6185
|
+
// the HTML5 backend; just strip the dragging class here.
|
|
5388
6186
|
toggleClass(this.element, 'dv-tab--dragging', false);
|
|
5389
|
-
|
|
5390
|
-
}), this.dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
|
|
6187
|
+
}), this.html5DragSource, addDisposableListener(this._element, 'pointerdown', (event) => {
|
|
5391
6188
|
this._onPointDown.fire(event);
|
|
5392
6189
|
}), addDisposableListener(this._element, 'click', (event) => {
|
|
5393
6190
|
this._onTabClick.fire(event);
|
|
5394
6191
|
}), addDisposableListener(this._element, 'contextmenu', (event) => {
|
|
5395
6192
|
this.accessor.contextMenuController.show(this.panel, this.group, event);
|
|
6193
|
+
}), new LongPressDetector(this._element, {
|
|
6194
|
+
onLongPress: (event) => {
|
|
6195
|
+
// Don't let a subsequent finger move arm a drag on top
|
|
6196
|
+
// of the just-opened menu.
|
|
6197
|
+
this.pointerDragSource.cancelPending();
|
|
6198
|
+
this.accessor.contextMenuController.show(this.panel, this.group, event);
|
|
6199
|
+
},
|
|
5396
6200
|
}), this.dropTarget.onDrop((event) => {
|
|
5397
6201
|
this._onDropped.fire(event);
|
|
5398
|
-
}), this.
|
|
6202
|
+
}), this.pointerDropTarget.onDrop((event) => {
|
|
6203
|
+
this._onDropped.fire(event);
|
|
6204
|
+
}), this.dropTarget, this.pointerDropTarget, this.pointerDragSource);
|
|
5399
6205
|
}
|
|
5400
6206
|
setActive(isActive) {
|
|
5401
6207
|
toggleClass(this.element, 'dv-active-tab', isActive);
|
|
@@ -5425,11 +6231,60 @@ class Tab extends CompositeDisposable {
|
|
|
5425
6231
|
}
|
|
5426
6232
|
setDirection(direction) {
|
|
5427
6233
|
this._direction = direction;
|
|
5428
|
-
|
|
6234
|
+
const zones = direction === 'vertical' ? ['top', 'bottom'] : ['left', 'right'];
|
|
6235
|
+
this.dropTarget.setTargetZones(zones);
|
|
6236
|
+
this.pointerDropTarget.setTargetZones(zones);
|
|
5429
6237
|
}
|
|
5430
6238
|
updateDragAndDropState() {
|
|
5431
|
-
|
|
5432
|
-
this.
|
|
6239
|
+
const caps = resolveDndCapabilities(this.accessor.options);
|
|
6240
|
+
this._element.draggable = caps.html5;
|
|
6241
|
+
this.html5DragSource.setDisabled(!caps.html5);
|
|
6242
|
+
this.pointerDragSource.setDisabled(!caps.pointer);
|
|
6243
|
+
this.pointerDragSource.setTouchOnly(!caps.pointerHandlesMouse);
|
|
6244
|
+
}
|
|
6245
|
+
/**
|
|
6246
|
+
* Vertical tabs are flipped to horizontal so the ghost stays readable
|
|
6247
|
+
* during the drag rather than appearing sideways-rotated.
|
|
6248
|
+
*/
|
|
6249
|
+
_buildGhostElement() {
|
|
6250
|
+
const style = getComputedStyle(this.element);
|
|
6251
|
+
const newNode = this.element.cloneNode(true);
|
|
6252
|
+
const isVertical = this._direction === 'vertical';
|
|
6253
|
+
const verticalSkip = new Set([
|
|
6254
|
+
'writing-mode',
|
|
6255
|
+
'inline-size',
|
|
6256
|
+
'block-size',
|
|
6257
|
+
'min-inline-size',
|
|
6258
|
+
'min-block-size',
|
|
6259
|
+
'max-inline-size',
|
|
6260
|
+
'max-block-size',
|
|
6261
|
+
'margin-inline',
|
|
6262
|
+
'margin-inline-start',
|
|
6263
|
+
'margin-inline-end',
|
|
6264
|
+
'margin-block',
|
|
6265
|
+
'margin-block-start',
|
|
6266
|
+
'margin-block-end',
|
|
6267
|
+
'padding-inline',
|
|
6268
|
+
'padding-inline-start',
|
|
6269
|
+
'padding-inline-end',
|
|
6270
|
+
'padding-block',
|
|
6271
|
+
'padding-block-start',
|
|
6272
|
+
'padding-block-end',
|
|
6273
|
+
]);
|
|
6274
|
+
Array.from(style).forEach((key) => {
|
|
6275
|
+
if (isVertical && verticalSkip.has(key)) {
|
|
6276
|
+
return;
|
|
6277
|
+
}
|
|
6278
|
+
newNode.style.setProperty(key, style.getPropertyValue(key), style.getPropertyPriority(key));
|
|
6279
|
+
});
|
|
6280
|
+
if (isVertical) {
|
|
6281
|
+
newNode.style.setProperty('writing-mode', 'horizontal-tb');
|
|
6282
|
+
newNode.style.setProperty('width', style.height);
|
|
6283
|
+
newNode.style.setProperty('height', style.width);
|
|
6284
|
+
}
|
|
6285
|
+
newNode.style.position = 'absolute';
|
|
6286
|
+
newNode.classList.add('dv-tab-ghost-drag');
|
|
6287
|
+
return newNode;
|
|
5433
6288
|
}
|
|
5434
6289
|
}
|
|
5435
6290
|
|
|
@@ -5437,6 +6292,7 @@ class DockviewWillShowOverlayLocationEvent {
|
|
|
5437
6292
|
get kind() {
|
|
5438
6293
|
return this.options.kind;
|
|
5439
6294
|
}
|
|
6295
|
+
/** Narrow with `instanceof DragEvent` before reading `dataTransfer`. */
|
|
5440
6296
|
get nativeEvent() {
|
|
5441
6297
|
return this.event.nativeEvent;
|
|
5442
6298
|
}
|
|
@@ -5467,131 +6323,202 @@ class DockviewWillShowOverlayLocationEvent {
|
|
|
5467
6323
|
}
|
|
5468
6324
|
}
|
|
5469
6325
|
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
5476
|
-
this.addDisposables(addDisposableListener(element, 'pointerdown', (e) => {
|
|
5477
|
-
if (e.shiftKey) {
|
|
5478
|
-
/**
|
|
5479
|
-
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
5480
|
-
* but we also need to stop any group overlay drag events from occuring
|
|
5481
|
-
* Use a custom event marker that can be checked by the overlay drag events
|
|
5482
|
-
*/
|
|
5483
|
-
quasiPreventDefault(e);
|
|
5484
|
-
}
|
|
5485
|
-
}, true));
|
|
5486
|
-
}
|
|
5487
|
-
isCancelled(_event) {
|
|
5488
|
-
if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
|
|
5489
|
-
return true;
|
|
5490
|
-
}
|
|
5491
|
-
if (this.group.api.location.type === 'edge' && this.group.size === 0) {
|
|
5492
|
-
return true;
|
|
5493
|
-
}
|
|
5494
|
-
return false;
|
|
5495
|
-
}
|
|
5496
|
-
getData(dragEvent) {
|
|
5497
|
-
const dataTransfer = dragEvent.dataTransfer;
|
|
5498
|
-
this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
|
|
5499
|
-
const style = window.getComputedStyle(this.el);
|
|
5500
|
-
const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
|
|
5501
|
-
const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
|
|
5502
|
-
if (dataTransfer) {
|
|
5503
|
-
const createGhost = this.accessor.options.createGroupDragGhostComponent;
|
|
5504
|
-
let ghostElement;
|
|
5505
|
-
let customRenderer;
|
|
5506
|
-
if (createGhost) {
|
|
5507
|
-
customRenderer = createGhost(this.group);
|
|
5508
|
-
customRenderer.init({
|
|
5509
|
-
group: this.group,
|
|
5510
|
-
api: this.accessor.api,
|
|
5511
|
-
});
|
|
5512
|
-
ghostElement = customRenderer.element;
|
|
5513
|
-
ghostElement.style.position = 'absolute';
|
|
5514
|
-
ghostElement.style.pointerEvents = 'none';
|
|
5515
|
-
ghostElement.style.top = '-9999px';
|
|
5516
|
-
}
|
|
5517
|
-
else {
|
|
5518
|
-
ghostElement = document.createElement('div');
|
|
5519
|
-
ghostElement.style.backgroundColor = bgColor;
|
|
5520
|
-
ghostElement.style.color = color;
|
|
5521
|
-
ghostElement.style.padding = '2px 8px';
|
|
5522
|
-
ghostElement.style.height = '24px';
|
|
5523
|
-
ghostElement.style.fontSize = '11px';
|
|
5524
|
-
ghostElement.style.lineHeight = '20px';
|
|
5525
|
-
ghostElement.style.borderRadius = '12px';
|
|
5526
|
-
ghostElement.style.position = 'absolute';
|
|
5527
|
-
ghostElement.style.pointerEvents = 'none';
|
|
5528
|
-
ghostElement.style.top = '-9999px';
|
|
5529
|
-
ghostElement.textContent = `Multiple Panels (${this.group.size})`;
|
|
5530
|
-
}
|
|
5531
|
-
addGhostImage(dataTransfer, ghostElement, { y: -10, x: 30 });
|
|
5532
|
-
if (customRenderer === null || customRenderer === void 0 ? void 0 : customRenderer.dispose) {
|
|
5533
|
-
// addGhostImage removes the element from the DOM on the next
|
|
5534
|
-
// tick; dispose the framework renderer on the same schedule.
|
|
5535
|
-
const renderer = customRenderer;
|
|
5536
|
-
setTimeout(() => { var _a; return (_a = renderer.dispose) === null || _a === void 0 ? void 0 : _a.call(renderer); }, 0);
|
|
5537
|
-
}
|
|
5538
|
-
}
|
|
5539
|
-
return {
|
|
5540
|
-
dispose: () => {
|
|
5541
|
-
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
5542
|
-
},
|
|
5543
|
-
};
|
|
5544
|
-
}
|
|
5545
|
-
}
|
|
5546
|
-
|
|
6326
|
+
// Floating-group redock via touch: require a deliberate long press so the
|
|
6327
|
+
// "move the float around" gesture doesn't double-trigger the redock ghost.
|
|
6328
|
+
// Infinity pressTolerance disables the pre-arm flick override; any motion
|
|
6329
|
+
// during the wait is treated as drag-the-float, not redock intent.
|
|
6330
|
+
const FLOATING_REDOCK_INITIATION_DELAY_MS = 500;
|
|
5547
6331
|
class VoidContainer extends CompositeDisposable {
|
|
5548
6332
|
get element() {
|
|
5549
6333
|
return this._element;
|
|
5550
6334
|
}
|
|
5551
6335
|
constructor(accessor, group) {
|
|
6336
|
+
var _a, _b;
|
|
5552
6337
|
super();
|
|
5553
6338
|
this.accessor = accessor;
|
|
5554
6339
|
this.group = group;
|
|
6340
|
+
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
5555
6341
|
this._onDrop = new Emitter();
|
|
5556
6342
|
this.onDrop = this._onDrop.event;
|
|
5557
6343
|
this._onDragStart = new Emitter();
|
|
5558
6344
|
this.onDragStart = this._onDragStart.event;
|
|
6345
|
+
const caps = resolveDndCapabilities(this.accessor.options);
|
|
5559
6346
|
this._element = document.createElement('div');
|
|
5560
6347
|
this._element.className = 'dv-void-container';
|
|
5561
|
-
this._element.draggable =
|
|
5562
|
-
toggleClass(this._element, 'dv-draggable',
|
|
6348
|
+
this._element.draggable = caps.html5;
|
|
6349
|
+
toggleClass(this._element, 'dv-draggable', caps.html5 || caps.pointer);
|
|
5563
6350
|
this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
|
|
5564
6351
|
this.accessor.doSetGroupActive(this.group);
|
|
5565
|
-
})
|
|
5566
|
-
|
|
5567
|
-
|
|
6352
|
+
}),
|
|
6353
|
+
// Shift+pointerdown marks the event so the group's overlay
|
|
6354
|
+
// drag (move-by-floating) sees it was consumed and doesn't
|
|
6355
|
+
// fire alongside the HTML5 drag. quasiPreventDefault sets the
|
|
6356
|
+
// marker without calling preventDefault — that would also
|
|
6357
|
+
// block dragstart, which we need to fire.
|
|
6358
|
+
addDisposableListener(this._element, 'pointerdown', (e) => {
|
|
6359
|
+
if (e.shiftKey) {
|
|
6360
|
+
quasiPreventDefault(e);
|
|
6361
|
+
}
|
|
6362
|
+
}, true));
|
|
6363
|
+
const canDisplayOverlay = (event, position) => {
|
|
6364
|
+
if (this.group.api.locked) {
|
|
6365
|
+
// Dropping on the void/header space adds the panel
|
|
6366
|
+
// to this group, which `locked` is meant to prevent
|
|
6367
|
+
// (both `true` and `'no-drop-target'`).
|
|
6368
|
+
return false;
|
|
6369
|
+
}
|
|
6370
|
+
const data = getPanelData();
|
|
6371
|
+
if (data && this.accessor.id === data.viewId) {
|
|
6372
|
+
return true;
|
|
6373
|
+
}
|
|
6374
|
+
return group.model.canDisplayOverlay(event, position, 'header_space');
|
|
6375
|
+
};
|
|
6376
|
+
this.dropTarget = html5Backend.createDropTarget(this._element, {
|
|
5568
6377
|
acceptedTargetZones: ['center'],
|
|
5569
|
-
canDisplayOverlay
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
6378
|
+
canDisplayOverlay,
|
|
6379
|
+
getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
|
|
6380
|
+
});
|
|
6381
|
+
this.pointerDropTarget = pointerBackend.createDropTarget(this._element, {
|
|
6382
|
+
acceptedTargetZones: ['center'],
|
|
6383
|
+
canDisplayOverlay,
|
|
6384
|
+
getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
|
|
6385
|
+
});
|
|
6386
|
+
const buildMultiPanelsGhost = () => {
|
|
6387
|
+
const ghostEl = document.createElement('div');
|
|
6388
|
+
const style = window.getComputedStyle(this._element);
|
|
6389
|
+
const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
|
|
6390
|
+
const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
|
|
6391
|
+
ghostEl.style.backgroundColor = bgColor;
|
|
6392
|
+
ghostEl.style.color = color;
|
|
6393
|
+
ghostEl.style.padding = '2px 8px';
|
|
6394
|
+
ghostEl.style.height = '24px';
|
|
6395
|
+
ghostEl.style.fontSize = '11px';
|
|
6396
|
+
ghostEl.style.lineHeight = '20px';
|
|
6397
|
+
ghostEl.style.borderRadius = '12px';
|
|
6398
|
+
ghostEl.style.whiteSpace = 'nowrap';
|
|
6399
|
+
ghostEl.style.boxSizing = 'border-box';
|
|
6400
|
+
// HTML5 setDragImage snapshots the element as appended to the
|
|
6401
|
+
// document; a default block-level div would stretch to the
|
|
6402
|
+
// body's width and render as a viewport-wide bar.
|
|
6403
|
+
ghostEl.style.display = 'inline-block';
|
|
6404
|
+
ghostEl.textContent = `Multiple Panels (${this.group.size})`;
|
|
6405
|
+
return ghostEl;
|
|
6406
|
+
};
|
|
6407
|
+
const buildGhostSpec = () => {
|
|
6408
|
+
const createGhost = this.accessor.options.createGroupDragGhostComponent;
|
|
6409
|
+
if (createGhost) {
|
|
6410
|
+
const renderer = createGhost(this.group);
|
|
6411
|
+
renderer.init({
|
|
6412
|
+
group: this.group,
|
|
6413
|
+
api: this.accessor.api,
|
|
6414
|
+
});
|
|
6415
|
+
return {
|
|
6416
|
+
element: renderer.element,
|
|
6417
|
+
offsetX: 30,
|
|
6418
|
+
offsetY: -10,
|
|
6419
|
+
dispose: renderer.dispose
|
|
6420
|
+
? () => { var _a; return (_a = renderer.dispose) === null || _a === void 0 ? void 0 : _a.call(renderer); }
|
|
6421
|
+
: undefined,
|
|
6422
|
+
};
|
|
6423
|
+
}
|
|
6424
|
+
return {
|
|
6425
|
+
element: buildMultiPanelsGhost(),
|
|
6426
|
+
offsetX: 30,
|
|
6427
|
+
offsetY: -10,
|
|
6428
|
+
};
|
|
6429
|
+
};
|
|
6430
|
+
const sharedDragOptions = {
|
|
6431
|
+
getData: () => {
|
|
6432
|
+
this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
|
|
6433
|
+
return {
|
|
6434
|
+
dispose: () => {
|
|
6435
|
+
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
6436
|
+
},
|
|
6437
|
+
};
|
|
6438
|
+
},
|
|
6439
|
+
createGhost: buildGhostSpec,
|
|
6440
|
+
onDragStart: (event) => {
|
|
6441
|
+
this._onDragStart.fire(event);
|
|
6442
|
+
},
|
|
6443
|
+
};
|
|
6444
|
+
this.html5DragSource = html5Backend.createDragSource(this._element, Object.assign(Object.assign({}, sharedDragOptions), { disabled: !caps.html5, isCancelled: (event) => {
|
|
6445
|
+
// HTML5: floating groups need shift+drag as the explicit
|
|
6446
|
+
// detach gesture (otherwise click-and-drag conflicts with
|
|
6447
|
+
// moving the floating group itself).
|
|
6448
|
+
if (this.group.api.location.type === 'floating' &&
|
|
6449
|
+
!event.shiftKey) {
|
|
6450
|
+
return true;
|
|
5575
6451
|
}
|
|
5576
|
-
|
|
5577
|
-
|
|
6452
|
+
if (this.group.api.location.type === 'edge' &&
|
|
6453
|
+
this.group.size === 0) {
|
|
5578
6454
|
return true;
|
|
5579
6455
|
}
|
|
5580
|
-
return
|
|
5581
|
-
}
|
|
5582
|
-
|
|
5583
|
-
})
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
6456
|
+
return false;
|
|
6457
|
+
} }));
|
|
6458
|
+
const isFloating = () => { var _a, _b, _c; return ((_c = (_b = (_a = this.group) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.location) === null || _c === void 0 ? void 0 : _c.type) === 'floating'; };
|
|
6459
|
+
this.pointerDragSource = pointerBackend.createDragSource(this._element, Object.assign(Object.assign({}, sharedDragOptions), { disabled: !caps.pointer, touchOnly: !caps.pointerHandlesMouse,
|
|
6460
|
+
// Floating groups share this element with the overlay's
|
|
6461
|
+
// move-the-float drag. Without a longer hold + tolerance
|
|
6462
|
+
// override, both gestures commit simultaneously and the
|
|
6463
|
+
// user sees the float follow their finger *and* a ghost.
|
|
6464
|
+
touchInitiationDelay: () => isFloating() ? FLOATING_REDOCK_INITIATION_DELAY_MS : 250, pressTolerance: () => (isFloating() ? Infinity : 8), isCancelled: () => {
|
|
6465
|
+
if (!resolveDndCapabilities(this.accessor.options).pointer) {
|
|
6466
|
+
return true;
|
|
6467
|
+
}
|
|
6468
|
+
// Pointer: long-press IS the deliberate gesture, so
|
|
6469
|
+
// floating groups don't need the shift gate.
|
|
6470
|
+
if (this.group.api.location.type === 'edge' &&
|
|
6471
|
+
this.group.size === 0) {
|
|
6472
|
+
return true;
|
|
6473
|
+
}
|
|
6474
|
+
return false;
|
|
6475
|
+
}, onDragStart: (event) => {
|
|
6476
|
+
var _a;
|
|
6477
|
+
// Redock just committed — abort any in-flight overlay
|
|
6478
|
+
// move so the float stops following the finger while
|
|
6479
|
+
// the ghost takes over.
|
|
6480
|
+
(_a = this.getFloatingOverlay()) === null || _a === void 0 ? void 0 : _a.cancelPendingDrag();
|
|
6481
|
+
this._onDragStart.fire(event);
|
|
6482
|
+
} }));
|
|
6483
|
+
// Mirror direction: once the overlay's move-the-float gesture has
|
|
6484
|
+
// actually moved something, cancel the pending redock arm so the
|
|
6485
|
+
// ghost doesn't appear mid-drag if the user holds past 500ms.
|
|
6486
|
+
const overlayMoveSub = new MutableDisposable();
|
|
6487
|
+
const refreshOverlayMoveSub = () => {
|
|
6488
|
+
const overlay = this.getFloatingOverlay();
|
|
6489
|
+
overlayMoveSub.value = overlay
|
|
6490
|
+
? overlay.onDidStartMoving(() => {
|
|
6491
|
+
this.pointerDragSource.cancelPending();
|
|
6492
|
+
})
|
|
6493
|
+
: exports.DockviewDisposable.NONE;
|
|
6494
|
+
};
|
|
6495
|
+
refreshOverlayMoveSub();
|
|
6496
|
+
this.addDisposables(overlayMoveSub);
|
|
6497
|
+
const locationChange = (_b = (_a = this.group) === null || _a === void 0 ? void 0 : _a.api) === null || _b === void 0 ? void 0 : _b.onDidLocationChange;
|
|
6498
|
+
if (locationChange) {
|
|
6499
|
+
this.addDisposables(locationChange(refreshOverlayMoveSub));
|
|
6500
|
+
}
|
|
6501
|
+
this.onWillShowOverlay = exports.DockviewEvent.any(this.dropTarget.onWillShowOverlay, this.pointerDropTarget.onWillShowOverlay);
|
|
6502
|
+
this.addDisposables(this.html5DragSource, this.dropTarget.onDrop((event) => {
|
|
6503
|
+
this._onDrop.fire(event);
|
|
6504
|
+
}), this.pointerDropTarget.onDrop((event) => {
|
|
5588
6505
|
this._onDrop.fire(event);
|
|
5589
|
-
}), this.dropTarget);
|
|
6506
|
+
}), this.dropTarget, this.pointerDropTarget, this.pointerDragSource);
|
|
5590
6507
|
}
|
|
5591
6508
|
updateDragAndDropState() {
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
6509
|
+
const caps = resolveDndCapabilities(this.accessor.options);
|
|
6510
|
+
this._element.draggable = caps.html5;
|
|
6511
|
+
toggleClass(this._element, 'dv-draggable', caps.html5 || caps.pointer);
|
|
6512
|
+
this.html5DragSource.setDisabled(!caps.html5);
|
|
6513
|
+
this.pointerDragSource.setDisabled(!caps.pointer);
|
|
6514
|
+
this.pointerDragSource.setTouchOnly(!caps.pointerHandlesMouse);
|
|
6515
|
+
}
|
|
6516
|
+
getFloatingOverlay() {
|
|
6517
|
+
var _a, _b;
|
|
6518
|
+
if (!this.group) {
|
|
6519
|
+
return undefined;
|
|
6520
|
+
}
|
|
6521
|
+
return (_b = (_a = this.accessor.floatingGroups) === null || _a === void 0 ? void 0 : _a.find((fg) => fg.group === this.group)) === null || _b === void 0 ? void 0 : _b.overlay;
|
|
5595
6522
|
}
|
|
5596
6523
|
}
|
|
5597
6524
|
|
|
@@ -5847,6 +6774,14 @@ function resolveTabGroupAccent(color, palette) {
|
|
|
5847
6774
|
return (palette !== null && palette !== void 0 ? palette : getFallbackPalette()).resolveValue(color);
|
|
5848
6775
|
}
|
|
5849
6776
|
|
|
6777
|
+
/**
|
|
6778
|
+
* Visual chip for a tab group. Owns the DOM element, label, click /
|
|
6779
|
+
* context-menu interactions, and exposes a long-press gesture as a
|
|
6780
|
+
* second `onContextMenu` source. Drag-and-drop wiring lives in
|
|
6781
|
+
* `TabGroupManager` — the manager constructs the drag sources on this
|
|
6782
|
+
* chip's element so it can include tabs-list context (custom group
|
|
6783
|
+
* drag image, tab-group transfer payload).
|
|
6784
|
+
*/
|
|
5850
6785
|
class TabGroupChip extends CompositeDisposable {
|
|
5851
6786
|
get element() {
|
|
5852
6787
|
return this._element;
|
|
@@ -5857,22 +6792,22 @@ class TabGroupChip extends CompositeDisposable {
|
|
|
5857
6792
|
this._onClick = new Emitter();
|
|
5858
6793
|
this.onClick = this._onClick.event;
|
|
5859
6794
|
this._onContextMenu = new Emitter();
|
|
6795
|
+
/** Fires on right-click and on touch long-press. */
|
|
5860
6796
|
this.onContextMenu = this._onContextMenu.event;
|
|
5861
|
-
this._onDragStart = new Emitter();
|
|
5862
|
-
this.onDragStart = this._onDragStart.event;
|
|
5863
6797
|
this._element = document.createElement('div');
|
|
5864
6798
|
this._element.className = 'dv-tab-group-chip';
|
|
5865
6799
|
this._element.tabIndex = 0;
|
|
5866
|
-
this._element.draggable = true;
|
|
5867
6800
|
this._label = document.createElement('span');
|
|
5868
6801
|
this._label.className = 'dv-tab-group-chip-label';
|
|
5869
6802
|
this._element.appendChild(this._label);
|
|
5870
|
-
this.addDisposables(this._onClick, this._onContextMenu,
|
|
6803
|
+
this.addDisposables(this._onClick, this._onContextMenu, new LongPressDetector(this._element, {
|
|
6804
|
+
onLongPress: (event) => {
|
|
6805
|
+
this._onContextMenu.fire(event);
|
|
6806
|
+
},
|
|
6807
|
+
}), addDisposableListener(this._element, 'click', (event) => {
|
|
5871
6808
|
this._onClick.fire(event);
|
|
5872
6809
|
}), addDisposableListener(this._element, 'contextmenu', (event) => {
|
|
5873
6810
|
this._onContextMenu.fire(event);
|
|
5874
|
-
}), addDisposableListener(this._element, 'dragstart', (event) => {
|
|
5875
|
-
this._onDragStart.fire(event);
|
|
5876
6811
|
}));
|
|
5877
6812
|
}
|
|
5878
6813
|
init(params) {
|
|
@@ -6336,6 +7271,12 @@ class TabGroupManager {
|
|
|
6336
7271
|
this._positionChipForGroup(tabGroup);
|
|
6337
7272
|
}
|
|
6338
7273
|
}
|
|
7274
|
+
updateDirection() {
|
|
7275
|
+
const isVertical = this._ctx.getDirection() === 'vertical';
|
|
7276
|
+
for (const [, entry] of this._chipRenderers) {
|
|
7277
|
+
entry.dropTarget.setTargetZones(isVertical ? ['top'] : ['left']);
|
|
7278
|
+
}
|
|
7279
|
+
}
|
|
6339
7280
|
snapshotChipWidths() {
|
|
6340
7281
|
const widths = new Map();
|
|
6341
7282
|
for (const [groupId, entry] of this._chipRenderers) {
|
|
@@ -6429,6 +7370,45 @@ class TabGroupManager {
|
|
|
6429
7370
|
(_a = this._pendingTransitionCleanups.get(panelId)) === null || _a === void 0 ? void 0 : _a();
|
|
6430
7371
|
this._pendingTransitionCleanups.delete(panelId);
|
|
6431
7372
|
}
|
|
7373
|
+
updateDragAndDropState() {
|
|
7374
|
+
const caps = resolveDndCapabilities(this._ctx.accessor.options);
|
|
7375
|
+
for (const entry of this._chipRenderers.values()) {
|
|
7376
|
+
entry.chip.element.draggable = caps.html5;
|
|
7377
|
+
entry.html5DragSource.setDisabled(!caps.html5);
|
|
7378
|
+
entry.pointerDragSource.setDisabled(!caps.pointer);
|
|
7379
|
+
entry.pointerDragSource.setTouchOnly(!caps.pointerHandlesMouse);
|
|
7380
|
+
}
|
|
7381
|
+
}
|
|
7382
|
+
/**
|
|
7383
|
+
* Synchronously dispose the chip drag sources for an in-flight chip
|
|
7384
|
+
* drag. Called from `_commitGroupMove` so the transfer payload +
|
|
7385
|
+
* iframe shield are released BEFORE the cross-group move detaches
|
|
7386
|
+
* the chip (chip dispose is scheduled on a microtask via
|
|
7387
|
+
* `_scheduleTabGroupUpdate`, which is too late for callers that read
|
|
7388
|
+
* `getPanelData()` synchronously after the move). Idempotent — the
|
|
7389
|
+
* subsequent `update()` will also dispose the sources.
|
|
7390
|
+
*/
|
|
7391
|
+
disposeChipDrag(tabGroupId) {
|
|
7392
|
+
var _a, _b;
|
|
7393
|
+
const entry = this._chipRenderers.get(tabGroupId);
|
|
7394
|
+
if (!entry) {
|
|
7395
|
+
return;
|
|
7396
|
+
}
|
|
7397
|
+
// Optional-chained because tests may inject minimal entries
|
|
7398
|
+
// that skip the manager's normal `_ensureChipForGroup` flow.
|
|
7399
|
+
(_a = entry.html5DragSource) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
7400
|
+
(_b = entry.pointerDragSource) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
7401
|
+
}
|
|
7402
|
+
/** Cloned chip rect used as the pointer follow-finger ghost. */
|
|
7403
|
+
_buildChipGhostElement(chipEl) {
|
|
7404
|
+
const style = getComputedStyle(chipEl);
|
|
7405
|
+
const clone = chipEl.cloneNode(true);
|
|
7406
|
+
Array.from(style).forEach((key) => {
|
|
7407
|
+
clone.style.setProperty(key, style.getPropertyValue(key), style.getPropertyPriority(key));
|
|
7408
|
+
});
|
|
7409
|
+
clone.style.position = 'absolute';
|
|
7410
|
+
return clone;
|
|
7411
|
+
}
|
|
6432
7412
|
disposeAll() {
|
|
6433
7413
|
var _a;
|
|
6434
7414
|
(_a = this._indicator) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
@@ -6474,6 +7454,74 @@ class TabGroupManager {
|
|
|
6474
7454
|
? createChip(tabGroup)
|
|
6475
7455
|
: new TabGroupChip(this._ctx.accessor.tabGroupColorPalette);
|
|
6476
7456
|
chip.init({ tabGroup, api: this._ctx.accessor.api });
|
|
7457
|
+
const caps = resolveDndCapabilities(this._ctx.accessor.options);
|
|
7458
|
+
chip.element.draggable = caps.html5;
|
|
7459
|
+
const panelTransfer = LocalSelectionTransfer.getInstance();
|
|
7460
|
+
// Shared `getData` for both backends. Sets a group-level
|
|
7461
|
+
// PanelTransfer (panelId=null, tabGroupId identifies the group).
|
|
7462
|
+
// The returned disposer clears it on drag end.
|
|
7463
|
+
const getData = () => {
|
|
7464
|
+
panelTransfer.setData([
|
|
7465
|
+
new PanelTransfer(this._ctx.accessor.id, this._ctx.group.id, null, tabGroup.id),
|
|
7466
|
+
], PanelTransfer.prototype);
|
|
7467
|
+
return {
|
|
7468
|
+
dispose: () => {
|
|
7469
|
+
panelTransfer.clearData(PanelTransfer.prototype);
|
|
7470
|
+
},
|
|
7471
|
+
};
|
|
7472
|
+
};
|
|
7473
|
+
// The chip's HTML5 drag image is the cloned tabs list (chip only),
|
|
7474
|
+
// mounted inside the dockview root for CSS-variable inheritance and
|
|
7475
|
+
// positioned against the chip's in-place rect. Layout-dependent
|
|
7476
|
+
// offset means we set the drag image directly in `onDragStart`
|
|
7477
|
+
// (inside the dragstart handler) rather than via the generic
|
|
7478
|
+
// `createGhost` factory, which only knows about ghost specs that
|
|
7479
|
+
// can be appended to `document.body`.
|
|
7480
|
+
const html5DragSource = html5Backend.createDragSource(chip.element, {
|
|
7481
|
+
getData,
|
|
7482
|
+
disabled: !caps.html5,
|
|
7483
|
+
isCancelled: () => !resolveDndCapabilities(this._ctx.accessor.options).html5,
|
|
7484
|
+
onDragStart: (event) => {
|
|
7485
|
+
// Type guard via `dataTransfer` — `instanceof DragEvent`
|
|
7486
|
+
// would throw in jsdom which doesn't ship a DragEvent
|
|
7487
|
+
// constructor.
|
|
7488
|
+
if ('dataTransfer' in event && event.dataTransfer) {
|
|
7489
|
+
this.setGroupDragImage(event, tabGroup, chip.element);
|
|
7490
|
+
}
|
|
7491
|
+
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
7492
|
+
},
|
|
7493
|
+
onDragEnd: (event) => {
|
|
7494
|
+
var _a, _b;
|
|
7495
|
+
(_b = (_a = this._callbacks).onChipDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, tabGroup, chip, event);
|
|
7496
|
+
},
|
|
7497
|
+
});
|
|
7498
|
+
// Synchronous panelTransfer cleanup directly on the chip element.
|
|
7499
|
+
// `Html5DragSource`'s dragend defers data disposal via `setTimeout(0)`
|
|
7500
|
+
// so drop handlers can read the payload — but a chip drag that
|
|
7501
|
+
// ends via `moveGroupOrPanel` (no actual drop event) needs the
|
|
7502
|
+
// singleton cleared immediately, otherwise a synchronous
|
|
7503
|
+
// `getPanelData()` after the move still sees the stale chip
|
|
7504
|
+
// payload. Attached directly (not via `addDisposableListener`) so
|
|
7505
|
+
// the listener survives chip disposal in the detach-then-dragend
|
|
7506
|
+
// cross-group path; `once: true` auto-removes after the single
|
|
7507
|
+
// dragend that we care about. (#1254)
|
|
7508
|
+
chip.element.addEventListener('dragend', () => {
|
|
7509
|
+
panelTransfer.clearData(PanelTransfer.prototype);
|
|
7510
|
+
}, { once: true });
|
|
7511
|
+
const pointerDragSource = pointerBackend.createDragSource(chip.element, {
|
|
7512
|
+
getData,
|
|
7513
|
+
disabled: !caps.pointer,
|
|
7514
|
+
touchOnly: !caps.pointerHandlesMouse,
|
|
7515
|
+
isCancelled: () => !resolveDndCapabilities(this._ctx.accessor.options).pointer,
|
|
7516
|
+
createGhost: () => ({
|
|
7517
|
+
element: this._buildChipGhostElement(chip.element),
|
|
7518
|
+
offsetX: 8,
|
|
7519
|
+
offsetY: 8,
|
|
7520
|
+
}),
|
|
7521
|
+
onDragStart: (event) => {
|
|
7522
|
+
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
7523
|
+
},
|
|
7524
|
+
});
|
|
6477
7525
|
const disposables = [
|
|
6478
7526
|
tabGroup.onDidChange(() => {
|
|
6479
7527
|
var _a;
|
|
@@ -6487,24 +7535,70 @@ class TabGroupManager {
|
|
|
6487
7535
|
tabGroup.onDidCollapseChange(() => {
|
|
6488
7536
|
this._updateTabGroupClasses();
|
|
6489
7537
|
}),
|
|
7538
|
+
html5DragSource,
|
|
7539
|
+
pointerDragSource,
|
|
6490
7540
|
];
|
|
6491
|
-
//
|
|
7541
|
+
// Context menu: built-in TabGroupChip already aggregates right-click
|
|
7542
|
+
// + touch long-press into `onContextMenu`. Custom chip renderers
|
|
7543
|
+
// don't, so attach a long-press detector and contextmenu listener
|
|
7544
|
+
// directly on their element.
|
|
7545
|
+
const onContextMenu = (event) => {
|
|
7546
|
+
// A long-press on a chip should preempt the in-flight pointer
|
|
7547
|
+
// drag and open the menu instead.
|
|
7548
|
+
pointerDragSource.cancelPending();
|
|
7549
|
+
this._callbacks.onChipContextMenu(tabGroup, event);
|
|
7550
|
+
};
|
|
6492
7551
|
if (chip instanceof TabGroupChip) {
|
|
6493
|
-
disposables.push(chip.onContextMenu(
|
|
6494
|
-
this._callbacks.onChipContextMenu(tabGroup, event);
|
|
6495
|
-
}), chip.onDragStart((event) => {
|
|
6496
|
-
this._callbacks.onChipDragStart(tabGroup, chip, event);
|
|
6497
|
-
}));
|
|
7552
|
+
disposables.push(chip.onContextMenu(onContextMenu));
|
|
6498
7553
|
}
|
|
6499
7554
|
else {
|
|
6500
|
-
disposables.push(
|
|
6501
|
-
|
|
6502
|
-
}), addDisposableListener(chip.element, '
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
7555
|
+
disposables.push(new LongPressDetector(chip.element, {
|
|
7556
|
+
onLongPress: onContextMenu,
|
|
7557
|
+
}), addDisposableListener(chip.element, 'contextmenu', onContextMenu));
|
|
7558
|
+
}
|
|
7559
|
+
// The chip sits before its group's first tab in the DOM, so it
|
|
7560
|
+
// covers the "drop before the group" position. Without a drop
|
|
7561
|
+
// target here, dropping a tab over the chip is a dead zone —
|
|
7562
|
+
// particularly visible when the group is first in the tabs list
|
|
7563
|
+
// and there's no preceding tab whose right zone covers position 0.
|
|
7564
|
+
// The smooth animation path already shifts the chip's margin to
|
|
7565
|
+
// open a gap, so suppress the overlay in that mode.
|
|
7566
|
+
const isVertical = this._ctx.getDirection() === 'vertical';
|
|
7567
|
+
const dropTarget = new Droptarget(chip.element, {
|
|
7568
|
+
acceptedTargetZones: isVertical ? ['top'] : ['left'],
|
|
7569
|
+
overlayModel: {
|
|
7570
|
+
activationSize: { value: 100, type: 'percentage' },
|
|
7571
|
+
},
|
|
7572
|
+
canDisplayOverlay: (event, position) => {
|
|
7573
|
+
var _a;
|
|
7574
|
+
if (this._ctx.group.locked) {
|
|
7575
|
+
return false;
|
|
7576
|
+
}
|
|
7577
|
+
if (this._ctx.accessor.options.disableDnd) {
|
|
7578
|
+
return false;
|
|
7579
|
+
}
|
|
7580
|
+
const data = getPanelData();
|
|
7581
|
+
if (data && this._ctx.accessor.id === data.viewId) {
|
|
7582
|
+
if (((_a = this._ctx.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) ===
|
|
7583
|
+
'smooth') {
|
|
7584
|
+
return false;
|
|
7585
|
+
}
|
|
7586
|
+
return true;
|
|
7587
|
+
}
|
|
7588
|
+
return this._ctx.group.model.canDisplayOverlay(event, position, 'tab');
|
|
7589
|
+
},
|
|
7590
|
+
});
|
|
7591
|
+
disposables.push(dropTarget, dropTarget.onDrop((event) => {
|
|
7592
|
+
this._callbacks.onChipDrop(tabGroup, event);
|
|
7593
|
+
}));
|
|
6506
7594
|
const disposable = new CompositeDisposable(...disposables);
|
|
6507
|
-
this._chipRenderers.set(tabGroup.id, {
|
|
7595
|
+
this._chipRenderers.set(tabGroup.id, {
|
|
7596
|
+
chip,
|
|
7597
|
+
html5DragSource,
|
|
7598
|
+
pointerDragSource,
|
|
7599
|
+
disposable,
|
|
7600
|
+
dropTarget,
|
|
7601
|
+
});
|
|
6508
7602
|
// Group is born collapsed (cross-group drop, layout restore, etc.):
|
|
6509
7603
|
// its tabs are about to be added without the collapsed class. Skip
|
|
6510
7604
|
// the animation in the upcoming _updateTabGroupClasses call so they
|
|
@@ -6763,6 +7857,7 @@ class Tabs extends CompositeDisposable {
|
|
|
6763
7857
|
for (const tab of this._tabs) {
|
|
6764
7858
|
tab.value.setDirection(value);
|
|
6765
7859
|
}
|
|
7860
|
+
this._tabGroupManager.updateDirection();
|
|
6766
7861
|
}
|
|
6767
7862
|
constructor(group, accessor, options) {
|
|
6768
7863
|
super();
|
|
@@ -6782,7 +7877,7 @@ class Tabs extends CompositeDisposable {
|
|
|
6782
7877
|
this._voidContainer = null;
|
|
6783
7878
|
this._voidContainerListeners = null;
|
|
6784
7879
|
this._extendedDropZone = null;
|
|
6785
|
-
this.
|
|
7880
|
+
this._pointerInsideTabsList = false;
|
|
6786
7881
|
this._onTabDragStart = new Emitter();
|
|
6787
7882
|
this.onTabDragStart = this._onTabDragStart.event;
|
|
6788
7883
|
this._onDrop = new Emitter();
|
|
@@ -6817,13 +7912,40 @@ class Tabs extends CompositeDisposable {
|
|
|
6817
7912
|
onChipDragStart: (tabGroup, chip, event) => {
|
|
6818
7913
|
this._handleChipDragStart(tabGroup, chip, event);
|
|
6819
7914
|
},
|
|
7915
|
+
onChipDragEnd: () => {
|
|
7916
|
+
// HTML5 chip dragend (incl. cancels). The Html5DragSource
|
|
7917
|
+
// owns the listener on the chip element, so this fires
|
|
7918
|
+
// even if the chip was detached cross-group — the
|
|
7919
|
+
// element keeps its listeners until the source is
|
|
7920
|
+
// disposed. resetDragAnimation is a no-op after a
|
|
7921
|
+
// successful drop (anim state already null) thanks to
|
|
7922
|
+
// the gating inside it.
|
|
7923
|
+
this.resetDragAnimation();
|
|
7924
|
+
},
|
|
7925
|
+
onChipDrop: (tabGroup, event) => {
|
|
7926
|
+
this._handleChipDrop(tabGroup, event);
|
|
7927
|
+
},
|
|
6820
7928
|
});
|
|
6821
7929
|
this.addDisposables(this._onOverflowTabsChange, this._observerDisposable, this._onWillShowOverlay, this._onDrop, this._onTabDragStart, {
|
|
6822
7930
|
dispose: () => {
|
|
6823
7931
|
var _a;
|
|
6824
7932
|
(_a = this._flipTransitionCleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6825
7933
|
},
|
|
6826
|
-
},
|
|
7934
|
+
},
|
|
7935
|
+
// Pointer-side cleanup: when any pointer drag ends, tear
|
|
7936
|
+
// down smooth-reorder anim state the dragover bridge may
|
|
7937
|
+
// have installed. The chip's pointer drag source handles
|
|
7938
|
+
// its own transfer payload + iframe-shield cleanup.
|
|
7939
|
+
PointerDragController.getInstance().onDragEnd(() => {
|
|
7940
|
+
this._pointerInsideTabsList = false;
|
|
7941
|
+
this.resetDragAnimation();
|
|
7942
|
+
}),
|
|
7943
|
+
// Pointer-event mirror of the HTML5 dragover / dragleave handlers
|
|
7944
|
+
// below. Drives smooth-reorder for `dndStrategy: 'pointer'` and
|
|
7945
|
+
// for touch drags in `'auto'`.
|
|
7946
|
+
PointerDragController.getInstance().onDragMove((e) => {
|
|
7947
|
+
this._handlePointerDragMove(e.clientX, e.clientY);
|
|
7948
|
+
}), addDisposableListener(this.element, 'pointerdown', (event) => {
|
|
6827
7949
|
if (event.defaultPrevented) {
|
|
6828
7950
|
return;
|
|
6829
7951
|
}
|
|
@@ -6831,135 +7953,60 @@ class Tabs extends CompositeDisposable {
|
|
|
6831
7953
|
if (isLeftClick) {
|
|
6832
7954
|
this.accessor.doSetGroupActive(this.group);
|
|
6833
7955
|
}
|
|
6834
|
-
}),
|
|
6835
|
-
|
|
6836
|
-
|
|
7956
|
+
}),
|
|
7957
|
+
// Trackpad / wheel forwarding. The strip scrolls along its own
|
|
7958
|
+
// axis (x for horizontal headers, y for vertical), so deltaY
|
|
7959
|
+
// from a plain mouse wheel maps onto the strip's axis too —
|
|
7960
|
+
// this gives the VS Code-style "scroll over tab bar to page
|
|
7961
|
+
// through tabs" feel. We only consume the event when the strip
|
|
7962
|
+
// is actually overflowing in the direction the user wheeled in,
|
|
7963
|
+
// so a wheel at the edge of a non-overflowing strip still
|
|
7964
|
+
// bubbles up and scrolls the page. `{ passive: false }` is
|
|
7965
|
+
// required because we call preventDefault().
|
|
7966
|
+
addDisposableListener(this._tabsList, 'wheel', (event) => {
|
|
7967
|
+
const isVertical = this._direction === 'vertical';
|
|
7968
|
+
const primary = isVertical
|
|
7969
|
+
? event.deltaY || event.deltaX
|
|
7970
|
+
: event.deltaX || event.deltaY;
|
|
7971
|
+
if (primary === 0) {
|
|
6837
7972
|
return;
|
|
6838
7973
|
}
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
data.groupId !== this.group.id &&
|
|
6846
|
-
this._animState.sourceTabGroupId !== data.tabGroupId) {
|
|
6847
|
-
this._animState = null;
|
|
6848
|
-
}
|
|
6849
|
-
}
|
|
6850
|
-
if (!this._animState) {
|
|
6851
|
-
const data = getPanelData();
|
|
6852
|
-
// In default animation mode, individual tab drops
|
|
6853
|
-
// are handled by per-tab Droptargets. But tab group
|
|
6854
|
-
// chip drags still need tab-list-level handling so
|
|
6855
|
-
// that drops on gaps / void space work.
|
|
6856
|
-
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) ===
|
|
6857
|
-
'default' &&
|
|
6858
|
-
!(data === null || data === void 0 ? void 0 : data.tabGroupId)) {
|
|
6859
|
-
return;
|
|
6860
|
-
}
|
|
6861
|
-
if (data &&
|
|
6862
|
-
(data.panelId || data.tabGroupId) &&
|
|
6863
|
-
data.groupId !== this.group.id) {
|
|
6864
|
-
const avgWidth = this.getAverageTabWidth();
|
|
6865
|
-
if (data.tabGroupId) {
|
|
6866
|
-
// External group drag — look up the
|
|
6867
|
-
// source tab group to size the gap
|
|
6868
|
-
const sourceGroup = this.accessor.getPanel(data.groupId);
|
|
6869
|
-
const sourceTg = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.getTabGroups().find((tg) => tg.id === data.tabGroupId);
|
|
6870
|
-
const panelCount = (_b = sourceTg === null || sourceTg === void 0 ? void 0 : sourceTg.panelIds.length) !== null && _b !== void 0 ? _b : 1;
|
|
6871
|
-
const groupGapWidth = avgWidth * panelCount + avgWidth;
|
|
6872
|
-
this._animState = {
|
|
6873
|
-
sourceTabId: '',
|
|
6874
|
-
sourceIndex: -1,
|
|
6875
|
-
tabPositions: this.snapshotTabPositions(),
|
|
6876
|
-
chipPositions: this._tabGroupManager.snapshotChipWidths(),
|
|
6877
|
-
currentInsertionIndex: null,
|
|
6878
|
-
targetTabGroupId: null,
|
|
6879
|
-
sourceTabGroupId: data.tabGroupId,
|
|
6880
|
-
sourceGroupPanelIds: sourceTg
|
|
6881
|
-
? new Set(sourceTg.panelIds)
|
|
6882
|
-
: new Set(),
|
|
6883
|
-
sourceChipWidth: avgWidth,
|
|
6884
|
-
cursorOffsetFromDragLeft: groupGapWidth / 2,
|
|
6885
|
-
sourceGapWidth: groupGapWidth,
|
|
6886
|
-
containerLeft: this._tabsList.getBoundingClientRect()
|
|
6887
|
-
.left,
|
|
6888
|
-
};
|
|
6889
|
-
}
|
|
6890
|
-
else {
|
|
6891
|
-
this._animState = {
|
|
6892
|
-
sourceTabId: data.panelId,
|
|
6893
|
-
sourceIndex: -1,
|
|
6894
|
-
tabPositions: this.snapshotTabPositions(),
|
|
6895
|
-
chipPositions: this._tabGroupManager.snapshotChipWidths(),
|
|
6896
|
-
currentInsertionIndex: null,
|
|
6897
|
-
targetTabGroupId: null,
|
|
6898
|
-
sourceTabGroupId: null,
|
|
6899
|
-
sourceGroupPanelIds: null,
|
|
6900
|
-
sourceChipWidth: 0,
|
|
6901
|
-
cursorOffsetFromDragLeft: avgWidth / 2,
|
|
6902
|
-
sourceGapWidth: avgWidth,
|
|
6903
|
-
containerLeft: this._tabsList.getBoundingClientRect()
|
|
6904
|
-
.left,
|
|
6905
|
-
};
|
|
6906
|
-
}
|
|
6907
|
-
}
|
|
6908
|
-
else {
|
|
6909
|
-
return;
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
event.preventDefault(); // allow drop to fire on the container
|
|
6913
|
-
// For intra-group drag (sourceIndex >= 0) the gap
|
|
6914
|
-
// animation is the sole visual indicator — clear any
|
|
6915
|
-
// stale anchor overlay that may have been set while the
|
|
6916
|
-
// cursor was over the panel content area or another zone.
|
|
6917
|
-
// External drags (sourceIndex === -1) leave the overlay
|
|
6918
|
-
// to the individual tab Droptargets so cross-group
|
|
6919
|
-
// animation is not disrupted.
|
|
6920
|
-
if (this._animState.sourceIndex !== -1) {
|
|
6921
|
-
(_d = (_c = this.group.model.dropTargetContainer) === null || _c === void 0 ? void 0 : _c.model) === null || _d === void 0 ? void 0 : _d.clear();
|
|
6922
|
-
}
|
|
6923
|
-
this.handleDragOver(event);
|
|
6924
|
-
}, true), addDisposableListener(this._tabsList, 'dragleave', (event) => {
|
|
6925
|
-
var _a, _b, _c;
|
|
6926
|
-
if (!this._animState) {
|
|
7974
|
+
const max = isVertical
|
|
7975
|
+
? this._tabsList.scrollHeight -
|
|
7976
|
+
this._tabsList.clientHeight
|
|
7977
|
+
: this._tabsList.scrollWidth -
|
|
7978
|
+
this._tabsList.clientWidth;
|
|
7979
|
+
if (max <= 0) {
|
|
6927
7980
|
return;
|
|
6928
7981
|
}
|
|
6929
|
-
const
|
|
6930
|
-
|
|
6931
|
-
|
|
7982
|
+
const current = isVertical
|
|
7983
|
+
? this._tabsList.scrollTop
|
|
7984
|
+
: this._tabsList.scrollLeft;
|
|
7985
|
+
// At the edge in the wheel direction: let the page
|
|
7986
|
+
// scroll instead of trapping the gesture.
|
|
7987
|
+
if ((primary < 0 && current <= 0) ||
|
|
7988
|
+
(primary > 0 && current >= max)) {
|
|
6932
7989
|
return;
|
|
6933
7990
|
}
|
|
6934
|
-
|
|
6935
|
-
//
|
|
6936
|
-
//
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
7991
|
+
event.preventDefault();
|
|
7992
|
+
// Custom-scrollbar mode wraps the tabs list and installs
|
|
7993
|
+
// its own wheel listener that rewrites scrollLeft from a
|
|
7994
|
+
// deltaY-only tracker. Without stopPropagation that
|
|
7995
|
+
// handler would clobber our deltaX-aware update.
|
|
7996
|
+
event.stopPropagation();
|
|
7997
|
+
if (isVertical) {
|
|
7998
|
+
this._tabsList.scrollTop = current + primary;
|
|
6941
7999
|
}
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
// still land at the end position.
|
|
6945
|
-
const rt = event.relatedTarget;
|
|
6946
|
-
const isVoid = this._voidContainer &&
|
|
6947
|
-
rt &&
|
|
6948
|
-
(rt === this._voidContainer ||
|
|
6949
|
-
this._voidContainer.contains(rt));
|
|
6950
|
-
if (isVoid) {
|
|
6951
|
-
return;
|
|
8000
|
+
else {
|
|
8001
|
+
this._tabsList.scrollLeft = current + primary;
|
|
6952
8002
|
}
|
|
6953
|
-
|
|
6954
|
-
if (this.
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
this._animState = null;
|
|
6958
|
-
}
|
|
6959
|
-
else {
|
|
6960
|
-
this._animState.currentInsertionIndex = null;
|
|
6961
|
-
}
|
|
8003
|
+
}, { passive: false }), addDisposableListener(this._tabsList, 'dragover', (event) => {
|
|
8004
|
+
if (this._processDragOver(event.clientX)) {
|
|
8005
|
+
// Allow `drop` to fire on the tabs list container.
|
|
8006
|
+
event.preventDefault();
|
|
6962
8007
|
}
|
|
8008
|
+
}, true), addDisposableListener(this._tabsList, 'dragleave', (event) => {
|
|
8009
|
+
this._processDragLeave(event.relatedTarget);
|
|
6963
8010
|
}, true), addDisposableListener(this._tabsList, 'dragend', () => {
|
|
6964
8011
|
this.resetDragAnimation();
|
|
6965
8012
|
}), addDisposableListener(this._tabsList, 'drop', (event) => {
|
|
@@ -7081,6 +8128,9 @@ class Tabs extends CompositeDisposable {
|
|
|
7081
8128
|
const disposable = new CompositeDisposable(tab.onDragStart((event) => {
|
|
7082
8129
|
var _a;
|
|
7083
8130
|
this._onTabDragStart.fire({ nativeEvent: event, panel });
|
|
8131
|
+
// Both HTML5 and pointer drags initialize _animState. Cleanup
|
|
8132
|
+
// is wired in both paths: HTML5 via dragend/drop on _tabsList,
|
|
8133
|
+
// pointer via PointerDragController.onDragEnd subscriptions.
|
|
7084
8134
|
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'smooth') {
|
|
7085
8135
|
const tabWidth = tab.element.getBoundingClientRect().width;
|
|
7086
8136
|
const sourceIndex = this._tabs.findIndex((x) => x.value === tab);
|
|
@@ -7340,6 +8390,7 @@ class Tabs extends CompositeDisposable {
|
|
|
7340
8390
|
for (const tab of this._tabs) {
|
|
7341
8391
|
tab.value.updateDragAndDropState();
|
|
7342
8392
|
}
|
|
8393
|
+
this._tabGroupManager.updateDragAndDropState();
|
|
7343
8394
|
}
|
|
7344
8395
|
/**
|
|
7345
8396
|
* Synchronize chip elements and CSS classes for all tab groups
|
|
@@ -7351,6 +8402,13 @@ class Tabs extends CompositeDisposable {
|
|
|
7351
8402
|
refreshTabGroupAccent() {
|
|
7352
8403
|
this._tabGroupManager.refreshAccents();
|
|
7353
8404
|
}
|
|
8405
|
+
/**
|
|
8406
|
+
* Tabs-list-specific side effects of a chip drag start. The chip's
|
|
8407
|
+
* drag sources (constructed by `TabGroupManager`) own the transfer
|
|
8408
|
+
* payload, iframe shielding, dataTransfer setup, and the HTML5 drag
|
|
8409
|
+
* image. This method just sets up the smooth-reorder anim state and
|
|
8410
|
+
* collapses the source-group tabs in the tabs list.
|
|
8411
|
+
*/
|
|
7354
8412
|
_handleChipDragStart(tabGroup, chip, event) {
|
|
7355
8413
|
var _a;
|
|
7356
8414
|
const firstPanelId = tabGroup.panelIds[0];
|
|
@@ -7381,89 +8439,79 @@ class Tabs extends CompositeDisposable {
|
|
|
7381
8439
|
sourceGapWidth: groupGapWidth,
|
|
7382
8440
|
containerLeft: this._tabsList.getBoundingClientRect().left,
|
|
7383
8441
|
};
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
};
|
|
7405
|
-
chipElement.addEventListener('dragend', onChipDragEnd);
|
|
7406
|
-
this._chipDragCleanup = {
|
|
7407
|
-
dispose: () => {
|
|
7408
|
-
chipElement.removeEventListener('dragend', onChipDragEnd);
|
|
7409
|
-
panelTransfer.clearData(PanelTransfer.prototype);
|
|
7410
|
-
iframes.release();
|
|
7411
|
-
},
|
|
7412
|
-
};
|
|
7413
|
-
if (event.dataTransfer) {
|
|
7414
|
-
event.dataTransfer.effectAllowed = 'move';
|
|
7415
|
-
if (event.dataTransfer.items.length === 0) {
|
|
7416
|
-
event.dataTransfer.setData('text/plain', '');
|
|
7417
|
-
}
|
|
7418
|
-
}
|
|
7419
|
-
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'smooth') {
|
|
7420
|
-
// Collapse group tabs + chip after the browser
|
|
7421
|
-
// captures the drag image, then open the gap at the
|
|
7422
|
-
// source position — all instant (no transitions).
|
|
7423
|
-
const groupPanelIds = new Set(tabGroup.panelIds);
|
|
7424
|
-
this._pendingCollapse = true;
|
|
7425
|
-
requestAnimationFrame(() => {
|
|
7426
|
-
var _a;
|
|
7427
|
-
var _b;
|
|
7428
|
-
this._pendingCollapse = false;
|
|
7429
|
-
if (!this._animState) {
|
|
7430
|
-
return;
|
|
7431
|
-
}
|
|
7432
|
-
// Collapse all group tabs instantly
|
|
7433
|
-
for (const t of this._tabs) {
|
|
7434
|
-
if (groupPanelIds.has(t.value.panel.id)) {
|
|
7435
|
-
t.value.element.style.transition = 'none';
|
|
7436
|
-
toggleClass(t.value.element, 'dv-tab--dragging', true);
|
|
7437
|
-
}
|
|
7438
|
-
}
|
|
7439
|
-
// Collapse the group chip instantly
|
|
7440
|
-
const chipEntry = this._tabGroupManager.chipRenderers.get(tabGroup.id);
|
|
7441
|
-
if (chipEntry) {
|
|
7442
|
-
chipEntry.chip.element.style.transition = 'none';
|
|
7443
|
-
toggleClass(chipEntry.chip.element, 'dv-tab-group-chip--dragging', true);
|
|
7444
|
-
}
|
|
7445
|
-
// Single reflow for the entire batch
|
|
7446
|
-
void this._tabsList.offsetHeight;
|
|
7447
|
-
const underline = this._tabGroupManager.groupUnderlines.get(tabGroup.id);
|
|
7448
|
-
if (underline) {
|
|
7449
|
-
underline.style.display = 'none';
|
|
7450
|
-
}
|
|
7451
|
-
(_a = (_b = this._animState).currentInsertionIndex) !== null && _a !== void 0 ? _a : (_b.currentInsertionIndex = firstIdx);
|
|
7452
|
-
// Apply gap with transitions disabled
|
|
7453
|
-
this.applyDragOverTransforms(true);
|
|
7454
|
-
// Re-enable transitions for subsequent moves
|
|
7455
|
-
for (const t of this._tabs) {
|
|
7456
|
-
if (groupPanelIds.has(t.value.panel.id)) {
|
|
7457
|
-
t.value.element.style.removeProperty('transition');
|
|
7458
|
-
}
|
|
8442
|
+
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) !== 'smooth') {
|
|
8443
|
+
return;
|
|
8444
|
+
}
|
|
8445
|
+
// Collapse group tabs + chip after the browser captures the drag
|
|
8446
|
+
// image, then open the gap at the source position — all instant
|
|
8447
|
+
// (no transitions).
|
|
8448
|
+
const groupPanelIds = new Set(tabGroup.panelIds);
|
|
8449
|
+
this._pendingCollapse = true;
|
|
8450
|
+
requestAnimationFrame(() => {
|
|
8451
|
+
var _a;
|
|
8452
|
+
var _b;
|
|
8453
|
+
this._pendingCollapse = false;
|
|
8454
|
+
if (!this._animState) {
|
|
8455
|
+
return;
|
|
8456
|
+
}
|
|
8457
|
+
// Collapse all group tabs instantly
|
|
8458
|
+
for (const t of this._tabs) {
|
|
8459
|
+
if (groupPanelIds.has(t.value.panel.id)) {
|
|
8460
|
+
t.value.element.style.transition = 'none';
|
|
8461
|
+
toggleClass(t.value.element, 'dv-tab--dragging', true);
|
|
7459
8462
|
}
|
|
7460
|
-
|
|
7461
|
-
|
|
8463
|
+
}
|
|
8464
|
+
// Collapse the group chip instantly
|
|
8465
|
+
const chipEntry = this._tabGroupManager.chipRenderers.get(tabGroup.id);
|
|
8466
|
+
if (chipEntry) {
|
|
8467
|
+
chipEntry.chip.element.style.transition = 'none';
|
|
8468
|
+
toggleClass(chipEntry.chip.element, 'dv-tab-group-chip--dragging', true);
|
|
8469
|
+
}
|
|
8470
|
+
// Single reflow for the entire batch
|
|
8471
|
+
void this._tabsList.offsetHeight;
|
|
8472
|
+
const underline = this._tabGroupManager.groupUnderlines.get(tabGroup.id);
|
|
8473
|
+
if (underline) {
|
|
8474
|
+
underline.style.display = 'none';
|
|
8475
|
+
}
|
|
8476
|
+
(_a = (_b = this._animState).currentInsertionIndex) !== null && _a !== void 0 ? _a : (_b.currentInsertionIndex = firstIdx);
|
|
8477
|
+
this.applyDragOverTransforms(true);
|
|
8478
|
+
for (const t of this._tabs) {
|
|
8479
|
+
if (groupPanelIds.has(t.value.panel.id)) {
|
|
8480
|
+
t.value.element.style.removeProperty('transition');
|
|
7462
8481
|
}
|
|
7463
|
-
}
|
|
8482
|
+
}
|
|
8483
|
+
if (chipEntry) {
|
|
8484
|
+
chipEntry.chip.element.style.removeProperty('transition');
|
|
8485
|
+
}
|
|
8486
|
+
});
|
|
8487
|
+
}
|
|
8488
|
+
/**
|
|
8489
|
+
* A drop on a tab group chip means "insert before this group". Resolve to
|
|
8490
|
+
* the index of the group's first tab, adjusting for same-group removal
|
|
8491
|
+
* (when the source tab is currently to the left of the target slot, its
|
|
8492
|
+
* removal shifts the insertion index down by one). Always clears
|
|
8493
|
+
* `targetTabGroupId` so the dropped tab lands outside the group.
|
|
8494
|
+
*/
|
|
8495
|
+
_handleChipDrop(tabGroup, event) {
|
|
8496
|
+
const firstPanelId = tabGroup.panelIds[0];
|
|
8497
|
+
if (!firstPanelId) {
|
|
8498
|
+
return;
|
|
8499
|
+
}
|
|
8500
|
+
const insertionIndex = this._tabs.findIndex((x) => x.value.panel.id === firstPanelId);
|
|
8501
|
+
if (insertionIndex === -1) {
|
|
8502
|
+
return;
|
|
7464
8503
|
}
|
|
7465
|
-
|
|
7466
|
-
this.
|
|
8504
|
+
const data = getPanelData();
|
|
8505
|
+
const sourceIndex = data && data.groupId === this.group.id && data.panelId
|
|
8506
|
+
? this._tabs.findIndex((x) => x.value.panel.id === data.panelId)
|
|
8507
|
+
: -1;
|
|
8508
|
+
const adjustedIndex = insertionIndex -
|
|
8509
|
+
(sourceIndex !== -1 && sourceIndex < insertionIndex ? 1 : 0);
|
|
8510
|
+
this._onDrop.fire({
|
|
8511
|
+
event: event.nativeEvent,
|
|
8512
|
+
index: adjustedIndex,
|
|
8513
|
+
targetTabGroupId: null,
|
|
8514
|
+
});
|
|
7467
8515
|
}
|
|
7468
8516
|
/**
|
|
7469
8517
|
* Sets the broader container that is part of the same logical drop surface
|
|
@@ -7525,6 +8573,164 @@ class Tabs extends CompositeDisposable {
|
|
|
7525
8573
|
}
|
|
7526
8574
|
return total / this._tabs.length;
|
|
7527
8575
|
}
|
|
8576
|
+
/**
|
|
8577
|
+
* Pointer-event entry point. The HTML5 path enters via the per-element
|
|
8578
|
+
* `dragover` listener; this one hit-tests the global pointer-drag
|
|
8579
|
+
* position against the tabs list and routes through the same shared
|
|
8580
|
+
* `_processDragOver` / `_processDragLeave` helpers.
|
|
8581
|
+
*/
|
|
8582
|
+
_handlePointerDragMove(clientX, clientY) {
|
|
8583
|
+
var _a;
|
|
8584
|
+
const sourceDoc = (_a = this._tabsList.ownerDocument) !== null && _a !== void 0 ? _a : document;
|
|
8585
|
+
const elAtPoint = sourceDoc.elementFromPoint(clientX, clientY);
|
|
8586
|
+
const inside = !!elAtPoint &&
|
|
8587
|
+
(this._tabsList.contains(elAtPoint) ||
|
|
8588
|
+
(!!this._extendedDropZone &&
|
|
8589
|
+
this._extendedDropZone.contains(elAtPoint)));
|
|
8590
|
+
if (!inside) {
|
|
8591
|
+
if (this._pointerInsideTabsList) {
|
|
8592
|
+
this._pointerInsideTabsList = false;
|
|
8593
|
+
this._processDragLeave(elAtPoint);
|
|
8594
|
+
}
|
|
8595
|
+
return;
|
|
8596
|
+
}
|
|
8597
|
+
this._pointerInsideTabsList = true;
|
|
8598
|
+
this._processDragOver(clientX);
|
|
8599
|
+
}
|
|
8600
|
+
/**
|
|
8601
|
+
* Shared body of the dragover entry point. Refreshes stale anim state
|
|
8602
|
+
* for a changed drag identity, initializes anim state for incoming
|
|
8603
|
+
* cross-group drags, and dispatches to the gap-following math in
|
|
8604
|
+
* `handleDragOver`. Returns true when this tabs list has taken
|
|
8605
|
+
* ownership of the drag — HTML5 callers use this to gate
|
|
8606
|
+
* `event.preventDefault()`.
|
|
8607
|
+
*/
|
|
8608
|
+
_processDragOver(clientX) {
|
|
8609
|
+
var _a, _b, _c, _d;
|
|
8610
|
+
if (this.accessor.options.disableDnd) {
|
|
8611
|
+
return false;
|
|
8612
|
+
}
|
|
8613
|
+
// Stale-state guard: if a previous drag's anim state is still here
|
|
8614
|
+
// but the current drag is a different identity, drop the stale one
|
|
8615
|
+
// so the new drag starts from a clean slate.
|
|
8616
|
+
if (this._animState) {
|
|
8617
|
+
const data = getPanelData();
|
|
8618
|
+
if ((data === null || data === void 0 ? void 0 : data.tabGroupId) &&
|
|
8619
|
+
data.groupId !== this.group.id &&
|
|
8620
|
+
this._animState.sourceTabGroupId !== data.tabGroupId) {
|
|
8621
|
+
this._animState = null;
|
|
8622
|
+
}
|
|
8623
|
+
}
|
|
8624
|
+
if (!this._animState) {
|
|
8625
|
+
const data = getPanelData();
|
|
8626
|
+
// In default animation mode, individual tab drops are handled
|
|
8627
|
+
// by per-tab Droptargets; only chip drags need tabs-list-level
|
|
8628
|
+
// handling so drops on void space still work.
|
|
8629
|
+
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'default' &&
|
|
8630
|
+
!(data === null || data === void 0 ? void 0 : data.tabGroupId)) {
|
|
8631
|
+
return false;
|
|
8632
|
+
}
|
|
8633
|
+
if (data &&
|
|
8634
|
+
(data.panelId || data.tabGroupId) &&
|
|
8635
|
+
data.groupId !== this.group.id) {
|
|
8636
|
+
const avgWidth = this.getAverageTabWidth();
|
|
8637
|
+
if (data.tabGroupId) {
|
|
8638
|
+
// External group drag — look up the source group to
|
|
8639
|
+
// size the gap.
|
|
8640
|
+
const sourceGroup = this.accessor.getPanel(data.groupId);
|
|
8641
|
+
const sourceTg = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.getTabGroups().find((tg) => tg.id === data.tabGroupId);
|
|
8642
|
+
const panelCount = (_b = sourceTg === null || sourceTg === void 0 ? void 0 : sourceTg.panelIds.length) !== null && _b !== void 0 ? _b : 1;
|
|
8643
|
+
const groupGapWidth = avgWidth * panelCount + avgWidth;
|
|
8644
|
+
this._animState = {
|
|
8645
|
+
sourceTabId: '',
|
|
8646
|
+
sourceIndex: -1,
|
|
8647
|
+
tabPositions: this.snapshotTabPositions(),
|
|
8648
|
+
chipPositions: this._tabGroupManager.snapshotChipWidths(),
|
|
8649
|
+
currentInsertionIndex: null,
|
|
8650
|
+
targetTabGroupId: null,
|
|
8651
|
+
sourceTabGroupId: data.tabGroupId,
|
|
8652
|
+
sourceGroupPanelIds: sourceTg
|
|
8653
|
+
? new Set(sourceTg.panelIds)
|
|
8654
|
+
: new Set(),
|
|
8655
|
+
sourceChipWidth: avgWidth,
|
|
8656
|
+
cursorOffsetFromDragLeft: groupGapWidth / 2,
|
|
8657
|
+
sourceGapWidth: groupGapWidth,
|
|
8658
|
+
containerLeft: this._tabsList.getBoundingClientRect().left,
|
|
8659
|
+
};
|
|
8660
|
+
}
|
|
8661
|
+
else {
|
|
8662
|
+
this._animState = {
|
|
8663
|
+
sourceTabId: data.panelId,
|
|
8664
|
+
sourceIndex: -1,
|
|
8665
|
+
tabPositions: this.snapshotTabPositions(),
|
|
8666
|
+
chipPositions: this._tabGroupManager.snapshotChipWidths(),
|
|
8667
|
+
currentInsertionIndex: null,
|
|
8668
|
+
targetTabGroupId: null,
|
|
8669
|
+
sourceTabGroupId: null,
|
|
8670
|
+
sourceGroupPanelIds: null,
|
|
8671
|
+
sourceChipWidth: 0,
|
|
8672
|
+
cursorOffsetFromDragLeft: avgWidth / 2,
|
|
8673
|
+
sourceGapWidth: avgWidth,
|
|
8674
|
+
containerLeft: this._tabsList.getBoundingClientRect().left,
|
|
8675
|
+
};
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8678
|
+
else {
|
|
8679
|
+
return false;
|
|
8680
|
+
}
|
|
8681
|
+
}
|
|
8682
|
+
// For intra-group drag (sourceIndex >= 0) the gap animation is the
|
|
8683
|
+
// sole visual indicator — clear any stale anchor overlay that may
|
|
8684
|
+
// have been set while the cursor was over the panel content area or
|
|
8685
|
+
// another zone. External drags (sourceIndex === -1) leave the
|
|
8686
|
+
// overlay to the individual tab Droptargets so cross-group
|
|
8687
|
+
// animation is not disrupted.
|
|
8688
|
+
if (this._animState.sourceIndex !== -1) {
|
|
8689
|
+
(_d = (_c = this.group.model.dropTargetContainer) === null || _c === void 0 ? void 0 : _c.model) === null || _d === void 0 ? void 0 : _d.clear();
|
|
8690
|
+
}
|
|
8691
|
+
this.handleDragOver({ clientX });
|
|
8692
|
+
return true;
|
|
8693
|
+
}
|
|
8694
|
+
/**
|
|
8695
|
+
* Shared body of the dragleave entry point. Preserves anim state when
|
|
8696
|
+
* the drag moves between tabs-list children, into the extended drop
|
|
8697
|
+
* zone, or into the void container; tears it down otherwise.
|
|
8698
|
+
*/
|
|
8699
|
+
_processDragLeave(related) {
|
|
8700
|
+
var _a, _b, _c;
|
|
8701
|
+
if (!this._animState) {
|
|
8702
|
+
return;
|
|
8703
|
+
}
|
|
8704
|
+
// Moves between children of the tabs list aren't real leaves.
|
|
8705
|
+
if (related && this._tabsList.contains(related)) {
|
|
8706
|
+
return;
|
|
8707
|
+
}
|
|
8708
|
+
// Moving into the broader drop zone (e.g. void container, left
|
|
8709
|
+
// actions) — keep anim state alive so external listeners can
|
|
8710
|
+
// continue the gap animation.
|
|
8711
|
+
if (related && ((_a = this._extendedDropZone) === null || _a === void 0 ? void 0 : _a.contains(related))) {
|
|
8712
|
+
this.resetTabTransforms();
|
|
8713
|
+
this._animState.currentInsertionIndex = null;
|
|
8714
|
+
return;
|
|
8715
|
+
}
|
|
8716
|
+
// Leaving toward the void container (empty header space to the
|
|
8717
|
+
// right): keep anim state so a drop can still land at the end.
|
|
8718
|
+
const isVoid = this._voidContainer &&
|
|
8719
|
+
related &&
|
|
8720
|
+
(related === this._voidContainer ||
|
|
8721
|
+
this._voidContainer.contains(related));
|
|
8722
|
+
if (isVoid) {
|
|
8723
|
+
return;
|
|
8724
|
+
}
|
|
8725
|
+
this.resetTabTransforms();
|
|
8726
|
+
if (this._animState.sourceIndex === -1) {
|
|
8727
|
+
(_c = (_b = this.group.model.dropTargetContainer) === null || _b === void 0 ? void 0 : _b.model) === null || _c === void 0 ? void 0 : _c.clear();
|
|
8728
|
+
this._animState = null;
|
|
8729
|
+
}
|
|
8730
|
+
else {
|
|
8731
|
+
this._animState.currentInsertionIndex = null;
|
|
8732
|
+
}
|
|
8733
|
+
}
|
|
7528
8734
|
handleDragOver(event) {
|
|
7529
8735
|
var _a, _b, _c, _d, _e;
|
|
7530
8736
|
if (!this._animState) {
|
|
@@ -7934,20 +9140,23 @@ class Tabs extends CompositeDisposable {
|
|
|
7934
9140
|
* in the model, and run a FLIP animation.
|
|
7935
9141
|
*/
|
|
7936
9142
|
_commitGroupMove(sourceTabGroupId, insertionIndex) {
|
|
7937
|
-
var _a, _b
|
|
7938
|
-
// Read transfer data
|
|
7939
|
-
// _chipDragCleanup clears the global LocalSelectionTransfer
|
|
7940
|
-
// singleton which getPanelData() reads from.
|
|
9143
|
+
var _a, _b;
|
|
9144
|
+
// Read transfer data first.
|
|
7941
9145
|
const data = getPanelData();
|
|
7942
|
-
|
|
7943
|
-
|
|
9146
|
+
// Synchronously dispose the source chip's drag sources, which
|
|
9147
|
+
// clears the panelTransfer payload + iframe shield. Cross-group
|
|
9148
|
+
// moves dissolve the source chip on a microtask, which is too
|
|
9149
|
+
// late: a synchronous `getPanelData()` after this method (or any
|
|
9150
|
+
// sibling dragover handler firing in the same tick) would
|
|
9151
|
+
// otherwise see stale data still referencing the old tabGroupId.
|
|
9152
|
+
this._tabGroupManager.disposeChipDrag(sourceTabGroupId);
|
|
7944
9153
|
// Check if the tab group exists in this group (within-group reorder)
|
|
7945
9154
|
// or in another group (cross-group move).
|
|
7946
9155
|
const isLocal = this.group.model
|
|
7947
9156
|
.getTabGroups()
|
|
7948
9157
|
.some((tg) => tg.id === sourceTabGroupId);
|
|
7949
9158
|
if (isLocal) {
|
|
7950
|
-
if (((
|
|
9159
|
+
if (((_a = this.accessor.options.theme) === null || _a === void 0 ? void 0 : _a.tabAnimation) === 'smooth') {
|
|
7951
9160
|
this._clearGroupDragClasses(sourceTabGroupId);
|
|
7952
9161
|
const firstPositions = this.snapshotTabPositions();
|
|
7953
9162
|
this.resetTabTransforms();
|
|
@@ -7975,7 +9184,7 @@ class Tabs extends CompositeDisposable {
|
|
|
7975
9184
|
this.accessor.moveGroupOrPanel({
|
|
7976
9185
|
from: {
|
|
7977
9186
|
groupId: data.groupId,
|
|
7978
|
-
tabGroupId: (
|
|
9187
|
+
tabGroupId: (_b = data.tabGroupId) !== null && _b !== void 0 ? _b : sourceTabGroupId,
|
|
7979
9188
|
},
|
|
7980
9189
|
to: {
|
|
7981
9190
|
group: this.group,
|
|
@@ -8003,22 +9212,27 @@ class Tabs extends CompositeDisposable {
|
|
|
8003
9212
|
this._tabGroupManager.skipNextCollapseAnimation = true;
|
|
8004
9213
|
}
|
|
8005
9214
|
resetDragAnimation() {
|
|
8006
|
-
var _a, _b;
|
|
8007
9215
|
this._pendingCollapse = false;
|
|
8008
|
-
|
|
8009
|
-
//
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
9216
|
+
// After a drop, `tab.onDrop` consumes _animState (sets it to null)
|
|
9217
|
+
// and immediately calls `runFlipAnimation`, which sets transforms
|
|
9218
|
+
// and queues an rAF to trigger the CSS transition. dragend fires
|
|
9219
|
+
// synchronously on the source element BEFORE that rAF runs — if
|
|
9220
|
+
// we cleared transforms here we'd clobber the in-flight FLIP, so
|
|
9221
|
+
// gate the cleanup on _animState still being set (i.e. drag was
|
|
9222
|
+
// cancelled rather than dropped).
|
|
9223
|
+
if (this._animState) {
|
|
9224
|
+
this.resetTabTransforms();
|
|
9225
|
+
if (this._animState.sourceTabGroupId) {
|
|
9226
|
+
this._clearGroupDragClasses(this._animState.sourceTabGroupId);
|
|
9227
|
+
}
|
|
9228
|
+
else {
|
|
9229
|
+
this._removeClassInstantlyBatch(this._tabs.map((t) => t.value.element), 'dv-tab--dragging');
|
|
9230
|
+
}
|
|
9231
|
+
this._animState = null;
|
|
9232
|
+
// Restore any hidden underlines from group drags.
|
|
9233
|
+
for (const [, el] of this._tabGroupManager.groupUnderlines) {
|
|
9234
|
+
el.style.removeProperty('display');
|
|
9235
|
+
}
|
|
8022
9236
|
}
|
|
8023
9237
|
}
|
|
8024
9238
|
runFlipAnimation(firstPositions, sourceTabId, isCrossGroup = false, animRange) {
|
|
@@ -8518,6 +9732,7 @@ const PROPERTY_KEYS_DOCKVIEW = (() => {
|
|
|
8518
9732
|
rootOverlayModel: undefined,
|
|
8519
9733
|
locked: undefined,
|
|
8520
9734
|
disableDnd: undefined,
|
|
9735
|
+
dndStrategy: undefined,
|
|
8521
9736
|
className: undefined,
|
|
8522
9737
|
noPanelsOverlay: undefined,
|
|
8523
9738
|
dndEdges: undefined,
|
|
@@ -8702,6 +9917,10 @@ class TabGroup extends CompositeDisposable {
|
|
|
8702
9917
|
}
|
|
8703
9918
|
|
|
8704
9919
|
class DockviewDidDropEvent extends DockviewEvent {
|
|
9920
|
+
/**
|
|
9921
|
+
* `PointerEvent` for touch drags has no `dataTransfer`; use
|
|
9922
|
+
* `getData()` for the dockview payload regardless of input method.
|
|
9923
|
+
*/
|
|
8705
9924
|
get nativeEvent() {
|
|
8706
9925
|
return this.options.nativeEvent;
|
|
8707
9926
|
}
|
|
@@ -8806,29 +10025,28 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
8806
10025
|
toggleClass(this.container, 'dv-groupview-floating', false);
|
|
8807
10026
|
toggleClass(this.container, 'dv-groupview-popout', false);
|
|
8808
10027
|
toggleClass(this.container, 'dv-groupview-edge', false);
|
|
10028
|
+
// Mouse and touch drop targets must agree on accepted zones.
|
|
10029
|
+
const applyZones = (zones) => {
|
|
10030
|
+
this.contentContainer.dropTarget.setTargetZones(zones);
|
|
10031
|
+
this.contentContainer.pointerDropTarget.setTargetZones(zones);
|
|
10032
|
+
};
|
|
8809
10033
|
switch (value.type) {
|
|
8810
10034
|
case 'grid':
|
|
8811
|
-
|
|
8812
|
-
'top',
|
|
8813
|
-
'bottom',
|
|
8814
|
-
'left',
|
|
8815
|
-
'right',
|
|
8816
|
-
'center',
|
|
8817
|
-
]);
|
|
10035
|
+
applyZones(['top', 'bottom', 'left', 'right', 'center']);
|
|
8818
10036
|
break;
|
|
8819
10037
|
case 'floating':
|
|
8820
|
-
|
|
8821
|
-
|
|
10038
|
+
applyZones(['center']);
|
|
10039
|
+
applyZones(value
|
|
8822
10040
|
? ['center']
|
|
8823
10041
|
: ['top', 'bottom', 'left', 'right', 'center']);
|
|
8824
10042
|
toggleClass(this.container, 'dv-groupview-floating', true);
|
|
8825
10043
|
break;
|
|
8826
10044
|
case 'popout':
|
|
8827
|
-
|
|
10045
|
+
applyZones(['center']);
|
|
8828
10046
|
toggleClass(this.container, 'dv-groupview-popout', true);
|
|
8829
10047
|
break;
|
|
8830
10048
|
case 'edge':
|
|
8831
|
-
|
|
10049
|
+
applyZones(['center']);
|
|
8832
10050
|
toggleClass(this.container, 'dv-groupview-edge', true);
|
|
8833
10051
|
break;
|
|
8834
10052
|
}
|
|
@@ -8954,6 +10172,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
8954
10172
|
// noop
|
|
8955
10173
|
}), this.contentContainer.dropTarget.onDrop((event) => {
|
|
8956
10174
|
this.handleDropEvent('content', event.nativeEvent, event.position);
|
|
10175
|
+
}), this.contentContainer.pointerDropTarget.onDrop((event) => {
|
|
10176
|
+
this.handleDropEvent('content', event.nativeEvent, event.position);
|
|
8957
10177
|
}), this.tabsContainer.onWillShowOverlay((event) => {
|
|
8958
10178
|
this._onWillShowOverlay.fire(event);
|
|
8959
10179
|
}), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
|
|
@@ -8964,6 +10184,14 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
8964
10184
|
group: this.groupPanel,
|
|
8965
10185
|
getData: getPanelData,
|
|
8966
10186
|
}));
|
|
10187
|
+
}), this.contentContainer.pointerDropTarget.onWillShowOverlay((event) => {
|
|
10188
|
+
this._onWillShowOverlay.fire(new DockviewWillShowOverlayLocationEvent(event, {
|
|
10189
|
+
kind: 'content',
|
|
10190
|
+
panel: this.activePanel,
|
|
10191
|
+
api: this._api,
|
|
10192
|
+
group: this.groupPanel,
|
|
10193
|
+
getData: getPanelData,
|
|
10194
|
+
}));
|
|
8967
10195
|
}), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent, this._onDidPanelTitleChange, this._onDidPanelParametersChange, this._onDidCreateTabGroup, this._onDidDestroyTabGroup, this._onDidAddPanelToTabGroup, this._onDidRemovePanelFromTabGroup, this._onDidTabGroupChange, this._onDidTabGroupCollapsedChange, this._onDidCreateTabGroup.event(() => {
|
|
8968
10196
|
this._scheduleTabGroupUpdate();
|
|
8969
10197
|
}), this._onDidDestroyTabGroup.event(() => {
|
|
@@ -10967,7 +12195,12 @@ class Overlay extends CompositeDisposable {
|
|
|
10967
12195
|
this.onDidChange = this._onDidChange.event;
|
|
10968
12196
|
this._onDidChangeEnd = new Emitter();
|
|
10969
12197
|
this.onDidChangeEnd = this._onDidChangeEnd.event;
|
|
10970
|
-
this.
|
|
12198
|
+
this._onDidStartMoving = new Emitter();
|
|
12199
|
+
/** Fires once per drag, the first time the float actually moves. */
|
|
12200
|
+
this.onDidStartMoving = this._onDidStartMoving.event;
|
|
12201
|
+
this._dragMove = new MutableDisposable();
|
|
12202
|
+
this._dragCancelled = false;
|
|
12203
|
+
this.addDisposables(this._onDidChange, this._onDidChangeEnd, this._onDidStartMoving, this._dragMove);
|
|
10971
12204
|
this._element.className = 'dv-resize-container';
|
|
10972
12205
|
this._isVisible = true;
|
|
10973
12206
|
this.setupResize('top');
|
|
@@ -11076,16 +12309,60 @@ class Overlay extends CompositeDisposable {
|
|
|
11076
12309
|
result.height = element.height;
|
|
11077
12310
|
return result;
|
|
11078
12311
|
}
|
|
12312
|
+
/**
|
|
12313
|
+
* Abort an in-flight move-the-float drag. Used by the void container
|
|
12314
|
+
* when a redock long-press fires after the move started, so the ghost
|
|
12315
|
+
* gesture wins without the float continuing to follow the finger.
|
|
12316
|
+
* Does not emit `onDidChangeEnd` because no change is being committed.
|
|
12317
|
+
*/
|
|
12318
|
+
cancelPendingDrag() {
|
|
12319
|
+
if (!this._dragMove.value) {
|
|
12320
|
+
return;
|
|
12321
|
+
}
|
|
12322
|
+
this._dragCancelled = true;
|
|
12323
|
+
toggleClass(this._element, 'dv-resize-container-dragging', false);
|
|
12324
|
+
this._dragMove.value = exports.DockviewDisposable.NONE;
|
|
12325
|
+
}
|
|
11079
12326
|
setupDrag(dragTarget, options = { inDragMode: false }) {
|
|
11080
|
-
const
|
|
11081
|
-
const track = () => {
|
|
12327
|
+
const track = (captureTarget, pointerId) => {
|
|
11082
12328
|
let offset = null;
|
|
12329
|
+
let hasMoved = false;
|
|
12330
|
+
this._dragCancelled = false;
|
|
11083
12331
|
const iframes = disableIframePointEvents();
|
|
11084
|
-
|
|
12332
|
+
if (captureTarget &&
|
|
12333
|
+
typeof pointerId === 'number' &&
|
|
12334
|
+
typeof captureTarget.setPointerCapture === 'function') {
|
|
12335
|
+
try {
|
|
12336
|
+
captureTarget.setPointerCapture(pointerId);
|
|
12337
|
+
}
|
|
12338
|
+
catch (_a) {
|
|
12339
|
+
// ignore – non-fatal if the browser refuses capture
|
|
12340
|
+
}
|
|
12341
|
+
}
|
|
12342
|
+
const end = () => {
|
|
12343
|
+
toggleClass(this._element, 'dv-resize-container-dragging', false);
|
|
12344
|
+
this._dragMove.value = exports.DockviewDisposable.NONE;
|
|
12345
|
+
this._onDidChangeEnd.fire();
|
|
12346
|
+
};
|
|
12347
|
+
this._dragMove.value = new CompositeDisposable({
|
|
11085
12348
|
dispose: () => {
|
|
11086
12349
|
iframes.release();
|
|
12350
|
+
if (captureTarget &&
|
|
12351
|
+
typeof pointerId === 'number' &&
|
|
12352
|
+
typeof captureTarget.releasePointerCapture ===
|
|
12353
|
+
'function') {
|
|
12354
|
+
try {
|
|
12355
|
+
captureTarget.releasePointerCapture(pointerId);
|
|
12356
|
+
}
|
|
12357
|
+
catch (_a) {
|
|
12358
|
+
// ignore – pointer may already be released
|
|
12359
|
+
}
|
|
12360
|
+
}
|
|
11087
12361
|
},
|
|
11088
12362
|
}, addDisposableListener(window, 'pointermove', (e) => {
|
|
12363
|
+
if (this._dragCancelled) {
|
|
12364
|
+
return;
|
|
12365
|
+
}
|
|
11089
12366
|
const containerRect = this.options.container.getBoundingClientRect();
|
|
11090
12367
|
const x = e.clientX - containerRect.left;
|
|
11091
12368
|
const y = e.clientY - containerRect.top;
|
|
@@ -11122,13 +12399,13 @@ class Overlay extends CompositeDisposable {
|
|
|
11122
12399
|
bounds.right = right;
|
|
11123
12400
|
}
|
|
11124
12401
|
this.setBounds(bounds);
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
}));
|
|
12402
|
+
if (!hasMoved) {
|
|
12403
|
+
hasMoved = true;
|
|
12404
|
+
this._onDidStartMoving.fire();
|
|
12405
|
+
}
|
|
12406
|
+
}), addDisposableListener(window, 'pointerup', end), addDisposableListener(window, 'pointercancel', end));
|
|
11130
12407
|
};
|
|
11131
|
-
this.addDisposables(
|
|
12408
|
+
this.addDisposables(addDisposableListener(dragTarget, 'pointerdown', (event) => {
|
|
11132
12409
|
if (event.defaultPrevented) {
|
|
11133
12410
|
event.preventDefault();
|
|
11134
12411
|
return;
|
|
@@ -11138,7 +12415,7 @@ class Overlay extends CompositeDisposable {
|
|
|
11138
12415
|
if (quasiDefaultPrevented(event)) {
|
|
11139
12416
|
return;
|
|
11140
12417
|
}
|
|
11141
|
-
track();
|
|
12418
|
+
track(dragTarget, event.pointerId);
|
|
11142
12419
|
}), addDisposableListener(this.options.content, 'pointerdown', (event) => {
|
|
11143
12420
|
if (event.defaultPrevented) {
|
|
11144
12421
|
return;
|
|
@@ -11149,7 +12426,7 @@ class Overlay extends CompositeDisposable {
|
|
|
11149
12426
|
return;
|
|
11150
12427
|
}
|
|
11151
12428
|
if (event.shiftKey) {
|
|
11152
|
-
track();
|
|
12429
|
+
track(this.options.content, event.pointerId);
|
|
11153
12430
|
}
|
|
11154
12431
|
}), addDisposableListener(this.options.content, 'pointerdown', () => {
|
|
11155
12432
|
arialLevelTracker.push(this._element);
|
|
@@ -11167,6 +12444,19 @@ class Overlay extends CompositeDisposable {
|
|
|
11167
12444
|
e.preventDefault();
|
|
11168
12445
|
let startPosition = null;
|
|
11169
12446
|
const iframes = disableIframePointEvents();
|
|
12447
|
+
const pointerId = e.pointerId;
|
|
12448
|
+
if (typeof resizeHandleElement.setPointerCapture === 'function') {
|
|
12449
|
+
try {
|
|
12450
|
+
resizeHandleElement.setPointerCapture(pointerId);
|
|
12451
|
+
}
|
|
12452
|
+
catch (_a) {
|
|
12453
|
+
// ignore – non-fatal if the browser refuses capture
|
|
12454
|
+
}
|
|
12455
|
+
}
|
|
12456
|
+
const end = () => {
|
|
12457
|
+
move.dispose();
|
|
12458
|
+
this._onDidChangeEnd.fire();
|
|
12459
|
+
};
|
|
11170
12460
|
move.value = new CompositeDisposable(addDisposableListener(window, 'pointermove', (e) => {
|
|
11171
12461
|
const containerRect = this.options.container.getBoundingClientRect();
|
|
11172
12462
|
const overlayRect = this._element.getBoundingClientRect();
|
|
@@ -11301,11 +12591,17 @@ class Overlay extends CompositeDisposable {
|
|
|
11301
12591
|
}), {
|
|
11302
12592
|
dispose: () => {
|
|
11303
12593
|
iframes.release();
|
|
12594
|
+
if (typeof resizeHandleElement.releasePointerCapture ===
|
|
12595
|
+
'function') {
|
|
12596
|
+
try {
|
|
12597
|
+
resizeHandleElement.releasePointerCapture(pointerId);
|
|
12598
|
+
}
|
|
12599
|
+
catch (_a) {
|
|
12600
|
+
// ignore – pointer may already be released
|
|
12601
|
+
}
|
|
12602
|
+
}
|
|
11304
12603
|
},
|
|
11305
|
-
}, addDisposableListener(window, 'pointerup',
|
|
11306
|
-
move.dispose();
|
|
11307
|
-
this._onDidChangeEnd.fire();
|
|
11308
|
-
}));
|
|
12604
|
+
}, addDisposableListener(window, 'pointerup', end), addDisposableListener(window, 'pointercancel', end));
|
|
11309
12605
|
}));
|
|
11310
12606
|
}
|
|
11311
12607
|
getMinimumWidth(width) {
|
|
@@ -11830,6 +13126,14 @@ class StrictEventsSequencing extends CompositeDisposable {
|
|
|
11830
13126
|
}
|
|
11831
13127
|
}
|
|
11832
13128
|
|
|
13129
|
+
function isCoarsePrimaryInput$1(win) {
|
|
13130
|
+
if (!win.matchMedia) {
|
|
13131
|
+
return false;
|
|
13132
|
+
}
|
|
13133
|
+
const coarse = win.matchMedia('(pointer: coarse)').matches;
|
|
13134
|
+
const fine = win.matchMedia('(pointer: fine)').matches;
|
|
13135
|
+
return coarse && !fine;
|
|
13136
|
+
}
|
|
11833
13137
|
class PopupService extends CompositeDisposable {
|
|
11834
13138
|
constructor(root, win = window) {
|
|
11835
13139
|
super();
|
|
@@ -11868,8 +13172,22 @@ class PopupService extends CompositeDisposable {
|
|
|
11868
13172
|
wrapper.style.left = `${position.x - offsetX}px`;
|
|
11869
13173
|
this._element.appendChild(wrapper);
|
|
11870
13174
|
this._active = wrapper;
|
|
13175
|
+
// Outside-pointerdown dismissal is suppressed for a short grace
|
|
13176
|
+
// window after opening. Touch long-press callers (chip / tab context
|
|
13177
|
+
// menus) open the popover while the user's finger is still pressing
|
|
13178
|
+
// the source element — Android Chrome can dispatch a follow-up
|
|
13179
|
+
// synthetic pointerdown tied to the gesture, and the release-then-
|
|
13180
|
+
// retap motion can land just outside the wrapper. Either would
|
|
13181
|
+
// dismiss the popover before the user can see or interact with it.
|
|
13182
|
+
// The grace window is short enough that intentional outside taps
|
|
13183
|
+
// still feel responsive.
|
|
13184
|
+
const openedAt = Date.now();
|
|
13185
|
+
const POINTERDOWN_GRACE_MS = 200;
|
|
11871
13186
|
this._activeDisposable.value = new CompositeDisposable(addDisposableListener(this._window, 'pointerdown', (event) => {
|
|
11872
13187
|
var _a;
|
|
13188
|
+
if (Date.now() - openedAt < POINTERDOWN_GRACE_MS) {
|
|
13189
|
+
return;
|
|
13190
|
+
}
|
|
11873
13191
|
const target = event.target;
|
|
11874
13192
|
if (!(target instanceof HTMLElement)) {
|
|
11875
13193
|
return;
|
|
@@ -11887,6 +13205,18 @@ class PopupService extends CompositeDisposable {
|
|
|
11887
13205
|
this.close();
|
|
11888
13206
|
}
|
|
11889
13207
|
}), addDisposableListener(this._window, 'resize', () => {
|
|
13208
|
+
// On touch-primary devices, common interactions resize the
|
|
13209
|
+
// window: on-screen keyboard pop, orientation change, browser
|
|
13210
|
+
// address-bar collapse. None of these mean "the user wants
|
|
13211
|
+
// the popover dismissed". Specifically, focusing the chip
|
|
13212
|
+
// context menu's rename input pops the keyboard, which would
|
|
13213
|
+
// otherwise close the menu the moment the user goes to edit
|
|
13214
|
+
// it. Desktop / hybrid input keeps the existing behaviour —
|
|
13215
|
+
// there a resize genuinely means the user has resized the
|
|
13216
|
+
// window and the popover position is now stale.
|
|
13217
|
+
if (isCoarsePrimaryInput$1(this._window)) {
|
|
13218
|
+
return;
|
|
13219
|
+
}
|
|
11890
13220
|
this.close();
|
|
11891
13221
|
}));
|
|
11892
13222
|
this._window.requestAnimationFrame(() => {
|
|
@@ -11943,6 +13273,14 @@ function buildSeparator() {
|
|
|
11943
13273
|
el.setAttribute('role', 'separator');
|
|
11944
13274
|
return el;
|
|
11945
13275
|
}
|
|
13276
|
+
function isCoarsePrimaryInput() {
|
|
13277
|
+
if (typeof window === 'undefined' || !window.matchMedia) {
|
|
13278
|
+
return false;
|
|
13279
|
+
}
|
|
13280
|
+
const coarse = window.matchMedia('(pointer: coarse)').matches;
|
|
13281
|
+
const fine = window.matchMedia('(pointer: fine)').matches;
|
|
13282
|
+
return coarse && !fine;
|
|
13283
|
+
}
|
|
11946
13284
|
function buildRenameInput(tabGroup) {
|
|
11947
13285
|
const wrapper = document.createElement('div');
|
|
11948
13286
|
wrapper.className = 'dv-context-menu-rename';
|
|
@@ -11963,10 +13301,17 @@ function buildRenameInput(tabGroup) {
|
|
|
11963
13301
|
e.stopPropagation();
|
|
11964
13302
|
});
|
|
11965
13303
|
wrapper.appendChild(input);
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
13304
|
+
// Skip auto-focus on touch-primary devices: focusing the input pops the
|
|
13305
|
+
// on-screen keyboard, which fires `window resize`, which `PopupService`
|
|
13306
|
+
// listens to and uses to dismiss the popover — so the menu opens, the
|
|
13307
|
+
// keyboard appears, and the menu immediately closes before the user can
|
|
13308
|
+
// type. The user can still tap the input to focus it intentionally.
|
|
13309
|
+
if (!isCoarsePrimaryInput()) {
|
|
13310
|
+
requestAnimationFrame(() => {
|
|
13311
|
+
input.focus();
|
|
13312
|
+
input.select();
|
|
13313
|
+
});
|
|
13314
|
+
}
|
|
11970
13315
|
return wrapper;
|
|
11971
13316
|
}
|
|
11972
13317
|
function buildColorPicker(tabGroup, palette) {
|
|
@@ -12881,7 +14226,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
12881
14226
|
return this._popoutRestorationPromise;
|
|
12882
14227
|
}
|
|
12883
14228
|
constructor(container, options) {
|
|
12884
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14229
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12885
14230
|
super(container, {
|
|
12886
14231
|
proportionalLayout: true,
|
|
12887
14232
|
orientation: exports.Orientation.HORIZONTAL,
|
|
@@ -12980,37 +14325,51 @@ class DockviewComponent extends BaseGrid {
|
|
|
12980
14325
|
this._floatingOverlayHost = document.createElement('div');
|
|
12981
14326
|
this._floatingOverlayHost.className = 'dv-floating-overlay-host';
|
|
12982
14327
|
this._shellManager.element.appendChild(this._floatingOverlayHost);
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
if (data) {
|
|
12988
|
-
if (data.viewId !== this.id) {
|
|
12989
|
-
return false;
|
|
12990
|
-
}
|
|
12991
|
-
if (position === 'center') {
|
|
12992
|
-
// center drop target is only allowed if there are no panels in the grid
|
|
12993
|
-
// floating panels are allowed
|
|
12994
|
-
return this.gridview.length === 0;
|
|
12995
|
-
}
|
|
12996
|
-
return true;
|
|
12997
|
-
}
|
|
12998
|
-
if (position === 'center' && this.gridview.length !== 0) {
|
|
12999
|
-
/**
|
|
13000
|
-
* for external events only show the four-corner drag overlays, disable
|
|
13001
|
-
* the center position so that external drag events can fall through to the group
|
|
13002
|
-
* and panel drop target handlers
|
|
13003
|
-
*/
|
|
14328
|
+
const rootCanDisplayOverlay = (event, position) => {
|
|
14329
|
+
const data = getPanelData();
|
|
14330
|
+
if (data) {
|
|
14331
|
+
if (data.viewId !== this.id) {
|
|
13004
14332
|
return false;
|
|
13005
14333
|
}
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
14334
|
+
if (position === 'center') {
|
|
14335
|
+
// center drop target is only allowed if there are no panels in the grid
|
|
14336
|
+
// floating panels are allowed
|
|
14337
|
+
return this.gridview.length === 0;
|
|
14338
|
+
}
|
|
14339
|
+
return true;
|
|
14340
|
+
}
|
|
14341
|
+
if (position === 'center' && this.gridview.length !== 0) {
|
|
14342
|
+
/**
|
|
14343
|
+
* for external events only show the four-corner drag overlays, disable
|
|
14344
|
+
* the center position so that external drag events can fall through to the group
|
|
14345
|
+
* and panel drop target handlers
|
|
14346
|
+
*/
|
|
14347
|
+
return false;
|
|
14348
|
+
}
|
|
14349
|
+
const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
|
|
14350
|
+
this._onUnhandledDragOverEvent.fire(firedEvent);
|
|
14351
|
+
return firedEvent.isAccepted;
|
|
14352
|
+
};
|
|
14353
|
+
this._rootDropTarget = html5Backend.createDropTarget(this.element, {
|
|
14354
|
+
className: 'dv-drop-target-edge',
|
|
14355
|
+
canDisplayOverlay: rootCanDisplayOverlay,
|
|
13010
14356
|
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
13011
14357
|
overlayModel: (_f = options.rootOverlayModel) !== null && _f !== void 0 ? _f : DEFAULT_ROOT_OVERLAY_MODEL,
|
|
13012
14358
|
getOverrideTarget: () => { var _a; return (_a = this.rootDropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
|
|
13013
14359
|
});
|
|
14360
|
+
this._rootPointerDropTarget = pointerBackend.createDropTarget(this.element, {
|
|
14361
|
+
className: 'dv-drop-target-edge',
|
|
14362
|
+
canDisplayOverlay: rootCanDisplayOverlay,
|
|
14363
|
+
acceptedTargetZones: [
|
|
14364
|
+
'top',
|
|
14365
|
+
'bottom',
|
|
14366
|
+
'left',
|
|
14367
|
+
'right',
|
|
14368
|
+
'center',
|
|
14369
|
+
],
|
|
14370
|
+
overlayModel: (_g = options.rootOverlayModel) !== null && _g !== void 0 ? _g : DEFAULT_ROOT_OVERLAY_MODEL,
|
|
14371
|
+
getOverrideTarget: () => { var _a; return (_a = this.rootDropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
|
|
14372
|
+
});
|
|
13014
14373
|
this.updateDropTargetModel(options);
|
|
13015
14374
|
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
13016
14375
|
toggleClass(this.element, 'dv-debug', !!options.debug);
|
|
@@ -13072,7 +14431,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
13072
14431
|
d.dispose();
|
|
13073
14432
|
}
|
|
13074
14433
|
this._edgeGroupDisposables.clear();
|
|
13075
|
-
}), this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
|
|
14434
|
+
}), this._rootDropTarget, this._rootPointerDropTarget, exports.DockviewEvent.any(this._rootDropTarget.onWillShowOverlay, this._rootPointerDropTarget.onWillShowOverlay)((event) => {
|
|
13076
14435
|
if (this.gridview.length > 0 && event.position === 'center') {
|
|
13077
14436
|
// option only available when no panels in primary grid
|
|
13078
14437
|
return;
|
|
@@ -13084,7 +14443,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
13084
14443
|
group: undefined,
|
|
13085
14444
|
getData: getPanelData,
|
|
13086
14445
|
}));
|
|
13087
|
-
}), this._rootDropTarget.onDrop((event) => {
|
|
14446
|
+
}), exports.DockviewEvent.any(this._rootDropTarget.onDrop, this._rootPointerDropTarget.onDrop)((event) => {
|
|
13088
14447
|
var _a;
|
|
13089
14448
|
const willDropEvent = new DockviewWillDropEvent({
|
|
13090
14449
|
nativeEvent: event.nativeEvent,
|
|
@@ -13122,7 +14481,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
13122
14481
|
getData: getPanelData,
|
|
13123
14482
|
}));
|
|
13124
14483
|
}
|
|
13125
|
-
})
|
|
14484
|
+
}));
|
|
13126
14485
|
}
|
|
13127
14486
|
setVisible(panel, visible) {
|
|
13128
14487
|
switch (panel.api.location.type) {
|
|
@@ -13634,9 +14993,12 @@ class DockviewComponent extends BaseGrid {
|
|
|
13634
14993
|
}
|
|
13635
14994
|
this.updateDropTargetModel(options);
|
|
13636
14995
|
const oldDisableDnd = this.options.disableDnd;
|
|
14996
|
+
const oldDndStrategy = this.options.dndStrategy;
|
|
13637
14997
|
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
13638
14998
|
const newDisableDnd = this.options.disableDnd;
|
|
13639
|
-
|
|
14999
|
+
const newDndStrategy = this.options.dndStrategy;
|
|
15000
|
+
if (oldDisableDnd !== newDisableDnd ||
|
|
15001
|
+
oldDndStrategy !== newDndStrategy) {
|
|
13640
15002
|
this.updateDragAndDropState();
|
|
13641
15003
|
}
|
|
13642
15004
|
if ('theme' in options) {
|
|
@@ -15200,15 +16562,18 @@ class DockviewComponent extends BaseGrid {
|
|
|
15200
16562
|
}
|
|
15201
16563
|
updateDropTargetModel(options) {
|
|
15202
16564
|
if ('dndEdges' in options) {
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
16565
|
+
const disabled = typeof options.dndEdges === 'boolean' &&
|
|
16566
|
+
options.dndEdges === false;
|
|
16567
|
+
this._rootDropTarget.disabled = disabled;
|
|
16568
|
+
this._rootPointerDropTarget.disabled = disabled;
|
|
15206
16569
|
if (typeof options.dndEdges === 'object' &&
|
|
15207
16570
|
options.dndEdges !== null) {
|
|
15208
16571
|
this._rootDropTarget.setOverlayModel(options.dndEdges);
|
|
16572
|
+
this._rootPointerDropTarget.setOverlayModel(options.dndEdges);
|
|
15209
16573
|
}
|
|
15210
16574
|
else {
|
|
15211
16575
|
this._rootDropTarget.setOverlayModel(DEFAULT_ROOT_OVERLAY_MODEL);
|
|
16576
|
+
this._rootPointerDropTarget.setOverlayModel(DEFAULT_ROOT_OVERLAY_MODEL);
|
|
15212
16577
|
}
|
|
15213
16578
|
}
|
|
15214
16579
|
if ('rootOverlayModel' in options) {
|