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.amd.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
|
*/
|
|
@@ -323,6 +323,31 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
327
|
+
const Component = typeof componentName === 'string'
|
|
328
|
+
? components[componentName]
|
|
329
|
+
: undefined;
|
|
330
|
+
const FrameworkComponent = typeof componentName === 'string'
|
|
331
|
+
? frameworkComponents[componentName]
|
|
332
|
+
: undefined;
|
|
333
|
+
if (Component && FrameworkComponent) {
|
|
334
|
+
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
335
|
+
}
|
|
336
|
+
if (FrameworkComponent) {
|
|
337
|
+
if (!createFrameworkComponent) {
|
|
338
|
+
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
339
|
+
}
|
|
340
|
+
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
341
|
+
}
|
|
342
|
+
if (!Component) {
|
|
343
|
+
if (fallback) {
|
|
344
|
+
return fallback();
|
|
345
|
+
}
|
|
346
|
+
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
347
|
+
}
|
|
348
|
+
return new Component(id, componentName);
|
|
349
|
+
}
|
|
350
|
+
|
|
326
351
|
function watchElementResize(element, cb) {
|
|
327
352
|
const observer = new ResizeObserver((entires) => {
|
|
328
353
|
/**
|
|
@@ -436,31 +461,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
436
461
|
refreshState() {
|
|
437
462
|
this._refreshStateHandler();
|
|
438
463
|
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
450
|
-
}
|
|
451
|
-
if (FrameworkComponent) {
|
|
452
|
-
if (!createFrameworkComponent) {
|
|
453
|
-
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
454
|
-
}
|
|
455
|
-
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
456
|
-
}
|
|
457
|
-
if (!Component) {
|
|
458
|
-
if (fallback) {
|
|
459
|
-
return fallback();
|
|
460
|
-
}
|
|
461
|
-
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
462
|
-
}
|
|
463
|
-
return new Component(id, componentName);
|
|
464
|
+
}
|
|
465
|
+
// quasi: apparently, but not really; seemingly
|
|
466
|
+
const QUASI_PREVENT_DEFAULT_KEY = 'dv-quasiPreventDefault';
|
|
467
|
+
// mark an event directly for other listeners to check
|
|
468
|
+
function quasiPreventDefault(event) {
|
|
469
|
+
event[QUASI_PREVENT_DEFAULT_KEY] = true;
|
|
470
|
+
}
|
|
471
|
+
// check if this event has been marked
|
|
472
|
+
function quasiDefaultPrevented(event) {
|
|
473
|
+
return event[QUASI_PREVENT_DEFAULT_KEY];
|
|
464
474
|
}
|
|
465
475
|
|
|
466
476
|
function tail(arr) {
|
|
@@ -511,6 +521,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
511
521
|
}
|
|
512
522
|
}
|
|
513
523
|
return -1;
|
|
524
|
+
}
|
|
525
|
+
function remove(array, value) {
|
|
526
|
+
const index = array.findIndex((t) => t === value);
|
|
527
|
+
if (index > -1) {
|
|
528
|
+
array.splice(index, 1);
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
return false;
|
|
514
532
|
}
|
|
515
533
|
|
|
516
534
|
const clamp = (value, min, max) => {
|
|
@@ -1653,7 +1671,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
1653
1671
|
: true,
|
|
1654
1672
|
};
|
|
1655
1673
|
}),
|
|
1656
|
-
size: this.
|
|
1674
|
+
size: this.orthogonalSize,
|
|
1657
1675
|
};
|
|
1658
1676
|
this.children = childDescriptors.map((c) => c.node);
|
|
1659
1677
|
this.splitview = new Splitview(this.element, {
|
|
@@ -1716,7 +1734,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
1716
1734
|
layout(size, orthogonalSize) {
|
|
1717
1735
|
this._size = orthogonalSize;
|
|
1718
1736
|
this._orthogonalSize = size;
|
|
1719
|
-
this.splitview.layout(
|
|
1737
|
+
this.splitview.layout(orthogonalSize, size);
|
|
1720
1738
|
}
|
|
1721
1739
|
addChild(node, size, index, skipLayout) {
|
|
1722
1740
|
if (index < 0 || index > this.children.length) {
|
|
@@ -1941,9 +1959,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
1941
1959
|
this._deserialize(json.root, orientation, deserializer, height);
|
|
1942
1960
|
}
|
|
1943
1961
|
_deserialize(root, orientation, deserializer, orthogonalSize) {
|
|
1944
|
-
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize
|
|
1962
|
+
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
|
|
1945
1963
|
}
|
|
1946
|
-
_deserializeNode(node, orientation, deserializer, orthogonalSize
|
|
1964
|
+
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
1947
1965
|
let result;
|
|
1948
1966
|
if (node.type === 'branch') {
|
|
1949
1967
|
const serializedChildren = node.data;
|
|
@@ -1953,9 +1971,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
1953
1971
|
visible: serializedChild.visible,
|
|
1954
1972
|
};
|
|
1955
1973
|
});
|
|
1956
|
-
//
|
|
1957
|
-
//
|
|
1958
|
-
|
|
1974
|
+
result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
|
|
1975
|
+
orthogonalSize, // <- size - flips at each depth
|
|
1976
|
+
children);
|
|
1959
1977
|
}
|
|
1960
1978
|
else {
|
|
1961
1979
|
result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
|
|
@@ -1988,7 +2006,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
1988
2006
|
const oldRoot = this.root;
|
|
1989
2007
|
oldRoot.element.remove();
|
|
1990
2008
|
this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
|
|
1991
|
-
if (oldRoot.children.length ===
|
|
2009
|
+
if (oldRoot.children.length === 0) ;
|
|
2010
|
+
else if (oldRoot.children.length === 1) {
|
|
1992
2011
|
// can remove one level of redundant branching if there is only a single child
|
|
1993
2012
|
const childReference = oldRoot.children[0];
|
|
1994
2013
|
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
@@ -2504,6 +2523,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2504
2523
|
addPanel(options) {
|
|
2505
2524
|
return this.component.addPanel(options);
|
|
2506
2525
|
}
|
|
2526
|
+
removePanel(panel) {
|
|
2527
|
+
this.component.removePanel(panel);
|
|
2528
|
+
}
|
|
2507
2529
|
addGroup(options) {
|
|
2508
2530
|
return this.component.addGroup(options);
|
|
2509
2531
|
}
|
|
@@ -2522,6 +2544,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2522
2544
|
getGroup(id) {
|
|
2523
2545
|
return this.component.getPanel(id);
|
|
2524
2546
|
}
|
|
2547
|
+
addFloatingGroup(item, coord) {
|
|
2548
|
+
return this.component.addFloatingGroup(item, coord);
|
|
2549
|
+
}
|
|
2525
2550
|
fromJSON(data) {
|
|
2526
2551
|
this.component.fromJSON(data);
|
|
2527
2552
|
}
|
|
@@ -2614,10 +2639,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2614
2639
|
this._onDrop = new Emitter();
|
|
2615
2640
|
this.onDrop = this._onDrop.event;
|
|
2616
2641
|
// use a set to take advantage of #<set>.has
|
|
2617
|
-
|
|
2642
|
+
this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
|
|
2618
2643
|
this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
|
|
2619
2644
|
onDragEnter: () => undefined,
|
|
2620
2645
|
onDragOver: (e) => {
|
|
2646
|
+
if (this._acceptedTargetZonesSet.size === 0) {
|
|
2647
|
+
this.removeDropTarget();
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2621
2650
|
const width = this.element.clientWidth;
|
|
2622
2651
|
const height = this.element.clientHeight;
|
|
2623
2652
|
if (width === 0 || height === 0) {
|
|
@@ -2626,20 +2655,28 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2626
2655
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
2627
2656
|
const x = e.clientX - rect.left;
|
|
2628
2657
|
const y = e.clientY - rect.top;
|
|
2629
|
-
const quadrant = this.calculateQuadrant(
|
|
2630
|
-
|
|
2658
|
+
const quadrant = this.calculateQuadrant(this._acceptedTargetZonesSet, x, y, width, height);
|
|
2659
|
+
/**
|
|
2660
|
+
* If the event has already been used by another DropTarget instance
|
|
2661
|
+
* then don't show a second drop target, only one target should be
|
|
2662
|
+
* active at any one time
|
|
2663
|
+
*/
|
|
2664
|
+
if (this.isAlreadyUsed(e) || quadrant === null) {
|
|
2631
2665
|
// no drop target should be displayed
|
|
2632
2666
|
this.removeDropTarget();
|
|
2633
2667
|
return;
|
|
2634
2668
|
}
|
|
2635
2669
|
if (typeof this.options.canDisplayOverlay === 'boolean') {
|
|
2636
2670
|
if (!this.options.canDisplayOverlay) {
|
|
2671
|
+
this.removeDropTarget();
|
|
2637
2672
|
return;
|
|
2638
2673
|
}
|
|
2639
2674
|
}
|
|
2640
2675
|
else if (!this.options.canDisplayOverlay(e, quadrant)) {
|
|
2676
|
+
this.removeDropTarget();
|
|
2641
2677
|
return;
|
|
2642
2678
|
}
|
|
2679
|
+
this.markAsUsed(e);
|
|
2643
2680
|
if (!this.targetElement) {
|
|
2644
2681
|
this.targetElement = document.createElement('div');
|
|
2645
2682
|
this.targetElement.className = 'drop-target-dropzone';
|
|
@@ -2650,12 +2687,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2650
2687
|
this.element.classList.add('drop-target');
|
|
2651
2688
|
this.element.append(this.targetElement);
|
|
2652
2689
|
}
|
|
2653
|
-
if (this.options.acceptedTargetZones.length === 0) {
|
|
2654
|
-
return;
|
|
2655
|
-
}
|
|
2656
|
-
if (!this.targetElement || !this.overlayElement) {
|
|
2657
|
-
return;
|
|
2658
|
-
}
|
|
2659
2690
|
this.toggleClasses(quadrant, width, height);
|
|
2660
2691
|
this.setState(quadrant);
|
|
2661
2692
|
},
|
|
@@ -2678,10 +2709,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2678
2709
|
},
|
|
2679
2710
|
}));
|
|
2680
2711
|
}
|
|
2712
|
+
setTargetZones(acceptedTargetZones) {
|
|
2713
|
+
this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
|
|
2714
|
+
}
|
|
2681
2715
|
dispose() {
|
|
2682
2716
|
this.removeDropTarget();
|
|
2683
2717
|
super.dispose();
|
|
2684
2718
|
}
|
|
2719
|
+
/**
|
|
2720
|
+
* Add a property to the event object for other potential listeners to check
|
|
2721
|
+
*/
|
|
2722
|
+
markAsUsed(event) {
|
|
2723
|
+
event[Droptarget.USED_EVENT_ID] = true;
|
|
2724
|
+
}
|
|
2725
|
+
/**
|
|
2726
|
+
* Check is the event has already been used by another instance od DropTarget
|
|
2727
|
+
*/
|
|
2728
|
+
isAlreadyUsed(event) {
|
|
2729
|
+
const value = event[Droptarget.USED_EVENT_ID];
|
|
2730
|
+
return typeof value === 'boolean' && value;
|
|
2731
|
+
}
|
|
2685
2732
|
toggleClasses(quadrant, width, height) {
|
|
2686
2733
|
var _a, _b, _c, _d;
|
|
2687
2734
|
if (!this.overlayElement) {
|
|
@@ -2776,6 +2823,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2776
2823
|
}
|
|
2777
2824
|
}
|
|
2778
2825
|
}
|
|
2826
|
+
Droptarget.USED_EVENT_ID = '__dockview_droptarget_event_is_used__';
|
|
2779
2827
|
function calculateQuadrantAsPercentage(overlayType, x, y, width, height, threshold) {
|
|
2780
2828
|
const xp = (100 * x) / width;
|
|
2781
2829
|
const yp = (100 * y) / height;
|
|
@@ -2905,8 +2953,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2905
2953
|
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2906
2954
|
this.configure();
|
|
2907
2955
|
}
|
|
2956
|
+
isCancelled(_event) {
|
|
2957
|
+
return false;
|
|
2958
|
+
}
|
|
2908
2959
|
configure() {
|
|
2909
2960
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2961
|
+
if (this.isCancelled(event)) {
|
|
2962
|
+
event.preventDefault();
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2910
2965
|
const iframes = [
|
|
2911
2966
|
...getElementsByTagName('iframe'),
|
|
2912
2967
|
...getElementsByTagName('webview'),
|
|
@@ -2980,13 +3035,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
2980
3035
|
if (event.defaultPrevented) {
|
|
2981
3036
|
return;
|
|
2982
3037
|
}
|
|
2983
|
-
/**
|
|
2984
|
-
* TODO: alternative to stopPropagation
|
|
2985
|
-
*
|
|
2986
|
-
* I need to stop the event propagation here since otherwise it'll be intercepted by event handlers
|
|
2987
|
-
* on the tabs-container. I cannot use event.preventDefault() since I need the on DragStart event to occur
|
|
2988
|
-
*/
|
|
2989
|
-
event.stopPropagation();
|
|
2990
3038
|
this._onChanged.fire(event);
|
|
2991
3039
|
}));
|
|
2992
3040
|
this.droptarget = new Droptarget(this._element, {
|
|
@@ -3044,6 +3092,22 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3044
3092
|
this.accessorId = accessorId;
|
|
3045
3093
|
this.group = group;
|
|
3046
3094
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
3095
|
+
this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
|
|
3096
|
+
if (e.shiftKey) {
|
|
3097
|
+
/**
|
|
3098
|
+
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
3099
|
+
* but we also need to stop any group overlay drag events from occuring
|
|
3100
|
+
* Use a custom event marker that can be checked by the overlay drag events
|
|
3101
|
+
*/
|
|
3102
|
+
quasiPreventDefault(e);
|
|
3103
|
+
}
|
|
3104
|
+
}, true));
|
|
3105
|
+
}
|
|
3106
|
+
isCancelled(_event) {
|
|
3107
|
+
if (this.group.api.isFloating && !_event.shiftKey) {
|
|
3108
|
+
return true;
|
|
3109
|
+
}
|
|
3110
|
+
return false;
|
|
3047
3111
|
}
|
|
3048
3112
|
getData(dataTransfer) {
|
|
3049
3113
|
this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
|
|
@@ -3134,17 +3198,30 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3134
3198
|
hide() {
|
|
3135
3199
|
this._element.style.display = 'none';
|
|
3136
3200
|
}
|
|
3137
|
-
|
|
3138
|
-
if (this.
|
|
3201
|
+
setRightActionsElement(element) {
|
|
3202
|
+
if (this.rightActions === element) {
|
|
3203
|
+
return;
|
|
3204
|
+
}
|
|
3205
|
+
if (this.rightActions) {
|
|
3206
|
+
this.rightActions.remove();
|
|
3207
|
+
this.rightActions = undefined;
|
|
3208
|
+
}
|
|
3209
|
+
if (element) {
|
|
3210
|
+
this.rightActionsContainer.appendChild(element);
|
|
3211
|
+
this.rightActions = element;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
setLeftActionsElement(element) {
|
|
3215
|
+
if (this.leftActions === element) {
|
|
3139
3216
|
return;
|
|
3140
3217
|
}
|
|
3141
|
-
if (this.
|
|
3142
|
-
this.
|
|
3143
|
-
this.
|
|
3218
|
+
if (this.leftActions) {
|
|
3219
|
+
this.leftActions.remove();
|
|
3220
|
+
this.leftActions = undefined;
|
|
3144
3221
|
}
|
|
3145
3222
|
if (element) {
|
|
3146
|
-
this.
|
|
3147
|
-
this.
|
|
3223
|
+
this.leftActionsContainer.appendChild(element);
|
|
3224
|
+
this.leftActions = element;
|
|
3148
3225
|
}
|
|
3149
3226
|
}
|
|
3150
3227
|
get element() {
|
|
@@ -3179,19 +3256,35 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3179
3256
|
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
3180
3257
|
}
|
|
3181
3258
|
}));
|
|
3182
|
-
this.
|
|
3183
|
-
this.
|
|
3259
|
+
this.rightActionsContainer = document.createElement('div');
|
|
3260
|
+
this.rightActionsContainer.className = 'right-actions-container';
|
|
3261
|
+
this.leftActionsContainer = document.createElement('div');
|
|
3262
|
+
this.leftActionsContainer.className = 'left-actions-container';
|
|
3184
3263
|
this.tabContainer = document.createElement('div');
|
|
3185
3264
|
this.tabContainer.className = 'tabs-container';
|
|
3186
3265
|
this.voidContainer = new VoidContainer(this.accessor, this.group);
|
|
3187
3266
|
this._element.appendChild(this.tabContainer);
|
|
3267
|
+
this._element.appendChild(this.leftActionsContainer);
|
|
3188
3268
|
this._element.appendChild(this.voidContainer.element);
|
|
3189
|
-
this._element.appendChild(this.
|
|
3269
|
+
this._element.appendChild(this.rightActionsContainer);
|
|
3190
3270
|
this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
|
|
3191
3271
|
this._onDrop.fire({
|
|
3192
3272
|
event: event.nativeEvent,
|
|
3193
3273
|
index: this.tabs.length,
|
|
3194
3274
|
});
|
|
3275
|
+
}), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
|
|
3276
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3277
|
+
if (isFloatingGroupsEnabled &&
|
|
3278
|
+
event.shiftKey &&
|
|
3279
|
+
!this.group.api.isFloating) {
|
|
3280
|
+
event.preventDefault();
|
|
3281
|
+
const { top, left } = this.element.getBoundingClientRect();
|
|
3282
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3283
|
+
this.accessor.addFloatingGroup(this.group, {
|
|
3284
|
+
x: left - rootLeft + 20,
|
|
3285
|
+
y: top - rootTop + 20,
|
|
3286
|
+
}, { inDragMode: true });
|
|
3287
|
+
}
|
|
3195
3288
|
}), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
|
|
3196
3289
|
if (event.defaultPrevented) {
|
|
3197
3290
|
return;
|
|
@@ -3245,6 +3338,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3245
3338
|
tabToAdd.setContent(panel.view.tab);
|
|
3246
3339
|
const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
|
|
3247
3340
|
var _a;
|
|
3341
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3342
|
+
const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
|
|
3343
|
+
if (isFloatingGroupsEnabled &&
|
|
3344
|
+
!isFloatingWithOnePanel &&
|
|
3345
|
+
event.shiftKey) {
|
|
3346
|
+
event.preventDefault();
|
|
3347
|
+
const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
|
|
3348
|
+
const { top, left } = tabToAdd.element.getBoundingClientRect();
|
|
3349
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3350
|
+
this.accessor.addFloatingGroup(panel, {
|
|
3351
|
+
x: left - rootLeft,
|
|
3352
|
+
y: top - rootTop,
|
|
3353
|
+
}, { inDragMode: true });
|
|
3354
|
+
return;
|
|
3355
|
+
}
|
|
3248
3356
|
const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
3249
3357
|
this.group.model.isContentFocused;
|
|
3250
3358
|
const isLeftClick = event.button === 0;
|
|
@@ -3314,6 +3422,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3314
3422
|
}
|
|
3315
3423
|
return isAncestor(document.activeElement, this.contentContainer.element);
|
|
3316
3424
|
}
|
|
3425
|
+
get isFloating() {
|
|
3426
|
+
return this._isFloating;
|
|
3427
|
+
}
|
|
3428
|
+
set isFloating(value) {
|
|
3429
|
+
this._isFloating = value;
|
|
3430
|
+
this.dropTarget.setTargetZones(value ? ['center'] : ['top', 'bottom', 'left', 'right', 'center']);
|
|
3431
|
+
toggleClass(this.container, 'dv-groupview-floating', value);
|
|
3432
|
+
this.groupPanel.api._onDidFloatingStateChange.fire({
|
|
3433
|
+
isFloating: this.isFloating,
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
3317
3436
|
constructor(container, accessor, id, options, groupPanel) {
|
|
3318
3437
|
super();
|
|
3319
3438
|
this.container = container;
|
|
@@ -3323,6 +3442,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3323
3442
|
this.groupPanel = groupPanel;
|
|
3324
3443
|
this._isGroupActive = false;
|
|
3325
3444
|
this._locked = false;
|
|
3445
|
+
this._isFloating = false;
|
|
3326
3446
|
this.mostRecentlyUsed = [];
|
|
3327
3447
|
this._onDidChange = new Emitter();
|
|
3328
3448
|
this.onDidChange = this._onDidChange.event;
|
|
@@ -3339,7 +3459,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3339
3459
|
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
3340
3460
|
this._onDidActivePanelChange = new Emitter();
|
|
3341
3461
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
3342
|
-
this.container
|
|
3462
|
+
toggleClass(this.container, 'groupview', true);
|
|
3343
3463
|
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
|
3344
3464
|
this.contentContainer = new ContentContainer();
|
|
3345
3465
|
this.dropTarget = new Droptarget(this.contentContainer.element, {
|
|
@@ -3349,6 +3469,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3349
3469
|
return false;
|
|
3350
3470
|
}
|
|
3351
3471
|
const data = getPanelData();
|
|
3472
|
+
if (!data && event.shiftKey && !this.isFloating) {
|
|
3473
|
+
return false;
|
|
3474
|
+
}
|
|
3352
3475
|
if (data && data.viewId === this.accessor.id) {
|
|
3353
3476
|
if (data.groupId === this.id) {
|
|
3354
3477
|
if (position === 'center') {
|
|
@@ -3393,14 +3516,25 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3393
3516
|
// correctly initialized
|
|
3394
3517
|
this.setActive(this.isActive, true, true);
|
|
3395
3518
|
this.updateContainer();
|
|
3396
|
-
if (this.accessor.options.
|
|
3397
|
-
this.
|
|
3398
|
-
|
|
3399
|
-
this.
|
|
3519
|
+
if (this.accessor.options.createRightHeaderActionsElement) {
|
|
3520
|
+
this._rightHeaderActions =
|
|
3521
|
+
this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
|
|
3522
|
+
this.addDisposables(this._rightHeaderActions);
|
|
3523
|
+
this._rightHeaderActions.init({
|
|
3400
3524
|
containerApi: new DockviewApi(this.accessor),
|
|
3401
3525
|
api: this.groupPanel.api,
|
|
3402
3526
|
});
|
|
3403
|
-
this.tabsContainer.
|
|
3527
|
+
this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
|
|
3528
|
+
}
|
|
3529
|
+
if (this.accessor.options.createLeftHeaderActionsElement) {
|
|
3530
|
+
this._leftHeaderActions =
|
|
3531
|
+
this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
|
|
3532
|
+
this.addDisposables(this._leftHeaderActions);
|
|
3533
|
+
this._leftHeaderActions.init({
|
|
3534
|
+
containerApi: new DockviewApi(this.accessor),
|
|
3535
|
+
api: this.groupPanel.api,
|
|
3536
|
+
});
|
|
3537
|
+
this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
|
|
3404
3538
|
}
|
|
3405
3539
|
}
|
|
3406
3540
|
indexOf(panel) {
|
|
@@ -3533,7 +3667,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3533
3667
|
return this._activePanel === panel;
|
|
3534
3668
|
}
|
|
3535
3669
|
updateActions(element) {
|
|
3536
|
-
this.tabsContainer.
|
|
3670
|
+
this.tabsContainer.setRightActionsElement(element);
|
|
3537
3671
|
}
|
|
3538
3672
|
setActive(isGroupActive, skipFocus = false, force = false) {
|
|
3539
3673
|
var _a, _b, _c, _d;
|
|
@@ -3705,9 +3839,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
3705
3839
|
}
|
|
3706
3840
|
}
|
|
3707
3841
|
dispose() {
|
|
3708
|
-
var _a, _b;
|
|
3842
|
+
var _a, _b, _c;
|
|
3709
3843
|
super.dispose();
|
|
3710
|
-
(
|
|
3844
|
+
(_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
|
|
3845
|
+
(_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3711
3846
|
for (const panel of this.panels) {
|
|
3712
3847
|
panel.dispose();
|
|
3713
3848
|
}
|
|
@@ -4501,8 +4636,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4501
4636
|
get isActive() {
|
|
4502
4637
|
return this.api.isActive;
|
|
4503
4638
|
}
|
|
4504
|
-
constructor(id, component, options) {
|
|
4505
|
-
super(id, component, new GridviewPanelApiImpl(id));
|
|
4639
|
+
constructor(id, component, options, api) {
|
|
4640
|
+
super(id, component, api !== null && api !== void 0 ? api : new GridviewPanelApiImpl(id));
|
|
4506
4641
|
this._evaluatedMinimumWidth = 0;
|
|
4507
4642
|
this._evaluatedMaximumWidth = Number.MAX_SAFE_INTEGER;
|
|
4508
4643
|
this._evaluatedMinimumHeight = 0;
|
|
@@ -4600,6 +4735,32 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4600
4735
|
}
|
|
4601
4736
|
}
|
|
4602
4737
|
|
|
4738
|
+
class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|
4739
|
+
get isFloating() {
|
|
4740
|
+
if (!this._group) {
|
|
4741
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4742
|
+
}
|
|
4743
|
+
return this._group.model.isFloating;
|
|
4744
|
+
}
|
|
4745
|
+
constructor(id, accessor) {
|
|
4746
|
+
super(id);
|
|
4747
|
+
this.accessor = accessor;
|
|
4748
|
+
this._onDidFloatingStateChange = new Emitter();
|
|
4749
|
+
this.onDidFloatingStateChange = this._onDidFloatingStateChange.event;
|
|
4750
|
+
this.addDisposables(this._onDidFloatingStateChange);
|
|
4751
|
+
}
|
|
4752
|
+
moveTo(options) {
|
|
4753
|
+
var _a;
|
|
4754
|
+
if (!this._group) {
|
|
4755
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4756
|
+
}
|
|
4757
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, undefined, (_a = options.position) !== null && _a !== void 0 ? _a : 'center');
|
|
4758
|
+
}
|
|
4759
|
+
initialize(group) {
|
|
4760
|
+
this._group = group;
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4603
4764
|
class DockviewGroupPanel extends GridviewPanel {
|
|
4604
4765
|
get panels() {
|
|
4605
4766
|
return this._model.panels;
|
|
@@ -4626,7 +4787,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4626
4787
|
super(id, 'groupview_default', {
|
|
4627
4788
|
minimumHeight: 100,
|
|
4628
4789
|
minimumWidth: 100,
|
|
4629
|
-
});
|
|
4790
|
+
}, new DockviewGroupPanelApiImpl(id, accessor));
|
|
4791
|
+
this.api.initialize(this); // cannot use 'this' after after 'super' call
|
|
4630
4792
|
this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
|
|
4631
4793
|
}
|
|
4632
4794
|
initialize() {
|
|
@@ -4644,7 +4806,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4644
4806
|
return this._model;
|
|
4645
4807
|
}
|
|
4646
4808
|
toJSON() {
|
|
4647
|
-
// TODO fix typing
|
|
4648
4809
|
return this.model.toJSON();
|
|
4649
4810
|
}
|
|
4650
4811
|
}
|
|
@@ -4698,9 +4859,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4698
4859
|
get group() {
|
|
4699
4860
|
return this._group;
|
|
4700
4861
|
}
|
|
4701
|
-
constructor(panel, group) {
|
|
4862
|
+
constructor(panel, group, accessor) {
|
|
4702
4863
|
super(panel.id);
|
|
4703
4864
|
this.panel = panel;
|
|
4865
|
+
this.accessor = accessor;
|
|
4704
4866
|
this._onDidTitleChange = new Emitter();
|
|
4705
4867
|
this.onDidTitleChange = this._onDidTitleChange.event;
|
|
4706
4868
|
this._onDidActiveGroupChange = new Emitter();
|
|
@@ -4712,6 +4874,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4712
4874
|
this._group = group;
|
|
4713
4875
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4714
4876
|
}
|
|
4877
|
+
moveTo(options) {
|
|
4878
|
+
var _a;
|
|
4879
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
|
|
4880
|
+
}
|
|
4715
4881
|
setTitle(title) {
|
|
4716
4882
|
this.panel.setTitle(title);
|
|
4717
4883
|
}
|
|
@@ -4736,7 +4902,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
4736
4902
|
this.containerApi = containerApi;
|
|
4737
4903
|
this.view = view;
|
|
4738
4904
|
this._group = group;
|
|
4739
|
-
this.api = new DockviewPanelApiImpl(this, this._group);
|
|
4905
|
+
this.api = new DockviewPanelApiImpl(this, this._group, accessor);
|
|
4740
4906
|
this.addDisposables(this.api.onActiveChange(() => {
|
|
4741
4907
|
accessor.setActivePanel(this);
|
|
4742
4908
|
}), this.api.onDidSizeChange((event) => {
|
|
@@ -5077,6 +5243,296 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5077
5243
|
}
|
|
5078
5244
|
}
|
|
5079
5245
|
|
|
5246
|
+
const bringElementToFront = (() => {
|
|
5247
|
+
let previous = null;
|
|
5248
|
+
function pushToTop(element) {
|
|
5249
|
+
if (previous !== element && previous !== null) {
|
|
5250
|
+
toggleClass(previous, 'dv-bring-to-front', false);
|
|
5251
|
+
}
|
|
5252
|
+
toggleClass(element, 'dv-bring-to-front', true);
|
|
5253
|
+
previous = element;
|
|
5254
|
+
}
|
|
5255
|
+
return pushToTop;
|
|
5256
|
+
})();
|
|
5257
|
+
class Overlay extends CompositeDisposable {
|
|
5258
|
+
constructor(options) {
|
|
5259
|
+
super();
|
|
5260
|
+
this.options = options;
|
|
5261
|
+
this._element = document.createElement('div');
|
|
5262
|
+
this._onDidChange = new Emitter();
|
|
5263
|
+
this.onDidChange = this._onDidChange.event;
|
|
5264
|
+
this._onDidChangeEnd = new Emitter();
|
|
5265
|
+
this.onDidChangeEnd = this._onDidChangeEnd.event;
|
|
5266
|
+
this.addDisposables(this._onDidChange, this._onDidChangeEnd);
|
|
5267
|
+
this._element.className = 'dv-resize-container';
|
|
5268
|
+
this.setupResize('top');
|
|
5269
|
+
this.setupResize('bottom');
|
|
5270
|
+
this.setupResize('left');
|
|
5271
|
+
this.setupResize('right');
|
|
5272
|
+
this.setupResize('topleft');
|
|
5273
|
+
this.setupResize('topright');
|
|
5274
|
+
this.setupResize('bottomleft');
|
|
5275
|
+
this.setupResize('bottomright');
|
|
5276
|
+
this._element.appendChild(this.options.content);
|
|
5277
|
+
this.options.container.appendChild(this._element);
|
|
5278
|
+
// if input bad resize within acceptable boundaries
|
|
5279
|
+
this.setBounds({
|
|
5280
|
+
height: this.options.height,
|
|
5281
|
+
width: this.options.width,
|
|
5282
|
+
top: this.options.top,
|
|
5283
|
+
left: this.options.left,
|
|
5284
|
+
});
|
|
5285
|
+
}
|
|
5286
|
+
setBounds(bounds = {}) {
|
|
5287
|
+
if (typeof bounds.height === 'number') {
|
|
5288
|
+
this._element.style.height = `${bounds.height}px`;
|
|
5289
|
+
}
|
|
5290
|
+
if (typeof bounds.width === 'number') {
|
|
5291
|
+
this._element.style.width = `${bounds.width}px`;
|
|
5292
|
+
}
|
|
5293
|
+
if (typeof bounds.top === 'number') {
|
|
5294
|
+
this._element.style.top = `${bounds.top}px`;
|
|
5295
|
+
}
|
|
5296
|
+
if (typeof bounds.left === 'number') {
|
|
5297
|
+
this._element.style.left = `${bounds.left}px`;
|
|
5298
|
+
}
|
|
5299
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5300
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5301
|
+
// region: ensure bounds within allowable limits
|
|
5302
|
+
// a minimum width of minimumViewportWidth must be inside the viewport
|
|
5303
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5304
|
+
// a minimum height of minimumViewportHeight must be inside the viewport
|
|
5305
|
+
const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
|
|
5306
|
+
const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5307
|
+
const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5308
|
+
this._element.style.left = `${left}px`;
|
|
5309
|
+
this._element.style.top = `${top}px`;
|
|
5310
|
+
this._onDidChange.fire();
|
|
5311
|
+
}
|
|
5312
|
+
toJSON() {
|
|
5313
|
+
const container = this.options.container.getBoundingClientRect();
|
|
5314
|
+
const element = this._element.getBoundingClientRect();
|
|
5315
|
+
return {
|
|
5316
|
+
top: element.top - container.top,
|
|
5317
|
+
left: element.left - container.left,
|
|
5318
|
+
width: element.width,
|
|
5319
|
+
height: element.height,
|
|
5320
|
+
};
|
|
5321
|
+
}
|
|
5322
|
+
setupDrag(dragTarget, options = { inDragMode: false }) {
|
|
5323
|
+
const move = new MutableDisposable();
|
|
5324
|
+
const track = () => {
|
|
5325
|
+
let offset = null;
|
|
5326
|
+
const iframes = [
|
|
5327
|
+
...getElementsByTagName('iframe'),
|
|
5328
|
+
...getElementsByTagName('webview'),
|
|
5329
|
+
];
|
|
5330
|
+
for (const iframe of iframes) {
|
|
5331
|
+
iframe.style.pointerEvents = 'none';
|
|
5332
|
+
}
|
|
5333
|
+
move.value = new CompositeDisposable({
|
|
5334
|
+
dispose: () => {
|
|
5335
|
+
for (const iframe of iframes) {
|
|
5336
|
+
iframe.style.pointerEvents = 'auto';
|
|
5337
|
+
}
|
|
5338
|
+
},
|
|
5339
|
+
}, addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5340
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5341
|
+
const x = e.clientX - containerRect.left;
|
|
5342
|
+
const y = e.clientY - containerRect.top;
|
|
5343
|
+
toggleClass(this._element, 'dv-resize-container-dragging', true);
|
|
5344
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5345
|
+
if (offset === null) {
|
|
5346
|
+
offset = {
|
|
5347
|
+
x: e.clientX - overlayRect.left,
|
|
5348
|
+
y: e.clientY - overlayRect.top,
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5352
|
+
const yOffset = Math.max(0, overlayRect.height -
|
|
5353
|
+
this.options.minimumInViewportHeight);
|
|
5354
|
+
const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5355
|
+
const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5356
|
+
this.setBounds({ top, left });
|
|
5357
|
+
}), addDisposableWindowListener(window, 'mouseup', () => {
|
|
5358
|
+
toggleClass(this._element, 'dv-resize-container-dragging', false);
|
|
5359
|
+
move.dispose();
|
|
5360
|
+
this._onDidChangeEnd.fire();
|
|
5361
|
+
}));
|
|
5362
|
+
};
|
|
5363
|
+
this.addDisposables(move, addDisposableListener(dragTarget, 'mousedown', (event) => {
|
|
5364
|
+
if (event.defaultPrevented) {
|
|
5365
|
+
event.preventDefault();
|
|
5366
|
+
return;
|
|
5367
|
+
}
|
|
5368
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5369
|
+
// without actually calling event.preventDefault()
|
|
5370
|
+
if (quasiDefaultPrevented(event)) {
|
|
5371
|
+
return;
|
|
5372
|
+
}
|
|
5373
|
+
track();
|
|
5374
|
+
}), addDisposableListener(this.options.content, 'mousedown', (event) => {
|
|
5375
|
+
if (event.defaultPrevented) {
|
|
5376
|
+
return;
|
|
5377
|
+
}
|
|
5378
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5379
|
+
// without actually calling event.preventDefault()
|
|
5380
|
+
if (quasiDefaultPrevented(event)) {
|
|
5381
|
+
return;
|
|
5382
|
+
}
|
|
5383
|
+
if (event.shiftKey) {
|
|
5384
|
+
track();
|
|
5385
|
+
}
|
|
5386
|
+
}), addDisposableListener(this.options.content, 'mousedown', () => {
|
|
5387
|
+
bringElementToFront(this._element);
|
|
5388
|
+
}, true));
|
|
5389
|
+
bringElementToFront(this._element);
|
|
5390
|
+
if (options.inDragMode) {
|
|
5391
|
+
track();
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
setupResize(direction) {
|
|
5395
|
+
const resizeHandleElement = document.createElement('div');
|
|
5396
|
+
resizeHandleElement.className = `dv-resize-handle-${direction}`;
|
|
5397
|
+
this._element.appendChild(resizeHandleElement);
|
|
5398
|
+
const move = new MutableDisposable();
|
|
5399
|
+
this.addDisposables(move, addDisposableListener(resizeHandleElement, 'mousedown', (e) => {
|
|
5400
|
+
e.preventDefault();
|
|
5401
|
+
let startPosition = null;
|
|
5402
|
+
const iframes = [
|
|
5403
|
+
...getElementsByTagName('iframe'),
|
|
5404
|
+
...getElementsByTagName('webview'),
|
|
5405
|
+
];
|
|
5406
|
+
for (const iframe of iframes) {
|
|
5407
|
+
iframe.style.pointerEvents = 'none';
|
|
5408
|
+
}
|
|
5409
|
+
move.value = new CompositeDisposable(addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5410
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5411
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5412
|
+
const y = e.clientY - containerRect.top;
|
|
5413
|
+
const x = e.clientX - containerRect.left;
|
|
5414
|
+
if (startPosition === null) {
|
|
5415
|
+
// record the initial dimensions since as all subsequence moves are relative to this
|
|
5416
|
+
startPosition = {
|
|
5417
|
+
originalY: y,
|
|
5418
|
+
originalHeight: overlayRect.height,
|
|
5419
|
+
originalX: x,
|
|
5420
|
+
originalWidth: overlayRect.width,
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
let top = undefined;
|
|
5424
|
+
let height = undefined;
|
|
5425
|
+
let left = undefined;
|
|
5426
|
+
let width = undefined;
|
|
5427
|
+
const minimumInViewportHeight = this.options.minimumInViewportHeight;
|
|
5428
|
+
const minimumInViewportWidth = this.options.minimumInViewportWidth;
|
|
5429
|
+
function moveTop() {
|
|
5430
|
+
top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
|
|
5431
|
+
startPosition.originalHeight >
|
|
5432
|
+
containerRect.height
|
|
5433
|
+
? containerRect.height -
|
|
5434
|
+
minimumInViewportHeight
|
|
5435
|
+
: Math.max(0, startPosition.originalY +
|
|
5436
|
+
startPosition.originalHeight -
|
|
5437
|
+
Overlay.MINIMUM_HEIGHT));
|
|
5438
|
+
height =
|
|
5439
|
+
startPosition.originalY +
|
|
5440
|
+
startPosition.originalHeight -
|
|
5441
|
+
top;
|
|
5442
|
+
}
|
|
5443
|
+
function moveBottom() {
|
|
5444
|
+
top =
|
|
5445
|
+
startPosition.originalY -
|
|
5446
|
+
startPosition.originalHeight;
|
|
5447
|
+
height = clamp(y - top, top < 0
|
|
5448
|
+
? -top + minimumInViewportHeight
|
|
5449
|
+
: Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
|
|
5450
|
+
}
|
|
5451
|
+
function moveLeft() {
|
|
5452
|
+
left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
|
|
5453
|
+
startPosition.originalWidth >
|
|
5454
|
+
containerRect.width
|
|
5455
|
+
? containerRect.width -
|
|
5456
|
+
minimumInViewportWidth
|
|
5457
|
+
: Math.max(0, startPosition.originalX +
|
|
5458
|
+
startPosition.originalWidth -
|
|
5459
|
+
Overlay.MINIMUM_WIDTH));
|
|
5460
|
+
width =
|
|
5461
|
+
startPosition.originalX +
|
|
5462
|
+
startPosition.originalWidth -
|
|
5463
|
+
left;
|
|
5464
|
+
}
|
|
5465
|
+
function moveRight() {
|
|
5466
|
+
left =
|
|
5467
|
+
startPosition.originalX -
|
|
5468
|
+
startPosition.originalWidth;
|
|
5469
|
+
width = clamp(x - left, left < 0
|
|
5470
|
+
? -left + minimumInViewportWidth
|
|
5471
|
+
: Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
|
|
5472
|
+
}
|
|
5473
|
+
switch (direction) {
|
|
5474
|
+
case 'top':
|
|
5475
|
+
moveTop();
|
|
5476
|
+
break;
|
|
5477
|
+
case 'bottom':
|
|
5478
|
+
moveBottom();
|
|
5479
|
+
break;
|
|
5480
|
+
case 'left':
|
|
5481
|
+
moveLeft();
|
|
5482
|
+
break;
|
|
5483
|
+
case 'right':
|
|
5484
|
+
moveRight();
|
|
5485
|
+
break;
|
|
5486
|
+
case 'topleft':
|
|
5487
|
+
moveTop();
|
|
5488
|
+
moveLeft();
|
|
5489
|
+
break;
|
|
5490
|
+
case 'topright':
|
|
5491
|
+
moveTop();
|
|
5492
|
+
moveRight();
|
|
5493
|
+
break;
|
|
5494
|
+
case 'bottomleft':
|
|
5495
|
+
moveBottom();
|
|
5496
|
+
moveLeft();
|
|
5497
|
+
break;
|
|
5498
|
+
case 'bottomright':
|
|
5499
|
+
moveBottom();
|
|
5500
|
+
moveRight();
|
|
5501
|
+
break;
|
|
5502
|
+
}
|
|
5503
|
+
this.setBounds({ height, width, top, left });
|
|
5504
|
+
}), {
|
|
5505
|
+
dispose: () => {
|
|
5506
|
+
for (const iframe of iframes) {
|
|
5507
|
+
iframe.style.pointerEvents = 'auto';
|
|
5508
|
+
}
|
|
5509
|
+
},
|
|
5510
|
+
}, addDisposableWindowListener(window, 'mouseup', () => {
|
|
5511
|
+
move.dispose();
|
|
5512
|
+
this._onDidChangeEnd.fire();
|
|
5513
|
+
}));
|
|
5514
|
+
}));
|
|
5515
|
+
}
|
|
5516
|
+
dispose() {
|
|
5517
|
+
this._element.remove();
|
|
5518
|
+
super.dispose();
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
Overlay.MINIMUM_HEIGHT = 20;
|
|
5522
|
+
Overlay.MINIMUM_WIDTH = 20;
|
|
5523
|
+
|
|
5524
|
+
class DockviewFloatingGroupPanel extends CompositeDisposable {
|
|
5525
|
+
constructor(group, overlay) {
|
|
5526
|
+
super();
|
|
5527
|
+
this.group = group;
|
|
5528
|
+
this.overlay = overlay;
|
|
5529
|
+
this.addDisposables(overlay);
|
|
5530
|
+
}
|
|
5531
|
+
position(bounds) {
|
|
5532
|
+
this.overlay.setBounds(bounds);
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
|
|
5080
5536
|
class DockviewComponent extends BaseGrid {
|
|
5081
5537
|
get orientation() {
|
|
5082
5538
|
return this.gridview.orientation;
|
|
@@ -5117,7 +5573,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5117
5573
|
this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
|
|
5118
5574
|
this._onDidActivePanelChange = new Emitter();
|
|
5119
5575
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
5120
|
-
this.
|
|
5576
|
+
this.floatingGroups = [];
|
|
5577
|
+
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
5121
5578
|
this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
|
|
5122
5579
|
this.updateWatermark();
|
|
5123
5580
|
}), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
|
|
@@ -5147,9 +5604,22 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5147
5604
|
if (data.viewId !== this.id) {
|
|
5148
5605
|
return false;
|
|
5149
5606
|
}
|
|
5607
|
+
if (position === 'center') {
|
|
5608
|
+
// center drop target is only allowed if there are no panels in the grid
|
|
5609
|
+
// floating panels are allowed
|
|
5610
|
+
return this.gridview.length === 0;
|
|
5611
|
+
}
|
|
5150
5612
|
return true;
|
|
5151
5613
|
}
|
|
5152
5614
|
if (this.options.showDndOverlay) {
|
|
5615
|
+
if (position === 'center') {
|
|
5616
|
+
/**
|
|
5617
|
+
* for external events only show the four-corner drag overlays, disable
|
|
5618
|
+
* the center position so that external drag events can fall through to the group
|
|
5619
|
+
* and panel drop target handlers
|
|
5620
|
+
*/
|
|
5621
|
+
return false;
|
|
5622
|
+
}
|
|
5153
5623
|
return this.options.showDndOverlay({
|
|
5154
5624
|
nativeEvent: event,
|
|
5155
5625
|
position: position,
|
|
@@ -5159,7 +5629,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5159
5629
|
}
|
|
5160
5630
|
return false;
|
|
5161
5631
|
},
|
|
5162
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
|
|
5632
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5163
5633
|
overlayModel: {
|
|
5164
5634
|
activationSize: { type: 'pixels', value: 10 },
|
|
5165
5635
|
size: { type: 'pixels', value: 20 },
|
|
@@ -5177,6 +5647,75 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5177
5647
|
this._api = new DockviewApi(this);
|
|
5178
5648
|
this.updateWatermark();
|
|
5179
5649
|
}
|
|
5650
|
+
addFloatingGroup(item, coord, options) {
|
|
5651
|
+
var _a, _b;
|
|
5652
|
+
let group;
|
|
5653
|
+
if (item instanceof DockviewPanel) {
|
|
5654
|
+
group = this.createGroup();
|
|
5655
|
+
this.removePanel(item, {
|
|
5656
|
+
removeEmptyGroup: true,
|
|
5657
|
+
skipDispose: true,
|
|
5658
|
+
});
|
|
5659
|
+
group.model.openPanel(item);
|
|
5660
|
+
}
|
|
5661
|
+
else {
|
|
5662
|
+
group = item;
|
|
5663
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
5664
|
+
options.skipRemoveGroup;
|
|
5665
|
+
if (!skip) {
|
|
5666
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
group.model.isFloating = true;
|
|
5670
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
5671
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
5672
|
+
const overlay = new Overlay({
|
|
5673
|
+
container: this.gridview.element,
|
|
5674
|
+
content: group.element,
|
|
5675
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
5676
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
5677
|
+
left: overlayLeft,
|
|
5678
|
+
top: overlayTop,
|
|
5679
|
+
minimumInViewportWidth: 100,
|
|
5680
|
+
minimumInViewportHeight: 100,
|
|
5681
|
+
});
|
|
5682
|
+
const el = group.element.querySelector('.void-container');
|
|
5683
|
+
if (!el) {
|
|
5684
|
+
throw new Error('failed to find drag handle');
|
|
5685
|
+
}
|
|
5686
|
+
overlay.setupDrag(el, {
|
|
5687
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
5688
|
+
? options.inDragMode
|
|
5689
|
+
: false,
|
|
5690
|
+
});
|
|
5691
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
5692
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
5693
|
+
const { width, height } = entry.contentRect;
|
|
5694
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
5695
|
+
});
|
|
5696
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
5697
|
+
// this is either a resize or a move
|
|
5698
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
5699
|
+
// don't care about resize since the above watcher handles that
|
|
5700
|
+
group.layout(group.height, group.width);
|
|
5701
|
+
}), overlay.onDidChangeEnd(() => {
|
|
5702
|
+
this._bufferOnDidLayoutChange.fire();
|
|
5703
|
+
}), group.onDidChange((event) => {
|
|
5704
|
+
overlay.setBounds({
|
|
5705
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
5706
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
5707
|
+
});
|
|
5708
|
+
}), {
|
|
5709
|
+
dispose: () => {
|
|
5710
|
+
disposable.dispose();
|
|
5711
|
+
group.model.isFloating = false;
|
|
5712
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
5713
|
+
this.updateWatermark();
|
|
5714
|
+
},
|
|
5715
|
+
});
|
|
5716
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
5717
|
+
this.updateWatermark();
|
|
5718
|
+
}
|
|
5180
5719
|
orthogonalize(position) {
|
|
5181
5720
|
switch (position) {
|
|
5182
5721
|
case 'top':
|
|
@@ -5199,6 +5738,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5199
5738
|
switch (position) {
|
|
5200
5739
|
case 'top':
|
|
5201
5740
|
case 'left':
|
|
5741
|
+
case 'center':
|
|
5202
5742
|
return this.createGroupAtLocation([0]); // insert into first position
|
|
5203
5743
|
case 'bottom':
|
|
5204
5744
|
case 'right':
|
|
@@ -5216,6 +5756,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5216
5756
|
}
|
|
5217
5757
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
5218
5758
|
}
|
|
5759
|
+
layout(width, height, forceResize) {
|
|
5760
|
+
super.layout(width, height, forceResize);
|
|
5761
|
+
if (this.floatingGroups) {
|
|
5762
|
+
for (const floating of this.floatingGroups) {
|
|
5763
|
+
// ensure floting groups stay within visible boundaries
|
|
5764
|
+
floating.overlay.setBounds();
|
|
5765
|
+
}
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5219
5768
|
focus() {
|
|
5220
5769
|
var _a;
|
|
5221
5770
|
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -5278,51 +5827,81 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5278
5827
|
collection[panel.id] = panel.toJSON();
|
|
5279
5828
|
return collection;
|
|
5280
5829
|
}, {});
|
|
5281
|
-
|
|
5830
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
5831
|
+
return {
|
|
5832
|
+
data: floatingGroup.group.toJSON(),
|
|
5833
|
+
position: floatingGroup.overlay.toJSON(),
|
|
5834
|
+
};
|
|
5835
|
+
});
|
|
5836
|
+
const result = {
|
|
5282
5837
|
grid: data,
|
|
5283
5838
|
panels,
|
|
5284
5839
|
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
5285
5840
|
};
|
|
5841
|
+
if (floats.length > 0) {
|
|
5842
|
+
result.floatingGroups = floats;
|
|
5843
|
+
}
|
|
5844
|
+
return result;
|
|
5286
5845
|
}
|
|
5287
5846
|
fromJSON(data) {
|
|
5847
|
+
var _a;
|
|
5288
5848
|
this.clear();
|
|
5289
5849
|
const { grid, panels, activeGroup } = data;
|
|
5290
5850
|
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
5291
5851
|
throw new Error('root must be of type branch');
|
|
5292
5852
|
}
|
|
5853
|
+
// take note of the existing dimensions
|
|
5854
|
+
const width = this.width;
|
|
5855
|
+
const height = this.height;
|
|
5856
|
+
const createGroupFromSerializedState = (data) => {
|
|
5857
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
5858
|
+
const group = this.createGroup({
|
|
5859
|
+
id,
|
|
5860
|
+
locked: !!locked,
|
|
5861
|
+
hideHeader: !!hideHeader,
|
|
5862
|
+
});
|
|
5863
|
+
this._onDidAddGroup.fire(group);
|
|
5864
|
+
for (const child of views) {
|
|
5865
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5866
|
+
const isActive = typeof activeView === 'string' && activeView === panel.id;
|
|
5867
|
+
group.model.openPanel(panel, {
|
|
5868
|
+
skipSetPanelActive: !isActive,
|
|
5869
|
+
skipSetGroupActive: true,
|
|
5870
|
+
});
|
|
5871
|
+
}
|
|
5872
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
5873
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5874
|
+
skipSetGroupActive: true,
|
|
5875
|
+
});
|
|
5876
|
+
}
|
|
5877
|
+
return group;
|
|
5878
|
+
};
|
|
5293
5879
|
this.gridview.deserialize(grid, {
|
|
5294
5880
|
fromJSON: (node) => {
|
|
5295
|
-
|
|
5296
|
-
const group = this.createGroup({
|
|
5297
|
-
id,
|
|
5298
|
-
locked: !!locked,
|
|
5299
|
-
hideHeader: !!hideHeader,
|
|
5300
|
-
});
|
|
5301
|
-
this._onDidAddGroup.fire(group);
|
|
5302
|
-
for (const child of views) {
|
|
5303
|
-
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5304
|
-
const isActive = typeof activeView === 'string' &&
|
|
5305
|
-
activeView === panel.id;
|
|
5306
|
-
group.model.openPanel(panel, {
|
|
5307
|
-
skipSetPanelActive: !isActive,
|
|
5308
|
-
skipSetGroupActive: true,
|
|
5309
|
-
});
|
|
5310
|
-
}
|
|
5311
|
-
if (!group.activePanel && group.panels.length > 0) {
|
|
5312
|
-
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5313
|
-
skipSetGroupActive: true,
|
|
5314
|
-
});
|
|
5315
|
-
}
|
|
5316
|
-
return group;
|
|
5881
|
+
return createGroupFromSerializedState(node.data);
|
|
5317
5882
|
},
|
|
5318
5883
|
});
|
|
5884
|
+
this.layout(width, height, true);
|
|
5885
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
5886
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
5887
|
+
const { data, position } = serializedFloatingGroup;
|
|
5888
|
+
const group = createGroupFromSerializedState(data);
|
|
5889
|
+
this.addFloatingGroup(group, {
|
|
5890
|
+
x: position.left,
|
|
5891
|
+
y: position.top,
|
|
5892
|
+
height: position.height,
|
|
5893
|
+
width: position.width,
|
|
5894
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
5895
|
+
}
|
|
5896
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
5897
|
+
floatingGroup.overlay.setBounds();
|
|
5898
|
+
}
|
|
5319
5899
|
if (typeof activeGroup === 'string') {
|
|
5320
5900
|
const panel = this.getPanel(activeGroup);
|
|
5321
5901
|
if (panel) {
|
|
5322
5902
|
this.doSetGroupActive(panel);
|
|
5323
5903
|
}
|
|
5324
5904
|
}
|
|
5325
|
-
this.gridview.layout(this.width, this.height);
|
|
5326
5905
|
this._onDidLayoutFromJSON.fire();
|
|
5327
5906
|
}
|
|
5328
5907
|
clear() {
|
|
@@ -5331,7 +5910,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5331
5910
|
const hasActivePanel = !!this.activePanel;
|
|
5332
5911
|
for (const group of groups) {
|
|
5333
5912
|
// remove the group will automatically remove the panels
|
|
5334
|
-
this.removeGroup(group, true);
|
|
5913
|
+
this.removeGroup(group, { skipActive: true });
|
|
5335
5914
|
}
|
|
5336
5915
|
if (hasActiveGroup) {
|
|
5337
5916
|
this.doSetGroupActive(undefined);
|
|
@@ -5353,6 +5932,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5353
5932
|
throw new Error(`panel with id ${options.id} already exists`);
|
|
5354
5933
|
}
|
|
5355
5934
|
let referenceGroup;
|
|
5935
|
+
if (options.position && options.floating) {
|
|
5936
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
5937
|
+
}
|
|
5356
5938
|
if (options.position) {
|
|
5357
5939
|
if (isPanelOptionsWithPanel(options.position)) {
|
|
5358
5940
|
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
@@ -5385,7 +5967,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5385
5967
|
let panel;
|
|
5386
5968
|
if (referenceGroup) {
|
|
5387
5969
|
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
5388
|
-
if (
|
|
5970
|
+
if (options.floating) {
|
|
5971
|
+
const group = this.createGroup();
|
|
5972
|
+
panel = this.createPanel(options, group);
|
|
5973
|
+
group.model.openPanel(panel);
|
|
5974
|
+
const o = typeof options.floating === 'object' &&
|
|
5975
|
+
options.floating !== null
|
|
5976
|
+
? options.floating
|
|
5977
|
+
: {};
|
|
5978
|
+
this.addFloatingGroup(group, o, {
|
|
5979
|
+
inDragMode: false,
|
|
5980
|
+
skipRemoveGroup: true,
|
|
5981
|
+
});
|
|
5982
|
+
}
|
|
5983
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
5389
5984
|
panel = this.createPanel(options, referenceGroup);
|
|
5390
5985
|
referenceGroup.model.openPanel(panel);
|
|
5391
5986
|
}
|
|
@@ -5397,6 +5992,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5397
5992
|
group.model.openPanel(panel);
|
|
5398
5993
|
}
|
|
5399
5994
|
}
|
|
5995
|
+
else if (options.floating) {
|
|
5996
|
+
const group = this.createGroup();
|
|
5997
|
+
panel = this.createPanel(options, group);
|
|
5998
|
+
group.model.openPanel(panel);
|
|
5999
|
+
const o = typeof options.floating === 'object' &&
|
|
6000
|
+
options.floating !== null
|
|
6001
|
+
? options.floating
|
|
6002
|
+
: {};
|
|
6003
|
+
this.addFloatingGroup(group, o, {
|
|
6004
|
+
inDragMode: false,
|
|
6005
|
+
skipRemoveGroup: true,
|
|
6006
|
+
});
|
|
6007
|
+
}
|
|
5400
6008
|
else {
|
|
5401
6009
|
const group = this.createGroupAtLocation();
|
|
5402
6010
|
panel = this.createPanel(options, group);
|
|
@@ -5413,7 +6021,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5413
6021
|
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
5414
6022
|
}
|
|
5415
6023
|
group.model.removePanel(panel);
|
|
5416
|
-
|
|
6024
|
+
if (!options.skipDispose) {
|
|
6025
|
+
panel.dispose();
|
|
6026
|
+
}
|
|
5417
6027
|
if (group.size === 0 && options.removeEmptyGroup) {
|
|
5418
6028
|
this.removeGroup(group);
|
|
5419
6029
|
}
|
|
@@ -5428,7 +6038,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5428
6038
|
}
|
|
5429
6039
|
updateWatermark() {
|
|
5430
6040
|
var _a, _b;
|
|
5431
|
-
if (this.groups.length === 0) {
|
|
6041
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
5432
6042
|
if (!this.watermark) {
|
|
5433
6043
|
this.watermark = this.createWatermarkComponent();
|
|
5434
6044
|
this.watermark.init({
|
|
@@ -5437,7 +6047,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5437
6047
|
const watermarkContainer = document.createElement('div');
|
|
5438
6048
|
watermarkContainer.className = 'dv-watermark-container';
|
|
5439
6049
|
watermarkContainer.appendChild(this.watermark.element);
|
|
5440
|
-
this.element.appendChild(watermarkContainer);
|
|
6050
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
5441
6051
|
}
|
|
5442
6052
|
}
|
|
5443
6053
|
else if (this.watermark) {
|
|
@@ -5487,15 +6097,28 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5487
6097
|
return group;
|
|
5488
6098
|
}
|
|
5489
6099
|
}
|
|
5490
|
-
removeGroup(group,
|
|
6100
|
+
removeGroup(group, options) {
|
|
6101
|
+
var _a;
|
|
5491
6102
|
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
5492
6103
|
for (const panel of panels) {
|
|
5493
6104
|
this.removePanel(panel, {
|
|
5494
6105
|
removeEmptyGroup: false,
|
|
5495
|
-
skipDispose: false,
|
|
6106
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
5496
6107
|
});
|
|
5497
6108
|
}
|
|
5498
|
-
|
|
6109
|
+
this.doRemoveGroup(group, options);
|
|
6110
|
+
}
|
|
6111
|
+
doRemoveGroup(group, options) {
|
|
6112
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
6113
|
+
if (floatingGroup) {
|
|
6114
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
6115
|
+
floatingGroup.group.dispose();
|
|
6116
|
+
this._groups.delete(group.id);
|
|
6117
|
+
}
|
|
6118
|
+
floatingGroup.dispose();
|
|
6119
|
+
return floatingGroup.group;
|
|
6120
|
+
}
|
|
6121
|
+
return super.doRemoveGroup(group, options);
|
|
5499
6122
|
}
|
|
5500
6123
|
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5501
6124
|
var _a;
|
|
@@ -5526,25 +6149,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5526
6149
|
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5527
6150
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5528
6151
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5529
|
-
const
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
5540
|
-
skipActive: true,
|
|
5541
|
-
skipDispose: true,
|
|
5542
|
-
});
|
|
5543
|
-
// after deleting the group we need to re-evaulate the ref location
|
|
5544
|
-
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5545
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5546
|
-
this.doAddGroup(targetGroup, location);
|
|
6152
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6153
|
+
if (!isFloating) {
|
|
6154
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
6155
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
6156
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
6157
|
+
// special case when 'swapping' two views within same grid location
|
|
6158
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
6159
|
+
// which is equivalent to swapping two views in this case
|
|
6160
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
6161
|
+
}
|
|
5547
6162
|
}
|
|
6163
|
+
// source group will become empty so delete the group
|
|
6164
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
6165
|
+
skipActive: true,
|
|
6166
|
+
skipDispose: true,
|
|
6167
|
+
});
|
|
6168
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
6169
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
6170
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
6171
|
+
this.doAddGroup(targetGroup, location);
|
|
5548
6172
|
}
|
|
5549
6173
|
else {
|
|
5550
6174
|
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
@@ -5573,7 +6197,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5573
6197
|
}
|
|
5574
6198
|
}
|
|
5575
6199
|
else {
|
|
5576
|
-
this.
|
|
6200
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6201
|
+
if (floatingGroup) {
|
|
6202
|
+
floatingGroup.dispose();
|
|
6203
|
+
}
|
|
6204
|
+
else {
|
|
6205
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
6206
|
+
}
|
|
5577
6207
|
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
5578
6208
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
5579
6209
|
this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
|
|
@@ -5728,6 +6358,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5728
6358
|
this.clear();
|
|
5729
6359
|
const { grid, activePanel } = serializedGridview;
|
|
5730
6360
|
const queue = [];
|
|
6361
|
+
// take note of the existing dimensions
|
|
6362
|
+
const width = this.width;
|
|
6363
|
+
const height = this.height;
|
|
5731
6364
|
this.gridview.deserialize(grid, {
|
|
5732
6365
|
fromJSON: (node) => {
|
|
5733
6366
|
const { data } = node;
|
|
@@ -5753,7 +6386,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
5753
6386
|
return view;
|
|
5754
6387
|
},
|
|
5755
6388
|
});
|
|
5756
|
-
this.layout(
|
|
6389
|
+
this.layout(width, height, true);
|
|
5757
6390
|
queue.forEach((f) => f());
|
|
5758
6391
|
if (typeof activePanel === 'string') {
|
|
5759
6392
|
const panel = this.getPanel(activePanel);
|
|
@@ -6067,6 +6700,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6067
6700
|
this.clear();
|
|
6068
6701
|
const { views, orientation, size, activeView } = serializedSplitview;
|
|
6069
6702
|
const queue = [];
|
|
6703
|
+
// take note of the existing dimensions
|
|
6704
|
+
const width = this.width;
|
|
6705
|
+
const height = this.height;
|
|
6070
6706
|
this.splitview = new Splitview(this.element, {
|
|
6071
6707
|
orientation,
|
|
6072
6708
|
proportionalLayout: this.options.proportionalLayout,
|
|
@@ -6103,7 +6739,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6103
6739
|
}),
|
|
6104
6740
|
},
|
|
6105
6741
|
});
|
|
6106
|
-
this.layout(
|
|
6742
|
+
this.layout(width, height);
|
|
6107
6743
|
queue.forEach((f) => f());
|
|
6108
6744
|
if (typeof activeView === 'string') {
|
|
6109
6745
|
const panel = this.getPanel(activeView);
|
|
@@ -6370,6 +7006,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6370
7006
|
this.clear();
|
|
6371
7007
|
const { views, size } = serializedPaneview;
|
|
6372
7008
|
const queue = [];
|
|
7009
|
+
// take note of the existing dimensions
|
|
7010
|
+
const width = this.width;
|
|
7011
|
+
const height = this.height;
|
|
6373
7012
|
this.paneview = new Paneview(this.element, {
|
|
6374
7013
|
orientation: exports.Orientation.VERTICAL,
|
|
6375
7014
|
descriptor: {
|
|
@@ -6425,7 +7064,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6425
7064
|
}),
|
|
6426
7065
|
},
|
|
6427
7066
|
});
|
|
6428
|
-
this.layout(
|
|
7067
|
+
this.layout(width, height);
|
|
6429
7068
|
queue.forEach((f) => f());
|
|
6430
7069
|
this._onDidLayoutfromJSON.fire();
|
|
6431
7070
|
}
|
|
@@ -6808,7 +7447,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6808
7447
|
}
|
|
6809
7448
|
}
|
|
6810
7449
|
|
|
6811
|
-
class
|
|
7450
|
+
class ReactHeaderActionsRendererPart {
|
|
6812
7451
|
get element() {
|
|
6813
7452
|
return this._element;
|
|
6814
7453
|
}
|
|
@@ -6845,6 +7484,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6845
7484
|
panels: this._group.model.panels,
|
|
6846
7485
|
activePanel: this._group.model.activePanel,
|
|
6847
7486
|
isGroupActive: this._group.api.isActive,
|
|
7487
|
+
group: this._group,
|
|
6848
7488
|
});
|
|
6849
7489
|
}
|
|
6850
7490
|
update(event) {
|
|
@@ -6878,7 +7518,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6878
7518
|
function createGroupControlElement(component, store) {
|
|
6879
7519
|
return component
|
|
6880
7520
|
? (groupPanel) => {
|
|
6881
|
-
return new
|
|
7521
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
6882
7522
|
}
|
|
6883
7523
|
: undefined;
|
|
6884
7524
|
}
|
|
@@ -6935,8 +7575,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6935
7575
|
? { separatorBorder: 'transparent' }
|
|
6936
7576
|
: undefined,
|
|
6937
7577
|
showDndOverlay: props.showDndOverlay,
|
|
6938
|
-
|
|
7578
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7579
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
6939
7580
|
singleTabMode: props.singleTabMode,
|
|
7581
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
6940
7582
|
});
|
|
6941
7583
|
const { clientWidth, clientHeight } = domRef.current;
|
|
6942
7584
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -6995,6 +7637,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
6995
7637
|
frameworkTabComponents: props.tabComponents,
|
|
6996
7638
|
});
|
|
6997
7639
|
}, [props.tabComponents]);
|
|
7640
|
+
React__namespace.useEffect(() => {
|
|
7641
|
+
if (!dockviewRef.current) {
|
|
7642
|
+
return;
|
|
7643
|
+
}
|
|
7644
|
+
dockviewRef.current.updateOptions({
|
|
7645
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
7646
|
+
});
|
|
7647
|
+
}, [props.disableFloatingGroups]);
|
|
6998
7648
|
React__namespace.useEffect(() => {
|
|
6999
7649
|
if (!dockviewRef.current) {
|
|
7000
7650
|
return;
|
|
@@ -7016,9 +7666,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
7016
7666
|
return;
|
|
7017
7667
|
}
|
|
7018
7668
|
dockviewRef.current.updateOptions({
|
|
7019
|
-
|
|
7669
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
7670
|
+
});
|
|
7671
|
+
}, [props.rightHeaderActionsComponent]);
|
|
7672
|
+
React__namespace.useEffect(() => {
|
|
7673
|
+
if (!dockviewRef.current) {
|
|
7674
|
+
return;
|
|
7675
|
+
}
|
|
7676
|
+
dockviewRef.current.updateOptions({
|
|
7677
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7020
7678
|
});
|
|
7021
|
-
}, [props.
|
|
7679
|
+
}, [props.leftHeaderActionsComponent]);
|
|
7022
7680
|
return (React__namespace.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
7023
7681
|
});
|
|
7024
7682
|
DockviewReact.displayName = 'DockviewComponent';
|
|
@@ -7037,6 +7695,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
7037
7695
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
7038
7696
|
PERFORMANCE OF THIS SOFTWARE.
|
|
7039
7697
|
***************************************************************************** */
|
|
7698
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
7699
|
+
|
|
7040
7700
|
|
|
7041
7701
|
function __rest(s, e) {
|
|
7042
7702
|
var t = {};
|
|
@@ -7048,7 +7708,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
7048
7708
|
t[p[i]] = s[p[i]];
|
|
7049
7709
|
}
|
|
7050
7710
|
return t;
|
|
7051
|
-
}
|
|
7711
|
+
}
|
|
7712
|
+
|
|
7713
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
7714
|
+
var e = new Error(message);
|
|
7715
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
7716
|
+
};
|
|
7052
7717
|
|
|
7053
7718
|
const CloseButton = () => (React__namespace.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
|
|
7054
7719
|
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" })));
|
|
@@ -7376,6 +8041,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
|
|
|
7376
8041
|
exports.positionToDirection = positionToDirection;
|
|
7377
8042
|
exports.toTarget = toTarget;
|
|
7378
8043
|
exports.usePortalsLifecycle = usePortalsLifecycle;
|
|
7379
|
-
exports.watchElementResize = watchElementResize;
|
|
7380
8044
|
|
|
7381
8045
|
}));
|
|
8046
|
+
//# sourceMappingURL=dockview.amd.js.map
|