dockview 1.7.6 → 1.8.1
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 +803 -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 +803 -138
- package/dist/dockview.amd.noStyle.js.map +1 -0
- package/dist/dockview.cjs.js +803 -138
- package/dist/dockview.cjs.js.map +1 -0
- package/dist/dockview.esm.js +804 -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 +803 -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 +803 -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.1
|
|
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) {
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
if (this.rightActions) {
|
|
3209
|
+
this.rightActions.remove();
|
|
3210
|
+
this.rightActions = undefined;
|
|
3211
|
+
}
|
|
3212
|
+
if (element) {
|
|
3213
|
+
this.rightActionsContainer.appendChild(element);
|
|
3214
|
+
this.rightActions = element;
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
setLeftActionsElement(element) {
|
|
3218
|
+
if (this.leftActions === element) {
|
|
3142
3219
|
return;
|
|
3143
3220
|
}
|
|
3144
|
-
if (this.
|
|
3145
|
-
this.
|
|
3146
|
-
this.
|
|
3221
|
+
if (this.leftActions) {
|
|
3222
|
+
this.leftActions.remove();
|
|
3223
|
+
this.leftActions = undefined;
|
|
3147
3224
|
}
|
|
3148
3225
|
if (element) {
|
|
3149
|
-
this.
|
|
3150
|
-
this.
|
|
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,9 +5607,22 @@ 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) {
|
|
5618
|
+
if (position === 'center') {
|
|
5619
|
+
/**
|
|
5620
|
+
* for external events only show the four-corner drag overlays, disable
|
|
5621
|
+
* the center position so that external drag events can fall through to the group
|
|
5622
|
+
* and panel drop target handlers
|
|
5623
|
+
*/
|
|
5624
|
+
return false;
|
|
5625
|
+
}
|
|
5156
5626
|
return this.options.showDndOverlay({
|
|
5157
5627
|
nativeEvent: event,
|
|
5158
5628
|
position: position,
|
|
@@ -5162,7 +5632,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5162
5632
|
}
|
|
5163
5633
|
return false;
|
|
5164
5634
|
},
|
|
5165
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
|
|
5635
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5166
5636
|
overlayModel: {
|
|
5167
5637
|
activationSize: { type: 'pixels', value: 10 },
|
|
5168
5638
|
size: { type: 'pixels', value: 20 },
|
|
@@ -5180,6 +5650,75 @@ class DockviewComponent extends BaseGrid {
|
|
|
5180
5650
|
this._api = new DockviewApi(this);
|
|
5181
5651
|
this.updateWatermark();
|
|
5182
5652
|
}
|
|
5653
|
+
addFloatingGroup(item, coord, options) {
|
|
5654
|
+
var _a, _b;
|
|
5655
|
+
let group;
|
|
5656
|
+
if (item instanceof DockviewPanel) {
|
|
5657
|
+
group = this.createGroup();
|
|
5658
|
+
this.removePanel(item, {
|
|
5659
|
+
removeEmptyGroup: true,
|
|
5660
|
+
skipDispose: true,
|
|
5661
|
+
});
|
|
5662
|
+
group.model.openPanel(item);
|
|
5663
|
+
}
|
|
5664
|
+
else {
|
|
5665
|
+
group = item;
|
|
5666
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
5667
|
+
options.skipRemoveGroup;
|
|
5668
|
+
if (!skip) {
|
|
5669
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
5670
|
+
}
|
|
5671
|
+
}
|
|
5672
|
+
group.model.isFloating = true;
|
|
5673
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
5674
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
5675
|
+
const overlay = new Overlay({
|
|
5676
|
+
container: this.gridview.element,
|
|
5677
|
+
content: group.element,
|
|
5678
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
5679
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
5680
|
+
left: overlayLeft,
|
|
5681
|
+
top: overlayTop,
|
|
5682
|
+
minimumInViewportWidth: 100,
|
|
5683
|
+
minimumInViewportHeight: 100,
|
|
5684
|
+
});
|
|
5685
|
+
const el = group.element.querySelector('.void-container');
|
|
5686
|
+
if (!el) {
|
|
5687
|
+
throw new Error('failed to find drag handle');
|
|
5688
|
+
}
|
|
5689
|
+
overlay.setupDrag(el, {
|
|
5690
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
5691
|
+
? options.inDragMode
|
|
5692
|
+
: false,
|
|
5693
|
+
});
|
|
5694
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
5695
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
5696
|
+
const { width, height } = entry.contentRect;
|
|
5697
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
5698
|
+
});
|
|
5699
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
5700
|
+
// this is either a resize or a move
|
|
5701
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
5702
|
+
// don't care about resize since the above watcher handles that
|
|
5703
|
+
group.layout(group.height, group.width);
|
|
5704
|
+
}), overlay.onDidChangeEnd(() => {
|
|
5705
|
+
this._bufferOnDidLayoutChange.fire();
|
|
5706
|
+
}), group.onDidChange((event) => {
|
|
5707
|
+
overlay.setBounds({
|
|
5708
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
5709
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
5710
|
+
});
|
|
5711
|
+
}), {
|
|
5712
|
+
dispose: () => {
|
|
5713
|
+
disposable.dispose();
|
|
5714
|
+
group.model.isFloating = false;
|
|
5715
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
5716
|
+
this.updateWatermark();
|
|
5717
|
+
},
|
|
5718
|
+
});
|
|
5719
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
5720
|
+
this.updateWatermark();
|
|
5721
|
+
}
|
|
5183
5722
|
orthogonalize(position) {
|
|
5184
5723
|
switch (position) {
|
|
5185
5724
|
case 'top':
|
|
@@ -5202,6 +5741,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5202
5741
|
switch (position) {
|
|
5203
5742
|
case 'top':
|
|
5204
5743
|
case 'left':
|
|
5744
|
+
case 'center':
|
|
5205
5745
|
return this.createGroupAtLocation([0]); // insert into first position
|
|
5206
5746
|
case 'bottom':
|
|
5207
5747
|
case 'right':
|
|
@@ -5219,6 +5759,15 @@ class DockviewComponent extends BaseGrid {
|
|
|
5219
5759
|
}
|
|
5220
5760
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
5221
5761
|
}
|
|
5762
|
+
layout(width, height, forceResize) {
|
|
5763
|
+
super.layout(width, height, forceResize);
|
|
5764
|
+
if (this.floatingGroups) {
|
|
5765
|
+
for (const floating of this.floatingGroups) {
|
|
5766
|
+
// ensure floting groups stay within visible boundaries
|
|
5767
|
+
floating.overlay.setBounds();
|
|
5768
|
+
}
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5222
5771
|
focus() {
|
|
5223
5772
|
var _a;
|
|
5224
5773
|
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -5281,51 +5830,81 @@ class DockviewComponent extends BaseGrid {
|
|
|
5281
5830
|
collection[panel.id] = panel.toJSON();
|
|
5282
5831
|
return collection;
|
|
5283
5832
|
}, {});
|
|
5284
|
-
|
|
5833
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
5834
|
+
return {
|
|
5835
|
+
data: floatingGroup.group.toJSON(),
|
|
5836
|
+
position: floatingGroup.overlay.toJSON(),
|
|
5837
|
+
};
|
|
5838
|
+
});
|
|
5839
|
+
const result = {
|
|
5285
5840
|
grid: data,
|
|
5286
5841
|
panels,
|
|
5287
5842
|
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
5288
5843
|
};
|
|
5844
|
+
if (floats.length > 0) {
|
|
5845
|
+
result.floatingGroups = floats;
|
|
5846
|
+
}
|
|
5847
|
+
return result;
|
|
5289
5848
|
}
|
|
5290
5849
|
fromJSON(data) {
|
|
5850
|
+
var _a;
|
|
5291
5851
|
this.clear();
|
|
5292
5852
|
const { grid, panels, activeGroup } = data;
|
|
5293
5853
|
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
5294
5854
|
throw new Error('root must be of type branch');
|
|
5295
5855
|
}
|
|
5856
|
+
// take note of the existing dimensions
|
|
5857
|
+
const width = this.width;
|
|
5858
|
+
const height = this.height;
|
|
5859
|
+
const createGroupFromSerializedState = (data) => {
|
|
5860
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
5861
|
+
const group = this.createGroup({
|
|
5862
|
+
id,
|
|
5863
|
+
locked: !!locked,
|
|
5864
|
+
hideHeader: !!hideHeader,
|
|
5865
|
+
});
|
|
5866
|
+
this._onDidAddGroup.fire(group);
|
|
5867
|
+
for (const child of views) {
|
|
5868
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5869
|
+
const isActive = typeof activeView === 'string' && activeView === panel.id;
|
|
5870
|
+
group.model.openPanel(panel, {
|
|
5871
|
+
skipSetPanelActive: !isActive,
|
|
5872
|
+
skipSetGroupActive: true,
|
|
5873
|
+
});
|
|
5874
|
+
}
|
|
5875
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
5876
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5877
|
+
skipSetGroupActive: true,
|
|
5878
|
+
});
|
|
5879
|
+
}
|
|
5880
|
+
return group;
|
|
5881
|
+
};
|
|
5296
5882
|
this.gridview.deserialize(grid, {
|
|
5297
5883
|
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;
|
|
5884
|
+
return createGroupFromSerializedState(node.data);
|
|
5320
5885
|
},
|
|
5321
5886
|
});
|
|
5887
|
+
this.layout(width, height, true);
|
|
5888
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
5889
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
5890
|
+
const { data, position } = serializedFloatingGroup;
|
|
5891
|
+
const group = createGroupFromSerializedState(data);
|
|
5892
|
+
this.addFloatingGroup(group, {
|
|
5893
|
+
x: position.left,
|
|
5894
|
+
y: position.top,
|
|
5895
|
+
height: position.height,
|
|
5896
|
+
width: position.width,
|
|
5897
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
5898
|
+
}
|
|
5899
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
5900
|
+
floatingGroup.overlay.setBounds();
|
|
5901
|
+
}
|
|
5322
5902
|
if (typeof activeGroup === 'string') {
|
|
5323
5903
|
const panel = this.getPanel(activeGroup);
|
|
5324
5904
|
if (panel) {
|
|
5325
5905
|
this.doSetGroupActive(panel);
|
|
5326
5906
|
}
|
|
5327
5907
|
}
|
|
5328
|
-
this.gridview.layout(this.width, this.height);
|
|
5329
5908
|
this._onDidLayoutFromJSON.fire();
|
|
5330
5909
|
}
|
|
5331
5910
|
clear() {
|
|
@@ -5334,7 +5913,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5334
5913
|
const hasActivePanel = !!this.activePanel;
|
|
5335
5914
|
for (const group of groups) {
|
|
5336
5915
|
// remove the group will automatically remove the panels
|
|
5337
|
-
this.removeGroup(group, true);
|
|
5916
|
+
this.removeGroup(group, { skipActive: true });
|
|
5338
5917
|
}
|
|
5339
5918
|
if (hasActiveGroup) {
|
|
5340
5919
|
this.doSetGroupActive(undefined);
|
|
@@ -5356,6 +5935,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5356
5935
|
throw new Error(`panel with id ${options.id} already exists`);
|
|
5357
5936
|
}
|
|
5358
5937
|
let referenceGroup;
|
|
5938
|
+
if (options.position && options.floating) {
|
|
5939
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
5940
|
+
}
|
|
5359
5941
|
if (options.position) {
|
|
5360
5942
|
if (isPanelOptionsWithPanel(options.position)) {
|
|
5361
5943
|
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
@@ -5388,7 +5970,20 @@ class DockviewComponent extends BaseGrid {
|
|
|
5388
5970
|
let panel;
|
|
5389
5971
|
if (referenceGroup) {
|
|
5390
5972
|
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
5391
|
-
if (
|
|
5973
|
+
if (options.floating) {
|
|
5974
|
+
const group = this.createGroup();
|
|
5975
|
+
panel = this.createPanel(options, group);
|
|
5976
|
+
group.model.openPanel(panel);
|
|
5977
|
+
const o = typeof options.floating === 'object' &&
|
|
5978
|
+
options.floating !== null
|
|
5979
|
+
? options.floating
|
|
5980
|
+
: {};
|
|
5981
|
+
this.addFloatingGroup(group, o, {
|
|
5982
|
+
inDragMode: false,
|
|
5983
|
+
skipRemoveGroup: true,
|
|
5984
|
+
});
|
|
5985
|
+
}
|
|
5986
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
5392
5987
|
panel = this.createPanel(options, referenceGroup);
|
|
5393
5988
|
referenceGroup.model.openPanel(panel);
|
|
5394
5989
|
}
|
|
@@ -5400,6 +5995,19 @@ class DockviewComponent extends BaseGrid {
|
|
|
5400
5995
|
group.model.openPanel(panel);
|
|
5401
5996
|
}
|
|
5402
5997
|
}
|
|
5998
|
+
else if (options.floating) {
|
|
5999
|
+
const group = this.createGroup();
|
|
6000
|
+
panel = this.createPanel(options, group);
|
|
6001
|
+
group.model.openPanel(panel);
|
|
6002
|
+
const o = typeof options.floating === 'object' &&
|
|
6003
|
+
options.floating !== null
|
|
6004
|
+
? options.floating
|
|
6005
|
+
: {};
|
|
6006
|
+
this.addFloatingGroup(group, o, {
|
|
6007
|
+
inDragMode: false,
|
|
6008
|
+
skipRemoveGroup: true,
|
|
6009
|
+
});
|
|
6010
|
+
}
|
|
5403
6011
|
else {
|
|
5404
6012
|
const group = this.createGroupAtLocation();
|
|
5405
6013
|
panel = this.createPanel(options, group);
|
|
@@ -5416,7 +6024,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5416
6024
|
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
5417
6025
|
}
|
|
5418
6026
|
group.model.removePanel(panel);
|
|
5419
|
-
|
|
6027
|
+
if (!options.skipDispose) {
|
|
6028
|
+
panel.dispose();
|
|
6029
|
+
}
|
|
5420
6030
|
if (group.size === 0 && options.removeEmptyGroup) {
|
|
5421
6031
|
this.removeGroup(group);
|
|
5422
6032
|
}
|
|
@@ -5431,7 +6041,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5431
6041
|
}
|
|
5432
6042
|
updateWatermark() {
|
|
5433
6043
|
var _a, _b;
|
|
5434
|
-
if (this.groups.length === 0) {
|
|
6044
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
5435
6045
|
if (!this.watermark) {
|
|
5436
6046
|
this.watermark = this.createWatermarkComponent();
|
|
5437
6047
|
this.watermark.init({
|
|
@@ -5440,7 +6050,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5440
6050
|
const watermarkContainer = document.createElement('div');
|
|
5441
6051
|
watermarkContainer.className = 'dv-watermark-container';
|
|
5442
6052
|
watermarkContainer.appendChild(this.watermark.element);
|
|
5443
|
-
this.element.appendChild(watermarkContainer);
|
|
6053
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
5444
6054
|
}
|
|
5445
6055
|
}
|
|
5446
6056
|
else if (this.watermark) {
|
|
@@ -5490,15 +6100,28 @@ class DockviewComponent extends BaseGrid {
|
|
|
5490
6100
|
return group;
|
|
5491
6101
|
}
|
|
5492
6102
|
}
|
|
5493
|
-
removeGroup(group,
|
|
6103
|
+
removeGroup(group, options) {
|
|
6104
|
+
var _a;
|
|
5494
6105
|
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
5495
6106
|
for (const panel of panels) {
|
|
5496
6107
|
this.removePanel(panel, {
|
|
5497
6108
|
removeEmptyGroup: false,
|
|
5498
|
-
skipDispose: false,
|
|
6109
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
5499
6110
|
});
|
|
5500
6111
|
}
|
|
5501
|
-
|
|
6112
|
+
this.doRemoveGroup(group, options);
|
|
6113
|
+
}
|
|
6114
|
+
doRemoveGroup(group, options) {
|
|
6115
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
6116
|
+
if (floatingGroup) {
|
|
6117
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
6118
|
+
floatingGroup.group.dispose();
|
|
6119
|
+
this._groups.delete(group.id);
|
|
6120
|
+
}
|
|
6121
|
+
floatingGroup.dispose();
|
|
6122
|
+
return floatingGroup.group;
|
|
6123
|
+
}
|
|
6124
|
+
return super.doRemoveGroup(group, options);
|
|
5502
6125
|
}
|
|
5503
6126
|
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5504
6127
|
var _a;
|
|
@@ -5529,25 +6152,26 @@ class DockviewComponent extends BaseGrid {
|
|
|
5529
6152
|
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5530
6153
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5531
6154
|
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);
|
|
6155
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6156
|
+
if (!isFloating) {
|
|
6157
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
6158
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
6159
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
6160
|
+
// special case when 'swapping' two views within same grid location
|
|
6161
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
6162
|
+
// which is equivalent to swapping two views in this case
|
|
6163
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
6164
|
+
}
|
|
5550
6165
|
}
|
|
6166
|
+
// source group will become empty so delete the group
|
|
6167
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
6168
|
+
skipActive: true,
|
|
6169
|
+
skipDispose: true,
|
|
6170
|
+
});
|
|
6171
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
6172
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
6173
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
6174
|
+
this.doAddGroup(targetGroup, location);
|
|
5551
6175
|
}
|
|
5552
6176
|
else {
|
|
5553
6177
|
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
@@ -5576,7 +6200,13 @@ class DockviewComponent extends BaseGrid {
|
|
|
5576
6200
|
}
|
|
5577
6201
|
}
|
|
5578
6202
|
else {
|
|
5579
|
-
this.
|
|
6203
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6204
|
+
if (floatingGroup) {
|
|
6205
|
+
floatingGroup.dispose();
|
|
6206
|
+
}
|
|
6207
|
+
else {
|
|
6208
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
6209
|
+
}
|
|
5580
6210
|
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
5581
6211
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
5582
6212
|
this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
|
|
@@ -5731,6 +6361,9 @@ class GridviewComponent extends BaseGrid {
|
|
|
5731
6361
|
this.clear();
|
|
5732
6362
|
const { grid, activePanel } = serializedGridview;
|
|
5733
6363
|
const queue = [];
|
|
6364
|
+
// take note of the existing dimensions
|
|
6365
|
+
const width = this.width;
|
|
6366
|
+
const height = this.height;
|
|
5734
6367
|
this.gridview.deserialize(grid, {
|
|
5735
6368
|
fromJSON: (node) => {
|
|
5736
6369
|
const { data } = node;
|
|
@@ -5756,7 +6389,7 @@ class GridviewComponent extends BaseGrid {
|
|
|
5756
6389
|
return view;
|
|
5757
6390
|
},
|
|
5758
6391
|
});
|
|
5759
|
-
this.layout(
|
|
6392
|
+
this.layout(width, height, true);
|
|
5760
6393
|
queue.forEach((f) => f());
|
|
5761
6394
|
if (typeof activePanel === 'string') {
|
|
5762
6395
|
const panel = this.getPanel(activePanel);
|
|
@@ -6070,6 +6703,9 @@ class SplitviewComponent extends Resizable {
|
|
|
6070
6703
|
this.clear();
|
|
6071
6704
|
const { views, orientation, size, activeView } = serializedSplitview;
|
|
6072
6705
|
const queue = [];
|
|
6706
|
+
// take note of the existing dimensions
|
|
6707
|
+
const width = this.width;
|
|
6708
|
+
const height = this.height;
|
|
6073
6709
|
this.splitview = new Splitview(this.element, {
|
|
6074
6710
|
orientation,
|
|
6075
6711
|
proportionalLayout: this.options.proportionalLayout,
|
|
@@ -6106,7 +6742,7 @@ class SplitviewComponent extends Resizable {
|
|
|
6106
6742
|
}),
|
|
6107
6743
|
},
|
|
6108
6744
|
});
|
|
6109
|
-
this.layout(
|
|
6745
|
+
this.layout(width, height);
|
|
6110
6746
|
queue.forEach((f) => f());
|
|
6111
6747
|
if (typeof activeView === 'string') {
|
|
6112
6748
|
const panel = this.getPanel(activeView);
|
|
@@ -6373,6 +7009,9 @@ class PaneviewComponent extends Resizable {
|
|
|
6373
7009
|
this.clear();
|
|
6374
7010
|
const { views, size } = serializedPaneview;
|
|
6375
7011
|
const queue = [];
|
|
7012
|
+
// take note of the existing dimensions
|
|
7013
|
+
const width = this.width;
|
|
7014
|
+
const height = this.height;
|
|
6376
7015
|
this.paneview = new Paneview(this.element, {
|
|
6377
7016
|
orientation: exports.Orientation.VERTICAL,
|
|
6378
7017
|
descriptor: {
|
|
@@ -6428,7 +7067,7 @@ class PaneviewComponent extends Resizable {
|
|
|
6428
7067
|
}),
|
|
6429
7068
|
},
|
|
6430
7069
|
});
|
|
6431
|
-
this.layout(
|
|
7070
|
+
this.layout(width, height);
|
|
6432
7071
|
queue.forEach((f) => f());
|
|
6433
7072
|
this._onDidLayoutfromJSON.fire();
|
|
6434
7073
|
}
|
|
@@ -6811,7 +7450,7 @@ class ReactWatermarkPart {
|
|
|
6811
7450
|
}
|
|
6812
7451
|
}
|
|
6813
7452
|
|
|
6814
|
-
class
|
|
7453
|
+
class ReactHeaderActionsRendererPart {
|
|
6815
7454
|
get element() {
|
|
6816
7455
|
return this._element;
|
|
6817
7456
|
}
|
|
@@ -6848,6 +7487,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6848
7487
|
panels: this._group.model.panels,
|
|
6849
7488
|
activePanel: this._group.model.activePanel,
|
|
6850
7489
|
isGroupActive: this._group.api.isActive,
|
|
7490
|
+
group: this._group,
|
|
6851
7491
|
});
|
|
6852
7492
|
}
|
|
6853
7493
|
update(event) {
|
|
@@ -6881,7 +7521,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6881
7521
|
function createGroupControlElement(component, store) {
|
|
6882
7522
|
return component
|
|
6883
7523
|
? (groupPanel) => {
|
|
6884
|
-
return new
|
|
7524
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
6885
7525
|
}
|
|
6886
7526
|
: undefined;
|
|
6887
7527
|
}
|
|
@@ -6938,8 +7578,10 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
|
|
|
6938
7578
|
? { separatorBorder: 'transparent' }
|
|
6939
7579
|
: undefined,
|
|
6940
7580
|
showDndOverlay: props.showDndOverlay,
|
|
6941
|
-
|
|
7581
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7582
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
6942
7583
|
singleTabMode: props.singleTabMode,
|
|
7584
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
6943
7585
|
});
|
|
6944
7586
|
const { clientWidth, clientHeight } = domRef.current;
|
|
6945
7587
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -6998,6 +7640,14 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
|
|
|
6998
7640
|
frameworkTabComponents: props.tabComponents,
|
|
6999
7641
|
});
|
|
7000
7642
|
}, [props.tabComponents]);
|
|
7643
|
+
React__namespace.useEffect(() => {
|
|
7644
|
+
if (!dockviewRef.current) {
|
|
7645
|
+
return;
|
|
7646
|
+
}
|
|
7647
|
+
dockviewRef.current.updateOptions({
|
|
7648
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
7649
|
+
});
|
|
7650
|
+
}, [props.disableFloatingGroups]);
|
|
7001
7651
|
React__namespace.useEffect(() => {
|
|
7002
7652
|
if (!dockviewRef.current) {
|
|
7003
7653
|
return;
|
|
@@ -7019,9 +7669,17 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
|
|
|
7019
7669
|
return;
|
|
7020
7670
|
}
|
|
7021
7671
|
dockviewRef.current.updateOptions({
|
|
7022
|
-
|
|
7672
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
7673
|
+
});
|
|
7674
|
+
}, [props.rightHeaderActionsComponent]);
|
|
7675
|
+
React__namespace.useEffect(() => {
|
|
7676
|
+
if (!dockviewRef.current) {
|
|
7677
|
+
return;
|
|
7678
|
+
}
|
|
7679
|
+
dockviewRef.current.updateOptions({
|
|
7680
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7023
7681
|
});
|
|
7024
|
-
}, [props.
|
|
7682
|
+
}, [props.leftHeaderActionsComponent]);
|
|
7025
7683
|
return (React__namespace.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
7026
7684
|
});
|
|
7027
7685
|
DockviewReact.displayName = 'DockviewComponent';
|
|
@@ -7040,6 +7698,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
7040
7698
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
7041
7699
|
PERFORMANCE OF THIS SOFTWARE.
|
|
7042
7700
|
***************************************************************************** */
|
|
7701
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
7702
|
+
|
|
7043
7703
|
|
|
7044
7704
|
function __rest(s, e) {
|
|
7045
7705
|
var t = {};
|
|
@@ -7051,7 +7711,12 @@ function __rest(s, e) {
|
|
|
7051
7711
|
t[p[i]] = s[p[i]];
|
|
7052
7712
|
}
|
|
7053
7713
|
return t;
|
|
7054
|
-
}
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7716
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
7717
|
+
var e = new Error(message);
|
|
7718
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
7719
|
+
};
|
|
7055
7720
|
|
|
7056
7721
|
const CloseButton = () => (React__namespace.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
|
|
7057
7722
|
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 +8044,4 @@ exports.orthogonal = orthogonal;
|
|
|
7379
8044
|
exports.positionToDirection = positionToDirection;
|
|
7380
8045
|
exports.toTarget = toTarget;
|
|
7381
8046
|
exports.usePortalsLifecycle = usePortalsLifecycle;
|
|
7382
|
-
|
|
8047
|
+
//# sourceMappingURL=dockview.cjs.js.map
|