dockview-core 1.7.6 → 1.8.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 +2 -1
- package/dist/cjs/api/component.api.d.ts +6 -1
- package/dist/cjs/api/component.api.d.ts.map +1 -1
- package/dist/cjs/api/component.api.js +6 -0
- package/dist/cjs/api/component.api.js.map +1 -1
- package/dist/cjs/api/dockviewGroupPanelApi.d.ts +30 -0
- package/dist/cjs/api/dockviewGroupPanelApi.d.ts.map +1 -0
- package/dist/cjs/api/dockviewGroupPanelApi.js +54 -0
- package/dist/cjs/api/dockviewGroupPanelApi.js.map +1 -0
- package/dist/cjs/api/dockviewPanelApi.d.ts +14 -1
- package/dist/cjs/api/dockviewPanelApi.d.ts.map +1 -1
- package/dist/cjs/api/dockviewPanelApi.js +6 -1
- package/dist/cjs/api/dockviewPanelApi.js.map +1 -1
- package/dist/cjs/array.d.ts +1 -0
- package/dist/cjs/array.d.ts.map +1 -1
- package/dist/cjs/array.js +10 -1
- package/dist/cjs/array.js.map +1 -1
- package/dist/cjs/dnd/abstractDragHandler.d.ts +1 -0
- package/dist/cjs/dnd/abstractDragHandler.d.ts.map +1 -1
- package/dist/cjs/dnd/abstractDragHandler.js +7 -0
- package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
- package/dist/cjs/dnd/droptarget.d.ts +11 -0
- package/dist/cjs/dnd/droptarget.d.ts.map +1 -1
- package/dist/cjs/dnd/droptarget.js +32 -9
- package/dist/cjs/dnd/droptarget.js.map +1 -1
- package/dist/cjs/dnd/groupDragHandler.d.ts +1 -0
- package/dist/cjs/dnd/groupDragHandler.d.ts.map +1 -1
- package/dist/cjs/dnd/groupDragHandler.js +18 -0
- package/dist/cjs/dnd/groupDragHandler.js.map +1 -1
- package/dist/cjs/dnd/overlay.d.ts +40 -0
- package/dist/cjs/dnd/overlay.d.ts.map +1 -0
- package/dist/cjs/dnd/overlay.js +382 -0
- package/dist/cjs/dnd/overlay.js.map +1 -0
- package/dist/cjs/dockview/components/tab/tab.d.ts +2 -2
- package/dist/cjs/dockview/components/tab/tab.d.ts.map +1 -1
- package/dist/cjs/dockview/components/tab/tab.js +0 -7
- package/dist/cjs/dockview/components/tab/tab.js.map +1 -1
- package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +8 -4
- package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
- package/dist/cjs/dockview/components/titlebar/tabsContainer.js +54 -10
- package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
- package/dist/cjs/dockview/deserializer.d.ts +2 -2
- package/dist/cjs/dockview/deserializer.d.ts.map +1 -1
- package/dist/cjs/dockview/deserializer.js.map +1 -1
- package/dist/cjs/dockview/dockviewComponent.d.ts +41 -9
- package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
- package/dist/cjs/dockview/dockviewComponent.js +277 -76
- package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +24 -0
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts.map +1 -0
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +35 -0
- package/dist/cjs/dockview/dockviewFloatingGroupPanel.js.map +1 -0
- package/dist/cjs/dockview/dockviewGroupPanel.d.ts +5 -6
- package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -1
- package/dist/cjs/dockview/dockviewGroupPanel.js +3 -2
- package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
- package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +5 -1
- package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
- package/dist/cjs/dockview/dockviewGroupPanelModel.js +43 -12
- package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
- package/dist/cjs/dockview/dockviewPanel.d.ts +2 -2
- package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -1
- package/dist/cjs/dockview/dockviewPanel.js +1 -1
- package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
- package/dist/cjs/dockview/options.d.ts +22 -6
- package/dist/cjs/dockview/options.d.ts.map +1 -1
- package/dist/cjs/dockview/options.js.map +1 -1
- package/dist/cjs/dom.d.ts +5 -3
- package/dist/cjs/dom.d.ts.map +1 -1
- package/dist/cjs/dom.js +13 -1
- package/dist/cjs/dom.js.map +1 -1
- package/dist/cjs/events.d.ts.map +1 -1
- package/dist/cjs/gridview/branchNode.js +2 -2
- package/dist/cjs/gridview/branchNode.js.map +1 -1
- package/dist/cjs/gridview/gridview.d.ts.map +1 -1
- package/dist/cjs/gridview/gridview.js +9 -7
- package/dist/cjs/gridview/gridview.js.map +1 -1
- package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
- package/dist/cjs/gridview/gridviewComponent.js +4 -1
- package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
- package/dist/cjs/gridview/gridviewPanel.d.ts +3 -3
- package/dist/cjs/gridview/gridviewPanel.d.ts.map +1 -1
- package/dist/cjs/gridview/gridviewPanel.js +2 -2
- package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/math.d.ts.map +1 -1
- package/dist/cjs/paneview/paneviewComponent.d.ts.map +1 -1
- package/dist/cjs/paneview/paneviewComponent.js +4 -1
- package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
- package/dist/cjs/splitview/splitviewComponent.d.ts.map +1 -1
- package/dist/cjs/splitview/splitviewComponent.js +4 -1
- package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
- package/dist/dockview-core.amd.js +764 -133
- package/dist/dockview-core.amd.js.map +1 -0
- package/dist/dockview-core.amd.min.js +3 -2
- package/dist/dockview-core.amd.min.js.map +1 -0
- package/dist/dockview-core.amd.min.noStyle.js +3 -2
- package/dist/dockview-core.amd.min.noStyle.js.map +1 -0
- package/dist/dockview-core.amd.noStyle.js +763 -132
- package/dist/dockview-core.amd.noStyle.js.map +1 -0
- package/dist/dockview-core.cjs.js +764 -133
- package/dist/dockview-core.cjs.js.map +1 -0
- package/dist/dockview-core.esm.js +765 -133
- package/dist/dockview-core.esm.js.map +1 -0
- package/dist/dockview-core.esm.min.js +3 -2
- package/dist/dockview-core.esm.min.js.map +1 -0
- package/dist/dockview-core.js +764 -133
- package/dist/dockview-core.js.map +1 -0
- package/dist/dockview-core.min.js +3 -2
- package/dist/dockview-core.min.js.map +1 -0
- package/dist/dockview-core.min.noStyle.js +3 -2
- package/dist/dockview-core.min.noStyle.js.map +1 -0
- package/dist/dockview-core.noStyle.js +763 -132
- package/dist/dockview-core.noStyle.js.map +1 -0
- package/dist/esm/api/component.api.d.ts +6 -1
- package/dist/esm/api/component.api.d.ts.map +1 -1
- package/dist/esm/api/component.api.js +6 -0
- package/dist/esm/api/component.api.js.map +1 -1
- package/dist/esm/api/dockviewGroupPanelApi.d.ts +30 -0
- package/dist/esm/api/dockviewGroupPanelApi.d.ts.map +1 -0
- package/dist/esm/api/dockviewGroupPanelApi.js +28 -0
- package/dist/esm/api/dockviewGroupPanelApi.js.map +1 -0
- package/dist/esm/api/dockviewPanelApi.d.ts +14 -1
- package/dist/esm/api/dockviewPanelApi.d.ts.map +1 -1
- package/dist/esm/api/dockviewPanelApi.js +6 -1
- package/dist/esm/api/dockviewPanelApi.js.map +1 -1
- package/dist/esm/array.d.ts +1 -0
- package/dist/esm/array.d.ts.map +1 -1
- package/dist/esm/array.js +8 -0
- package/dist/esm/array.js.map +1 -1
- package/dist/esm/dnd/abstractDragHandler.d.ts +1 -0
- package/dist/esm/dnd/abstractDragHandler.d.ts.map +1 -1
- package/dist/esm/dnd/abstractDragHandler.js +7 -0
- package/dist/esm/dnd/abstractDragHandler.js.map +1 -1
- package/dist/esm/dnd/droptarget.d.ts +11 -0
- package/dist/esm/dnd/droptarget.d.ts.map +1 -1
- package/dist/esm/dnd/droptarget.js +32 -9
- package/dist/esm/dnd/droptarget.js.map +1 -1
- package/dist/esm/dnd/groupDragHandler.d.ts +1 -0
- package/dist/esm/dnd/groupDragHandler.d.ts.map +1 -1
- package/dist/esm/dnd/groupDragHandler.js +18 -0
- package/dist/esm/dnd/groupDragHandler.js.map +1 -1
- package/dist/esm/dnd/overlay.d.ts +40 -0
- package/dist/esm/dnd/overlay.d.ts.map +1 -0
- package/dist/esm/dnd/overlay.js +282 -0
- package/dist/esm/dnd/overlay.js.map +1 -0
- package/dist/esm/dockview/components/tab/tab.d.ts +2 -2
- package/dist/esm/dockview/components/tab/tab.d.ts.map +1 -1
- package/dist/esm/dockview/components/tab/tab.js +0 -7
- package/dist/esm/dockview/components/tab/tab.js.map +1 -1
- package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +8 -4
- package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
- package/dist/esm/dockview/components/titlebar/tabsContainer.js +54 -10
- package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -1
- package/dist/esm/dockview/deserializer.d.ts +2 -2
- package/dist/esm/dockview/deserializer.d.ts.map +1 -1
- package/dist/esm/dockview/deserializer.js.map +1 -1
- package/dist/esm/dockview/dockviewComponent.d.ts +41 -9
- package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
- package/dist/esm/dockview/dockviewComponent.js +223 -54
- package/dist/esm/dockview/dockviewComponent.js.map +1 -1
- package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +24 -0
- package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts.map +1 -0
- package/dist/esm/dockview/dockviewFloatingGroupPanel.js +13 -0
- package/dist/esm/dockview/dockviewFloatingGroupPanel.js.map +1 -0
- package/dist/esm/dockview/dockviewGroupPanel.d.ts +5 -6
- package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -1
- package/dist/esm/dockview/dockviewGroupPanel.js +3 -2
- package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -1
- package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +5 -1
- package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
- package/dist/esm/dockview/dockviewGroupPanelModel.js +36 -9
- package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
- package/dist/esm/dockview/dockviewPanel.d.ts +2 -2
- package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -1
- package/dist/esm/dockview/dockviewPanel.js +1 -1
- package/dist/esm/dockview/dockviewPanel.js.map +1 -1
- package/dist/esm/dockview/options.d.ts +22 -6
- package/dist/esm/dockview/options.d.ts.map +1 -1
- package/dist/esm/dockview/options.js.map +1 -1
- package/dist/esm/dom.d.ts +5 -3
- package/dist/esm/dom.d.ts.map +1 -1
- package/dist/esm/dom.js +10 -0
- package/dist/esm/dom.js.map +1 -1
- package/dist/esm/events.d.ts.map +1 -1
- package/dist/esm/gridview/branchNode.js +2 -2
- package/dist/esm/gridview/branchNode.js.map +1 -1
- package/dist/esm/gridview/gridview.d.ts.map +1 -1
- package/dist/esm/gridview/gridview.js +9 -6
- package/dist/esm/gridview/gridview.js.map +1 -1
- package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
- package/dist/esm/gridview/gridviewComponent.js +4 -1
- package/dist/esm/gridview/gridviewComponent.js.map +1 -1
- package/dist/esm/gridview/gridviewPanel.d.ts +3 -3
- package/dist/esm/gridview/gridviewPanel.d.ts.map +1 -1
- package/dist/esm/gridview/gridviewPanel.js +2 -2
- package/dist/esm/gridview/gridviewPanel.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/math.d.ts.map +1 -1
- package/dist/esm/math.js.map +1 -1
- package/dist/esm/paneview/paneviewComponent.d.ts.map +1 -1
- package/dist/esm/paneview/paneviewComponent.js +4 -1
- package/dist/esm/paneview/paneviewComponent.js.map +1 -1
- package/dist/esm/splitview/splitviewComponent.d.ts.map +1 -1
- package/dist/esm/splitview/splitviewComponent.js +4 -1
- package/dist/esm/splitview/splitviewComponent.js.map +1 -1
- package/dist/styles/dockview.css +216 -1
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview-core
|
|
3
|
-
* @version 1.
|
|
3
|
+
* @version 1.8.0
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -277,6 +277,31 @@
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
281
|
+
const Component = typeof componentName === 'string'
|
|
282
|
+
? components[componentName]
|
|
283
|
+
: undefined;
|
|
284
|
+
const FrameworkComponent = typeof componentName === 'string'
|
|
285
|
+
? frameworkComponents[componentName]
|
|
286
|
+
: undefined;
|
|
287
|
+
if (Component && FrameworkComponent) {
|
|
288
|
+
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
289
|
+
}
|
|
290
|
+
if (FrameworkComponent) {
|
|
291
|
+
if (!createFrameworkComponent) {
|
|
292
|
+
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
293
|
+
}
|
|
294
|
+
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
295
|
+
}
|
|
296
|
+
if (!Component) {
|
|
297
|
+
if (fallback) {
|
|
298
|
+
return fallback();
|
|
299
|
+
}
|
|
300
|
+
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
301
|
+
}
|
|
302
|
+
return new Component(id, componentName);
|
|
303
|
+
}
|
|
304
|
+
|
|
280
305
|
function watchElementResize(element, cb) {
|
|
281
306
|
const observer = new ResizeObserver((entires) => {
|
|
282
307
|
/**
|
|
@@ -390,31 +415,16 @@
|
|
|
390
415
|
refreshState() {
|
|
391
416
|
this._refreshStateHandler();
|
|
392
417
|
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
404
|
-
}
|
|
405
|
-
if (FrameworkComponent) {
|
|
406
|
-
if (!createFrameworkComponent) {
|
|
407
|
-
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
408
|
-
}
|
|
409
|
-
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
410
|
-
}
|
|
411
|
-
if (!Component) {
|
|
412
|
-
if (fallback) {
|
|
413
|
-
return fallback();
|
|
414
|
-
}
|
|
415
|
-
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
416
|
-
}
|
|
417
|
-
return new Component(id, componentName);
|
|
418
|
+
}
|
|
419
|
+
// quasi: apparently, but not really; seemingly
|
|
420
|
+
const QUASI_PREVENT_DEFAULT_KEY = 'dv-quasiPreventDefault';
|
|
421
|
+
// mark an event directly for other listeners to check
|
|
422
|
+
function quasiPreventDefault(event) {
|
|
423
|
+
event[QUASI_PREVENT_DEFAULT_KEY] = true;
|
|
424
|
+
}
|
|
425
|
+
// check if this event has been marked
|
|
426
|
+
function quasiDefaultPrevented(event) {
|
|
427
|
+
return event[QUASI_PREVENT_DEFAULT_KEY];
|
|
418
428
|
}
|
|
419
429
|
|
|
420
430
|
function tail(arr) {
|
|
@@ -465,6 +475,14 @@
|
|
|
465
475
|
}
|
|
466
476
|
}
|
|
467
477
|
return -1;
|
|
478
|
+
}
|
|
479
|
+
function remove(array, value) {
|
|
480
|
+
const index = array.findIndex((t) => t === value);
|
|
481
|
+
if (index > -1) {
|
|
482
|
+
array.splice(index, 1);
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
return false;
|
|
468
486
|
}
|
|
469
487
|
|
|
470
488
|
const clamp = (value, min, max) => {
|
|
@@ -1607,7 +1625,7 @@
|
|
|
1607
1625
|
: true,
|
|
1608
1626
|
};
|
|
1609
1627
|
}),
|
|
1610
|
-
size: this.
|
|
1628
|
+
size: this.orthogonalSize,
|
|
1611
1629
|
};
|
|
1612
1630
|
this.children = childDescriptors.map((c) => c.node);
|
|
1613
1631
|
this.splitview = new Splitview(this.element, {
|
|
@@ -1670,7 +1688,7 @@
|
|
|
1670
1688
|
layout(size, orthogonalSize) {
|
|
1671
1689
|
this._size = orthogonalSize;
|
|
1672
1690
|
this._orthogonalSize = size;
|
|
1673
|
-
this.splitview.layout(
|
|
1691
|
+
this.splitview.layout(orthogonalSize, size);
|
|
1674
1692
|
}
|
|
1675
1693
|
addChild(node, size, index, skipLayout) {
|
|
1676
1694
|
if (index < 0 || index > this.children.length) {
|
|
@@ -1895,9 +1913,9 @@
|
|
|
1895
1913
|
this._deserialize(json.root, orientation, deserializer, height);
|
|
1896
1914
|
}
|
|
1897
1915
|
_deserialize(root, orientation, deserializer, orthogonalSize) {
|
|
1898
|
-
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize
|
|
1916
|
+
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
|
|
1899
1917
|
}
|
|
1900
|
-
_deserializeNode(node, orientation, deserializer, orthogonalSize
|
|
1918
|
+
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
1901
1919
|
let result;
|
|
1902
1920
|
if (node.type === 'branch') {
|
|
1903
1921
|
const serializedChildren = node.data;
|
|
@@ -1907,9 +1925,9 @@
|
|
|
1907
1925
|
visible: serializedChild.visible,
|
|
1908
1926
|
};
|
|
1909
1927
|
});
|
|
1910
|
-
//
|
|
1911
|
-
//
|
|
1912
|
-
|
|
1928
|
+
result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
|
|
1929
|
+
orthogonalSize, // <- size - flips at each depth
|
|
1930
|
+
children);
|
|
1913
1931
|
}
|
|
1914
1932
|
else {
|
|
1915
1933
|
result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
|
|
@@ -1942,7 +1960,8 @@
|
|
|
1942
1960
|
const oldRoot = this.root;
|
|
1943
1961
|
oldRoot.element.remove();
|
|
1944
1962
|
this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
|
|
1945
|
-
if (oldRoot.children.length ===
|
|
1963
|
+
if (oldRoot.children.length === 0) ;
|
|
1964
|
+
else if (oldRoot.children.length === 1) {
|
|
1946
1965
|
// can remove one level of redundant branching if there is only a single child
|
|
1947
1966
|
const childReference = oldRoot.children[0];
|
|
1948
1967
|
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
@@ -2458,6 +2477,9 @@
|
|
|
2458
2477
|
addPanel(options) {
|
|
2459
2478
|
return this.component.addPanel(options);
|
|
2460
2479
|
}
|
|
2480
|
+
removePanel(panel) {
|
|
2481
|
+
this.component.removePanel(panel);
|
|
2482
|
+
}
|
|
2461
2483
|
addGroup(options) {
|
|
2462
2484
|
return this.component.addGroup(options);
|
|
2463
2485
|
}
|
|
@@ -2476,6 +2498,9 @@
|
|
|
2476
2498
|
getGroup(id) {
|
|
2477
2499
|
return this.component.getPanel(id);
|
|
2478
2500
|
}
|
|
2501
|
+
addFloatingGroup(item, coord) {
|
|
2502
|
+
return this.component.addFloatingGroup(item, coord);
|
|
2503
|
+
}
|
|
2479
2504
|
fromJSON(data) {
|
|
2480
2505
|
this.component.fromJSON(data);
|
|
2481
2506
|
}
|
|
@@ -2568,10 +2593,14 @@
|
|
|
2568
2593
|
this._onDrop = new Emitter();
|
|
2569
2594
|
this.onDrop = this._onDrop.event;
|
|
2570
2595
|
// use a set to take advantage of #<set>.has
|
|
2571
|
-
|
|
2596
|
+
this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
|
|
2572
2597
|
this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
|
|
2573
2598
|
onDragEnter: () => undefined,
|
|
2574
2599
|
onDragOver: (e) => {
|
|
2600
|
+
if (this._acceptedTargetZonesSet.size === 0) {
|
|
2601
|
+
this.removeDropTarget();
|
|
2602
|
+
return;
|
|
2603
|
+
}
|
|
2575
2604
|
const width = this.element.clientWidth;
|
|
2576
2605
|
const height = this.element.clientHeight;
|
|
2577
2606
|
if (width === 0 || height === 0) {
|
|
@@ -2580,20 +2609,28 @@
|
|
|
2580
2609
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
2581
2610
|
const x = e.clientX - rect.left;
|
|
2582
2611
|
const y = e.clientY - rect.top;
|
|
2583
|
-
const quadrant = this.calculateQuadrant(
|
|
2584
|
-
|
|
2612
|
+
const quadrant = this.calculateQuadrant(this._acceptedTargetZonesSet, x, y, width, height);
|
|
2613
|
+
/**
|
|
2614
|
+
* If the event has already been used by another DropTarget instance
|
|
2615
|
+
* then don't show a second drop target, only one target should be
|
|
2616
|
+
* active at any one time
|
|
2617
|
+
*/
|
|
2618
|
+
if (this.isAlreadyUsed(e) || quadrant === null) {
|
|
2585
2619
|
// no drop target should be displayed
|
|
2586
2620
|
this.removeDropTarget();
|
|
2587
2621
|
return;
|
|
2588
2622
|
}
|
|
2589
2623
|
if (typeof this.options.canDisplayOverlay === 'boolean') {
|
|
2590
2624
|
if (!this.options.canDisplayOverlay) {
|
|
2625
|
+
this.removeDropTarget();
|
|
2591
2626
|
return;
|
|
2592
2627
|
}
|
|
2593
2628
|
}
|
|
2594
2629
|
else if (!this.options.canDisplayOverlay(e, quadrant)) {
|
|
2630
|
+
this.removeDropTarget();
|
|
2595
2631
|
return;
|
|
2596
2632
|
}
|
|
2633
|
+
this.markAsUsed(e);
|
|
2597
2634
|
if (!this.targetElement) {
|
|
2598
2635
|
this.targetElement = document.createElement('div');
|
|
2599
2636
|
this.targetElement.className = 'drop-target-dropzone';
|
|
@@ -2604,12 +2641,6 @@
|
|
|
2604
2641
|
this.element.classList.add('drop-target');
|
|
2605
2642
|
this.element.append(this.targetElement);
|
|
2606
2643
|
}
|
|
2607
|
-
if (this.options.acceptedTargetZones.length === 0) {
|
|
2608
|
-
return;
|
|
2609
|
-
}
|
|
2610
|
-
if (!this.targetElement || !this.overlayElement) {
|
|
2611
|
-
return;
|
|
2612
|
-
}
|
|
2613
2644
|
this.toggleClasses(quadrant, width, height);
|
|
2614
2645
|
this.setState(quadrant);
|
|
2615
2646
|
},
|
|
@@ -2632,10 +2663,26 @@
|
|
|
2632
2663
|
},
|
|
2633
2664
|
}));
|
|
2634
2665
|
}
|
|
2666
|
+
setTargetZones(acceptedTargetZones) {
|
|
2667
|
+
this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
|
|
2668
|
+
}
|
|
2635
2669
|
dispose() {
|
|
2636
2670
|
this.removeDropTarget();
|
|
2637
2671
|
super.dispose();
|
|
2638
2672
|
}
|
|
2673
|
+
/**
|
|
2674
|
+
* Add a property to the event object for other potential listeners to check
|
|
2675
|
+
*/
|
|
2676
|
+
markAsUsed(event) {
|
|
2677
|
+
event[Droptarget.USED_EVENT_ID] = true;
|
|
2678
|
+
}
|
|
2679
|
+
/**
|
|
2680
|
+
* Check is the event has already been used by another instance od DropTarget
|
|
2681
|
+
*/
|
|
2682
|
+
isAlreadyUsed(event) {
|
|
2683
|
+
const value = event[Droptarget.USED_EVENT_ID];
|
|
2684
|
+
return typeof value === 'boolean' && value;
|
|
2685
|
+
}
|
|
2639
2686
|
toggleClasses(quadrant, width, height) {
|
|
2640
2687
|
var _a, _b, _c, _d;
|
|
2641
2688
|
if (!this.overlayElement) {
|
|
@@ -2730,6 +2777,7 @@
|
|
|
2730
2777
|
}
|
|
2731
2778
|
}
|
|
2732
2779
|
}
|
|
2780
|
+
Droptarget.USED_EVENT_ID = '__dockview_droptarget_event_is_used__';
|
|
2733
2781
|
function calculateQuadrantAsPercentage(overlayType, x, y, width, height, threshold) {
|
|
2734
2782
|
const xp = (100 * x) / width;
|
|
2735
2783
|
const yp = (100 * y) / height;
|
|
@@ -2859,8 +2907,15 @@
|
|
|
2859
2907
|
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2860
2908
|
this.configure();
|
|
2861
2909
|
}
|
|
2910
|
+
isCancelled(_event) {
|
|
2911
|
+
return false;
|
|
2912
|
+
}
|
|
2862
2913
|
configure() {
|
|
2863
2914
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2915
|
+
if (this.isCancelled(event)) {
|
|
2916
|
+
event.preventDefault();
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2864
2919
|
const iframes = [
|
|
2865
2920
|
...getElementsByTagName('iframe'),
|
|
2866
2921
|
...getElementsByTagName('webview'),
|
|
@@ -2934,13 +2989,6 @@
|
|
|
2934
2989
|
if (event.defaultPrevented) {
|
|
2935
2990
|
return;
|
|
2936
2991
|
}
|
|
2937
|
-
/**
|
|
2938
|
-
* TODO: alternative to stopPropagation
|
|
2939
|
-
*
|
|
2940
|
-
* I need to stop the event propagation here since otherwise it'll be intercepted by event handlers
|
|
2941
|
-
* on the tabs-container. I cannot use event.preventDefault() since I need the on DragStart event to occur
|
|
2942
|
-
*/
|
|
2943
|
-
event.stopPropagation();
|
|
2944
2992
|
this._onChanged.fire(event);
|
|
2945
2993
|
}));
|
|
2946
2994
|
this.droptarget = new Droptarget(this._element, {
|
|
@@ -2998,6 +3046,22 @@
|
|
|
2998
3046
|
this.accessorId = accessorId;
|
|
2999
3047
|
this.group = group;
|
|
3000
3048
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
3049
|
+
this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
|
|
3050
|
+
if (e.shiftKey) {
|
|
3051
|
+
/**
|
|
3052
|
+
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
3053
|
+
* but we also need to stop any group overlay drag events from occuring
|
|
3054
|
+
* Use a custom event marker that can be checked by the overlay drag events
|
|
3055
|
+
*/
|
|
3056
|
+
quasiPreventDefault(e);
|
|
3057
|
+
}
|
|
3058
|
+
}, true));
|
|
3059
|
+
}
|
|
3060
|
+
isCancelled(_event) {
|
|
3061
|
+
if (this.group.api.isFloating && !_event.shiftKey) {
|
|
3062
|
+
return true;
|
|
3063
|
+
}
|
|
3064
|
+
return false;
|
|
3001
3065
|
}
|
|
3002
3066
|
getData(dataTransfer) {
|
|
3003
3067
|
this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
|
|
@@ -3088,17 +3152,30 @@
|
|
|
3088
3152
|
hide() {
|
|
3089
3153
|
this._element.style.display = 'none';
|
|
3090
3154
|
}
|
|
3091
|
-
|
|
3092
|
-
if (this.
|
|
3155
|
+
setRightActionsElement(element) {
|
|
3156
|
+
if (this.rightActions === element) {
|
|
3093
3157
|
return;
|
|
3094
3158
|
}
|
|
3095
|
-
if (this.
|
|
3096
|
-
this.
|
|
3097
|
-
this.
|
|
3159
|
+
if (this.rightActions) {
|
|
3160
|
+
this.rightActions.remove();
|
|
3161
|
+
this.rightActions = undefined;
|
|
3098
3162
|
}
|
|
3099
3163
|
if (element) {
|
|
3100
|
-
this.
|
|
3101
|
-
this.
|
|
3164
|
+
this.rightActionsContainer.appendChild(element);
|
|
3165
|
+
this.rightActions = element;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
setLeftActionsElement(element) {
|
|
3169
|
+
if (this.leftActions === element) {
|
|
3170
|
+
return;
|
|
3171
|
+
}
|
|
3172
|
+
if (this.leftActions) {
|
|
3173
|
+
this.leftActions.remove();
|
|
3174
|
+
this.leftActions = undefined;
|
|
3175
|
+
}
|
|
3176
|
+
if (element) {
|
|
3177
|
+
this.leftActionsContainer.appendChild(element);
|
|
3178
|
+
this.leftActions = element;
|
|
3102
3179
|
}
|
|
3103
3180
|
}
|
|
3104
3181
|
get element() {
|
|
@@ -3133,19 +3210,35 @@
|
|
|
3133
3210
|
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
3134
3211
|
}
|
|
3135
3212
|
}));
|
|
3136
|
-
this.
|
|
3137
|
-
this.
|
|
3213
|
+
this.rightActionsContainer = document.createElement('div');
|
|
3214
|
+
this.rightActionsContainer.className = 'right-actions-container';
|
|
3215
|
+
this.leftActionsContainer = document.createElement('div');
|
|
3216
|
+
this.leftActionsContainer.className = 'left-actions-container';
|
|
3138
3217
|
this.tabContainer = document.createElement('div');
|
|
3139
3218
|
this.tabContainer.className = 'tabs-container';
|
|
3140
3219
|
this.voidContainer = new VoidContainer(this.accessor, this.group);
|
|
3141
3220
|
this._element.appendChild(this.tabContainer);
|
|
3221
|
+
this._element.appendChild(this.leftActionsContainer);
|
|
3142
3222
|
this._element.appendChild(this.voidContainer.element);
|
|
3143
|
-
this._element.appendChild(this.
|
|
3223
|
+
this._element.appendChild(this.rightActionsContainer);
|
|
3144
3224
|
this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
|
|
3145
3225
|
this._onDrop.fire({
|
|
3146
3226
|
event: event.nativeEvent,
|
|
3147
3227
|
index: this.tabs.length,
|
|
3148
3228
|
});
|
|
3229
|
+
}), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
|
|
3230
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3231
|
+
if (isFloatingGroupsEnabled &&
|
|
3232
|
+
event.shiftKey &&
|
|
3233
|
+
!this.group.api.isFloating) {
|
|
3234
|
+
event.preventDefault();
|
|
3235
|
+
const { top, left } = this.element.getBoundingClientRect();
|
|
3236
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3237
|
+
this.accessor.addFloatingGroup(this.group, {
|
|
3238
|
+
x: left - rootLeft + 20,
|
|
3239
|
+
y: top - rootTop + 20,
|
|
3240
|
+
}, { inDragMode: true });
|
|
3241
|
+
}
|
|
3149
3242
|
}), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
|
|
3150
3243
|
if (event.defaultPrevented) {
|
|
3151
3244
|
return;
|
|
@@ -3199,6 +3292,21 @@
|
|
|
3199
3292
|
tabToAdd.setContent(panel.view.tab);
|
|
3200
3293
|
const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
|
|
3201
3294
|
var _a;
|
|
3295
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3296
|
+
const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
|
|
3297
|
+
if (isFloatingGroupsEnabled &&
|
|
3298
|
+
!isFloatingWithOnePanel &&
|
|
3299
|
+
event.shiftKey) {
|
|
3300
|
+
event.preventDefault();
|
|
3301
|
+
const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
|
|
3302
|
+
const { top, left } = tabToAdd.element.getBoundingClientRect();
|
|
3303
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3304
|
+
this.accessor.addFloatingGroup(panel, {
|
|
3305
|
+
x: left - rootLeft,
|
|
3306
|
+
y: top - rootTop,
|
|
3307
|
+
}, { inDragMode: true });
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3202
3310
|
const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
3203
3311
|
this.group.model.isContentFocused;
|
|
3204
3312
|
const isLeftClick = event.button === 0;
|
|
@@ -3268,6 +3376,17 @@
|
|
|
3268
3376
|
}
|
|
3269
3377
|
return isAncestor(document.activeElement, this.contentContainer.element);
|
|
3270
3378
|
}
|
|
3379
|
+
get isFloating() {
|
|
3380
|
+
return this._isFloating;
|
|
3381
|
+
}
|
|
3382
|
+
set isFloating(value) {
|
|
3383
|
+
this._isFloating = value;
|
|
3384
|
+
this.dropTarget.setTargetZones(value ? ['center'] : ['top', 'bottom', 'left', 'right', 'center']);
|
|
3385
|
+
toggleClass(this.container, 'dv-groupview-floating', value);
|
|
3386
|
+
this.groupPanel.api._onDidFloatingStateChange.fire({
|
|
3387
|
+
isFloating: this.isFloating,
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3271
3390
|
constructor(container, accessor, id, options, groupPanel) {
|
|
3272
3391
|
super();
|
|
3273
3392
|
this.container = container;
|
|
@@ -3277,6 +3396,7 @@
|
|
|
3277
3396
|
this.groupPanel = groupPanel;
|
|
3278
3397
|
this._isGroupActive = false;
|
|
3279
3398
|
this._locked = false;
|
|
3399
|
+
this._isFloating = false;
|
|
3280
3400
|
this.mostRecentlyUsed = [];
|
|
3281
3401
|
this._onDidChange = new Emitter();
|
|
3282
3402
|
this.onDidChange = this._onDidChange.event;
|
|
@@ -3293,7 +3413,7 @@
|
|
|
3293
3413
|
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
3294
3414
|
this._onDidActivePanelChange = new Emitter();
|
|
3295
3415
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
3296
|
-
this.container
|
|
3416
|
+
toggleClass(this.container, 'groupview', true);
|
|
3297
3417
|
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
|
3298
3418
|
this.contentContainer = new ContentContainer();
|
|
3299
3419
|
this.dropTarget = new Droptarget(this.contentContainer.element, {
|
|
@@ -3303,6 +3423,9 @@
|
|
|
3303
3423
|
return false;
|
|
3304
3424
|
}
|
|
3305
3425
|
const data = getPanelData();
|
|
3426
|
+
if (!data && event.shiftKey && !this.isFloating) {
|
|
3427
|
+
return false;
|
|
3428
|
+
}
|
|
3306
3429
|
if (data && data.viewId === this.accessor.id) {
|
|
3307
3430
|
if (data.groupId === this.id) {
|
|
3308
3431
|
if (position === 'center') {
|
|
@@ -3347,14 +3470,25 @@
|
|
|
3347
3470
|
// correctly initialized
|
|
3348
3471
|
this.setActive(this.isActive, true, true);
|
|
3349
3472
|
this.updateContainer();
|
|
3350
|
-
if (this.accessor.options.
|
|
3351
|
-
this.
|
|
3352
|
-
|
|
3353
|
-
this.
|
|
3473
|
+
if (this.accessor.options.createRightHeaderActionsElement) {
|
|
3474
|
+
this._rightHeaderActions =
|
|
3475
|
+
this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
|
|
3476
|
+
this.addDisposables(this._rightHeaderActions);
|
|
3477
|
+
this._rightHeaderActions.init({
|
|
3478
|
+
containerApi: new DockviewApi(this.accessor),
|
|
3479
|
+
api: this.groupPanel.api,
|
|
3480
|
+
});
|
|
3481
|
+
this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
|
|
3482
|
+
}
|
|
3483
|
+
if (this.accessor.options.createLeftHeaderActionsElement) {
|
|
3484
|
+
this._leftHeaderActions =
|
|
3485
|
+
this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
|
|
3486
|
+
this.addDisposables(this._leftHeaderActions);
|
|
3487
|
+
this._leftHeaderActions.init({
|
|
3354
3488
|
containerApi: new DockviewApi(this.accessor),
|
|
3355
3489
|
api: this.groupPanel.api,
|
|
3356
3490
|
});
|
|
3357
|
-
this.tabsContainer.
|
|
3491
|
+
this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
|
|
3358
3492
|
}
|
|
3359
3493
|
}
|
|
3360
3494
|
indexOf(panel) {
|
|
@@ -3487,7 +3621,7 @@
|
|
|
3487
3621
|
return this._activePanel === panel;
|
|
3488
3622
|
}
|
|
3489
3623
|
updateActions(element) {
|
|
3490
|
-
this.tabsContainer.
|
|
3624
|
+
this.tabsContainer.setRightActionsElement(element);
|
|
3491
3625
|
}
|
|
3492
3626
|
setActive(isGroupActive, skipFocus = false, force = false) {
|
|
3493
3627
|
var _a, _b, _c, _d;
|
|
@@ -3659,9 +3793,10 @@
|
|
|
3659
3793
|
}
|
|
3660
3794
|
}
|
|
3661
3795
|
dispose() {
|
|
3662
|
-
var _a, _b;
|
|
3796
|
+
var _a, _b, _c;
|
|
3663
3797
|
super.dispose();
|
|
3664
|
-
(
|
|
3798
|
+
(_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
|
|
3799
|
+
(_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3665
3800
|
for (const panel of this.panels) {
|
|
3666
3801
|
panel.dispose();
|
|
3667
3802
|
}
|
|
@@ -4455,8 +4590,8 @@
|
|
|
4455
4590
|
get isActive() {
|
|
4456
4591
|
return this.api.isActive;
|
|
4457
4592
|
}
|
|
4458
|
-
constructor(id, component, options) {
|
|
4459
|
-
super(id, component, new GridviewPanelApiImpl(id));
|
|
4593
|
+
constructor(id, component, options, api) {
|
|
4594
|
+
super(id, component, api !== null && api !== void 0 ? api : new GridviewPanelApiImpl(id));
|
|
4460
4595
|
this._evaluatedMinimumWidth = 0;
|
|
4461
4596
|
this._evaluatedMaximumWidth = Number.MAX_SAFE_INTEGER;
|
|
4462
4597
|
this._evaluatedMinimumHeight = 0;
|
|
@@ -4554,6 +4689,32 @@
|
|
|
4554
4689
|
}
|
|
4555
4690
|
}
|
|
4556
4691
|
|
|
4692
|
+
class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|
4693
|
+
get isFloating() {
|
|
4694
|
+
if (!this._group) {
|
|
4695
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4696
|
+
}
|
|
4697
|
+
return this._group.model.isFloating;
|
|
4698
|
+
}
|
|
4699
|
+
constructor(id, accessor) {
|
|
4700
|
+
super(id);
|
|
4701
|
+
this.accessor = accessor;
|
|
4702
|
+
this._onDidFloatingStateChange = new Emitter();
|
|
4703
|
+
this.onDidFloatingStateChange = this._onDidFloatingStateChange.event;
|
|
4704
|
+
this.addDisposables(this._onDidFloatingStateChange);
|
|
4705
|
+
}
|
|
4706
|
+
moveTo(options) {
|
|
4707
|
+
var _a;
|
|
4708
|
+
if (!this._group) {
|
|
4709
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4710
|
+
}
|
|
4711
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, undefined, (_a = options.position) !== null && _a !== void 0 ? _a : 'center');
|
|
4712
|
+
}
|
|
4713
|
+
initialize(group) {
|
|
4714
|
+
this._group = group;
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
|
|
4557
4718
|
class DockviewGroupPanel extends GridviewPanel {
|
|
4558
4719
|
get panels() {
|
|
4559
4720
|
return this._model.panels;
|
|
@@ -4580,7 +4741,8 @@
|
|
|
4580
4741
|
super(id, 'groupview_default', {
|
|
4581
4742
|
minimumHeight: 100,
|
|
4582
4743
|
minimumWidth: 100,
|
|
4583
|
-
});
|
|
4744
|
+
}, new DockviewGroupPanelApiImpl(id, accessor));
|
|
4745
|
+
this.api.initialize(this); // cannot use 'this' after after 'super' call
|
|
4584
4746
|
this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
|
|
4585
4747
|
}
|
|
4586
4748
|
initialize() {
|
|
@@ -4598,7 +4760,6 @@
|
|
|
4598
4760
|
return this._model;
|
|
4599
4761
|
}
|
|
4600
4762
|
toJSON() {
|
|
4601
|
-
// TODO fix typing
|
|
4602
4763
|
return this.model.toJSON();
|
|
4603
4764
|
}
|
|
4604
4765
|
}
|
|
@@ -4652,9 +4813,10 @@
|
|
|
4652
4813
|
get group() {
|
|
4653
4814
|
return this._group;
|
|
4654
4815
|
}
|
|
4655
|
-
constructor(panel, group) {
|
|
4816
|
+
constructor(panel, group, accessor) {
|
|
4656
4817
|
super(panel.id);
|
|
4657
4818
|
this.panel = panel;
|
|
4819
|
+
this.accessor = accessor;
|
|
4658
4820
|
this._onDidTitleChange = new Emitter();
|
|
4659
4821
|
this.onDidTitleChange = this._onDidTitleChange.event;
|
|
4660
4822
|
this._onDidActiveGroupChange = new Emitter();
|
|
@@ -4666,6 +4828,10 @@
|
|
|
4666
4828
|
this._group = group;
|
|
4667
4829
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4668
4830
|
}
|
|
4831
|
+
moveTo(options) {
|
|
4832
|
+
var _a;
|
|
4833
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
|
|
4834
|
+
}
|
|
4669
4835
|
setTitle(title) {
|
|
4670
4836
|
this.panel.setTitle(title);
|
|
4671
4837
|
}
|
|
@@ -4690,7 +4856,7 @@
|
|
|
4690
4856
|
this.containerApi = containerApi;
|
|
4691
4857
|
this.view = view;
|
|
4692
4858
|
this._group = group;
|
|
4693
|
-
this.api = new DockviewPanelApiImpl(this, this._group);
|
|
4859
|
+
this.api = new DockviewPanelApiImpl(this, this._group, accessor);
|
|
4694
4860
|
this.addDisposables(this.api.onActiveChange(() => {
|
|
4695
4861
|
accessor.setActivePanel(this);
|
|
4696
4862
|
}), this.api.onDidSizeChange((event) => {
|
|
@@ -5031,6 +5197,296 @@
|
|
|
5031
5197
|
}
|
|
5032
5198
|
}
|
|
5033
5199
|
|
|
5200
|
+
const bringElementToFront = (() => {
|
|
5201
|
+
let previous = null;
|
|
5202
|
+
function pushToTop(element) {
|
|
5203
|
+
if (previous !== element && previous !== null) {
|
|
5204
|
+
toggleClass(previous, 'dv-bring-to-front', false);
|
|
5205
|
+
}
|
|
5206
|
+
toggleClass(element, 'dv-bring-to-front', true);
|
|
5207
|
+
previous = element;
|
|
5208
|
+
}
|
|
5209
|
+
return pushToTop;
|
|
5210
|
+
})();
|
|
5211
|
+
class Overlay extends CompositeDisposable {
|
|
5212
|
+
constructor(options) {
|
|
5213
|
+
super();
|
|
5214
|
+
this.options = options;
|
|
5215
|
+
this._element = document.createElement('div');
|
|
5216
|
+
this._onDidChange = new Emitter();
|
|
5217
|
+
this.onDidChange = this._onDidChange.event;
|
|
5218
|
+
this._onDidChangeEnd = new Emitter();
|
|
5219
|
+
this.onDidChangeEnd = this._onDidChangeEnd.event;
|
|
5220
|
+
this.addDisposables(this._onDidChange, this._onDidChangeEnd);
|
|
5221
|
+
this._element.className = 'dv-resize-container';
|
|
5222
|
+
this.setupResize('top');
|
|
5223
|
+
this.setupResize('bottom');
|
|
5224
|
+
this.setupResize('left');
|
|
5225
|
+
this.setupResize('right');
|
|
5226
|
+
this.setupResize('topleft');
|
|
5227
|
+
this.setupResize('topright');
|
|
5228
|
+
this.setupResize('bottomleft');
|
|
5229
|
+
this.setupResize('bottomright');
|
|
5230
|
+
this._element.appendChild(this.options.content);
|
|
5231
|
+
this.options.container.appendChild(this._element);
|
|
5232
|
+
// if input bad resize within acceptable boundaries
|
|
5233
|
+
this.setBounds({
|
|
5234
|
+
height: this.options.height,
|
|
5235
|
+
width: this.options.width,
|
|
5236
|
+
top: this.options.top,
|
|
5237
|
+
left: this.options.left,
|
|
5238
|
+
});
|
|
5239
|
+
}
|
|
5240
|
+
setBounds(bounds = {}) {
|
|
5241
|
+
if (typeof bounds.height === 'number') {
|
|
5242
|
+
this._element.style.height = `${bounds.height}px`;
|
|
5243
|
+
}
|
|
5244
|
+
if (typeof bounds.width === 'number') {
|
|
5245
|
+
this._element.style.width = `${bounds.width}px`;
|
|
5246
|
+
}
|
|
5247
|
+
if (typeof bounds.top === 'number') {
|
|
5248
|
+
this._element.style.top = `${bounds.top}px`;
|
|
5249
|
+
}
|
|
5250
|
+
if (typeof bounds.left === 'number') {
|
|
5251
|
+
this._element.style.left = `${bounds.left}px`;
|
|
5252
|
+
}
|
|
5253
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5254
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5255
|
+
// region: ensure bounds within allowable limits
|
|
5256
|
+
// a minimum width of minimumViewportWidth must be inside the viewport
|
|
5257
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5258
|
+
// a minimum height of minimumViewportHeight must be inside the viewport
|
|
5259
|
+
const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
|
|
5260
|
+
const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5261
|
+
const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5262
|
+
this._element.style.left = `${left}px`;
|
|
5263
|
+
this._element.style.top = `${top}px`;
|
|
5264
|
+
this._onDidChange.fire();
|
|
5265
|
+
}
|
|
5266
|
+
toJSON() {
|
|
5267
|
+
const container = this.options.container.getBoundingClientRect();
|
|
5268
|
+
const element = this._element.getBoundingClientRect();
|
|
5269
|
+
return {
|
|
5270
|
+
top: element.top - container.top,
|
|
5271
|
+
left: element.left - container.left,
|
|
5272
|
+
width: element.width,
|
|
5273
|
+
height: element.height,
|
|
5274
|
+
};
|
|
5275
|
+
}
|
|
5276
|
+
setupDrag(dragTarget, options = { inDragMode: false }) {
|
|
5277
|
+
const move = new MutableDisposable();
|
|
5278
|
+
const track = () => {
|
|
5279
|
+
let offset = null;
|
|
5280
|
+
const iframes = [
|
|
5281
|
+
...getElementsByTagName('iframe'),
|
|
5282
|
+
...getElementsByTagName('webview'),
|
|
5283
|
+
];
|
|
5284
|
+
for (const iframe of iframes) {
|
|
5285
|
+
iframe.style.pointerEvents = 'none';
|
|
5286
|
+
}
|
|
5287
|
+
move.value = new CompositeDisposable({
|
|
5288
|
+
dispose: () => {
|
|
5289
|
+
for (const iframe of iframes) {
|
|
5290
|
+
iframe.style.pointerEvents = 'auto';
|
|
5291
|
+
}
|
|
5292
|
+
},
|
|
5293
|
+
}, addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5294
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5295
|
+
const x = e.clientX - containerRect.left;
|
|
5296
|
+
const y = e.clientY - containerRect.top;
|
|
5297
|
+
toggleClass(this._element, 'dv-resize-container-dragging', true);
|
|
5298
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5299
|
+
if (offset === null) {
|
|
5300
|
+
offset = {
|
|
5301
|
+
x: e.clientX - overlayRect.left,
|
|
5302
|
+
y: e.clientY - overlayRect.top,
|
|
5303
|
+
};
|
|
5304
|
+
}
|
|
5305
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5306
|
+
const yOffset = Math.max(0, overlayRect.height -
|
|
5307
|
+
this.options.minimumInViewportHeight);
|
|
5308
|
+
const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5309
|
+
const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5310
|
+
this.setBounds({ top, left });
|
|
5311
|
+
}), addDisposableWindowListener(window, 'mouseup', () => {
|
|
5312
|
+
toggleClass(this._element, 'dv-resize-container-dragging', false);
|
|
5313
|
+
move.dispose();
|
|
5314
|
+
this._onDidChangeEnd.fire();
|
|
5315
|
+
}));
|
|
5316
|
+
};
|
|
5317
|
+
this.addDisposables(move, addDisposableListener(dragTarget, 'mousedown', (event) => {
|
|
5318
|
+
if (event.defaultPrevented) {
|
|
5319
|
+
event.preventDefault();
|
|
5320
|
+
return;
|
|
5321
|
+
}
|
|
5322
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5323
|
+
// without actually calling event.preventDefault()
|
|
5324
|
+
if (quasiDefaultPrevented(event)) {
|
|
5325
|
+
return;
|
|
5326
|
+
}
|
|
5327
|
+
track();
|
|
5328
|
+
}), addDisposableListener(this.options.content, 'mousedown', (event) => {
|
|
5329
|
+
if (event.defaultPrevented) {
|
|
5330
|
+
return;
|
|
5331
|
+
}
|
|
5332
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5333
|
+
// without actually calling event.preventDefault()
|
|
5334
|
+
if (quasiDefaultPrevented(event)) {
|
|
5335
|
+
return;
|
|
5336
|
+
}
|
|
5337
|
+
if (event.shiftKey) {
|
|
5338
|
+
track();
|
|
5339
|
+
}
|
|
5340
|
+
}), addDisposableListener(this.options.content, 'mousedown', () => {
|
|
5341
|
+
bringElementToFront(this._element);
|
|
5342
|
+
}, true));
|
|
5343
|
+
bringElementToFront(this._element);
|
|
5344
|
+
if (options.inDragMode) {
|
|
5345
|
+
track();
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
setupResize(direction) {
|
|
5349
|
+
const resizeHandleElement = document.createElement('div');
|
|
5350
|
+
resizeHandleElement.className = `dv-resize-handle-${direction}`;
|
|
5351
|
+
this._element.appendChild(resizeHandleElement);
|
|
5352
|
+
const move = new MutableDisposable();
|
|
5353
|
+
this.addDisposables(move, addDisposableListener(resizeHandleElement, 'mousedown', (e) => {
|
|
5354
|
+
e.preventDefault();
|
|
5355
|
+
let startPosition = null;
|
|
5356
|
+
const iframes = [
|
|
5357
|
+
...getElementsByTagName('iframe'),
|
|
5358
|
+
...getElementsByTagName('webview'),
|
|
5359
|
+
];
|
|
5360
|
+
for (const iframe of iframes) {
|
|
5361
|
+
iframe.style.pointerEvents = 'none';
|
|
5362
|
+
}
|
|
5363
|
+
move.value = new CompositeDisposable(addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5364
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5365
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5366
|
+
const y = e.clientY - containerRect.top;
|
|
5367
|
+
const x = e.clientX - containerRect.left;
|
|
5368
|
+
if (startPosition === null) {
|
|
5369
|
+
// record the initial dimensions since as all subsequence moves are relative to this
|
|
5370
|
+
startPosition = {
|
|
5371
|
+
originalY: y,
|
|
5372
|
+
originalHeight: overlayRect.height,
|
|
5373
|
+
originalX: x,
|
|
5374
|
+
originalWidth: overlayRect.width,
|
|
5375
|
+
};
|
|
5376
|
+
}
|
|
5377
|
+
let top = undefined;
|
|
5378
|
+
let height = undefined;
|
|
5379
|
+
let left = undefined;
|
|
5380
|
+
let width = undefined;
|
|
5381
|
+
const minimumInViewportHeight = this.options.minimumInViewportHeight;
|
|
5382
|
+
const minimumInViewportWidth = this.options.minimumInViewportWidth;
|
|
5383
|
+
function moveTop() {
|
|
5384
|
+
top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
|
|
5385
|
+
startPosition.originalHeight >
|
|
5386
|
+
containerRect.height
|
|
5387
|
+
? containerRect.height -
|
|
5388
|
+
minimumInViewportHeight
|
|
5389
|
+
: Math.max(0, startPosition.originalY +
|
|
5390
|
+
startPosition.originalHeight -
|
|
5391
|
+
Overlay.MINIMUM_HEIGHT));
|
|
5392
|
+
height =
|
|
5393
|
+
startPosition.originalY +
|
|
5394
|
+
startPosition.originalHeight -
|
|
5395
|
+
top;
|
|
5396
|
+
}
|
|
5397
|
+
function moveBottom() {
|
|
5398
|
+
top =
|
|
5399
|
+
startPosition.originalY -
|
|
5400
|
+
startPosition.originalHeight;
|
|
5401
|
+
height = clamp(y - top, top < 0
|
|
5402
|
+
? -top + minimumInViewportHeight
|
|
5403
|
+
: Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
|
|
5404
|
+
}
|
|
5405
|
+
function moveLeft() {
|
|
5406
|
+
left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
|
|
5407
|
+
startPosition.originalWidth >
|
|
5408
|
+
containerRect.width
|
|
5409
|
+
? containerRect.width -
|
|
5410
|
+
minimumInViewportWidth
|
|
5411
|
+
: Math.max(0, startPosition.originalX +
|
|
5412
|
+
startPosition.originalWidth -
|
|
5413
|
+
Overlay.MINIMUM_WIDTH));
|
|
5414
|
+
width =
|
|
5415
|
+
startPosition.originalX +
|
|
5416
|
+
startPosition.originalWidth -
|
|
5417
|
+
left;
|
|
5418
|
+
}
|
|
5419
|
+
function moveRight() {
|
|
5420
|
+
left =
|
|
5421
|
+
startPosition.originalX -
|
|
5422
|
+
startPosition.originalWidth;
|
|
5423
|
+
width = clamp(x - left, left < 0
|
|
5424
|
+
? -left + minimumInViewportWidth
|
|
5425
|
+
: Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
|
|
5426
|
+
}
|
|
5427
|
+
switch (direction) {
|
|
5428
|
+
case 'top':
|
|
5429
|
+
moveTop();
|
|
5430
|
+
break;
|
|
5431
|
+
case 'bottom':
|
|
5432
|
+
moveBottom();
|
|
5433
|
+
break;
|
|
5434
|
+
case 'left':
|
|
5435
|
+
moveLeft();
|
|
5436
|
+
break;
|
|
5437
|
+
case 'right':
|
|
5438
|
+
moveRight();
|
|
5439
|
+
break;
|
|
5440
|
+
case 'topleft':
|
|
5441
|
+
moveTop();
|
|
5442
|
+
moveLeft();
|
|
5443
|
+
break;
|
|
5444
|
+
case 'topright':
|
|
5445
|
+
moveTop();
|
|
5446
|
+
moveRight();
|
|
5447
|
+
break;
|
|
5448
|
+
case 'bottomleft':
|
|
5449
|
+
moveBottom();
|
|
5450
|
+
moveLeft();
|
|
5451
|
+
break;
|
|
5452
|
+
case 'bottomright':
|
|
5453
|
+
moveBottom();
|
|
5454
|
+
moveRight();
|
|
5455
|
+
break;
|
|
5456
|
+
}
|
|
5457
|
+
this.setBounds({ height, width, top, left });
|
|
5458
|
+
}), {
|
|
5459
|
+
dispose: () => {
|
|
5460
|
+
for (const iframe of iframes) {
|
|
5461
|
+
iframe.style.pointerEvents = 'auto';
|
|
5462
|
+
}
|
|
5463
|
+
},
|
|
5464
|
+
}, addDisposableWindowListener(window, 'mouseup', () => {
|
|
5465
|
+
move.dispose();
|
|
5466
|
+
this._onDidChangeEnd.fire();
|
|
5467
|
+
}));
|
|
5468
|
+
}));
|
|
5469
|
+
}
|
|
5470
|
+
dispose() {
|
|
5471
|
+
this._element.remove();
|
|
5472
|
+
super.dispose();
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
Overlay.MINIMUM_HEIGHT = 20;
|
|
5476
|
+
Overlay.MINIMUM_WIDTH = 20;
|
|
5477
|
+
|
|
5478
|
+
class DockviewFloatingGroupPanel extends CompositeDisposable {
|
|
5479
|
+
constructor(group, overlay) {
|
|
5480
|
+
super();
|
|
5481
|
+
this.group = group;
|
|
5482
|
+
this.overlay = overlay;
|
|
5483
|
+
this.addDisposables(overlay);
|
|
5484
|
+
}
|
|
5485
|
+
position(bounds) {
|
|
5486
|
+
this.overlay.setBounds(bounds);
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
|
|
5034
5490
|
class DockviewComponent extends BaseGrid {
|
|
5035
5491
|
get orientation() {
|
|
5036
5492
|
return this.gridview.orientation;
|
|
@@ -5071,7 +5527,8 @@
|
|
|
5071
5527
|
this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
|
|
5072
5528
|
this._onDidActivePanelChange = new Emitter();
|
|
5073
5529
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
5074
|
-
this.
|
|
5530
|
+
this.floatingGroups = [];
|
|
5531
|
+
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
5075
5532
|
this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
|
|
5076
5533
|
this.updateWatermark();
|
|
5077
5534
|
}), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
|
|
@@ -5101,6 +5558,11 @@
|
|
|
5101
5558
|
if (data.viewId !== this.id) {
|
|
5102
5559
|
return false;
|
|
5103
5560
|
}
|
|
5561
|
+
if (position === 'center') {
|
|
5562
|
+
// center drop target is only allowed if there are no panels in the grid
|
|
5563
|
+
// floating panels are allowed
|
|
5564
|
+
return this.gridview.length === 0;
|
|
5565
|
+
}
|
|
5104
5566
|
return true;
|
|
5105
5567
|
}
|
|
5106
5568
|
if (this.options.showDndOverlay) {
|
|
@@ -5113,7 +5575,7 @@
|
|
|
5113
5575
|
}
|
|
5114
5576
|
return false;
|
|
5115
5577
|
},
|
|
5116
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
|
|
5578
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5117
5579
|
overlayModel: {
|
|
5118
5580
|
activationSize: { type: 'pixels', value: 10 },
|
|
5119
5581
|
size: { type: 'pixels', value: 20 },
|
|
@@ -5131,6 +5593,75 @@
|
|
|
5131
5593
|
this._api = new DockviewApi(this);
|
|
5132
5594
|
this.updateWatermark();
|
|
5133
5595
|
}
|
|
5596
|
+
addFloatingGroup(item, coord, options) {
|
|
5597
|
+
var _a, _b;
|
|
5598
|
+
let group;
|
|
5599
|
+
if (item instanceof DockviewPanel) {
|
|
5600
|
+
group = this.createGroup();
|
|
5601
|
+
this.removePanel(item, {
|
|
5602
|
+
removeEmptyGroup: true,
|
|
5603
|
+
skipDispose: true,
|
|
5604
|
+
});
|
|
5605
|
+
group.model.openPanel(item);
|
|
5606
|
+
}
|
|
5607
|
+
else {
|
|
5608
|
+
group = item;
|
|
5609
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
5610
|
+
options.skipRemoveGroup;
|
|
5611
|
+
if (!skip) {
|
|
5612
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
group.model.isFloating = true;
|
|
5616
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
5617
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
5618
|
+
const overlay = new Overlay({
|
|
5619
|
+
container: this.gridview.element,
|
|
5620
|
+
content: group.element,
|
|
5621
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
5622
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
5623
|
+
left: overlayLeft,
|
|
5624
|
+
top: overlayTop,
|
|
5625
|
+
minimumInViewportWidth: 100,
|
|
5626
|
+
minimumInViewportHeight: 100,
|
|
5627
|
+
});
|
|
5628
|
+
const el = group.element.querySelector('.void-container');
|
|
5629
|
+
if (!el) {
|
|
5630
|
+
throw new Error('failed to find drag handle');
|
|
5631
|
+
}
|
|
5632
|
+
overlay.setupDrag(el, {
|
|
5633
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
5634
|
+
? options.inDragMode
|
|
5635
|
+
: false,
|
|
5636
|
+
});
|
|
5637
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
5638
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
5639
|
+
const { width, height } = entry.contentRect;
|
|
5640
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
5641
|
+
});
|
|
5642
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
5643
|
+
// this is either a resize or a move
|
|
5644
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
5645
|
+
// don't care about resize since the above watcher handles that
|
|
5646
|
+
group.layout(group.height, group.width);
|
|
5647
|
+
}), overlay.onDidChangeEnd(() => {
|
|
5648
|
+
this._bufferOnDidLayoutChange.fire();
|
|
5649
|
+
}), group.onDidChange((event) => {
|
|
5650
|
+
overlay.setBounds({
|
|
5651
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
5652
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
5653
|
+
});
|
|
5654
|
+
}), {
|
|
5655
|
+
dispose: () => {
|
|
5656
|
+
disposable.dispose();
|
|
5657
|
+
group.model.isFloating = false;
|
|
5658
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
5659
|
+
this.updateWatermark();
|
|
5660
|
+
},
|
|
5661
|
+
});
|
|
5662
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
5663
|
+
this.updateWatermark();
|
|
5664
|
+
}
|
|
5134
5665
|
orthogonalize(position) {
|
|
5135
5666
|
switch (position) {
|
|
5136
5667
|
case 'top':
|
|
@@ -5153,6 +5684,7 @@
|
|
|
5153
5684
|
switch (position) {
|
|
5154
5685
|
case 'top':
|
|
5155
5686
|
case 'left':
|
|
5687
|
+
case 'center':
|
|
5156
5688
|
return this.createGroupAtLocation([0]); // insert into first position
|
|
5157
5689
|
case 'bottom':
|
|
5158
5690
|
case 'right':
|
|
@@ -5170,6 +5702,15 @@
|
|
|
5170
5702
|
}
|
|
5171
5703
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
5172
5704
|
}
|
|
5705
|
+
layout(width, height, forceResize) {
|
|
5706
|
+
super.layout(width, height, forceResize);
|
|
5707
|
+
if (this.floatingGroups) {
|
|
5708
|
+
for (const floating of this.floatingGroups) {
|
|
5709
|
+
// ensure floting groups stay within visible boundaries
|
|
5710
|
+
floating.overlay.setBounds();
|
|
5711
|
+
}
|
|
5712
|
+
}
|
|
5713
|
+
}
|
|
5173
5714
|
focus() {
|
|
5174
5715
|
var _a;
|
|
5175
5716
|
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -5232,51 +5773,81 @@
|
|
|
5232
5773
|
collection[panel.id] = panel.toJSON();
|
|
5233
5774
|
return collection;
|
|
5234
5775
|
}, {});
|
|
5235
|
-
|
|
5776
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
5777
|
+
return {
|
|
5778
|
+
data: floatingGroup.group.toJSON(),
|
|
5779
|
+
position: floatingGroup.overlay.toJSON(),
|
|
5780
|
+
};
|
|
5781
|
+
});
|
|
5782
|
+
const result = {
|
|
5236
5783
|
grid: data,
|
|
5237
5784
|
panels,
|
|
5238
5785
|
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
5239
5786
|
};
|
|
5787
|
+
if (floats.length > 0) {
|
|
5788
|
+
result.floatingGroups = floats;
|
|
5789
|
+
}
|
|
5790
|
+
return result;
|
|
5240
5791
|
}
|
|
5241
5792
|
fromJSON(data) {
|
|
5793
|
+
var _a;
|
|
5242
5794
|
this.clear();
|
|
5243
5795
|
const { grid, panels, activeGroup } = data;
|
|
5244
5796
|
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
5245
5797
|
throw new Error('root must be of type branch');
|
|
5246
5798
|
}
|
|
5799
|
+
// take note of the existing dimensions
|
|
5800
|
+
const width = this.width;
|
|
5801
|
+
const height = this.height;
|
|
5802
|
+
const createGroupFromSerializedState = (data) => {
|
|
5803
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
5804
|
+
const group = this.createGroup({
|
|
5805
|
+
id,
|
|
5806
|
+
locked: !!locked,
|
|
5807
|
+
hideHeader: !!hideHeader,
|
|
5808
|
+
});
|
|
5809
|
+
this._onDidAddGroup.fire(group);
|
|
5810
|
+
for (const child of views) {
|
|
5811
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5812
|
+
const isActive = typeof activeView === 'string' && activeView === panel.id;
|
|
5813
|
+
group.model.openPanel(panel, {
|
|
5814
|
+
skipSetPanelActive: !isActive,
|
|
5815
|
+
skipSetGroupActive: true,
|
|
5816
|
+
});
|
|
5817
|
+
}
|
|
5818
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
5819
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5820
|
+
skipSetGroupActive: true,
|
|
5821
|
+
});
|
|
5822
|
+
}
|
|
5823
|
+
return group;
|
|
5824
|
+
};
|
|
5247
5825
|
this.gridview.deserialize(grid, {
|
|
5248
5826
|
fromJSON: (node) => {
|
|
5249
|
-
|
|
5250
|
-
const group = this.createGroup({
|
|
5251
|
-
id,
|
|
5252
|
-
locked: !!locked,
|
|
5253
|
-
hideHeader: !!hideHeader,
|
|
5254
|
-
});
|
|
5255
|
-
this._onDidAddGroup.fire(group);
|
|
5256
|
-
for (const child of views) {
|
|
5257
|
-
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5258
|
-
const isActive = typeof activeView === 'string' &&
|
|
5259
|
-
activeView === panel.id;
|
|
5260
|
-
group.model.openPanel(panel, {
|
|
5261
|
-
skipSetPanelActive: !isActive,
|
|
5262
|
-
skipSetGroupActive: true,
|
|
5263
|
-
});
|
|
5264
|
-
}
|
|
5265
|
-
if (!group.activePanel && group.panels.length > 0) {
|
|
5266
|
-
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5267
|
-
skipSetGroupActive: true,
|
|
5268
|
-
});
|
|
5269
|
-
}
|
|
5270
|
-
return group;
|
|
5827
|
+
return createGroupFromSerializedState(node.data);
|
|
5271
5828
|
},
|
|
5272
5829
|
});
|
|
5830
|
+
this.layout(width, height, true);
|
|
5831
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
5832
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
5833
|
+
const { data, position } = serializedFloatingGroup;
|
|
5834
|
+
const group = createGroupFromSerializedState(data);
|
|
5835
|
+
this.addFloatingGroup(group, {
|
|
5836
|
+
x: position.left,
|
|
5837
|
+
y: position.top,
|
|
5838
|
+
height: position.height,
|
|
5839
|
+
width: position.width,
|
|
5840
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
5841
|
+
}
|
|
5842
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
5843
|
+
floatingGroup.overlay.setBounds();
|
|
5844
|
+
}
|
|
5273
5845
|
if (typeof activeGroup === 'string') {
|
|
5274
5846
|
const panel = this.getPanel(activeGroup);
|
|
5275
5847
|
if (panel) {
|
|
5276
5848
|
this.doSetGroupActive(panel);
|
|
5277
5849
|
}
|
|
5278
5850
|
}
|
|
5279
|
-
this.gridview.layout(this.width, this.height);
|
|
5280
5851
|
this._onDidLayoutFromJSON.fire();
|
|
5281
5852
|
}
|
|
5282
5853
|
clear() {
|
|
@@ -5285,7 +5856,7 @@
|
|
|
5285
5856
|
const hasActivePanel = !!this.activePanel;
|
|
5286
5857
|
for (const group of groups) {
|
|
5287
5858
|
// remove the group will automatically remove the panels
|
|
5288
|
-
this.removeGroup(group, true);
|
|
5859
|
+
this.removeGroup(group, { skipActive: true });
|
|
5289
5860
|
}
|
|
5290
5861
|
if (hasActiveGroup) {
|
|
5291
5862
|
this.doSetGroupActive(undefined);
|
|
@@ -5307,6 +5878,9 @@
|
|
|
5307
5878
|
throw new Error(`panel with id ${options.id} already exists`);
|
|
5308
5879
|
}
|
|
5309
5880
|
let referenceGroup;
|
|
5881
|
+
if (options.position && options.floating) {
|
|
5882
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
5883
|
+
}
|
|
5310
5884
|
if (options.position) {
|
|
5311
5885
|
if (isPanelOptionsWithPanel(options.position)) {
|
|
5312
5886
|
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
@@ -5339,7 +5913,20 @@
|
|
|
5339
5913
|
let panel;
|
|
5340
5914
|
if (referenceGroup) {
|
|
5341
5915
|
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
5342
|
-
if (
|
|
5916
|
+
if (options.floating) {
|
|
5917
|
+
const group = this.createGroup();
|
|
5918
|
+
panel = this.createPanel(options, group);
|
|
5919
|
+
group.model.openPanel(panel);
|
|
5920
|
+
const o = typeof options.floating === 'object' &&
|
|
5921
|
+
options.floating !== null
|
|
5922
|
+
? options.floating
|
|
5923
|
+
: {};
|
|
5924
|
+
this.addFloatingGroup(group, o, {
|
|
5925
|
+
inDragMode: false,
|
|
5926
|
+
skipRemoveGroup: true,
|
|
5927
|
+
});
|
|
5928
|
+
}
|
|
5929
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
5343
5930
|
panel = this.createPanel(options, referenceGroup);
|
|
5344
5931
|
referenceGroup.model.openPanel(panel);
|
|
5345
5932
|
}
|
|
@@ -5351,6 +5938,19 @@
|
|
|
5351
5938
|
group.model.openPanel(panel);
|
|
5352
5939
|
}
|
|
5353
5940
|
}
|
|
5941
|
+
else if (options.floating) {
|
|
5942
|
+
const group = this.createGroup();
|
|
5943
|
+
panel = this.createPanel(options, group);
|
|
5944
|
+
group.model.openPanel(panel);
|
|
5945
|
+
const o = typeof options.floating === 'object' &&
|
|
5946
|
+
options.floating !== null
|
|
5947
|
+
? options.floating
|
|
5948
|
+
: {};
|
|
5949
|
+
this.addFloatingGroup(group, o, {
|
|
5950
|
+
inDragMode: false,
|
|
5951
|
+
skipRemoveGroup: true,
|
|
5952
|
+
});
|
|
5953
|
+
}
|
|
5354
5954
|
else {
|
|
5355
5955
|
const group = this.createGroupAtLocation();
|
|
5356
5956
|
panel = this.createPanel(options, group);
|
|
@@ -5367,7 +5967,9 @@
|
|
|
5367
5967
|
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
5368
5968
|
}
|
|
5369
5969
|
group.model.removePanel(panel);
|
|
5370
|
-
|
|
5970
|
+
if (!options.skipDispose) {
|
|
5971
|
+
panel.dispose();
|
|
5972
|
+
}
|
|
5371
5973
|
if (group.size === 0 && options.removeEmptyGroup) {
|
|
5372
5974
|
this.removeGroup(group);
|
|
5373
5975
|
}
|
|
@@ -5382,7 +5984,7 @@
|
|
|
5382
5984
|
}
|
|
5383
5985
|
updateWatermark() {
|
|
5384
5986
|
var _a, _b;
|
|
5385
|
-
if (this.groups.length === 0) {
|
|
5987
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
5386
5988
|
if (!this.watermark) {
|
|
5387
5989
|
this.watermark = this.createWatermarkComponent();
|
|
5388
5990
|
this.watermark.init({
|
|
@@ -5391,7 +5993,7 @@
|
|
|
5391
5993
|
const watermarkContainer = document.createElement('div');
|
|
5392
5994
|
watermarkContainer.className = 'dv-watermark-container';
|
|
5393
5995
|
watermarkContainer.appendChild(this.watermark.element);
|
|
5394
|
-
this.element.appendChild(watermarkContainer);
|
|
5996
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
5395
5997
|
}
|
|
5396
5998
|
}
|
|
5397
5999
|
else if (this.watermark) {
|
|
@@ -5441,15 +6043,28 @@
|
|
|
5441
6043
|
return group;
|
|
5442
6044
|
}
|
|
5443
6045
|
}
|
|
5444
|
-
removeGroup(group,
|
|
6046
|
+
removeGroup(group, options) {
|
|
6047
|
+
var _a;
|
|
5445
6048
|
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
5446
6049
|
for (const panel of panels) {
|
|
5447
6050
|
this.removePanel(panel, {
|
|
5448
6051
|
removeEmptyGroup: false,
|
|
5449
|
-
skipDispose: false,
|
|
6052
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
5450
6053
|
});
|
|
5451
6054
|
}
|
|
5452
|
-
|
|
6055
|
+
this.doRemoveGroup(group, options);
|
|
6056
|
+
}
|
|
6057
|
+
doRemoveGroup(group, options) {
|
|
6058
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
6059
|
+
if (floatingGroup) {
|
|
6060
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
6061
|
+
floatingGroup.group.dispose();
|
|
6062
|
+
this._groups.delete(group.id);
|
|
6063
|
+
}
|
|
6064
|
+
floatingGroup.dispose();
|
|
6065
|
+
return floatingGroup.group;
|
|
6066
|
+
}
|
|
6067
|
+
return super.doRemoveGroup(group, options);
|
|
5453
6068
|
}
|
|
5454
6069
|
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5455
6070
|
var _a;
|
|
@@ -5480,25 +6095,26 @@
|
|
|
5480
6095
|
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5481
6096
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5482
6097
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5483
|
-
const
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
5494
|
-
skipActive: true,
|
|
5495
|
-
skipDispose: true,
|
|
5496
|
-
});
|
|
5497
|
-
// after deleting the group we need to re-evaulate the ref location
|
|
5498
|
-
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5499
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5500
|
-
this.doAddGroup(targetGroup, location);
|
|
6098
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6099
|
+
if (!isFloating) {
|
|
6100
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
6101
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
6102
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
6103
|
+
// special case when 'swapping' two views within same grid location
|
|
6104
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
6105
|
+
// which is equivalent to swapping two views in this case
|
|
6106
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
6107
|
+
}
|
|
5501
6108
|
}
|
|
6109
|
+
// source group will become empty so delete the group
|
|
6110
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
6111
|
+
skipActive: true,
|
|
6112
|
+
skipDispose: true,
|
|
6113
|
+
});
|
|
6114
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
6115
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
6116
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
6117
|
+
this.doAddGroup(targetGroup, location);
|
|
5502
6118
|
}
|
|
5503
6119
|
else {
|
|
5504
6120
|
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
@@ -5527,7 +6143,13 @@
|
|
|
5527
6143
|
}
|
|
5528
6144
|
}
|
|
5529
6145
|
else {
|
|
5530
|
-
this.
|
|
6146
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6147
|
+
if (floatingGroup) {
|
|
6148
|
+
floatingGroup.dispose();
|
|
6149
|
+
}
|
|
6150
|
+
else {
|
|
6151
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
6152
|
+
}
|
|
5531
6153
|
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
5532
6154
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
5533
6155
|
this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
|
|
@@ -5682,6 +6304,9 @@
|
|
|
5682
6304
|
this.clear();
|
|
5683
6305
|
const { grid, activePanel } = serializedGridview;
|
|
5684
6306
|
const queue = [];
|
|
6307
|
+
// take note of the existing dimensions
|
|
6308
|
+
const width = this.width;
|
|
6309
|
+
const height = this.height;
|
|
5685
6310
|
this.gridview.deserialize(grid, {
|
|
5686
6311
|
fromJSON: (node) => {
|
|
5687
6312
|
const { data } = node;
|
|
@@ -5707,7 +6332,7 @@
|
|
|
5707
6332
|
return view;
|
|
5708
6333
|
},
|
|
5709
6334
|
});
|
|
5710
|
-
this.layout(
|
|
6335
|
+
this.layout(width, height, true);
|
|
5711
6336
|
queue.forEach((f) => f());
|
|
5712
6337
|
if (typeof activePanel === 'string') {
|
|
5713
6338
|
const panel = this.getPanel(activePanel);
|
|
@@ -6021,6 +6646,9 @@
|
|
|
6021
6646
|
this.clear();
|
|
6022
6647
|
const { views, orientation, size, activeView } = serializedSplitview;
|
|
6023
6648
|
const queue = [];
|
|
6649
|
+
// take note of the existing dimensions
|
|
6650
|
+
const width = this.width;
|
|
6651
|
+
const height = this.height;
|
|
6024
6652
|
this.splitview = new Splitview(this.element, {
|
|
6025
6653
|
orientation,
|
|
6026
6654
|
proportionalLayout: this.options.proportionalLayout,
|
|
@@ -6057,7 +6685,7 @@
|
|
|
6057
6685
|
}),
|
|
6058
6686
|
},
|
|
6059
6687
|
});
|
|
6060
|
-
this.layout(
|
|
6688
|
+
this.layout(width, height);
|
|
6061
6689
|
queue.forEach((f) => f());
|
|
6062
6690
|
if (typeof activeView === 'string') {
|
|
6063
6691
|
const panel = this.getPanel(activeView);
|
|
@@ -6324,6 +6952,9 @@
|
|
|
6324
6952
|
this.clear();
|
|
6325
6953
|
const { views, size } = serializedPaneview;
|
|
6326
6954
|
const queue = [];
|
|
6955
|
+
// take note of the existing dimensions
|
|
6956
|
+
const width = this.width;
|
|
6957
|
+
const height = this.height;
|
|
6327
6958
|
this.paneview = new Paneview(this.element, {
|
|
6328
6959
|
orientation: exports.Orientation.VERTICAL,
|
|
6329
6960
|
descriptor: {
|
|
@@ -6379,7 +7010,7 @@
|
|
|
6379
7010
|
}),
|
|
6380
7011
|
},
|
|
6381
7012
|
});
|
|
6382
|
-
this.layout(
|
|
7013
|
+
this.layout(width, height);
|
|
6383
7014
|
queue.forEach((f) => f());
|
|
6384
7015
|
this._onDidLayoutfromJSON.fire();
|
|
6385
7016
|
}
|
|
@@ -6565,6 +7196,6 @@
|
|
|
6565
7196
|
exports.orthogonal = orthogonal;
|
|
6566
7197
|
exports.positionToDirection = positionToDirection;
|
|
6567
7198
|
exports.toTarget = toTarget;
|
|
6568
|
-
exports.watchElementResize = watchElementResize;
|
|
6569
7199
|
|
|
6570
7200
|
}));
|
|
7201
|
+
//# sourceMappingURL=dockview-core.noStyle.js.map
|