dockview 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/dockview/dockview.d.ts +4 -2
- package/dist/cjs/dockview/dockview.d.ts.map +1 -1
- package/dist/cjs/dockview/dockview.js +23 -5
- package/dist/cjs/dockview/dockview.js.map +1 -1
- package/dist/cjs/dockview/{groupControlsRenderer.d.ts → headerActionsRenderer.d.ts} +6 -5
- package/dist/cjs/dockview/headerActionsRenderer.d.ts.map +1 -0
- package/dist/cjs/dockview/{groupControlsRenderer.js → headerActionsRenderer.js} +17 -16
- package/dist/cjs/dockview/{groupControlsRenderer.js.map → headerActionsRenderer.js.map} +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/svg.d.ts +3 -3
- package/dist/cjs/svg.d.ts.map +1 -1
- package/dist/dockview.amd.js +795 -138
- package/dist/dockview.amd.js.map +1 -0
- package/dist/dockview.amd.min.js +3 -2
- package/dist/dockview.amd.min.js.map +1 -0
- package/dist/dockview.amd.min.noStyle.js +3 -2
- package/dist/dockview.amd.min.noStyle.js.map +1 -0
- package/dist/dockview.amd.noStyle.js +795 -138
- package/dist/dockview.amd.noStyle.js.map +1 -0
- package/dist/dockview.cjs.js +795 -138
- package/dist/dockview.cjs.js.map +1 -0
- package/dist/dockview.esm.js +796 -138
- package/dist/dockview.esm.js.map +1 -0
- package/dist/dockview.esm.min.js +3 -2
- package/dist/dockview.esm.min.js.map +1 -0
- package/dist/dockview.js +795 -138
- package/dist/dockview.js.map +1 -0
- package/dist/dockview.min.js +3 -2
- package/dist/dockview.min.js.map +1 -0
- package/dist/dockview.min.noStyle.js +3 -2
- package/dist/dockview.min.noStyle.js.map +1 -0
- package/dist/dockview.noStyle.js +795 -138
- package/dist/dockview.noStyle.js.map +1 -0
- package/dist/esm/dockview/dockview.d.ts +4 -2
- package/dist/esm/dockview/dockview.d.ts.map +1 -1
- package/dist/esm/dockview/dockview.js +23 -5
- package/dist/esm/dockview/dockview.js.map +1 -1
- package/dist/esm/dockview/{groupControlsRenderer.d.ts → headerActionsRenderer.d.ts} +6 -5
- package/dist/esm/dockview/headerActionsRenderer.d.ts.map +1 -0
- package/dist/esm/dockview/{groupControlsRenderer.js → headerActionsRenderer.js} +3 -2
- package/dist/esm/dockview/{groupControlsRenderer.js.map → headerActionsRenderer.js.map} +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/svg.d.ts +3 -3
- package/dist/esm/svg.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/dockview/groupControlsRenderer.d.ts.map +0 -1
- package/dist/esm/dockview/groupControlsRenderer.d.ts.map +0 -1
package/dist/dockview.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.
|
|
3
|
+
* @version 1.8.0
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -326,6 +326,31 @@ class MutableDisposable {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
330
|
+
const Component = typeof componentName === 'string'
|
|
331
|
+
? components[componentName]
|
|
332
|
+
: undefined;
|
|
333
|
+
const FrameworkComponent = typeof componentName === 'string'
|
|
334
|
+
? frameworkComponents[componentName]
|
|
335
|
+
: undefined;
|
|
336
|
+
if (Component && FrameworkComponent) {
|
|
337
|
+
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
338
|
+
}
|
|
339
|
+
if (FrameworkComponent) {
|
|
340
|
+
if (!createFrameworkComponent) {
|
|
341
|
+
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
342
|
+
}
|
|
343
|
+
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
344
|
+
}
|
|
345
|
+
if (!Component) {
|
|
346
|
+
if (fallback) {
|
|
347
|
+
return fallback();
|
|
348
|
+
}
|
|
349
|
+
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
350
|
+
}
|
|
351
|
+
return new Component(id, componentName);
|
|
352
|
+
}
|
|
353
|
+
|
|
329
354
|
function watchElementResize(element, cb) {
|
|
330
355
|
const observer = new ResizeObserver((entires) => {
|
|
331
356
|
/**
|
|
@@ -439,31 +464,16 @@ class FocusTracker extends CompositeDisposable {
|
|
|
439
464
|
refreshState() {
|
|
440
465
|
this._refreshStateHandler();
|
|
441
466
|
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
453
|
-
}
|
|
454
|
-
if (FrameworkComponent) {
|
|
455
|
-
if (!createFrameworkComponent) {
|
|
456
|
-
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
457
|
-
}
|
|
458
|
-
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
459
|
-
}
|
|
460
|
-
if (!Component) {
|
|
461
|
-
if (fallback) {
|
|
462
|
-
return fallback();
|
|
463
|
-
}
|
|
464
|
-
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
465
|
-
}
|
|
466
|
-
return new Component(id, componentName);
|
|
467
|
+
}
|
|
468
|
+
// quasi: apparently, but not really; seemingly
|
|
469
|
+
const QUASI_PREVENT_DEFAULT_KEY = 'dv-quasiPreventDefault';
|
|
470
|
+
// mark an event directly for other listeners to check
|
|
471
|
+
function quasiPreventDefault(event) {
|
|
472
|
+
event[QUASI_PREVENT_DEFAULT_KEY] = true;
|
|
473
|
+
}
|
|
474
|
+
// check if this event has been marked
|
|
475
|
+
function quasiDefaultPrevented(event) {
|
|
476
|
+
return event[QUASI_PREVENT_DEFAULT_KEY];
|
|
467
477
|
}
|
|
468
478
|
|
|
469
479
|
function tail(arr) {
|
|
@@ -514,6 +524,14 @@ function firstIndex(array, fn) {
|
|
|
514
524
|
}
|
|
515
525
|
}
|
|
516
526
|
return -1;
|
|
527
|
+
}
|
|
528
|
+
function remove(array, value) {
|
|
529
|
+
const index = array.findIndex((t) => t === value);
|
|
530
|
+
if (index > -1) {
|
|
531
|
+
array.splice(index, 1);
|
|
532
|
+
return true;
|
|
533
|
+
}
|
|
534
|
+
return false;
|
|
517
535
|
}
|
|
518
536
|
|
|
519
537
|
const clamp = (value, min, max) => {
|
|
@@ -1656,7 +1674,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1656
1674
|
: true,
|
|
1657
1675
|
};
|
|
1658
1676
|
}),
|
|
1659
|
-
size: this.
|
|
1677
|
+
size: this.orthogonalSize,
|
|
1660
1678
|
};
|
|
1661
1679
|
this.children = childDescriptors.map((c) => c.node);
|
|
1662
1680
|
this.splitview = new Splitview(this.element, {
|
|
@@ -1719,7 +1737,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1719
1737
|
layout(size, orthogonalSize) {
|
|
1720
1738
|
this._size = orthogonalSize;
|
|
1721
1739
|
this._orthogonalSize = size;
|
|
1722
|
-
this.splitview.layout(
|
|
1740
|
+
this.splitview.layout(orthogonalSize, size);
|
|
1723
1741
|
}
|
|
1724
1742
|
addChild(node, size, index, skipLayout) {
|
|
1725
1743
|
if (index < 0 || index > this.children.length) {
|
|
@@ -1944,9 +1962,9 @@ class Gridview {
|
|
|
1944
1962
|
this._deserialize(json.root, orientation, deserializer, height);
|
|
1945
1963
|
}
|
|
1946
1964
|
_deserialize(root, orientation, deserializer, orthogonalSize) {
|
|
1947
|
-
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize
|
|
1965
|
+
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
|
|
1948
1966
|
}
|
|
1949
|
-
_deserializeNode(node, orientation, deserializer, orthogonalSize
|
|
1967
|
+
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
1950
1968
|
let result;
|
|
1951
1969
|
if (node.type === 'branch') {
|
|
1952
1970
|
const serializedChildren = node.data;
|
|
@@ -1956,9 +1974,9 @@ class Gridview {
|
|
|
1956
1974
|
visible: serializedChild.visible,
|
|
1957
1975
|
};
|
|
1958
1976
|
});
|
|
1959
|
-
//
|
|
1960
|
-
//
|
|
1961
|
-
|
|
1977
|
+
result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
|
|
1978
|
+
orthogonalSize, // <- size - flips at each depth
|
|
1979
|
+
children);
|
|
1962
1980
|
}
|
|
1963
1981
|
else {
|
|
1964
1982
|
result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
|
|
@@ -1991,7 +2009,8 @@ class Gridview {
|
|
|
1991
2009
|
const oldRoot = this.root;
|
|
1992
2010
|
oldRoot.element.remove();
|
|
1993
2011
|
this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
|
|
1994
|
-
if (oldRoot.children.length ===
|
|
2012
|
+
if (oldRoot.children.length === 0) ;
|
|
2013
|
+
else if (oldRoot.children.length === 1) {
|
|
1995
2014
|
// can remove one level of redundant branching if there is only a single child
|
|
1996
2015
|
const childReference = oldRoot.children[0];
|
|
1997
2016
|
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
@@ -2507,6 +2526,9 @@ class DockviewApi {
|
|
|
2507
2526
|
addPanel(options) {
|
|
2508
2527
|
return this.component.addPanel(options);
|
|
2509
2528
|
}
|
|
2529
|
+
removePanel(panel) {
|
|
2530
|
+
this.component.removePanel(panel);
|
|
2531
|
+
}
|
|
2510
2532
|
addGroup(options) {
|
|
2511
2533
|
return this.component.addGroup(options);
|
|
2512
2534
|
}
|
|
@@ -2525,6 +2547,9 @@ class DockviewApi {
|
|
|
2525
2547
|
getGroup(id) {
|
|
2526
2548
|
return this.component.getPanel(id);
|
|
2527
2549
|
}
|
|
2550
|
+
addFloatingGroup(item, coord) {
|
|
2551
|
+
return this.component.addFloatingGroup(item, coord);
|
|
2552
|
+
}
|
|
2528
2553
|
fromJSON(data) {
|
|
2529
2554
|
this.component.fromJSON(data);
|
|
2530
2555
|
}
|
|
@@ -2617,10 +2642,14 @@ class Droptarget extends CompositeDisposable {
|
|
|
2617
2642
|
this._onDrop = new Emitter();
|
|
2618
2643
|
this.onDrop = this._onDrop.event;
|
|
2619
2644
|
// use a set to take advantage of #<set>.has
|
|
2620
|
-
|
|
2645
|
+
this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
|
|
2621
2646
|
this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
|
|
2622
2647
|
onDragEnter: () => undefined,
|
|
2623
2648
|
onDragOver: (e) => {
|
|
2649
|
+
if (this._acceptedTargetZonesSet.size === 0) {
|
|
2650
|
+
this.removeDropTarget();
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2624
2653
|
const width = this.element.clientWidth;
|
|
2625
2654
|
const height = this.element.clientHeight;
|
|
2626
2655
|
if (width === 0 || height === 0) {
|
|
@@ -2629,20 +2658,28 @@ class Droptarget extends CompositeDisposable {
|
|
|
2629
2658
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
2630
2659
|
const x = e.clientX - rect.left;
|
|
2631
2660
|
const y = e.clientY - rect.top;
|
|
2632
|
-
const quadrant = this.calculateQuadrant(
|
|
2633
|
-
|
|
2661
|
+
const quadrant = this.calculateQuadrant(this._acceptedTargetZonesSet, x, y, width, height);
|
|
2662
|
+
/**
|
|
2663
|
+
* If the event has already been used by another DropTarget instance
|
|
2664
|
+
* then don't show a second drop target, only one target should be
|
|
2665
|
+
* active at any one time
|
|
2666
|
+
*/
|
|
2667
|
+
if (this.isAlreadyUsed(e) || quadrant === null) {
|
|
2634
2668
|
// no drop target should be displayed
|
|
2635
2669
|
this.removeDropTarget();
|
|
2636
2670
|
return;
|
|
2637
2671
|
}
|
|
2638
2672
|
if (typeof this.options.canDisplayOverlay === 'boolean') {
|
|
2639
2673
|
if (!this.options.canDisplayOverlay) {
|
|
2674
|
+
this.removeDropTarget();
|
|
2640
2675
|
return;
|
|
2641
2676
|
}
|
|
2642
2677
|
}
|
|
2643
2678
|
else if (!this.options.canDisplayOverlay(e, quadrant)) {
|
|
2679
|
+
this.removeDropTarget();
|
|
2644
2680
|
return;
|
|
2645
2681
|
}
|
|
2682
|
+
this.markAsUsed(e);
|
|
2646
2683
|
if (!this.targetElement) {
|
|
2647
2684
|
this.targetElement = document.createElement('div');
|
|
2648
2685
|
this.targetElement.className = 'drop-target-dropzone';
|
|
@@ -2653,12 +2690,6 @@ class Droptarget extends CompositeDisposable {
|
|
|
2653
2690
|
this.element.classList.add('drop-target');
|
|
2654
2691
|
this.element.append(this.targetElement);
|
|
2655
2692
|
}
|
|
2656
|
-
if (this.options.acceptedTargetZones.length === 0) {
|
|
2657
|
-
return;
|
|
2658
|
-
}
|
|
2659
|
-
if (!this.targetElement || !this.overlayElement) {
|
|
2660
|
-
return;
|
|
2661
|
-
}
|
|
2662
2693
|
this.toggleClasses(quadrant, width, height);
|
|
2663
2694
|
this.setState(quadrant);
|
|
2664
2695
|
},
|
|
@@ -2681,10 +2712,26 @@ class Droptarget extends CompositeDisposable {
|
|
|
2681
2712
|
},
|
|
2682
2713
|
}));
|
|
2683
2714
|
}
|
|
2715
|
+
setTargetZones(acceptedTargetZones) {
|
|
2716
|
+
this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
|
|
2717
|
+
}
|
|
2684
2718
|
dispose() {
|
|
2685
2719
|
this.removeDropTarget();
|
|
2686
2720
|
super.dispose();
|
|
2687
2721
|
}
|
|
2722
|
+
/**
|
|
2723
|
+
* Add a property to the event object for other potential listeners to check
|
|
2724
|
+
*/
|
|
2725
|
+
markAsUsed(event) {
|
|
2726
|
+
event[Droptarget.USED_EVENT_ID] = true;
|
|
2727
|
+
}
|
|
2728
|
+
/**
|
|
2729
|
+
* Check is the event has already been used by another instance od DropTarget
|
|
2730
|
+
*/
|
|
2731
|
+
isAlreadyUsed(event) {
|
|
2732
|
+
const value = event[Droptarget.USED_EVENT_ID];
|
|
2733
|
+
return typeof value === 'boolean' && value;
|
|
2734
|
+
}
|
|
2688
2735
|
toggleClasses(quadrant, width, height) {
|
|
2689
2736
|
var _a, _b, _c, _d;
|
|
2690
2737
|
if (!this.overlayElement) {
|
|
@@ -2779,6 +2826,7 @@ class Droptarget extends CompositeDisposable {
|
|
|
2779
2826
|
}
|
|
2780
2827
|
}
|
|
2781
2828
|
}
|
|
2829
|
+
Droptarget.USED_EVENT_ID = '__dockview_droptarget_event_is_used__';
|
|
2782
2830
|
function calculateQuadrantAsPercentage(overlayType, x, y, width, height, threshold) {
|
|
2783
2831
|
const xp = (100 * x) / width;
|
|
2784
2832
|
const yp = (100 * y) / height;
|
|
@@ -2908,8 +2956,15 @@ class DragHandler extends CompositeDisposable {
|
|
|
2908
2956
|
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2909
2957
|
this.configure();
|
|
2910
2958
|
}
|
|
2959
|
+
isCancelled(_event) {
|
|
2960
|
+
return false;
|
|
2961
|
+
}
|
|
2911
2962
|
configure() {
|
|
2912
2963
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2964
|
+
if (this.isCancelled(event)) {
|
|
2965
|
+
event.preventDefault();
|
|
2966
|
+
return;
|
|
2967
|
+
}
|
|
2913
2968
|
const iframes = [
|
|
2914
2969
|
...getElementsByTagName('iframe'),
|
|
2915
2970
|
...getElementsByTagName('webview'),
|
|
@@ -2983,13 +3038,6 @@ class Tab extends CompositeDisposable {
|
|
|
2983
3038
|
if (event.defaultPrevented) {
|
|
2984
3039
|
return;
|
|
2985
3040
|
}
|
|
2986
|
-
/**
|
|
2987
|
-
* TODO: alternative to stopPropagation
|
|
2988
|
-
*
|
|
2989
|
-
* I need to stop the event propagation here since otherwise it'll be intercepted by event handlers
|
|
2990
|
-
* on the tabs-container. I cannot use event.preventDefault() since I need the on DragStart event to occur
|
|
2991
|
-
*/
|
|
2992
|
-
event.stopPropagation();
|
|
2993
3041
|
this._onChanged.fire(event);
|
|
2994
3042
|
}));
|
|
2995
3043
|
this.droptarget = new Droptarget(this._element, {
|
|
@@ -3047,6 +3095,22 @@ class GroupDragHandler extends DragHandler {
|
|
|
3047
3095
|
this.accessorId = accessorId;
|
|
3048
3096
|
this.group = group;
|
|
3049
3097
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
3098
|
+
this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
|
|
3099
|
+
if (e.shiftKey) {
|
|
3100
|
+
/**
|
|
3101
|
+
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
3102
|
+
* but we also need to stop any group overlay drag events from occuring
|
|
3103
|
+
* Use a custom event marker that can be checked by the overlay drag events
|
|
3104
|
+
*/
|
|
3105
|
+
quasiPreventDefault(e);
|
|
3106
|
+
}
|
|
3107
|
+
}, true));
|
|
3108
|
+
}
|
|
3109
|
+
isCancelled(_event) {
|
|
3110
|
+
if (this.group.api.isFloating && !_event.shiftKey) {
|
|
3111
|
+
return true;
|
|
3112
|
+
}
|
|
3113
|
+
return false;
|
|
3050
3114
|
}
|
|
3051
3115
|
getData(dataTransfer) {
|
|
3052
3116
|
this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
|
|
@@ -3137,17 +3201,30 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3137
3201
|
hide() {
|
|
3138
3202
|
this._element.style.display = 'none';
|
|
3139
3203
|
}
|
|
3140
|
-
|
|
3141
|
-
if (this.
|
|
3204
|
+
setRightActionsElement(element) {
|
|
3205
|
+
if (this.rightActions === element) {
|
|
3142
3206
|
return;
|
|
3143
3207
|
}
|
|
3144
|
-
if (this.
|
|
3145
|
-
this.
|
|
3146
|
-
this.
|
|
3208
|
+
if (this.rightActions) {
|
|
3209
|
+
this.rightActions.remove();
|
|
3210
|
+
this.rightActions = undefined;
|
|
3147
3211
|
}
|
|
3148
3212
|
if (element) {
|
|
3149
|
-
this.
|
|
3150
|
-
this.
|
|
3213
|
+
this.rightActionsContainer.appendChild(element);
|
|
3214
|
+
this.rightActions = element;
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
setLeftActionsElement(element) {
|
|
3218
|
+
if (this.leftActions === element) {
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3221
|
+
if (this.leftActions) {
|
|
3222
|
+
this.leftActions.remove();
|
|
3223
|
+
this.leftActions = undefined;
|
|
3224
|
+
}
|
|
3225
|
+
if (element) {
|
|
3226
|
+
this.leftActionsContainer.appendChild(element);
|
|
3227
|
+
this.leftActions = element;
|
|
3151
3228
|
}
|
|
3152
3229
|
}
|
|
3153
3230
|
get element() {
|
|
@@ -3182,19 +3259,35 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3182
3259
|
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
3183
3260
|
}
|
|
3184
3261
|
}));
|
|
3185
|
-
this.
|
|
3186
|
-
this.
|
|
3262
|
+
this.rightActionsContainer = document.createElement('div');
|
|
3263
|
+
this.rightActionsContainer.className = 'right-actions-container';
|
|
3264
|
+
this.leftActionsContainer = document.createElement('div');
|
|
3265
|
+
this.leftActionsContainer.className = 'left-actions-container';
|
|
3187
3266
|
this.tabContainer = document.createElement('div');
|
|
3188
3267
|
this.tabContainer.className = 'tabs-container';
|
|
3189
3268
|
this.voidContainer = new VoidContainer(this.accessor, this.group);
|
|
3190
3269
|
this._element.appendChild(this.tabContainer);
|
|
3270
|
+
this._element.appendChild(this.leftActionsContainer);
|
|
3191
3271
|
this._element.appendChild(this.voidContainer.element);
|
|
3192
|
-
this._element.appendChild(this.
|
|
3272
|
+
this._element.appendChild(this.rightActionsContainer);
|
|
3193
3273
|
this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
|
|
3194
3274
|
this._onDrop.fire({
|
|
3195
3275
|
event: event.nativeEvent,
|
|
3196
3276
|
index: this.tabs.length,
|
|
3197
3277
|
});
|
|
3278
|
+
}), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
|
|
3279
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3280
|
+
if (isFloatingGroupsEnabled &&
|
|
3281
|
+
event.shiftKey &&
|
|
3282
|
+
!this.group.api.isFloating) {
|
|
3283
|
+
event.preventDefault();
|
|
3284
|
+
const { top, left } = this.element.getBoundingClientRect();
|
|
3285
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3286
|
+
this.accessor.addFloatingGroup(this.group, {
|
|
3287
|
+
x: left - rootLeft + 20,
|
|
3288
|
+
y: top - rootTop + 20,
|
|
3289
|
+
}, { inDragMode: true });
|
|
3290
|
+
}
|
|
3198
3291
|
}), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
|
|
3199
3292
|
if (event.defaultPrevented) {
|
|
3200
3293
|
return;
|
|
@@ -3248,6 +3341,21 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3248
3341
|
tabToAdd.setContent(panel.view.tab);
|
|
3249
3342
|
const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
|
|
3250
3343
|
var _a;
|
|
3344
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3345
|
+
const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
|
|
3346
|
+
if (isFloatingGroupsEnabled &&
|
|
3347
|
+
!isFloatingWithOnePanel &&
|
|
3348
|
+
event.shiftKey) {
|
|
3349
|
+
event.preventDefault();
|
|
3350
|
+
const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
|
|
3351
|
+
const { top, left } = tabToAdd.element.getBoundingClientRect();
|
|
3352
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3353
|
+
this.accessor.addFloatingGroup(panel, {
|
|
3354
|
+
x: left - rootLeft,
|
|
3355
|
+
y: top - rootTop,
|
|
3356
|
+
}, { inDragMode: true });
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
3251
3359
|
const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
3252
3360
|
this.group.model.isContentFocused;
|
|
3253
3361
|
const isLeftClick = event.button === 0;
|
|
@@ -3317,6 +3425,17 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3317
3425
|
}
|
|
3318
3426
|
return isAncestor(document.activeElement, this.contentContainer.element);
|
|
3319
3427
|
}
|
|
3428
|
+
get isFloating() {
|
|
3429
|
+
return this._isFloating;
|
|
3430
|
+
}
|
|
3431
|
+
set isFloating(value) {
|
|
3432
|
+
this._isFloating = value;
|
|
3433
|
+
this.dropTarget.setTargetZones(value ? ['center'] : ['top', 'bottom', 'left', 'right', 'center']);
|
|
3434
|
+
toggleClass(this.container, 'dv-groupview-floating', value);
|
|
3435
|
+
this.groupPanel.api._onDidFloatingStateChange.fire({
|
|
3436
|
+
isFloating: this.isFloating,
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3320
3439
|
constructor(container, accessor, id, options, groupPanel) {
|
|
3321
3440
|
super();
|
|
3322
3441
|
this.container = container;
|
|
@@ -3326,6 +3445,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3326
3445
|
this.groupPanel = groupPanel;
|
|
3327
3446
|
this._isGroupActive = false;
|
|
3328
3447
|
this._locked = false;
|
|
3448
|
+
this._isFloating = false;
|
|
3329
3449
|
this.mostRecentlyUsed = [];
|
|
3330
3450
|
this._onDidChange = new Emitter();
|
|
3331
3451
|
this.onDidChange = this._onDidChange.event;
|
|
@@ -3342,7 +3462,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3342
3462
|
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
3343
3463
|
this._onDidActivePanelChange = new Emitter();
|
|
3344
3464
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
3345
|
-
this.container
|
|
3465
|
+
toggleClass(this.container, 'groupview', true);
|
|
3346
3466
|
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
|
3347
3467
|
this.contentContainer = new ContentContainer();
|
|
3348
3468
|
this.dropTarget = new Droptarget(this.contentContainer.element, {
|
|
@@ -3352,6 +3472,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3352
3472
|
return false;
|
|
3353
3473
|
}
|
|
3354
3474
|
const data = getPanelData();
|
|
3475
|
+
if (!data && event.shiftKey && !this.isFloating) {
|
|
3476
|
+
return false;
|
|
3477
|
+
}
|
|
3355
3478
|
if (data && data.viewId === this.accessor.id) {
|
|
3356
3479
|
if (data.groupId === this.id) {
|
|
3357
3480
|
if (position === 'center') {
|
|
@@ -3396,14 +3519,25 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3396
3519
|
// correctly initialized
|
|
3397
3520
|
this.setActive(this.isActive, true, true);
|
|
3398
3521
|
this.updateContainer();
|
|
3399
|
-
if (this.accessor.options.
|
|
3400
|
-
this.
|
|
3401
|
-
|
|
3402
|
-
this.
|
|
3522
|
+
if (this.accessor.options.createRightHeaderActionsElement) {
|
|
3523
|
+
this._rightHeaderActions =
|
|
3524
|
+
this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
|
|
3525
|
+
this.addDisposables(this._rightHeaderActions);
|
|
3526
|
+
this._rightHeaderActions.init({
|
|
3403
3527
|
containerApi: new DockviewApi(this.accessor),
|
|
3404
3528
|
api: this.groupPanel.api,
|
|
3405
3529
|
});
|
|
3406
|
-
this.tabsContainer.
|
|
3530
|
+
this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
|
|
3531
|
+
}
|
|
3532
|
+
if (this.accessor.options.createLeftHeaderActionsElement) {
|
|
3533
|
+
this._leftHeaderActions =
|
|
3534
|
+
this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
|
|
3535
|
+
this.addDisposables(this._leftHeaderActions);
|
|
3536
|
+
this._leftHeaderActions.init({
|
|
3537
|
+
containerApi: new DockviewApi(this.accessor),
|
|
3538
|
+
api: this.groupPanel.api,
|
|
3539
|
+
});
|
|
3540
|
+
this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
|
|
3407
3541
|
}
|
|
3408
3542
|
}
|
|
3409
3543
|
indexOf(panel) {
|
|
@@ -3536,7 +3670,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3536
3670
|
return this._activePanel === panel;
|
|
3537
3671
|
}
|
|
3538
3672
|
updateActions(element) {
|
|
3539
|
-
this.tabsContainer.
|
|
3673
|
+
this.tabsContainer.setRightActionsElement(element);
|
|
3540
3674
|
}
|
|
3541
3675
|
setActive(isGroupActive, skipFocus = false, force = false) {
|
|
3542
3676
|
var _a, _b, _c, _d;
|
|
@@ -3708,9 +3842,10 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3708
3842
|
}
|
|
3709
3843
|
}
|
|
3710
3844
|
dispose() {
|
|
3711
|
-
var _a, _b;
|
|
3845
|
+
var _a, _b, _c;
|
|
3712
3846
|
super.dispose();
|
|
3713
|
-
(
|
|
3847
|
+
(_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
|
|
3848
|
+
(_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3714
3849
|
for (const panel of this.panels) {
|
|
3715
3850
|
panel.dispose();
|
|
3716
3851
|
}
|
|
@@ -4504,8 +4639,8 @@ class GridviewPanel extends BasePanelView {
|
|
|
4504
4639
|
get isActive() {
|
|
4505
4640
|
return this.api.isActive;
|
|
4506
4641
|
}
|
|
4507
|
-
constructor(id, component, options) {
|
|
4508
|
-
super(id, component, new GridviewPanelApiImpl(id));
|
|
4642
|
+
constructor(id, component, options, api) {
|
|
4643
|
+
super(id, component, api !== null && api !== void 0 ? api : new GridviewPanelApiImpl(id));
|
|
4509
4644
|
this._evaluatedMinimumWidth = 0;
|
|
4510
4645
|
this._evaluatedMaximumWidth = Number.MAX_SAFE_INTEGER;
|
|
4511
4646
|
this._evaluatedMinimumHeight = 0;
|
|
@@ -4603,6 +4738,32 @@ class GridviewPanel extends BasePanelView {
|
|
|
4603
4738
|
}
|
|
4604
4739
|
}
|
|
4605
4740
|
|
|
4741
|
+
class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|
4742
|
+
get isFloating() {
|
|
4743
|
+
if (!this._group) {
|
|
4744
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4745
|
+
}
|
|
4746
|
+
return this._group.model.isFloating;
|
|
4747
|
+
}
|
|
4748
|
+
constructor(id, accessor) {
|
|
4749
|
+
super(id);
|
|
4750
|
+
this.accessor = accessor;
|
|
4751
|
+
this._onDidFloatingStateChange = new Emitter();
|
|
4752
|
+
this.onDidFloatingStateChange = this._onDidFloatingStateChange.event;
|
|
4753
|
+
this.addDisposables(this._onDidFloatingStateChange);
|
|
4754
|
+
}
|
|
4755
|
+
moveTo(options) {
|
|
4756
|
+
var _a;
|
|
4757
|
+
if (!this._group) {
|
|
4758
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4759
|
+
}
|
|
4760
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, undefined, (_a = options.position) !== null && _a !== void 0 ? _a : 'center');
|
|
4761
|
+
}
|
|
4762
|
+
initialize(group) {
|
|
4763
|
+
this._group = group;
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4606
4767
|
class DockviewGroupPanel extends GridviewPanel {
|
|
4607
4768
|
get panels() {
|
|
4608
4769
|
return this._model.panels;
|
|
@@ -4629,7 +4790,8 @@ class DockviewGroupPanel extends GridviewPanel {
|
|
|
4629
4790
|
super(id, 'groupview_default', {
|
|
4630
4791
|
minimumHeight: 100,
|
|
4631
4792
|
minimumWidth: 100,
|
|
4632
|
-
});
|
|
4793
|
+
}, new DockviewGroupPanelApiImpl(id, accessor));
|
|
4794
|
+
this.api.initialize(this); // cannot use 'this' after after 'super' call
|
|
4633
4795
|
this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
|
|
4634
4796
|
}
|
|
4635
4797
|
initialize() {
|
|
@@ -4647,7 +4809,6 @@ class DockviewGroupPanel extends GridviewPanel {
|
|
|
4647
4809
|
return this._model;
|
|
4648
4810
|
}
|
|
4649
4811
|
toJSON() {
|
|
4650
|
-
// TODO fix typing
|
|
4651
4812
|
return this.model.toJSON();
|
|
4652
4813
|
}
|
|
4653
4814
|
}
|
|
@@ -4701,9 +4862,10 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4701
4862
|
get group() {
|
|
4702
4863
|
return this._group;
|
|
4703
4864
|
}
|
|
4704
|
-
constructor(panel, group) {
|
|
4865
|
+
constructor(panel, group, accessor) {
|
|
4705
4866
|
super(panel.id);
|
|
4706
4867
|
this.panel = panel;
|
|
4868
|
+
this.accessor = accessor;
|
|
4707
4869
|
this._onDidTitleChange = new Emitter();
|
|
4708
4870
|
this.onDidTitleChange = this._onDidTitleChange.event;
|
|
4709
4871
|
this._onDidActiveGroupChange = new Emitter();
|
|
@@ -4715,6 +4877,10 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4715
4877
|
this._group = group;
|
|
4716
4878
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4717
4879
|
}
|
|
4880
|
+
moveTo(options) {
|
|
4881
|
+
var _a;
|
|
4882
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
|
|
4883
|
+
}
|
|
4718
4884
|
setTitle(title) {
|
|
4719
4885
|
this.panel.setTitle(title);
|
|
4720
4886
|
}
|
|
@@ -4739,7 +4905,7 @@ class DockviewPanel extends CompositeDisposable {
|
|
|
4739
4905
|
this.containerApi = containerApi;
|
|
4740
4906
|
this.view = view;
|
|
4741
4907
|
this._group = group;
|
|
4742
|
-
this.api = new DockviewPanelApiImpl(this, this._group);
|
|
4908
|
+
this.api = new DockviewPanelApiImpl(this, this._group, accessor);
|
|
4743
4909
|
this.addDisposables(this.api.onActiveChange(() => {
|
|
4744
4910
|
accessor.setActivePanel(this);
|
|
4745
4911
|
}), this.api.onDidSizeChange((event) => {
|
|
@@ -5080,6 +5246,296 @@ class Watermark extends CompositeDisposable {
|
|
|
5080
5246
|
}
|
|
5081
5247
|
}
|
|
5082
5248
|
|
|
5249
|
+
const bringElementToFront = (() => {
|
|
5250
|
+
let previous = null;
|
|
5251
|
+
function pushToTop(element) {
|
|
5252
|
+
if (previous !== element && previous !== null) {
|
|
5253
|
+
toggleClass(previous, 'dv-bring-to-front', false);
|
|
5254
|
+
}
|
|
5255
|
+
toggleClass(element, 'dv-bring-to-front', true);
|
|
5256
|
+
previous = element;
|
|
5257
|
+
}
|
|
5258
|
+
return pushToTop;
|
|
5259
|
+
})();
|
|
5260
|
+
class Overlay extends CompositeDisposable {
|
|
5261
|
+
constructor(options) {
|
|
5262
|
+
super();
|
|
5263
|
+
this.options = options;
|
|
5264
|
+
this._element = document.createElement('div');
|
|
5265
|
+
this._onDidChange = new Emitter();
|
|
5266
|
+
this.onDidChange = this._onDidChange.event;
|
|
5267
|
+
this._onDidChangeEnd = new Emitter();
|
|
5268
|
+
this.onDidChangeEnd = this._onDidChangeEnd.event;
|
|
5269
|
+
this.addDisposables(this._onDidChange, this._onDidChangeEnd);
|
|
5270
|
+
this._element.className = 'dv-resize-container';
|
|
5271
|
+
this.setupResize('top');
|
|
5272
|
+
this.setupResize('bottom');
|
|
5273
|
+
this.setupResize('left');
|
|
5274
|
+
this.setupResize('right');
|
|
5275
|
+
this.setupResize('topleft');
|
|
5276
|
+
this.setupResize('topright');
|
|
5277
|
+
this.setupResize('bottomleft');
|
|
5278
|
+
this.setupResize('bottomright');
|
|
5279
|
+
this._element.appendChild(this.options.content);
|
|
5280
|
+
this.options.container.appendChild(this._element);
|
|
5281
|
+
// if input bad resize within acceptable boundaries
|
|
5282
|
+
this.setBounds({
|
|
5283
|
+
height: this.options.height,
|
|
5284
|
+
width: this.options.width,
|
|
5285
|
+
top: this.options.top,
|
|
5286
|
+
left: this.options.left,
|
|
5287
|
+
});
|
|
5288
|
+
}
|
|
5289
|
+
setBounds(bounds = {}) {
|
|
5290
|
+
if (typeof bounds.height === 'number') {
|
|
5291
|
+
this._element.style.height = `${bounds.height}px`;
|
|
5292
|
+
}
|
|
5293
|
+
if (typeof bounds.width === 'number') {
|
|
5294
|
+
this._element.style.width = `${bounds.width}px`;
|
|
5295
|
+
}
|
|
5296
|
+
if (typeof bounds.top === 'number') {
|
|
5297
|
+
this._element.style.top = `${bounds.top}px`;
|
|
5298
|
+
}
|
|
5299
|
+
if (typeof bounds.left === 'number') {
|
|
5300
|
+
this._element.style.left = `${bounds.left}px`;
|
|
5301
|
+
}
|
|
5302
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5303
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5304
|
+
// region: ensure bounds within allowable limits
|
|
5305
|
+
// a minimum width of minimumViewportWidth must be inside the viewport
|
|
5306
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5307
|
+
// a minimum height of minimumViewportHeight must be inside the viewport
|
|
5308
|
+
const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
|
|
5309
|
+
const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5310
|
+
const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5311
|
+
this._element.style.left = `${left}px`;
|
|
5312
|
+
this._element.style.top = `${top}px`;
|
|
5313
|
+
this._onDidChange.fire();
|
|
5314
|
+
}
|
|
5315
|
+
toJSON() {
|
|
5316
|
+
const container = this.options.container.getBoundingClientRect();
|
|
5317
|
+
const element = this._element.getBoundingClientRect();
|
|
5318
|
+
return {
|
|
5319
|
+
top: element.top - container.top,
|
|
5320
|
+
left: element.left - container.left,
|
|
5321
|
+
width: element.width,
|
|
5322
|
+
height: element.height,
|
|
5323
|
+
};
|
|
5324
|
+
}
|
|
5325
|
+
setupDrag(dragTarget, options = { inDragMode: false }) {
|
|
5326
|
+
const move = new MutableDisposable();
|
|
5327
|
+
const track = () => {
|
|
5328
|
+
let offset = null;
|
|
5329
|
+
const iframes = [
|
|
5330
|
+
...getElementsByTagName('iframe'),
|
|
5331
|
+
...getElementsByTagName('webview'),
|
|
5332
|
+
];
|
|
5333
|
+
for (const iframe of iframes) {
|
|
5334
|
+
iframe.style.pointerEvents = 'none';
|
|
5335
|
+
}
|
|
5336
|
+
move.value = new CompositeDisposable({
|
|
5337
|
+
dispose: () => {
|
|
5338
|
+
for (const iframe of iframes) {
|
|
5339
|
+
iframe.style.pointerEvents = 'auto';
|
|
5340
|
+
}
|
|
5341
|
+
},
|
|
5342
|
+
}, addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5343
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5344
|
+
const x = e.clientX - containerRect.left;
|
|
5345
|
+
const y = e.clientY - containerRect.top;
|
|
5346
|
+
toggleClass(this._element, 'dv-resize-container-dragging', true);
|
|
5347
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5348
|
+
if (offset === null) {
|
|
5349
|
+
offset = {
|
|
5350
|
+
x: e.clientX - overlayRect.left,
|
|
5351
|
+
y: e.clientY - overlayRect.top,
|
|
5352
|
+
};
|
|
5353
|
+
}
|
|
5354
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5355
|
+
const yOffset = Math.max(0, overlayRect.height -
|
|
5356
|
+
this.options.minimumInViewportHeight);
|
|
5357
|
+
const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5358
|
+
const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5359
|
+
this.setBounds({ top, left });
|
|
5360
|
+
}), addDisposableWindowListener(window, 'mouseup', () => {
|
|
5361
|
+
toggleClass(this._element, 'dv-resize-container-dragging', false);
|
|
5362
|
+
move.dispose();
|
|
5363
|
+
this._onDidChangeEnd.fire();
|
|
5364
|
+
}));
|
|
5365
|
+
};
|
|
5366
|
+
this.addDisposables(move, addDisposableListener(dragTarget, 'mousedown', (event) => {
|
|
5367
|
+
if (event.defaultPrevented) {
|
|
5368
|
+
event.preventDefault();
|
|
5369
|
+
return;
|
|
5370
|
+
}
|
|
5371
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5372
|
+
// without actually calling event.preventDefault()
|
|
5373
|
+
if (quasiDefaultPrevented(event)) {
|
|
5374
|
+
return;
|
|
5375
|
+
}
|
|
5376
|
+
track();
|
|
5377
|
+
}), addDisposableListener(this.options.content, 'mousedown', (event) => {
|
|
5378
|
+
if (event.defaultPrevented) {
|
|
5379
|
+
return;
|
|
5380
|
+
}
|
|
5381
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5382
|
+
// without actually calling event.preventDefault()
|
|
5383
|
+
if (quasiDefaultPrevented(event)) {
|
|
5384
|
+
return;
|
|
5385
|
+
}
|
|
5386
|
+
if (event.shiftKey) {
|
|
5387
|
+
track();
|
|
5388
|
+
}
|
|
5389
|
+
}), addDisposableListener(this.options.content, 'mousedown', () => {
|
|
5390
|
+
bringElementToFront(this._element);
|
|
5391
|
+
}, true));
|
|
5392
|
+
bringElementToFront(this._element);
|
|
5393
|
+
if (options.inDragMode) {
|
|
5394
|
+
track();
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
setupResize(direction) {
|
|
5398
|
+
const resizeHandleElement = document.createElement('div');
|
|
5399
|
+
resizeHandleElement.className = `dv-resize-handle-${direction}`;
|
|
5400
|
+
this._element.appendChild(resizeHandleElement);
|
|
5401
|
+
const move = new MutableDisposable();
|
|
5402
|
+
this.addDisposables(move, addDisposableListener(resizeHandleElement, 'mousedown', (e) => {
|
|
5403
|
+
e.preventDefault();
|
|
5404
|
+
let startPosition = null;
|
|
5405
|
+
const iframes = [
|
|
5406
|
+
...getElementsByTagName('iframe'),
|
|
5407
|
+
...getElementsByTagName('webview'),
|
|
5408
|
+
];
|
|
5409
|
+
for (const iframe of iframes) {
|
|
5410
|
+
iframe.style.pointerEvents = 'none';
|
|
5411
|
+
}
|
|
5412
|
+
move.value = new CompositeDisposable(addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5413
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5414
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5415
|
+
const y = e.clientY - containerRect.top;
|
|
5416
|
+
const x = e.clientX - containerRect.left;
|
|
5417
|
+
if (startPosition === null) {
|
|
5418
|
+
// record the initial dimensions since as all subsequence moves are relative to this
|
|
5419
|
+
startPosition = {
|
|
5420
|
+
originalY: y,
|
|
5421
|
+
originalHeight: overlayRect.height,
|
|
5422
|
+
originalX: x,
|
|
5423
|
+
originalWidth: overlayRect.width,
|
|
5424
|
+
};
|
|
5425
|
+
}
|
|
5426
|
+
let top = undefined;
|
|
5427
|
+
let height = undefined;
|
|
5428
|
+
let left = undefined;
|
|
5429
|
+
let width = undefined;
|
|
5430
|
+
const minimumInViewportHeight = this.options.minimumInViewportHeight;
|
|
5431
|
+
const minimumInViewportWidth = this.options.minimumInViewportWidth;
|
|
5432
|
+
function moveTop() {
|
|
5433
|
+
top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
|
|
5434
|
+
startPosition.originalHeight >
|
|
5435
|
+
containerRect.height
|
|
5436
|
+
? containerRect.height -
|
|
5437
|
+
minimumInViewportHeight
|
|
5438
|
+
: Math.max(0, startPosition.originalY +
|
|
5439
|
+
startPosition.originalHeight -
|
|
5440
|
+
Overlay.MINIMUM_HEIGHT));
|
|
5441
|
+
height =
|
|
5442
|
+
startPosition.originalY +
|
|
5443
|
+
startPosition.originalHeight -
|
|
5444
|
+
top;
|
|
5445
|
+
}
|
|
5446
|
+
function moveBottom() {
|
|
5447
|
+
top =
|
|
5448
|
+
startPosition.originalY -
|
|
5449
|
+
startPosition.originalHeight;
|
|
5450
|
+
height = clamp(y - top, top < 0
|
|
5451
|
+
? -top + minimumInViewportHeight
|
|
5452
|
+
: Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
|
|
5453
|
+
}
|
|
5454
|
+
function moveLeft() {
|
|
5455
|
+
left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
|
|
5456
|
+
startPosition.originalWidth >
|
|
5457
|
+
containerRect.width
|
|
5458
|
+
? containerRect.width -
|
|
5459
|
+
minimumInViewportWidth
|
|
5460
|
+
: Math.max(0, startPosition.originalX +
|
|
5461
|
+
startPosition.originalWidth -
|
|
5462
|
+
Overlay.MINIMUM_WIDTH));
|
|
5463
|
+
width =
|
|
5464
|
+
startPosition.originalX +
|
|
5465
|
+
startPosition.originalWidth -
|
|
5466
|
+
left;
|
|
5467
|
+
}
|
|
5468
|
+
function moveRight() {
|
|
5469
|
+
left =
|
|
5470
|
+
startPosition.originalX -
|
|
5471
|
+
startPosition.originalWidth;
|
|
5472
|
+
width = clamp(x - left, left < 0
|
|
5473
|
+
? -left + minimumInViewportWidth
|
|
5474
|
+
: Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
|
|
5475
|
+
}
|
|
5476
|
+
switch (direction) {
|
|
5477
|
+
case 'top':
|
|
5478
|
+
moveTop();
|
|
5479
|
+
break;
|
|
5480
|
+
case 'bottom':
|
|
5481
|
+
moveBottom();
|
|
5482
|
+
break;
|
|
5483
|
+
case 'left':
|
|
5484
|
+
moveLeft();
|
|
5485
|
+
break;
|
|
5486
|
+
case 'right':
|
|
5487
|
+
moveRight();
|
|
5488
|
+
break;
|
|
5489
|
+
case 'topleft':
|
|
5490
|
+
moveTop();
|
|
5491
|
+
moveLeft();
|
|
5492
|
+
break;
|
|
5493
|
+
case 'topright':
|
|
5494
|
+
moveTop();
|
|
5495
|
+
moveRight();
|
|
5496
|
+
break;
|
|
5497
|
+
case 'bottomleft':
|
|
5498
|
+
moveBottom();
|
|
5499
|
+
moveLeft();
|
|
5500
|
+
break;
|
|
5501
|
+
case 'bottomright':
|
|
5502
|
+
moveBottom();
|
|
5503
|
+
moveRight();
|
|
5504
|
+
break;
|
|
5505
|
+
}
|
|
5506
|
+
this.setBounds({ height, width, top, left });
|
|
5507
|
+
}), {
|
|
5508
|
+
dispose: () => {
|
|
5509
|
+
for (const iframe of iframes) {
|
|
5510
|
+
iframe.style.pointerEvents = 'auto';
|
|
5511
|
+
}
|
|
5512
|
+
},
|
|
5513
|
+
}, addDisposableWindowListener(window, 'mouseup', () => {
|
|
5514
|
+
move.dispose();
|
|
5515
|
+
this._onDidChangeEnd.fire();
|
|
5516
|
+
}));
|
|
5517
|
+
}));
|
|
5518
|
+
}
|
|
5519
|
+
dispose() {
|
|
5520
|
+
this._element.remove();
|
|
5521
|
+
super.dispose();
|
|
5522
|
+
}
|
|
5523
|
+
}
|
|
5524
|
+
Overlay.MINIMUM_HEIGHT = 20;
|
|
5525
|
+
Overlay.MINIMUM_WIDTH = 20;
|
|
5526
|
+
|
|
5527
|
+
class DockviewFloatingGroupPanel extends CompositeDisposable {
|
|
5528
|
+
constructor(group, overlay) {
|
|
5529
|
+
super();
|
|
5530
|
+
this.group = group;
|
|
5531
|
+
this.overlay = overlay;
|
|
5532
|
+
this.addDisposables(overlay);
|
|
5533
|
+
}
|
|
5534
|
+
position(bounds) {
|
|
5535
|
+
this.overlay.setBounds(bounds);
|
|
5536
|
+
}
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5083
5539
|
class DockviewComponent extends BaseGrid {
|
|
5084
5540
|
get orientation() {
|
|
5085
5541
|
return this.gridview.orientation;
|
|
@@ -5120,7 +5576,8 @@ class DockviewComponent extends BaseGrid {
|
|
|
5120
5576
|
this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
|
|
5121
5577
|
this._onDidActivePanelChange = new Emitter();
|
|
5122
5578
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
5123
|
-
this.
|
|
5579
|
+
this.floatingGroups = [];
|
|
5580
|
+
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
5124
5581
|
this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
|
|
5125
5582
|
this.updateWatermark();
|
|
5126
5583
|
}), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
|
|
@@ -5150,6 +5607,11 @@ class DockviewComponent extends BaseGrid {
|
|
|
5150
5607
|
if (data.viewId !== this.id) {
|
|
5151
5608
|
return false;
|
|
5152
5609
|
}
|
|
5610
|
+
if (position === 'center') {
|
|
5611
|
+
// center drop target is only allowed if there are no panels in the grid
|
|
5612
|
+
// floating panels are allowed
|
|
5613
|
+
return this.gridview.length === 0;
|
|
5614
|
+
}
|
|
5153
5615
|
return true;
|
|
5154
5616
|
}
|
|
5155
5617
|
if (this.options.showDndOverlay) {
|
|
@@ -5162,7 +5624,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5162
5624
|
}
|
|
5163
5625
|
return false;
|
|
5164
5626
|
},
|
|
5165
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
|
|
5627
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5166
5628
|
overlayModel: {
|
|
5167
5629
|
activationSize: { type: 'pixels', value: 10 },
|
|
5168
5630
|
size: { type: 'pixels', value: 20 },
|
|
@@ -5180,6 +5642,75 @@ class DockviewComponent extends BaseGrid {
|
|
|
5180
5642
|
this._api = new DockviewApi(this);
|
|
5181
5643
|
this.updateWatermark();
|
|
5182
5644
|
}
|
|
5645
|
+
addFloatingGroup(item, coord, options) {
|
|
5646
|
+
var _a, _b;
|
|
5647
|
+
let group;
|
|
5648
|
+
if (item instanceof DockviewPanel) {
|
|
5649
|
+
group = this.createGroup();
|
|
5650
|
+
this.removePanel(item, {
|
|
5651
|
+
removeEmptyGroup: true,
|
|
5652
|
+
skipDispose: true,
|
|
5653
|
+
});
|
|
5654
|
+
group.model.openPanel(item);
|
|
5655
|
+
}
|
|
5656
|
+
else {
|
|
5657
|
+
group = item;
|
|
5658
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
5659
|
+
options.skipRemoveGroup;
|
|
5660
|
+
if (!skip) {
|
|
5661
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
group.model.isFloating = true;
|
|
5665
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
5666
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
5667
|
+
const overlay = new Overlay({
|
|
5668
|
+
container: this.gridview.element,
|
|
5669
|
+
content: group.element,
|
|
5670
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
5671
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
5672
|
+
left: overlayLeft,
|
|
5673
|
+
top: overlayTop,
|
|
5674
|
+
minimumInViewportWidth: 100,
|
|
5675
|
+
minimumInViewportHeight: 100,
|
|
5676
|
+
});
|
|
5677
|
+
const el = group.element.querySelector('.void-container');
|
|
5678
|
+
if (!el) {
|
|
5679
|
+
throw new Error('failed to find drag handle');
|
|
5680
|
+
}
|
|
5681
|
+
overlay.setupDrag(el, {
|
|
5682
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
5683
|
+
? options.inDragMode
|
|
5684
|
+
: false,
|
|
5685
|
+
});
|
|
5686
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
5687
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
5688
|
+
const { width, height } = entry.contentRect;
|
|
5689
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
5690
|
+
});
|
|
5691
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
5692
|
+
// this is either a resize or a move
|
|
5693
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
5694
|
+
// don't care about resize since the above watcher handles that
|
|
5695
|
+
group.layout(group.height, group.width);
|
|
5696
|
+
}), overlay.onDidChangeEnd(() => {
|
|
5697
|
+
this._bufferOnDidLayoutChange.fire();
|
|
5698
|
+
}), group.onDidChange((event) => {
|
|
5699
|
+
overlay.setBounds({
|
|
5700
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
5701
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
5702
|
+
});
|
|
5703
|
+
}), {
|
|
5704
|
+
dispose: () => {
|
|
5705
|
+
disposable.dispose();
|
|
5706
|
+
group.model.isFloating = false;
|
|
5707
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
5708
|
+
this.updateWatermark();
|
|
5709
|
+
},
|
|
5710
|
+
});
|
|
5711
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
5712
|
+
this.updateWatermark();
|
|
5713
|
+
}
|
|
5183
5714
|
orthogonalize(position) {
|
|
5184
5715
|
switch (position) {
|
|
5185
5716
|
case 'top':
|
|
@@ -5202,6 +5733,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5202
5733
|
switch (position) {
|
|
5203
5734
|
case 'top':
|
|
5204
5735
|
case 'left':
|
|
5736
|
+
case 'center':
|
|
5205
5737
|
return this.createGroupAtLocation([0]); // insert into first position
|
|
5206
5738
|
case 'bottom':
|
|
5207
5739
|
case 'right':
|
|
@@ -5219,6 +5751,15 @@ class DockviewComponent extends BaseGrid {
|
|
|
5219
5751
|
}
|
|
5220
5752
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
5221
5753
|
}
|
|
5754
|
+
layout(width, height, forceResize) {
|
|
5755
|
+
super.layout(width, height, forceResize);
|
|
5756
|
+
if (this.floatingGroups) {
|
|
5757
|
+
for (const floating of this.floatingGroups) {
|
|
5758
|
+
// ensure floting groups stay within visible boundaries
|
|
5759
|
+
floating.overlay.setBounds();
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5222
5763
|
focus() {
|
|
5223
5764
|
var _a;
|
|
5224
5765
|
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -5281,51 +5822,81 @@ class DockviewComponent extends BaseGrid {
|
|
|
5281
5822
|
collection[panel.id] = panel.toJSON();
|
|
5282
5823
|
return collection;
|
|
5283
5824
|
}, {});
|
|
5284
|
-
|
|
5825
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
5826
|
+
return {
|
|
5827
|
+
data: floatingGroup.group.toJSON(),
|
|
5828
|
+
position: floatingGroup.overlay.toJSON(),
|
|
5829
|
+
};
|
|
5830
|
+
});
|
|
5831
|
+
const result = {
|
|
5285
5832
|
grid: data,
|
|
5286
5833
|
panels,
|
|
5287
5834
|
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
5288
5835
|
};
|
|
5836
|
+
if (floats.length > 0) {
|
|
5837
|
+
result.floatingGroups = floats;
|
|
5838
|
+
}
|
|
5839
|
+
return result;
|
|
5289
5840
|
}
|
|
5290
5841
|
fromJSON(data) {
|
|
5842
|
+
var _a;
|
|
5291
5843
|
this.clear();
|
|
5292
5844
|
const { grid, panels, activeGroup } = data;
|
|
5293
5845
|
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
5294
5846
|
throw new Error('root must be of type branch');
|
|
5295
5847
|
}
|
|
5848
|
+
// take note of the existing dimensions
|
|
5849
|
+
const width = this.width;
|
|
5850
|
+
const height = this.height;
|
|
5851
|
+
const createGroupFromSerializedState = (data) => {
|
|
5852
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
5853
|
+
const group = this.createGroup({
|
|
5854
|
+
id,
|
|
5855
|
+
locked: !!locked,
|
|
5856
|
+
hideHeader: !!hideHeader,
|
|
5857
|
+
});
|
|
5858
|
+
this._onDidAddGroup.fire(group);
|
|
5859
|
+
for (const child of views) {
|
|
5860
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5861
|
+
const isActive = typeof activeView === 'string' && activeView === panel.id;
|
|
5862
|
+
group.model.openPanel(panel, {
|
|
5863
|
+
skipSetPanelActive: !isActive,
|
|
5864
|
+
skipSetGroupActive: true,
|
|
5865
|
+
});
|
|
5866
|
+
}
|
|
5867
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
5868
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5869
|
+
skipSetGroupActive: true,
|
|
5870
|
+
});
|
|
5871
|
+
}
|
|
5872
|
+
return group;
|
|
5873
|
+
};
|
|
5296
5874
|
this.gridview.deserialize(grid, {
|
|
5297
5875
|
fromJSON: (node) => {
|
|
5298
|
-
|
|
5299
|
-
const group = this.createGroup({
|
|
5300
|
-
id,
|
|
5301
|
-
locked: !!locked,
|
|
5302
|
-
hideHeader: !!hideHeader,
|
|
5303
|
-
});
|
|
5304
|
-
this._onDidAddGroup.fire(group);
|
|
5305
|
-
for (const child of views) {
|
|
5306
|
-
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5307
|
-
const isActive = typeof activeView === 'string' &&
|
|
5308
|
-
activeView === panel.id;
|
|
5309
|
-
group.model.openPanel(panel, {
|
|
5310
|
-
skipSetPanelActive: !isActive,
|
|
5311
|
-
skipSetGroupActive: true,
|
|
5312
|
-
});
|
|
5313
|
-
}
|
|
5314
|
-
if (!group.activePanel && group.panels.length > 0) {
|
|
5315
|
-
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5316
|
-
skipSetGroupActive: true,
|
|
5317
|
-
});
|
|
5318
|
-
}
|
|
5319
|
-
return group;
|
|
5876
|
+
return createGroupFromSerializedState(node.data);
|
|
5320
5877
|
},
|
|
5321
5878
|
});
|
|
5879
|
+
this.layout(width, height, true);
|
|
5880
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
5881
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
5882
|
+
const { data, position } = serializedFloatingGroup;
|
|
5883
|
+
const group = createGroupFromSerializedState(data);
|
|
5884
|
+
this.addFloatingGroup(group, {
|
|
5885
|
+
x: position.left,
|
|
5886
|
+
y: position.top,
|
|
5887
|
+
height: position.height,
|
|
5888
|
+
width: position.width,
|
|
5889
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
5890
|
+
}
|
|
5891
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
5892
|
+
floatingGroup.overlay.setBounds();
|
|
5893
|
+
}
|
|
5322
5894
|
if (typeof activeGroup === 'string') {
|
|
5323
5895
|
const panel = this.getPanel(activeGroup);
|
|
5324
5896
|
if (panel) {
|
|
5325
5897
|
this.doSetGroupActive(panel);
|
|
5326
5898
|
}
|
|
5327
5899
|
}
|
|
5328
|
-
this.gridview.layout(this.width, this.height);
|
|
5329
5900
|
this._onDidLayoutFromJSON.fire();
|
|
5330
5901
|
}
|
|
5331
5902
|
clear() {
|
|
@@ -5334,7 +5905,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5334
5905
|
const hasActivePanel = !!this.activePanel;
|
|
5335
5906
|
for (const group of groups) {
|
|
5336
5907
|
// remove the group will automatically remove the panels
|
|
5337
|
-
this.removeGroup(group, true);
|
|
5908
|
+
this.removeGroup(group, { skipActive: true });
|
|
5338
5909
|
}
|
|
5339
5910
|
if (hasActiveGroup) {
|
|
5340
5911
|
this.doSetGroupActive(undefined);
|
|
@@ -5356,6 +5927,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5356
5927
|
throw new Error(`panel with id ${options.id} already exists`);
|
|
5357
5928
|
}
|
|
5358
5929
|
let referenceGroup;
|
|
5930
|
+
if (options.position && options.floating) {
|
|
5931
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
5932
|
+
}
|
|
5359
5933
|
if (options.position) {
|
|
5360
5934
|
if (isPanelOptionsWithPanel(options.position)) {
|
|
5361
5935
|
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
@@ -5388,7 +5962,20 @@ class DockviewComponent extends BaseGrid {
|
|
|
5388
5962
|
let panel;
|
|
5389
5963
|
if (referenceGroup) {
|
|
5390
5964
|
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
5391
|
-
if (
|
|
5965
|
+
if (options.floating) {
|
|
5966
|
+
const group = this.createGroup();
|
|
5967
|
+
panel = this.createPanel(options, group);
|
|
5968
|
+
group.model.openPanel(panel);
|
|
5969
|
+
const o = typeof options.floating === 'object' &&
|
|
5970
|
+
options.floating !== null
|
|
5971
|
+
? options.floating
|
|
5972
|
+
: {};
|
|
5973
|
+
this.addFloatingGroup(group, o, {
|
|
5974
|
+
inDragMode: false,
|
|
5975
|
+
skipRemoveGroup: true,
|
|
5976
|
+
});
|
|
5977
|
+
}
|
|
5978
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
5392
5979
|
panel = this.createPanel(options, referenceGroup);
|
|
5393
5980
|
referenceGroup.model.openPanel(panel);
|
|
5394
5981
|
}
|
|
@@ -5400,6 +5987,19 @@ class DockviewComponent extends BaseGrid {
|
|
|
5400
5987
|
group.model.openPanel(panel);
|
|
5401
5988
|
}
|
|
5402
5989
|
}
|
|
5990
|
+
else if (options.floating) {
|
|
5991
|
+
const group = this.createGroup();
|
|
5992
|
+
panel = this.createPanel(options, group);
|
|
5993
|
+
group.model.openPanel(panel);
|
|
5994
|
+
const o = typeof options.floating === 'object' &&
|
|
5995
|
+
options.floating !== null
|
|
5996
|
+
? options.floating
|
|
5997
|
+
: {};
|
|
5998
|
+
this.addFloatingGroup(group, o, {
|
|
5999
|
+
inDragMode: false,
|
|
6000
|
+
skipRemoveGroup: true,
|
|
6001
|
+
});
|
|
6002
|
+
}
|
|
5403
6003
|
else {
|
|
5404
6004
|
const group = this.createGroupAtLocation();
|
|
5405
6005
|
panel = this.createPanel(options, group);
|
|
@@ -5416,7 +6016,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5416
6016
|
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
5417
6017
|
}
|
|
5418
6018
|
group.model.removePanel(panel);
|
|
5419
|
-
|
|
6019
|
+
if (!options.skipDispose) {
|
|
6020
|
+
panel.dispose();
|
|
6021
|
+
}
|
|
5420
6022
|
if (group.size === 0 && options.removeEmptyGroup) {
|
|
5421
6023
|
this.removeGroup(group);
|
|
5422
6024
|
}
|
|
@@ -5431,7 +6033,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5431
6033
|
}
|
|
5432
6034
|
updateWatermark() {
|
|
5433
6035
|
var _a, _b;
|
|
5434
|
-
if (this.groups.length === 0) {
|
|
6036
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
5435
6037
|
if (!this.watermark) {
|
|
5436
6038
|
this.watermark = this.createWatermarkComponent();
|
|
5437
6039
|
this.watermark.init({
|
|
@@ -5440,7 +6042,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5440
6042
|
const watermarkContainer = document.createElement('div');
|
|
5441
6043
|
watermarkContainer.className = 'dv-watermark-container';
|
|
5442
6044
|
watermarkContainer.appendChild(this.watermark.element);
|
|
5443
|
-
this.element.appendChild(watermarkContainer);
|
|
6045
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
5444
6046
|
}
|
|
5445
6047
|
}
|
|
5446
6048
|
else if (this.watermark) {
|
|
@@ -5490,15 +6092,28 @@ class DockviewComponent extends BaseGrid {
|
|
|
5490
6092
|
return group;
|
|
5491
6093
|
}
|
|
5492
6094
|
}
|
|
5493
|
-
removeGroup(group,
|
|
6095
|
+
removeGroup(group, options) {
|
|
6096
|
+
var _a;
|
|
5494
6097
|
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
5495
6098
|
for (const panel of panels) {
|
|
5496
6099
|
this.removePanel(panel, {
|
|
5497
6100
|
removeEmptyGroup: false,
|
|
5498
|
-
skipDispose: false,
|
|
6101
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
5499
6102
|
});
|
|
5500
6103
|
}
|
|
5501
|
-
|
|
6104
|
+
this.doRemoveGroup(group, options);
|
|
6105
|
+
}
|
|
6106
|
+
doRemoveGroup(group, options) {
|
|
6107
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
6108
|
+
if (floatingGroup) {
|
|
6109
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
6110
|
+
floatingGroup.group.dispose();
|
|
6111
|
+
this._groups.delete(group.id);
|
|
6112
|
+
}
|
|
6113
|
+
floatingGroup.dispose();
|
|
6114
|
+
return floatingGroup.group;
|
|
6115
|
+
}
|
|
6116
|
+
return super.doRemoveGroup(group, options);
|
|
5502
6117
|
}
|
|
5503
6118
|
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5504
6119
|
var _a;
|
|
@@ -5529,25 +6144,26 @@ class DockviewComponent extends BaseGrid {
|
|
|
5529
6144
|
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5530
6145
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5531
6146
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5532
|
-
const
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
5543
|
-
skipActive: true,
|
|
5544
|
-
skipDispose: true,
|
|
5545
|
-
});
|
|
5546
|
-
// after deleting the group we need to re-evaulate the ref location
|
|
5547
|
-
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5548
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5549
|
-
this.doAddGroup(targetGroup, location);
|
|
6147
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6148
|
+
if (!isFloating) {
|
|
6149
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
6150
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
6151
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
6152
|
+
// special case when 'swapping' two views within same grid location
|
|
6153
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
6154
|
+
// which is equivalent to swapping two views in this case
|
|
6155
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
6156
|
+
}
|
|
5550
6157
|
}
|
|
6158
|
+
// source group will become empty so delete the group
|
|
6159
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
6160
|
+
skipActive: true,
|
|
6161
|
+
skipDispose: true,
|
|
6162
|
+
});
|
|
6163
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
6164
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
6165
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
6166
|
+
this.doAddGroup(targetGroup, location);
|
|
5551
6167
|
}
|
|
5552
6168
|
else {
|
|
5553
6169
|
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
@@ -5576,7 +6192,13 @@ class DockviewComponent extends BaseGrid {
|
|
|
5576
6192
|
}
|
|
5577
6193
|
}
|
|
5578
6194
|
else {
|
|
5579
|
-
this.
|
|
6195
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6196
|
+
if (floatingGroup) {
|
|
6197
|
+
floatingGroup.dispose();
|
|
6198
|
+
}
|
|
6199
|
+
else {
|
|
6200
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
6201
|
+
}
|
|
5580
6202
|
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
5581
6203
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
5582
6204
|
this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
|
|
@@ -5731,6 +6353,9 @@ class GridviewComponent extends BaseGrid {
|
|
|
5731
6353
|
this.clear();
|
|
5732
6354
|
const { grid, activePanel } = serializedGridview;
|
|
5733
6355
|
const queue = [];
|
|
6356
|
+
// take note of the existing dimensions
|
|
6357
|
+
const width = this.width;
|
|
6358
|
+
const height = this.height;
|
|
5734
6359
|
this.gridview.deserialize(grid, {
|
|
5735
6360
|
fromJSON: (node) => {
|
|
5736
6361
|
const { data } = node;
|
|
@@ -5756,7 +6381,7 @@ class GridviewComponent extends BaseGrid {
|
|
|
5756
6381
|
return view;
|
|
5757
6382
|
},
|
|
5758
6383
|
});
|
|
5759
|
-
this.layout(
|
|
6384
|
+
this.layout(width, height, true);
|
|
5760
6385
|
queue.forEach((f) => f());
|
|
5761
6386
|
if (typeof activePanel === 'string') {
|
|
5762
6387
|
const panel = this.getPanel(activePanel);
|
|
@@ -6070,6 +6695,9 @@ class SplitviewComponent extends Resizable {
|
|
|
6070
6695
|
this.clear();
|
|
6071
6696
|
const { views, orientation, size, activeView } = serializedSplitview;
|
|
6072
6697
|
const queue = [];
|
|
6698
|
+
// take note of the existing dimensions
|
|
6699
|
+
const width = this.width;
|
|
6700
|
+
const height = this.height;
|
|
6073
6701
|
this.splitview = new Splitview(this.element, {
|
|
6074
6702
|
orientation,
|
|
6075
6703
|
proportionalLayout: this.options.proportionalLayout,
|
|
@@ -6106,7 +6734,7 @@ class SplitviewComponent extends Resizable {
|
|
|
6106
6734
|
}),
|
|
6107
6735
|
},
|
|
6108
6736
|
});
|
|
6109
|
-
this.layout(
|
|
6737
|
+
this.layout(width, height);
|
|
6110
6738
|
queue.forEach((f) => f());
|
|
6111
6739
|
if (typeof activeView === 'string') {
|
|
6112
6740
|
const panel = this.getPanel(activeView);
|
|
@@ -6373,6 +7001,9 @@ class PaneviewComponent extends Resizable {
|
|
|
6373
7001
|
this.clear();
|
|
6374
7002
|
const { views, size } = serializedPaneview;
|
|
6375
7003
|
const queue = [];
|
|
7004
|
+
// take note of the existing dimensions
|
|
7005
|
+
const width = this.width;
|
|
7006
|
+
const height = this.height;
|
|
6376
7007
|
this.paneview = new Paneview(this.element, {
|
|
6377
7008
|
orientation: exports.Orientation.VERTICAL,
|
|
6378
7009
|
descriptor: {
|
|
@@ -6428,7 +7059,7 @@ class PaneviewComponent extends Resizable {
|
|
|
6428
7059
|
}),
|
|
6429
7060
|
},
|
|
6430
7061
|
});
|
|
6431
|
-
this.layout(
|
|
7062
|
+
this.layout(width, height);
|
|
6432
7063
|
queue.forEach((f) => f());
|
|
6433
7064
|
this._onDidLayoutfromJSON.fire();
|
|
6434
7065
|
}
|
|
@@ -6811,7 +7442,7 @@ class ReactWatermarkPart {
|
|
|
6811
7442
|
}
|
|
6812
7443
|
}
|
|
6813
7444
|
|
|
6814
|
-
class
|
|
7445
|
+
class ReactHeaderActionsRendererPart {
|
|
6815
7446
|
get element() {
|
|
6816
7447
|
return this._element;
|
|
6817
7448
|
}
|
|
@@ -6848,6 +7479,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6848
7479
|
panels: this._group.model.panels,
|
|
6849
7480
|
activePanel: this._group.model.activePanel,
|
|
6850
7481
|
isGroupActive: this._group.api.isActive,
|
|
7482
|
+
group: this._group,
|
|
6851
7483
|
});
|
|
6852
7484
|
}
|
|
6853
7485
|
update(event) {
|
|
@@ -6881,7 +7513,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6881
7513
|
function createGroupControlElement(component, store) {
|
|
6882
7514
|
return component
|
|
6883
7515
|
? (groupPanel) => {
|
|
6884
|
-
return new
|
|
7516
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
6885
7517
|
}
|
|
6886
7518
|
: undefined;
|
|
6887
7519
|
}
|
|
@@ -6938,8 +7570,10 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
|
|
|
6938
7570
|
? { separatorBorder: 'transparent' }
|
|
6939
7571
|
: undefined,
|
|
6940
7572
|
showDndOverlay: props.showDndOverlay,
|
|
6941
|
-
|
|
7573
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7574
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
6942
7575
|
singleTabMode: props.singleTabMode,
|
|
7576
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
6943
7577
|
});
|
|
6944
7578
|
const { clientWidth, clientHeight } = domRef.current;
|
|
6945
7579
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -6998,6 +7632,14 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
|
|
|
6998
7632
|
frameworkTabComponents: props.tabComponents,
|
|
6999
7633
|
});
|
|
7000
7634
|
}, [props.tabComponents]);
|
|
7635
|
+
React__namespace.useEffect(() => {
|
|
7636
|
+
if (!dockviewRef.current) {
|
|
7637
|
+
return;
|
|
7638
|
+
}
|
|
7639
|
+
dockviewRef.current.updateOptions({
|
|
7640
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
7641
|
+
});
|
|
7642
|
+
}, [props.disableFloatingGroups]);
|
|
7001
7643
|
React__namespace.useEffect(() => {
|
|
7002
7644
|
if (!dockviewRef.current) {
|
|
7003
7645
|
return;
|
|
@@ -7019,9 +7661,17 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
|
|
|
7019
7661
|
return;
|
|
7020
7662
|
}
|
|
7021
7663
|
dockviewRef.current.updateOptions({
|
|
7022
|
-
|
|
7664
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
7665
|
+
});
|
|
7666
|
+
}, [props.rightHeaderActionsComponent]);
|
|
7667
|
+
React__namespace.useEffect(() => {
|
|
7668
|
+
if (!dockviewRef.current) {
|
|
7669
|
+
return;
|
|
7670
|
+
}
|
|
7671
|
+
dockviewRef.current.updateOptions({
|
|
7672
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7023
7673
|
});
|
|
7024
|
-
}, [props.
|
|
7674
|
+
}, [props.leftHeaderActionsComponent]);
|
|
7025
7675
|
return (React__namespace.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
7026
7676
|
});
|
|
7027
7677
|
DockviewReact.displayName = 'DockviewComponent';
|
|
@@ -7040,6 +7690,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
7040
7690
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
7041
7691
|
PERFORMANCE OF THIS SOFTWARE.
|
|
7042
7692
|
***************************************************************************** */
|
|
7693
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
7694
|
+
|
|
7043
7695
|
|
|
7044
7696
|
function __rest(s, e) {
|
|
7045
7697
|
var t = {};
|
|
@@ -7051,7 +7703,12 @@ function __rest(s, e) {
|
|
|
7051
7703
|
t[p[i]] = s[p[i]];
|
|
7052
7704
|
}
|
|
7053
7705
|
return t;
|
|
7054
|
-
}
|
|
7706
|
+
}
|
|
7707
|
+
|
|
7708
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
7709
|
+
var e = new Error(message);
|
|
7710
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
7711
|
+
};
|
|
7055
7712
|
|
|
7056
7713
|
const CloseButton = () => (React__namespace.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
|
|
7057
7714
|
React__namespace.createElement("path", { d: "M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z" })));
|
|
@@ -7379,4 +8036,4 @@ exports.orthogonal = orthogonal;
|
|
|
7379
8036
|
exports.positionToDirection = positionToDirection;
|
|
7380
8037
|
exports.toTarget = toTarget;
|
|
7381
8038
|
exports.usePortalsLifecycle = usePortalsLifecycle;
|
|
7382
|
-
|
|
8039
|
+
//# sourceMappingURL=dockview.cjs.js.map
|