dockview 1.7.6 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cjs/dockview/dockview.d.ts +4 -2
- package/dist/cjs/dockview/dockview.d.ts.map +1 -1
- package/dist/cjs/dockview/dockview.js +23 -5
- package/dist/cjs/dockview/dockview.js.map +1 -1
- package/dist/cjs/dockview/{groupControlsRenderer.d.ts → headerActionsRenderer.d.ts} +6 -5
- package/dist/cjs/dockview/headerActionsRenderer.d.ts.map +1 -0
- package/dist/cjs/dockview/{groupControlsRenderer.js → headerActionsRenderer.js} +17 -16
- package/dist/cjs/dockview/{groupControlsRenderer.js.map → headerActionsRenderer.js.map} +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/svg.d.ts +3 -3
- package/dist/cjs/svg.d.ts.map +1 -1
- package/dist/dockview.amd.js +795 -138
- package/dist/dockview.amd.js.map +1 -0
- package/dist/dockview.amd.min.js +3 -2
- package/dist/dockview.amd.min.js.map +1 -0
- package/dist/dockview.amd.min.noStyle.js +3 -2
- package/dist/dockview.amd.min.noStyle.js.map +1 -0
- package/dist/dockview.amd.noStyle.js +795 -138
- package/dist/dockview.amd.noStyle.js.map +1 -0
- package/dist/dockview.cjs.js +795 -138
- package/dist/dockview.cjs.js.map +1 -0
- package/dist/dockview.esm.js +796 -138
- package/dist/dockview.esm.js.map +1 -0
- package/dist/dockview.esm.min.js +3 -2
- package/dist/dockview.esm.min.js.map +1 -0
- package/dist/dockview.js +795 -138
- package/dist/dockview.js.map +1 -0
- package/dist/dockview.min.js +3 -2
- package/dist/dockview.min.js.map +1 -0
- package/dist/dockview.min.noStyle.js +3 -2
- package/dist/dockview.min.noStyle.js.map +1 -0
- package/dist/dockview.noStyle.js +795 -138
- package/dist/dockview.noStyle.js.map +1 -0
- package/dist/esm/dockview/dockview.d.ts +4 -2
- package/dist/esm/dockview/dockview.d.ts.map +1 -1
- package/dist/esm/dockview/dockview.js +23 -5
- package/dist/esm/dockview/dockview.js.map +1 -1
- package/dist/esm/dockview/{groupControlsRenderer.d.ts → headerActionsRenderer.d.ts} +6 -5
- package/dist/esm/dockview/headerActionsRenderer.d.ts.map +1 -0
- package/dist/esm/dockview/{groupControlsRenderer.js → headerActionsRenderer.js} +3 -2
- package/dist/esm/dockview/{groupControlsRenderer.js.map → headerActionsRenderer.js.map} +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/svg.d.ts +3 -3
- package/dist/esm/svg.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/dockview/groupControlsRenderer.d.ts.map +0 -1
- package/dist/esm/dockview/groupControlsRenderer.d.ts.map +0 -1
package/dist/dockview.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.
|
|
3
|
+
* @version 1.8.0
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -304,6 +304,31 @@ class MutableDisposable {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
308
|
+
const Component = typeof componentName === 'string'
|
|
309
|
+
? components[componentName]
|
|
310
|
+
: undefined;
|
|
311
|
+
const FrameworkComponent = typeof componentName === 'string'
|
|
312
|
+
? frameworkComponents[componentName]
|
|
313
|
+
: undefined;
|
|
314
|
+
if (Component && FrameworkComponent) {
|
|
315
|
+
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
316
|
+
}
|
|
317
|
+
if (FrameworkComponent) {
|
|
318
|
+
if (!createFrameworkComponent) {
|
|
319
|
+
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
320
|
+
}
|
|
321
|
+
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
322
|
+
}
|
|
323
|
+
if (!Component) {
|
|
324
|
+
if (fallback) {
|
|
325
|
+
return fallback();
|
|
326
|
+
}
|
|
327
|
+
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
328
|
+
}
|
|
329
|
+
return new Component(id, componentName);
|
|
330
|
+
}
|
|
331
|
+
|
|
307
332
|
function watchElementResize(element, cb) {
|
|
308
333
|
const observer = new ResizeObserver((entires) => {
|
|
309
334
|
/**
|
|
@@ -417,31 +442,16 @@ class FocusTracker extends CompositeDisposable {
|
|
|
417
442
|
refreshState() {
|
|
418
443
|
this._refreshStateHandler();
|
|
419
444
|
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
|
|
431
|
-
}
|
|
432
|
-
if (FrameworkComponent) {
|
|
433
|
-
if (!createFrameworkComponent) {
|
|
434
|
-
throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
|
|
435
|
-
}
|
|
436
|
-
return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
|
|
437
|
-
}
|
|
438
|
-
if (!Component) {
|
|
439
|
-
if (fallback) {
|
|
440
|
-
return fallback();
|
|
441
|
-
}
|
|
442
|
-
throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
|
|
443
|
-
}
|
|
444
|
-
return new Component(id, componentName);
|
|
445
|
+
}
|
|
446
|
+
// quasi: apparently, but not really; seemingly
|
|
447
|
+
const QUASI_PREVENT_DEFAULT_KEY = 'dv-quasiPreventDefault';
|
|
448
|
+
// mark an event directly for other listeners to check
|
|
449
|
+
function quasiPreventDefault(event) {
|
|
450
|
+
event[QUASI_PREVENT_DEFAULT_KEY] = true;
|
|
451
|
+
}
|
|
452
|
+
// check if this event has been marked
|
|
453
|
+
function quasiDefaultPrevented(event) {
|
|
454
|
+
return event[QUASI_PREVENT_DEFAULT_KEY];
|
|
445
455
|
}
|
|
446
456
|
|
|
447
457
|
function tail(arr) {
|
|
@@ -492,6 +502,14 @@ function firstIndex(array, fn) {
|
|
|
492
502
|
}
|
|
493
503
|
}
|
|
494
504
|
return -1;
|
|
505
|
+
}
|
|
506
|
+
function remove(array, value) {
|
|
507
|
+
const index = array.findIndex((t) => t === value);
|
|
508
|
+
if (index > -1) {
|
|
509
|
+
array.splice(index, 1);
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
return false;
|
|
495
513
|
}
|
|
496
514
|
|
|
497
515
|
const clamp = (value, min, max) => {
|
|
@@ -1634,7 +1652,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1634
1652
|
: true,
|
|
1635
1653
|
};
|
|
1636
1654
|
}),
|
|
1637
|
-
size: this.
|
|
1655
|
+
size: this.orthogonalSize,
|
|
1638
1656
|
};
|
|
1639
1657
|
this.children = childDescriptors.map((c) => c.node);
|
|
1640
1658
|
this.splitview = new Splitview(this.element, {
|
|
@@ -1697,7 +1715,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1697
1715
|
layout(size, orthogonalSize) {
|
|
1698
1716
|
this._size = orthogonalSize;
|
|
1699
1717
|
this._orthogonalSize = size;
|
|
1700
|
-
this.splitview.layout(
|
|
1718
|
+
this.splitview.layout(orthogonalSize, size);
|
|
1701
1719
|
}
|
|
1702
1720
|
addChild(node, size, index, skipLayout) {
|
|
1703
1721
|
if (index < 0 || index > this.children.length) {
|
|
@@ -1922,9 +1940,9 @@ class Gridview {
|
|
|
1922
1940
|
this._deserialize(json.root, orientation, deserializer, height);
|
|
1923
1941
|
}
|
|
1924
1942
|
_deserialize(root, orientation, deserializer, orthogonalSize) {
|
|
1925
|
-
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize
|
|
1943
|
+
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
|
|
1926
1944
|
}
|
|
1927
|
-
_deserializeNode(node, orientation, deserializer, orthogonalSize
|
|
1945
|
+
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
1928
1946
|
let result;
|
|
1929
1947
|
if (node.type === 'branch') {
|
|
1930
1948
|
const serializedChildren = node.data;
|
|
@@ -1934,9 +1952,9 @@ class Gridview {
|
|
|
1934
1952
|
visible: serializedChild.visible,
|
|
1935
1953
|
};
|
|
1936
1954
|
});
|
|
1937
|
-
//
|
|
1938
|
-
//
|
|
1939
|
-
|
|
1955
|
+
result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
|
|
1956
|
+
orthogonalSize, // <- size - flips at each depth
|
|
1957
|
+
children);
|
|
1940
1958
|
}
|
|
1941
1959
|
else {
|
|
1942
1960
|
result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
|
|
@@ -1969,7 +1987,8 @@ class Gridview {
|
|
|
1969
1987
|
const oldRoot = this.root;
|
|
1970
1988
|
oldRoot.element.remove();
|
|
1971
1989
|
this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
|
|
1972
|
-
if (oldRoot.children.length ===
|
|
1990
|
+
if (oldRoot.children.length === 0) ;
|
|
1991
|
+
else if (oldRoot.children.length === 1) {
|
|
1973
1992
|
// can remove one level of redundant branching if there is only a single child
|
|
1974
1993
|
const childReference = oldRoot.children[0];
|
|
1975
1994
|
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
@@ -2485,6 +2504,9 @@ class DockviewApi {
|
|
|
2485
2504
|
addPanel(options) {
|
|
2486
2505
|
return this.component.addPanel(options);
|
|
2487
2506
|
}
|
|
2507
|
+
removePanel(panel) {
|
|
2508
|
+
this.component.removePanel(panel);
|
|
2509
|
+
}
|
|
2488
2510
|
addGroup(options) {
|
|
2489
2511
|
return this.component.addGroup(options);
|
|
2490
2512
|
}
|
|
@@ -2503,6 +2525,9 @@ class DockviewApi {
|
|
|
2503
2525
|
getGroup(id) {
|
|
2504
2526
|
return this.component.getPanel(id);
|
|
2505
2527
|
}
|
|
2528
|
+
addFloatingGroup(item, coord) {
|
|
2529
|
+
return this.component.addFloatingGroup(item, coord);
|
|
2530
|
+
}
|
|
2506
2531
|
fromJSON(data) {
|
|
2507
2532
|
this.component.fromJSON(data);
|
|
2508
2533
|
}
|
|
@@ -2595,10 +2620,14 @@ class Droptarget extends CompositeDisposable {
|
|
|
2595
2620
|
this._onDrop = new Emitter();
|
|
2596
2621
|
this.onDrop = this._onDrop.event;
|
|
2597
2622
|
// use a set to take advantage of #<set>.has
|
|
2598
|
-
|
|
2623
|
+
this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
|
|
2599
2624
|
this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
|
|
2600
2625
|
onDragEnter: () => undefined,
|
|
2601
2626
|
onDragOver: (e) => {
|
|
2627
|
+
if (this._acceptedTargetZonesSet.size === 0) {
|
|
2628
|
+
this.removeDropTarget();
|
|
2629
|
+
return;
|
|
2630
|
+
}
|
|
2602
2631
|
const width = this.element.clientWidth;
|
|
2603
2632
|
const height = this.element.clientHeight;
|
|
2604
2633
|
if (width === 0 || height === 0) {
|
|
@@ -2607,20 +2636,28 @@ class Droptarget extends CompositeDisposable {
|
|
|
2607
2636
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
2608
2637
|
const x = e.clientX - rect.left;
|
|
2609
2638
|
const y = e.clientY - rect.top;
|
|
2610
|
-
const quadrant = this.calculateQuadrant(
|
|
2611
|
-
|
|
2639
|
+
const quadrant = this.calculateQuadrant(this._acceptedTargetZonesSet, x, y, width, height);
|
|
2640
|
+
/**
|
|
2641
|
+
* If the event has already been used by another DropTarget instance
|
|
2642
|
+
* then don't show a second drop target, only one target should be
|
|
2643
|
+
* active at any one time
|
|
2644
|
+
*/
|
|
2645
|
+
if (this.isAlreadyUsed(e) || quadrant === null) {
|
|
2612
2646
|
// no drop target should be displayed
|
|
2613
2647
|
this.removeDropTarget();
|
|
2614
2648
|
return;
|
|
2615
2649
|
}
|
|
2616
2650
|
if (typeof this.options.canDisplayOverlay === 'boolean') {
|
|
2617
2651
|
if (!this.options.canDisplayOverlay) {
|
|
2652
|
+
this.removeDropTarget();
|
|
2618
2653
|
return;
|
|
2619
2654
|
}
|
|
2620
2655
|
}
|
|
2621
2656
|
else if (!this.options.canDisplayOverlay(e, quadrant)) {
|
|
2657
|
+
this.removeDropTarget();
|
|
2622
2658
|
return;
|
|
2623
2659
|
}
|
|
2660
|
+
this.markAsUsed(e);
|
|
2624
2661
|
if (!this.targetElement) {
|
|
2625
2662
|
this.targetElement = document.createElement('div');
|
|
2626
2663
|
this.targetElement.className = 'drop-target-dropzone';
|
|
@@ -2631,12 +2668,6 @@ class Droptarget extends CompositeDisposable {
|
|
|
2631
2668
|
this.element.classList.add('drop-target');
|
|
2632
2669
|
this.element.append(this.targetElement);
|
|
2633
2670
|
}
|
|
2634
|
-
if (this.options.acceptedTargetZones.length === 0) {
|
|
2635
|
-
return;
|
|
2636
|
-
}
|
|
2637
|
-
if (!this.targetElement || !this.overlayElement) {
|
|
2638
|
-
return;
|
|
2639
|
-
}
|
|
2640
2671
|
this.toggleClasses(quadrant, width, height);
|
|
2641
2672
|
this.setState(quadrant);
|
|
2642
2673
|
},
|
|
@@ -2659,10 +2690,26 @@ class Droptarget extends CompositeDisposable {
|
|
|
2659
2690
|
},
|
|
2660
2691
|
}));
|
|
2661
2692
|
}
|
|
2693
|
+
setTargetZones(acceptedTargetZones) {
|
|
2694
|
+
this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
|
|
2695
|
+
}
|
|
2662
2696
|
dispose() {
|
|
2663
2697
|
this.removeDropTarget();
|
|
2664
2698
|
super.dispose();
|
|
2665
2699
|
}
|
|
2700
|
+
/**
|
|
2701
|
+
* Add a property to the event object for other potential listeners to check
|
|
2702
|
+
*/
|
|
2703
|
+
markAsUsed(event) {
|
|
2704
|
+
event[Droptarget.USED_EVENT_ID] = true;
|
|
2705
|
+
}
|
|
2706
|
+
/**
|
|
2707
|
+
* Check is the event has already been used by another instance od DropTarget
|
|
2708
|
+
*/
|
|
2709
|
+
isAlreadyUsed(event) {
|
|
2710
|
+
const value = event[Droptarget.USED_EVENT_ID];
|
|
2711
|
+
return typeof value === 'boolean' && value;
|
|
2712
|
+
}
|
|
2666
2713
|
toggleClasses(quadrant, width, height) {
|
|
2667
2714
|
var _a, _b, _c, _d;
|
|
2668
2715
|
if (!this.overlayElement) {
|
|
@@ -2757,6 +2804,7 @@ class Droptarget extends CompositeDisposable {
|
|
|
2757
2804
|
}
|
|
2758
2805
|
}
|
|
2759
2806
|
}
|
|
2807
|
+
Droptarget.USED_EVENT_ID = '__dockview_droptarget_event_is_used__';
|
|
2760
2808
|
function calculateQuadrantAsPercentage(overlayType, x, y, width, height, threshold) {
|
|
2761
2809
|
const xp = (100 * x) / width;
|
|
2762
2810
|
const yp = (100 * y) / height;
|
|
@@ -2886,8 +2934,15 @@ class DragHandler extends CompositeDisposable {
|
|
|
2886
2934
|
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2887
2935
|
this.configure();
|
|
2888
2936
|
}
|
|
2937
|
+
isCancelled(_event) {
|
|
2938
|
+
return false;
|
|
2939
|
+
}
|
|
2889
2940
|
configure() {
|
|
2890
2941
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2942
|
+
if (this.isCancelled(event)) {
|
|
2943
|
+
event.preventDefault();
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2891
2946
|
const iframes = [
|
|
2892
2947
|
...getElementsByTagName('iframe'),
|
|
2893
2948
|
...getElementsByTagName('webview'),
|
|
@@ -2961,13 +3016,6 @@ class Tab extends CompositeDisposable {
|
|
|
2961
3016
|
if (event.defaultPrevented) {
|
|
2962
3017
|
return;
|
|
2963
3018
|
}
|
|
2964
|
-
/**
|
|
2965
|
-
* TODO: alternative to stopPropagation
|
|
2966
|
-
*
|
|
2967
|
-
* I need to stop the event propagation here since otherwise it'll be intercepted by event handlers
|
|
2968
|
-
* on the tabs-container. I cannot use event.preventDefault() since I need the on DragStart event to occur
|
|
2969
|
-
*/
|
|
2970
|
-
event.stopPropagation();
|
|
2971
3019
|
this._onChanged.fire(event);
|
|
2972
3020
|
}));
|
|
2973
3021
|
this.droptarget = new Droptarget(this._element, {
|
|
@@ -3025,6 +3073,22 @@ class GroupDragHandler extends DragHandler {
|
|
|
3025
3073
|
this.accessorId = accessorId;
|
|
3026
3074
|
this.group = group;
|
|
3027
3075
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
3076
|
+
this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
|
|
3077
|
+
if (e.shiftKey) {
|
|
3078
|
+
/**
|
|
3079
|
+
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
3080
|
+
* but we also need to stop any group overlay drag events from occuring
|
|
3081
|
+
* Use a custom event marker that can be checked by the overlay drag events
|
|
3082
|
+
*/
|
|
3083
|
+
quasiPreventDefault(e);
|
|
3084
|
+
}
|
|
3085
|
+
}, true));
|
|
3086
|
+
}
|
|
3087
|
+
isCancelled(_event) {
|
|
3088
|
+
if (this.group.api.isFloating && !_event.shiftKey) {
|
|
3089
|
+
return true;
|
|
3090
|
+
}
|
|
3091
|
+
return false;
|
|
3028
3092
|
}
|
|
3029
3093
|
getData(dataTransfer) {
|
|
3030
3094
|
this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
|
|
@@ -3115,17 +3179,30 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3115
3179
|
hide() {
|
|
3116
3180
|
this._element.style.display = 'none';
|
|
3117
3181
|
}
|
|
3118
|
-
|
|
3119
|
-
if (this.
|
|
3182
|
+
setRightActionsElement(element) {
|
|
3183
|
+
if (this.rightActions === element) {
|
|
3120
3184
|
return;
|
|
3121
3185
|
}
|
|
3122
|
-
if (this.
|
|
3123
|
-
this.
|
|
3124
|
-
this.
|
|
3186
|
+
if (this.rightActions) {
|
|
3187
|
+
this.rightActions.remove();
|
|
3188
|
+
this.rightActions = undefined;
|
|
3125
3189
|
}
|
|
3126
3190
|
if (element) {
|
|
3127
|
-
this.
|
|
3128
|
-
this.
|
|
3191
|
+
this.rightActionsContainer.appendChild(element);
|
|
3192
|
+
this.rightActions = element;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
setLeftActionsElement(element) {
|
|
3196
|
+
if (this.leftActions === element) {
|
|
3197
|
+
return;
|
|
3198
|
+
}
|
|
3199
|
+
if (this.leftActions) {
|
|
3200
|
+
this.leftActions.remove();
|
|
3201
|
+
this.leftActions = undefined;
|
|
3202
|
+
}
|
|
3203
|
+
if (element) {
|
|
3204
|
+
this.leftActionsContainer.appendChild(element);
|
|
3205
|
+
this.leftActions = element;
|
|
3129
3206
|
}
|
|
3130
3207
|
}
|
|
3131
3208
|
get element() {
|
|
@@ -3160,19 +3237,35 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3160
3237
|
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
3161
3238
|
}
|
|
3162
3239
|
}));
|
|
3163
|
-
this.
|
|
3164
|
-
this.
|
|
3240
|
+
this.rightActionsContainer = document.createElement('div');
|
|
3241
|
+
this.rightActionsContainer.className = 'right-actions-container';
|
|
3242
|
+
this.leftActionsContainer = document.createElement('div');
|
|
3243
|
+
this.leftActionsContainer.className = 'left-actions-container';
|
|
3165
3244
|
this.tabContainer = document.createElement('div');
|
|
3166
3245
|
this.tabContainer.className = 'tabs-container';
|
|
3167
3246
|
this.voidContainer = new VoidContainer(this.accessor, this.group);
|
|
3168
3247
|
this._element.appendChild(this.tabContainer);
|
|
3248
|
+
this._element.appendChild(this.leftActionsContainer);
|
|
3169
3249
|
this._element.appendChild(this.voidContainer.element);
|
|
3170
|
-
this._element.appendChild(this.
|
|
3250
|
+
this._element.appendChild(this.rightActionsContainer);
|
|
3171
3251
|
this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
|
|
3172
3252
|
this._onDrop.fire({
|
|
3173
3253
|
event: event.nativeEvent,
|
|
3174
3254
|
index: this.tabs.length,
|
|
3175
3255
|
});
|
|
3256
|
+
}), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
|
|
3257
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3258
|
+
if (isFloatingGroupsEnabled &&
|
|
3259
|
+
event.shiftKey &&
|
|
3260
|
+
!this.group.api.isFloating) {
|
|
3261
|
+
event.preventDefault();
|
|
3262
|
+
const { top, left } = this.element.getBoundingClientRect();
|
|
3263
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3264
|
+
this.accessor.addFloatingGroup(this.group, {
|
|
3265
|
+
x: left - rootLeft + 20,
|
|
3266
|
+
y: top - rootTop + 20,
|
|
3267
|
+
}, { inDragMode: true });
|
|
3268
|
+
}
|
|
3176
3269
|
}), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
|
|
3177
3270
|
if (event.defaultPrevented) {
|
|
3178
3271
|
return;
|
|
@@ -3226,6 +3319,21 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3226
3319
|
tabToAdd.setContent(panel.view.tab);
|
|
3227
3320
|
const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
|
|
3228
3321
|
var _a;
|
|
3322
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
3323
|
+
const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
|
|
3324
|
+
if (isFloatingGroupsEnabled &&
|
|
3325
|
+
!isFloatingWithOnePanel &&
|
|
3326
|
+
event.shiftKey) {
|
|
3327
|
+
event.preventDefault();
|
|
3328
|
+
const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
|
|
3329
|
+
const { top, left } = tabToAdd.element.getBoundingClientRect();
|
|
3330
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
3331
|
+
this.accessor.addFloatingGroup(panel, {
|
|
3332
|
+
x: left - rootLeft,
|
|
3333
|
+
y: top - rootTop,
|
|
3334
|
+
}, { inDragMode: true });
|
|
3335
|
+
return;
|
|
3336
|
+
}
|
|
3229
3337
|
const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
|
|
3230
3338
|
this.group.model.isContentFocused;
|
|
3231
3339
|
const isLeftClick = event.button === 0;
|
|
@@ -3295,6 +3403,17 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3295
3403
|
}
|
|
3296
3404
|
return isAncestor(document.activeElement, this.contentContainer.element);
|
|
3297
3405
|
}
|
|
3406
|
+
get isFloating() {
|
|
3407
|
+
return this._isFloating;
|
|
3408
|
+
}
|
|
3409
|
+
set isFloating(value) {
|
|
3410
|
+
this._isFloating = value;
|
|
3411
|
+
this.dropTarget.setTargetZones(value ? ['center'] : ['top', 'bottom', 'left', 'right', 'center']);
|
|
3412
|
+
toggleClass(this.container, 'dv-groupview-floating', value);
|
|
3413
|
+
this.groupPanel.api._onDidFloatingStateChange.fire({
|
|
3414
|
+
isFloating: this.isFloating,
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3298
3417
|
constructor(container, accessor, id, options, groupPanel) {
|
|
3299
3418
|
super();
|
|
3300
3419
|
this.container = container;
|
|
@@ -3304,6 +3423,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3304
3423
|
this.groupPanel = groupPanel;
|
|
3305
3424
|
this._isGroupActive = false;
|
|
3306
3425
|
this._locked = false;
|
|
3426
|
+
this._isFloating = false;
|
|
3307
3427
|
this.mostRecentlyUsed = [];
|
|
3308
3428
|
this._onDidChange = new Emitter();
|
|
3309
3429
|
this.onDidChange = this._onDidChange.event;
|
|
@@ -3320,7 +3440,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3320
3440
|
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
3321
3441
|
this._onDidActivePanelChange = new Emitter();
|
|
3322
3442
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
3323
|
-
this.container
|
|
3443
|
+
toggleClass(this.container, 'groupview', true);
|
|
3324
3444
|
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
|
3325
3445
|
this.contentContainer = new ContentContainer();
|
|
3326
3446
|
this.dropTarget = new Droptarget(this.contentContainer.element, {
|
|
@@ -3330,6 +3450,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3330
3450
|
return false;
|
|
3331
3451
|
}
|
|
3332
3452
|
const data = getPanelData();
|
|
3453
|
+
if (!data && event.shiftKey && !this.isFloating) {
|
|
3454
|
+
return false;
|
|
3455
|
+
}
|
|
3333
3456
|
if (data && data.viewId === this.accessor.id) {
|
|
3334
3457
|
if (data.groupId === this.id) {
|
|
3335
3458
|
if (position === 'center') {
|
|
@@ -3374,14 +3497,25 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3374
3497
|
// correctly initialized
|
|
3375
3498
|
this.setActive(this.isActive, true, true);
|
|
3376
3499
|
this.updateContainer();
|
|
3377
|
-
if (this.accessor.options.
|
|
3378
|
-
this.
|
|
3379
|
-
|
|
3380
|
-
this.
|
|
3500
|
+
if (this.accessor.options.createRightHeaderActionsElement) {
|
|
3501
|
+
this._rightHeaderActions =
|
|
3502
|
+
this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
|
|
3503
|
+
this.addDisposables(this._rightHeaderActions);
|
|
3504
|
+
this._rightHeaderActions.init({
|
|
3381
3505
|
containerApi: new DockviewApi(this.accessor),
|
|
3382
3506
|
api: this.groupPanel.api,
|
|
3383
3507
|
});
|
|
3384
|
-
this.tabsContainer.
|
|
3508
|
+
this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
|
|
3509
|
+
}
|
|
3510
|
+
if (this.accessor.options.createLeftHeaderActionsElement) {
|
|
3511
|
+
this._leftHeaderActions =
|
|
3512
|
+
this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
|
|
3513
|
+
this.addDisposables(this._leftHeaderActions);
|
|
3514
|
+
this._leftHeaderActions.init({
|
|
3515
|
+
containerApi: new DockviewApi(this.accessor),
|
|
3516
|
+
api: this.groupPanel.api,
|
|
3517
|
+
});
|
|
3518
|
+
this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
|
|
3385
3519
|
}
|
|
3386
3520
|
}
|
|
3387
3521
|
indexOf(panel) {
|
|
@@ -3514,7 +3648,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3514
3648
|
return this._activePanel === panel;
|
|
3515
3649
|
}
|
|
3516
3650
|
updateActions(element) {
|
|
3517
|
-
this.tabsContainer.
|
|
3651
|
+
this.tabsContainer.setRightActionsElement(element);
|
|
3518
3652
|
}
|
|
3519
3653
|
setActive(isGroupActive, skipFocus = false, force = false) {
|
|
3520
3654
|
var _a, _b, _c, _d;
|
|
@@ -3686,9 +3820,10 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3686
3820
|
}
|
|
3687
3821
|
}
|
|
3688
3822
|
dispose() {
|
|
3689
|
-
var _a, _b;
|
|
3823
|
+
var _a, _b, _c;
|
|
3690
3824
|
super.dispose();
|
|
3691
|
-
(
|
|
3825
|
+
(_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
|
|
3826
|
+
(_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3692
3827
|
for (const panel of this.panels) {
|
|
3693
3828
|
panel.dispose();
|
|
3694
3829
|
}
|
|
@@ -4482,8 +4617,8 @@ class GridviewPanel extends BasePanelView {
|
|
|
4482
4617
|
get isActive() {
|
|
4483
4618
|
return this.api.isActive;
|
|
4484
4619
|
}
|
|
4485
|
-
constructor(id, component, options) {
|
|
4486
|
-
super(id, component, new GridviewPanelApiImpl(id));
|
|
4620
|
+
constructor(id, component, options, api) {
|
|
4621
|
+
super(id, component, api !== null && api !== void 0 ? api : new GridviewPanelApiImpl(id));
|
|
4487
4622
|
this._evaluatedMinimumWidth = 0;
|
|
4488
4623
|
this._evaluatedMaximumWidth = Number.MAX_SAFE_INTEGER;
|
|
4489
4624
|
this._evaluatedMinimumHeight = 0;
|
|
@@ -4581,6 +4716,32 @@ class GridviewPanel extends BasePanelView {
|
|
|
4581
4716
|
}
|
|
4582
4717
|
}
|
|
4583
4718
|
|
|
4719
|
+
class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|
4720
|
+
get isFloating() {
|
|
4721
|
+
if (!this._group) {
|
|
4722
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4723
|
+
}
|
|
4724
|
+
return this._group.model.isFloating;
|
|
4725
|
+
}
|
|
4726
|
+
constructor(id, accessor) {
|
|
4727
|
+
super(id);
|
|
4728
|
+
this.accessor = accessor;
|
|
4729
|
+
this._onDidFloatingStateChange = new Emitter();
|
|
4730
|
+
this.onDidFloatingStateChange = this._onDidFloatingStateChange.event;
|
|
4731
|
+
this.addDisposables(this._onDidFloatingStateChange);
|
|
4732
|
+
}
|
|
4733
|
+
moveTo(options) {
|
|
4734
|
+
var _a;
|
|
4735
|
+
if (!this._group) {
|
|
4736
|
+
throw new Error(`DockviewGroupPanelApiImpl not initialized`);
|
|
4737
|
+
}
|
|
4738
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, undefined, (_a = options.position) !== null && _a !== void 0 ? _a : 'center');
|
|
4739
|
+
}
|
|
4740
|
+
initialize(group) {
|
|
4741
|
+
this._group = group;
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
|
|
4584
4745
|
class DockviewGroupPanel extends GridviewPanel {
|
|
4585
4746
|
get panels() {
|
|
4586
4747
|
return this._model.panels;
|
|
@@ -4607,7 +4768,8 @@ class DockviewGroupPanel extends GridviewPanel {
|
|
|
4607
4768
|
super(id, 'groupview_default', {
|
|
4608
4769
|
minimumHeight: 100,
|
|
4609
4770
|
minimumWidth: 100,
|
|
4610
|
-
});
|
|
4771
|
+
}, new DockviewGroupPanelApiImpl(id, accessor));
|
|
4772
|
+
this.api.initialize(this); // cannot use 'this' after after 'super' call
|
|
4611
4773
|
this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
|
|
4612
4774
|
}
|
|
4613
4775
|
initialize() {
|
|
@@ -4625,7 +4787,6 @@ class DockviewGroupPanel extends GridviewPanel {
|
|
|
4625
4787
|
return this._model;
|
|
4626
4788
|
}
|
|
4627
4789
|
toJSON() {
|
|
4628
|
-
// TODO fix typing
|
|
4629
4790
|
return this.model.toJSON();
|
|
4630
4791
|
}
|
|
4631
4792
|
}
|
|
@@ -4679,9 +4840,10 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4679
4840
|
get group() {
|
|
4680
4841
|
return this._group;
|
|
4681
4842
|
}
|
|
4682
|
-
constructor(panel, group) {
|
|
4843
|
+
constructor(panel, group, accessor) {
|
|
4683
4844
|
super(panel.id);
|
|
4684
4845
|
this.panel = panel;
|
|
4846
|
+
this.accessor = accessor;
|
|
4685
4847
|
this._onDidTitleChange = new Emitter();
|
|
4686
4848
|
this.onDidTitleChange = this._onDidTitleChange.event;
|
|
4687
4849
|
this._onDidActiveGroupChange = new Emitter();
|
|
@@ -4693,6 +4855,10 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4693
4855
|
this._group = group;
|
|
4694
4856
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4695
4857
|
}
|
|
4858
|
+
moveTo(options) {
|
|
4859
|
+
var _a;
|
|
4860
|
+
this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
|
|
4861
|
+
}
|
|
4696
4862
|
setTitle(title) {
|
|
4697
4863
|
this.panel.setTitle(title);
|
|
4698
4864
|
}
|
|
@@ -4717,7 +4883,7 @@ class DockviewPanel extends CompositeDisposable {
|
|
|
4717
4883
|
this.containerApi = containerApi;
|
|
4718
4884
|
this.view = view;
|
|
4719
4885
|
this._group = group;
|
|
4720
|
-
this.api = new DockviewPanelApiImpl(this, this._group);
|
|
4886
|
+
this.api = new DockviewPanelApiImpl(this, this._group, accessor);
|
|
4721
4887
|
this.addDisposables(this.api.onActiveChange(() => {
|
|
4722
4888
|
accessor.setActivePanel(this);
|
|
4723
4889
|
}), this.api.onDidSizeChange((event) => {
|
|
@@ -5058,6 +5224,296 @@ class Watermark extends CompositeDisposable {
|
|
|
5058
5224
|
}
|
|
5059
5225
|
}
|
|
5060
5226
|
|
|
5227
|
+
const bringElementToFront = (() => {
|
|
5228
|
+
let previous = null;
|
|
5229
|
+
function pushToTop(element) {
|
|
5230
|
+
if (previous !== element && previous !== null) {
|
|
5231
|
+
toggleClass(previous, 'dv-bring-to-front', false);
|
|
5232
|
+
}
|
|
5233
|
+
toggleClass(element, 'dv-bring-to-front', true);
|
|
5234
|
+
previous = element;
|
|
5235
|
+
}
|
|
5236
|
+
return pushToTop;
|
|
5237
|
+
})();
|
|
5238
|
+
class Overlay extends CompositeDisposable {
|
|
5239
|
+
constructor(options) {
|
|
5240
|
+
super();
|
|
5241
|
+
this.options = options;
|
|
5242
|
+
this._element = document.createElement('div');
|
|
5243
|
+
this._onDidChange = new Emitter();
|
|
5244
|
+
this.onDidChange = this._onDidChange.event;
|
|
5245
|
+
this._onDidChangeEnd = new Emitter();
|
|
5246
|
+
this.onDidChangeEnd = this._onDidChangeEnd.event;
|
|
5247
|
+
this.addDisposables(this._onDidChange, this._onDidChangeEnd);
|
|
5248
|
+
this._element.className = 'dv-resize-container';
|
|
5249
|
+
this.setupResize('top');
|
|
5250
|
+
this.setupResize('bottom');
|
|
5251
|
+
this.setupResize('left');
|
|
5252
|
+
this.setupResize('right');
|
|
5253
|
+
this.setupResize('topleft');
|
|
5254
|
+
this.setupResize('topright');
|
|
5255
|
+
this.setupResize('bottomleft');
|
|
5256
|
+
this.setupResize('bottomright');
|
|
5257
|
+
this._element.appendChild(this.options.content);
|
|
5258
|
+
this.options.container.appendChild(this._element);
|
|
5259
|
+
// if input bad resize within acceptable boundaries
|
|
5260
|
+
this.setBounds({
|
|
5261
|
+
height: this.options.height,
|
|
5262
|
+
width: this.options.width,
|
|
5263
|
+
top: this.options.top,
|
|
5264
|
+
left: this.options.left,
|
|
5265
|
+
});
|
|
5266
|
+
}
|
|
5267
|
+
setBounds(bounds = {}) {
|
|
5268
|
+
if (typeof bounds.height === 'number') {
|
|
5269
|
+
this._element.style.height = `${bounds.height}px`;
|
|
5270
|
+
}
|
|
5271
|
+
if (typeof bounds.width === 'number') {
|
|
5272
|
+
this._element.style.width = `${bounds.width}px`;
|
|
5273
|
+
}
|
|
5274
|
+
if (typeof bounds.top === 'number') {
|
|
5275
|
+
this._element.style.top = `${bounds.top}px`;
|
|
5276
|
+
}
|
|
5277
|
+
if (typeof bounds.left === 'number') {
|
|
5278
|
+
this._element.style.left = `${bounds.left}px`;
|
|
5279
|
+
}
|
|
5280
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5281
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5282
|
+
// region: ensure bounds within allowable limits
|
|
5283
|
+
// a minimum width of minimumViewportWidth must be inside the viewport
|
|
5284
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5285
|
+
// a minimum height of minimumViewportHeight must be inside the viewport
|
|
5286
|
+
const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
|
|
5287
|
+
const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5288
|
+
const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5289
|
+
this._element.style.left = `${left}px`;
|
|
5290
|
+
this._element.style.top = `${top}px`;
|
|
5291
|
+
this._onDidChange.fire();
|
|
5292
|
+
}
|
|
5293
|
+
toJSON() {
|
|
5294
|
+
const container = this.options.container.getBoundingClientRect();
|
|
5295
|
+
const element = this._element.getBoundingClientRect();
|
|
5296
|
+
return {
|
|
5297
|
+
top: element.top - container.top,
|
|
5298
|
+
left: element.left - container.left,
|
|
5299
|
+
width: element.width,
|
|
5300
|
+
height: element.height,
|
|
5301
|
+
};
|
|
5302
|
+
}
|
|
5303
|
+
setupDrag(dragTarget, options = { inDragMode: false }) {
|
|
5304
|
+
const move = new MutableDisposable();
|
|
5305
|
+
const track = () => {
|
|
5306
|
+
let offset = null;
|
|
5307
|
+
const iframes = [
|
|
5308
|
+
...getElementsByTagName('iframe'),
|
|
5309
|
+
...getElementsByTagName('webview'),
|
|
5310
|
+
];
|
|
5311
|
+
for (const iframe of iframes) {
|
|
5312
|
+
iframe.style.pointerEvents = 'none';
|
|
5313
|
+
}
|
|
5314
|
+
move.value = new CompositeDisposable({
|
|
5315
|
+
dispose: () => {
|
|
5316
|
+
for (const iframe of iframes) {
|
|
5317
|
+
iframe.style.pointerEvents = 'auto';
|
|
5318
|
+
}
|
|
5319
|
+
},
|
|
5320
|
+
}, addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5321
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5322
|
+
const x = e.clientX - containerRect.left;
|
|
5323
|
+
const y = e.clientY - containerRect.top;
|
|
5324
|
+
toggleClass(this._element, 'dv-resize-container-dragging', true);
|
|
5325
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5326
|
+
if (offset === null) {
|
|
5327
|
+
offset = {
|
|
5328
|
+
x: e.clientX - overlayRect.left,
|
|
5329
|
+
y: e.clientY - overlayRect.top,
|
|
5330
|
+
};
|
|
5331
|
+
}
|
|
5332
|
+
const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
|
|
5333
|
+
const yOffset = Math.max(0, overlayRect.height -
|
|
5334
|
+
this.options.minimumInViewportHeight);
|
|
5335
|
+
const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
|
|
5336
|
+
const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
|
|
5337
|
+
this.setBounds({ top, left });
|
|
5338
|
+
}), addDisposableWindowListener(window, 'mouseup', () => {
|
|
5339
|
+
toggleClass(this._element, 'dv-resize-container-dragging', false);
|
|
5340
|
+
move.dispose();
|
|
5341
|
+
this._onDidChangeEnd.fire();
|
|
5342
|
+
}));
|
|
5343
|
+
};
|
|
5344
|
+
this.addDisposables(move, addDisposableListener(dragTarget, 'mousedown', (event) => {
|
|
5345
|
+
if (event.defaultPrevented) {
|
|
5346
|
+
event.preventDefault();
|
|
5347
|
+
return;
|
|
5348
|
+
}
|
|
5349
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5350
|
+
// without actually calling event.preventDefault()
|
|
5351
|
+
if (quasiDefaultPrevented(event)) {
|
|
5352
|
+
return;
|
|
5353
|
+
}
|
|
5354
|
+
track();
|
|
5355
|
+
}), addDisposableListener(this.options.content, 'mousedown', (event) => {
|
|
5356
|
+
if (event.defaultPrevented) {
|
|
5357
|
+
return;
|
|
5358
|
+
}
|
|
5359
|
+
// if somebody has marked this event then treat as a defaultPrevented
|
|
5360
|
+
// without actually calling event.preventDefault()
|
|
5361
|
+
if (quasiDefaultPrevented(event)) {
|
|
5362
|
+
return;
|
|
5363
|
+
}
|
|
5364
|
+
if (event.shiftKey) {
|
|
5365
|
+
track();
|
|
5366
|
+
}
|
|
5367
|
+
}), addDisposableListener(this.options.content, 'mousedown', () => {
|
|
5368
|
+
bringElementToFront(this._element);
|
|
5369
|
+
}, true));
|
|
5370
|
+
bringElementToFront(this._element);
|
|
5371
|
+
if (options.inDragMode) {
|
|
5372
|
+
track();
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
setupResize(direction) {
|
|
5376
|
+
const resizeHandleElement = document.createElement('div');
|
|
5377
|
+
resizeHandleElement.className = `dv-resize-handle-${direction}`;
|
|
5378
|
+
this._element.appendChild(resizeHandleElement);
|
|
5379
|
+
const move = new MutableDisposable();
|
|
5380
|
+
this.addDisposables(move, addDisposableListener(resizeHandleElement, 'mousedown', (e) => {
|
|
5381
|
+
e.preventDefault();
|
|
5382
|
+
let startPosition = null;
|
|
5383
|
+
const iframes = [
|
|
5384
|
+
...getElementsByTagName('iframe'),
|
|
5385
|
+
...getElementsByTagName('webview'),
|
|
5386
|
+
];
|
|
5387
|
+
for (const iframe of iframes) {
|
|
5388
|
+
iframe.style.pointerEvents = 'none';
|
|
5389
|
+
}
|
|
5390
|
+
move.value = new CompositeDisposable(addDisposableWindowListener(window, 'mousemove', (e) => {
|
|
5391
|
+
const containerRect = this.options.container.getBoundingClientRect();
|
|
5392
|
+
const overlayRect = this._element.getBoundingClientRect();
|
|
5393
|
+
const y = e.clientY - containerRect.top;
|
|
5394
|
+
const x = e.clientX - containerRect.left;
|
|
5395
|
+
if (startPosition === null) {
|
|
5396
|
+
// record the initial dimensions since as all subsequence moves are relative to this
|
|
5397
|
+
startPosition = {
|
|
5398
|
+
originalY: y,
|
|
5399
|
+
originalHeight: overlayRect.height,
|
|
5400
|
+
originalX: x,
|
|
5401
|
+
originalWidth: overlayRect.width,
|
|
5402
|
+
};
|
|
5403
|
+
}
|
|
5404
|
+
let top = undefined;
|
|
5405
|
+
let height = undefined;
|
|
5406
|
+
let left = undefined;
|
|
5407
|
+
let width = undefined;
|
|
5408
|
+
const minimumInViewportHeight = this.options.minimumInViewportHeight;
|
|
5409
|
+
const minimumInViewportWidth = this.options.minimumInViewportWidth;
|
|
5410
|
+
function moveTop() {
|
|
5411
|
+
top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
|
|
5412
|
+
startPosition.originalHeight >
|
|
5413
|
+
containerRect.height
|
|
5414
|
+
? containerRect.height -
|
|
5415
|
+
minimumInViewportHeight
|
|
5416
|
+
: Math.max(0, startPosition.originalY +
|
|
5417
|
+
startPosition.originalHeight -
|
|
5418
|
+
Overlay.MINIMUM_HEIGHT));
|
|
5419
|
+
height =
|
|
5420
|
+
startPosition.originalY +
|
|
5421
|
+
startPosition.originalHeight -
|
|
5422
|
+
top;
|
|
5423
|
+
}
|
|
5424
|
+
function moveBottom() {
|
|
5425
|
+
top =
|
|
5426
|
+
startPosition.originalY -
|
|
5427
|
+
startPosition.originalHeight;
|
|
5428
|
+
height = clamp(y - top, top < 0
|
|
5429
|
+
? -top + minimumInViewportHeight
|
|
5430
|
+
: Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
|
|
5431
|
+
}
|
|
5432
|
+
function moveLeft() {
|
|
5433
|
+
left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
|
|
5434
|
+
startPosition.originalWidth >
|
|
5435
|
+
containerRect.width
|
|
5436
|
+
? containerRect.width -
|
|
5437
|
+
minimumInViewportWidth
|
|
5438
|
+
: Math.max(0, startPosition.originalX +
|
|
5439
|
+
startPosition.originalWidth -
|
|
5440
|
+
Overlay.MINIMUM_WIDTH));
|
|
5441
|
+
width =
|
|
5442
|
+
startPosition.originalX +
|
|
5443
|
+
startPosition.originalWidth -
|
|
5444
|
+
left;
|
|
5445
|
+
}
|
|
5446
|
+
function moveRight() {
|
|
5447
|
+
left =
|
|
5448
|
+
startPosition.originalX -
|
|
5449
|
+
startPosition.originalWidth;
|
|
5450
|
+
width = clamp(x - left, left < 0
|
|
5451
|
+
? -left + minimumInViewportWidth
|
|
5452
|
+
: Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
|
|
5453
|
+
}
|
|
5454
|
+
switch (direction) {
|
|
5455
|
+
case 'top':
|
|
5456
|
+
moveTop();
|
|
5457
|
+
break;
|
|
5458
|
+
case 'bottom':
|
|
5459
|
+
moveBottom();
|
|
5460
|
+
break;
|
|
5461
|
+
case 'left':
|
|
5462
|
+
moveLeft();
|
|
5463
|
+
break;
|
|
5464
|
+
case 'right':
|
|
5465
|
+
moveRight();
|
|
5466
|
+
break;
|
|
5467
|
+
case 'topleft':
|
|
5468
|
+
moveTop();
|
|
5469
|
+
moveLeft();
|
|
5470
|
+
break;
|
|
5471
|
+
case 'topright':
|
|
5472
|
+
moveTop();
|
|
5473
|
+
moveRight();
|
|
5474
|
+
break;
|
|
5475
|
+
case 'bottomleft':
|
|
5476
|
+
moveBottom();
|
|
5477
|
+
moveLeft();
|
|
5478
|
+
break;
|
|
5479
|
+
case 'bottomright':
|
|
5480
|
+
moveBottom();
|
|
5481
|
+
moveRight();
|
|
5482
|
+
break;
|
|
5483
|
+
}
|
|
5484
|
+
this.setBounds({ height, width, top, left });
|
|
5485
|
+
}), {
|
|
5486
|
+
dispose: () => {
|
|
5487
|
+
for (const iframe of iframes) {
|
|
5488
|
+
iframe.style.pointerEvents = 'auto';
|
|
5489
|
+
}
|
|
5490
|
+
},
|
|
5491
|
+
}, addDisposableWindowListener(window, 'mouseup', () => {
|
|
5492
|
+
move.dispose();
|
|
5493
|
+
this._onDidChangeEnd.fire();
|
|
5494
|
+
}));
|
|
5495
|
+
}));
|
|
5496
|
+
}
|
|
5497
|
+
dispose() {
|
|
5498
|
+
this._element.remove();
|
|
5499
|
+
super.dispose();
|
|
5500
|
+
}
|
|
5501
|
+
}
|
|
5502
|
+
Overlay.MINIMUM_HEIGHT = 20;
|
|
5503
|
+
Overlay.MINIMUM_WIDTH = 20;
|
|
5504
|
+
|
|
5505
|
+
class DockviewFloatingGroupPanel extends CompositeDisposable {
|
|
5506
|
+
constructor(group, overlay) {
|
|
5507
|
+
super();
|
|
5508
|
+
this.group = group;
|
|
5509
|
+
this.overlay = overlay;
|
|
5510
|
+
this.addDisposables(overlay);
|
|
5511
|
+
}
|
|
5512
|
+
position(bounds) {
|
|
5513
|
+
this.overlay.setBounds(bounds);
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5516
|
+
|
|
5061
5517
|
class DockviewComponent extends BaseGrid {
|
|
5062
5518
|
get orientation() {
|
|
5063
5519
|
return this.gridview.orientation;
|
|
@@ -5098,7 +5554,8 @@ class DockviewComponent extends BaseGrid {
|
|
|
5098
5554
|
this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
|
|
5099
5555
|
this._onDidActivePanelChange = new Emitter();
|
|
5100
5556
|
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
5101
|
-
this.
|
|
5557
|
+
this.floatingGroups = [];
|
|
5558
|
+
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
5102
5559
|
this.addDisposables(this._onDidDrop, Event.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
|
|
5103
5560
|
this.updateWatermark();
|
|
5104
5561
|
}), Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
|
|
@@ -5128,6 +5585,11 @@ class DockviewComponent extends BaseGrid {
|
|
|
5128
5585
|
if (data.viewId !== this.id) {
|
|
5129
5586
|
return false;
|
|
5130
5587
|
}
|
|
5588
|
+
if (position === 'center') {
|
|
5589
|
+
// center drop target is only allowed if there are no panels in the grid
|
|
5590
|
+
// floating panels are allowed
|
|
5591
|
+
return this.gridview.length === 0;
|
|
5592
|
+
}
|
|
5131
5593
|
return true;
|
|
5132
5594
|
}
|
|
5133
5595
|
if (this.options.showDndOverlay) {
|
|
@@ -5140,7 +5602,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5140
5602
|
}
|
|
5141
5603
|
return false;
|
|
5142
5604
|
},
|
|
5143
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
|
|
5605
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5144
5606
|
overlayModel: {
|
|
5145
5607
|
activationSize: { type: 'pixels', value: 10 },
|
|
5146
5608
|
size: { type: 'pixels', value: 20 },
|
|
@@ -5158,6 +5620,75 @@ class DockviewComponent extends BaseGrid {
|
|
|
5158
5620
|
this._api = new DockviewApi(this);
|
|
5159
5621
|
this.updateWatermark();
|
|
5160
5622
|
}
|
|
5623
|
+
addFloatingGroup(item, coord, options) {
|
|
5624
|
+
var _a, _b;
|
|
5625
|
+
let group;
|
|
5626
|
+
if (item instanceof DockviewPanel) {
|
|
5627
|
+
group = this.createGroup();
|
|
5628
|
+
this.removePanel(item, {
|
|
5629
|
+
removeEmptyGroup: true,
|
|
5630
|
+
skipDispose: true,
|
|
5631
|
+
});
|
|
5632
|
+
group.model.openPanel(item);
|
|
5633
|
+
}
|
|
5634
|
+
else {
|
|
5635
|
+
group = item;
|
|
5636
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
5637
|
+
options.skipRemoveGroup;
|
|
5638
|
+
if (!skip) {
|
|
5639
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
5640
|
+
}
|
|
5641
|
+
}
|
|
5642
|
+
group.model.isFloating = true;
|
|
5643
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
5644
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
5645
|
+
const overlay = new Overlay({
|
|
5646
|
+
container: this.gridview.element,
|
|
5647
|
+
content: group.element,
|
|
5648
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
5649
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
5650
|
+
left: overlayLeft,
|
|
5651
|
+
top: overlayTop,
|
|
5652
|
+
minimumInViewportWidth: 100,
|
|
5653
|
+
minimumInViewportHeight: 100,
|
|
5654
|
+
});
|
|
5655
|
+
const el = group.element.querySelector('.void-container');
|
|
5656
|
+
if (!el) {
|
|
5657
|
+
throw new Error('failed to find drag handle');
|
|
5658
|
+
}
|
|
5659
|
+
overlay.setupDrag(el, {
|
|
5660
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
5661
|
+
? options.inDragMode
|
|
5662
|
+
: false,
|
|
5663
|
+
});
|
|
5664
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
5665
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
5666
|
+
const { width, height } = entry.contentRect;
|
|
5667
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
5668
|
+
});
|
|
5669
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
5670
|
+
// this is either a resize or a move
|
|
5671
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
5672
|
+
// don't care about resize since the above watcher handles that
|
|
5673
|
+
group.layout(group.height, group.width);
|
|
5674
|
+
}), overlay.onDidChangeEnd(() => {
|
|
5675
|
+
this._bufferOnDidLayoutChange.fire();
|
|
5676
|
+
}), group.onDidChange((event) => {
|
|
5677
|
+
overlay.setBounds({
|
|
5678
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
5679
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
5680
|
+
});
|
|
5681
|
+
}), {
|
|
5682
|
+
dispose: () => {
|
|
5683
|
+
disposable.dispose();
|
|
5684
|
+
group.model.isFloating = false;
|
|
5685
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
5686
|
+
this.updateWatermark();
|
|
5687
|
+
},
|
|
5688
|
+
});
|
|
5689
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
5690
|
+
this.updateWatermark();
|
|
5691
|
+
}
|
|
5161
5692
|
orthogonalize(position) {
|
|
5162
5693
|
switch (position) {
|
|
5163
5694
|
case 'top':
|
|
@@ -5180,6 +5711,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5180
5711
|
switch (position) {
|
|
5181
5712
|
case 'top':
|
|
5182
5713
|
case 'left':
|
|
5714
|
+
case 'center':
|
|
5183
5715
|
return this.createGroupAtLocation([0]); // insert into first position
|
|
5184
5716
|
case 'bottom':
|
|
5185
5717
|
case 'right':
|
|
@@ -5197,6 +5729,15 @@ class DockviewComponent extends BaseGrid {
|
|
|
5197
5729
|
}
|
|
5198
5730
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
5199
5731
|
}
|
|
5732
|
+
layout(width, height, forceResize) {
|
|
5733
|
+
super.layout(width, height, forceResize);
|
|
5734
|
+
if (this.floatingGroups) {
|
|
5735
|
+
for (const floating of this.floatingGroups) {
|
|
5736
|
+
// ensure floting groups stay within visible boundaries
|
|
5737
|
+
floating.overlay.setBounds();
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5200
5741
|
focus() {
|
|
5201
5742
|
var _a;
|
|
5202
5743
|
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -5259,51 +5800,81 @@ class DockviewComponent extends BaseGrid {
|
|
|
5259
5800
|
collection[panel.id] = panel.toJSON();
|
|
5260
5801
|
return collection;
|
|
5261
5802
|
}, {});
|
|
5262
|
-
|
|
5803
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
5804
|
+
return {
|
|
5805
|
+
data: floatingGroup.group.toJSON(),
|
|
5806
|
+
position: floatingGroup.overlay.toJSON(),
|
|
5807
|
+
};
|
|
5808
|
+
});
|
|
5809
|
+
const result = {
|
|
5263
5810
|
grid: data,
|
|
5264
5811
|
panels,
|
|
5265
5812
|
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
5266
5813
|
};
|
|
5814
|
+
if (floats.length > 0) {
|
|
5815
|
+
result.floatingGroups = floats;
|
|
5816
|
+
}
|
|
5817
|
+
return result;
|
|
5267
5818
|
}
|
|
5268
5819
|
fromJSON(data) {
|
|
5820
|
+
var _a;
|
|
5269
5821
|
this.clear();
|
|
5270
5822
|
const { grid, panels, activeGroup } = data;
|
|
5271
5823
|
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
5272
5824
|
throw new Error('root must be of type branch');
|
|
5273
5825
|
}
|
|
5826
|
+
// take note of the existing dimensions
|
|
5827
|
+
const width = this.width;
|
|
5828
|
+
const height = this.height;
|
|
5829
|
+
const createGroupFromSerializedState = (data) => {
|
|
5830
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
5831
|
+
const group = this.createGroup({
|
|
5832
|
+
id,
|
|
5833
|
+
locked: !!locked,
|
|
5834
|
+
hideHeader: !!hideHeader,
|
|
5835
|
+
});
|
|
5836
|
+
this._onDidAddGroup.fire(group);
|
|
5837
|
+
for (const child of views) {
|
|
5838
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5839
|
+
const isActive = typeof activeView === 'string' && activeView === panel.id;
|
|
5840
|
+
group.model.openPanel(panel, {
|
|
5841
|
+
skipSetPanelActive: !isActive,
|
|
5842
|
+
skipSetGroupActive: true,
|
|
5843
|
+
});
|
|
5844
|
+
}
|
|
5845
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
5846
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5847
|
+
skipSetGroupActive: true,
|
|
5848
|
+
});
|
|
5849
|
+
}
|
|
5850
|
+
return group;
|
|
5851
|
+
};
|
|
5274
5852
|
this.gridview.deserialize(grid, {
|
|
5275
5853
|
fromJSON: (node) => {
|
|
5276
|
-
|
|
5277
|
-
const group = this.createGroup({
|
|
5278
|
-
id,
|
|
5279
|
-
locked: !!locked,
|
|
5280
|
-
hideHeader: !!hideHeader,
|
|
5281
|
-
});
|
|
5282
|
-
this._onDidAddGroup.fire(group);
|
|
5283
|
-
for (const child of views) {
|
|
5284
|
-
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5285
|
-
const isActive = typeof activeView === 'string' &&
|
|
5286
|
-
activeView === panel.id;
|
|
5287
|
-
group.model.openPanel(panel, {
|
|
5288
|
-
skipSetPanelActive: !isActive,
|
|
5289
|
-
skipSetGroupActive: true,
|
|
5290
|
-
});
|
|
5291
|
-
}
|
|
5292
|
-
if (!group.activePanel && group.panels.length > 0) {
|
|
5293
|
-
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5294
|
-
skipSetGroupActive: true,
|
|
5295
|
-
});
|
|
5296
|
-
}
|
|
5297
|
-
return group;
|
|
5854
|
+
return createGroupFromSerializedState(node.data);
|
|
5298
5855
|
},
|
|
5299
5856
|
});
|
|
5857
|
+
this.layout(width, height, true);
|
|
5858
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
5859
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
5860
|
+
const { data, position } = serializedFloatingGroup;
|
|
5861
|
+
const group = createGroupFromSerializedState(data);
|
|
5862
|
+
this.addFloatingGroup(group, {
|
|
5863
|
+
x: position.left,
|
|
5864
|
+
y: position.top,
|
|
5865
|
+
height: position.height,
|
|
5866
|
+
width: position.width,
|
|
5867
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
5868
|
+
}
|
|
5869
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
5870
|
+
floatingGroup.overlay.setBounds();
|
|
5871
|
+
}
|
|
5300
5872
|
if (typeof activeGroup === 'string') {
|
|
5301
5873
|
const panel = this.getPanel(activeGroup);
|
|
5302
5874
|
if (panel) {
|
|
5303
5875
|
this.doSetGroupActive(panel);
|
|
5304
5876
|
}
|
|
5305
5877
|
}
|
|
5306
|
-
this.gridview.layout(this.width, this.height);
|
|
5307
5878
|
this._onDidLayoutFromJSON.fire();
|
|
5308
5879
|
}
|
|
5309
5880
|
clear() {
|
|
@@ -5312,7 +5883,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5312
5883
|
const hasActivePanel = !!this.activePanel;
|
|
5313
5884
|
for (const group of groups) {
|
|
5314
5885
|
// remove the group will automatically remove the panels
|
|
5315
|
-
this.removeGroup(group, true);
|
|
5886
|
+
this.removeGroup(group, { skipActive: true });
|
|
5316
5887
|
}
|
|
5317
5888
|
if (hasActiveGroup) {
|
|
5318
5889
|
this.doSetGroupActive(undefined);
|
|
@@ -5334,6 +5905,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5334
5905
|
throw new Error(`panel with id ${options.id} already exists`);
|
|
5335
5906
|
}
|
|
5336
5907
|
let referenceGroup;
|
|
5908
|
+
if (options.position && options.floating) {
|
|
5909
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
5910
|
+
}
|
|
5337
5911
|
if (options.position) {
|
|
5338
5912
|
if (isPanelOptionsWithPanel(options.position)) {
|
|
5339
5913
|
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
@@ -5366,7 +5940,20 @@ class DockviewComponent extends BaseGrid {
|
|
|
5366
5940
|
let panel;
|
|
5367
5941
|
if (referenceGroup) {
|
|
5368
5942
|
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
5369
|
-
if (
|
|
5943
|
+
if (options.floating) {
|
|
5944
|
+
const group = this.createGroup();
|
|
5945
|
+
panel = this.createPanel(options, group);
|
|
5946
|
+
group.model.openPanel(panel);
|
|
5947
|
+
const o = typeof options.floating === 'object' &&
|
|
5948
|
+
options.floating !== null
|
|
5949
|
+
? options.floating
|
|
5950
|
+
: {};
|
|
5951
|
+
this.addFloatingGroup(group, o, {
|
|
5952
|
+
inDragMode: false,
|
|
5953
|
+
skipRemoveGroup: true,
|
|
5954
|
+
});
|
|
5955
|
+
}
|
|
5956
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
5370
5957
|
panel = this.createPanel(options, referenceGroup);
|
|
5371
5958
|
referenceGroup.model.openPanel(panel);
|
|
5372
5959
|
}
|
|
@@ -5378,6 +5965,19 @@ class DockviewComponent extends BaseGrid {
|
|
|
5378
5965
|
group.model.openPanel(panel);
|
|
5379
5966
|
}
|
|
5380
5967
|
}
|
|
5968
|
+
else if (options.floating) {
|
|
5969
|
+
const group = this.createGroup();
|
|
5970
|
+
panel = this.createPanel(options, group);
|
|
5971
|
+
group.model.openPanel(panel);
|
|
5972
|
+
const o = typeof options.floating === 'object' &&
|
|
5973
|
+
options.floating !== null
|
|
5974
|
+
? options.floating
|
|
5975
|
+
: {};
|
|
5976
|
+
this.addFloatingGroup(group, o, {
|
|
5977
|
+
inDragMode: false,
|
|
5978
|
+
skipRemoveGroup: true,
|
|
5979
|
+
});
|
|
5980
|
+
}
|
|
5381
5981
|
else {
|
|
5382
5982
|
const group = this.createGroupAtLocation();
|
|
5383
5983
|
panel = this.createPanel(options, group);
|
|
@@ -5394,7 +5994,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5394
5994
|
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
5395
5995
|
}
|
|
5396
5996
|
group.model.removePanel(panel);
|
|
5397
|
-
|
|
5997
|
+
if (!options.skipDispose) {
|
|
5998
|
+
panel.dispose();
|
|
5999
|
+
}
|
|
5398
6000
|
if (group.size === 0 && options.removeEmptyGroup) {
|
|
5399
6001
|
this.removeGroup(group);
|
|
5400
6002
|
}
|
|
@@ -5409,7 +6011,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5409
6011
|
}
|
|
5410
6012
|
updateWatermark() {
|
|
5411
6013
|
var _a, _b;
|
|
5412
|
-
if (this.groups.length === 0) {
|
|
6014
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
5413
6015
|
if (!this.watermark) {
|
|
5414
6016
|
this.watermark = this.createWatermarkComponent();
|
|
5415
6017
|
this.watermark.init({
|
|
@@ -5418,7 +6020,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5418
6020
|
const watermarkContainer = document.createElement('div');
|
|
5419
6021
|
watermarkContainer.className = 'dv-watermark-container';
|
|
5420
6022
|
watermarkContainer.appendChild(this.watermark.element);
|
|
5421
|
-
this.element.appendChild(watermarkContainer);
|
|
6023
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
5422
6024
|
}
|
|
5423
6025
|
}
|
|
5424
6026
|
else if (this.watermark) {
|
|
@@ -5468,15 +6070,28 @@ class DockviewComponent extends BaseGrid {
|
|
|
5468
6070
|
return group;
|
|
5469
6071
|
}
|
|
5470
6072
|
}
|
|
5471
|
-
removeGroup(group,
|
|
6073
|
+
removeGroup(group, options) {
|
|
6074
|
+
var _a;
|
|
5472
6075
|
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
5473
6076
|
for (const panel of panels) {
|
|
5474
6077
|
this.removePanel(panel, {
|
|
5475
6078
|
removeEmptyGroup: false,
|
|
5476
|
-
skipDispose: false,
|
|
6079
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
5477
6080
|
});
|
|
5478
6081
|
}
|
|
5479
|
-
|
|
6082
|
+
this.doRemoveGroup(group, options);
|
|
6083
|
+
}
|
|
6084
|
+
doRemoveGroup(group, options) {
|
|
6085
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
6086
|
+
if (floatingGroup) {
|
|
6087
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
6088
|
+
floatingGroup.group.dispose();
|
|
6089
|
+
this._groups.delete(group.id);
|
|
6090
|
+
}
|
|
6091
|
+
floatingGroup.dispose();
|
|
6092
|
+
return floatingGroup.group;
|
|
6093
|
+
}
|
|
6094
|
+
return super.doRemoveGroup(group, options);
|
|
5480
6095
|
}
|
|
5481
6096
|
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5482
6097
|
var _a;
|
|
@@ -5507,25 +6122,26 @@ class DockviewComponent extends BaseGrid {
|
|
|
5507
6122
|
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5508
6123
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5509
6124
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5510
|
-
const
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
5521
|
-
skipActive: true,
|
|
5522
|
-
skipDispose: true,
|
|
5523
|
-
});
|
|
5524
|
-
// after deleting the group we need to re-evaulate the ref location
|
|
5525
|
-
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5526
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5527
|
-
this.doAddGroup(targetGroup, location);
|
|
6125
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6126
|
+
if (!isFloating) {
|
|
6127
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
6128
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
6129
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
6130
|
+
// special case when 'swapping' two views within same grid location
|
|
6131
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
6132
|
+
// which is equivalent to swapping two views in this case
|
|
6133
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
6134
|
+
}
|
|
5528
6135
|
}
|
|
6136
|
+
// source group will become empty so delete the group
|
|
6137
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
6138
|
+
skipActive: true,
|
|
6139
|
+
skipDispose: true,
|
|
6140
|
+
});
|
|
6141
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
6142
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
6143
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
6144
|
+
this.doAddGroup(targetGroup, location);
|
|
5529
6145
|
}
|
|
5530
6146
|
else {
|
|
5531
6147
|
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
@@ -5554,7 +6170,13 @@ class DockviewComponent extends BaseGrid {
|
|
|
5554
6170
|
}
|
|
5555
6171
|
}
|
|
5556
6172
|
else {
|
|
5557
|
-
this.
|
|
6173
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6174
|
+
if (floatingGroup) {
|
|
6175
|
+
floatingGroup.dispose();
|
|
6176
|
+
}
|
|
6177
|
+
else {
|
|
6178
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
6179
|
+
}
|
|
5558
6180
|
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
5559
6181
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
5560
6182
|
this.gridview.addView(sourceGroup, Sizing.Distribute, dropLocation);
|
|
@@ -5709,6 +6331,9 @@ class GridviewComponent extends BaseGrid {
|
|
|
5709
6331
|
this.clear();
|
|
5710
6332
|
const { grid, activePanel } = serializedGridview;
|
|
5711
6333
|
const queue = [];
|
|
6334
|
+
// take note of the existing dimensions
|
|
6335
|
+
const width = this.width;
|
|
6336
|
+
const height = this.height;
|
|
5712
6337
|
this.gridview.deserialize(grid, {
|
|
5713
6338
|
fromJSON: (node) => {
|
|
5714
6339
|
const { data } = node;
|
|
@@ -5734,7 +6359,7 @@ class GridviewComponent extends BaseGrid {
|
|
|
5734
6359
|
return view;
|
|
5735
6360
|
},
|
|
5736
6361
|
});
|
|
5737
|
-
this.layout(
|
|
6362
|
+
this.layout(width, height, true);
|
|
5738
6363
|
queue.forEach((f) => f());
|
|
5739
6364
|
if (typeof activePanel === 'string') {
|
|
5740
6365
|
const panel = this.getPanel(activePanel);
|
|
@@ -6048,6 +6673,9 @@ class SplitviewComponent extends Resizable {
|
|
|
6048
6673
|
this.clear();
|
|
6049
6674
|
const { views, orientation, size, activeView } = serializedSplitview;
|
|
6050
6675
|
const queue = [];
|
|
6676
|
+
// take note of the existing dimensions
|
|
6677
|
+
const width = this.width;
|
|
6678
|
+
const height = this.height;
|
|
6051
6679
|
this.splitview = new Splitview(this.element, {
|
|
6052
6680
|
orientation,
|
|
6053
6681
|
proportionalLayout: this.options.proportionalLayout,
|
|
@@ -6084,7 +6712,7 @@ class SplitviewComponent extends Resizable {
|
|
|
6084
6712
|
}),
|
|
6085
6713
|
},
|
|
6086
6714
|
});
|
|
6087
|
-
this.layout(
|
|
6715
|
+
this.layout(width, height);
|
|
6088
6716
|
queue.forEach((f) => f());
|
|
6089
6717
|
if (typeof activeView === 'string') {
|
|
6090
6718
|
const panel = this.getPanel(activeView);
|
|
@@ -6351,6 +6979,9 @@ class PaneviewComponent extends Resizable {
|
|
|
6351
6979
|
this.clear();
|
|
6352
6980
|
const { views, size } = serializedPaneview;
|
|
6353
6981
|
const queue = [];
|
|
6982
|
+
// take note of the existing dimensions
|
|
6983
|
+
const width = this.width;
|
|
6984
|
+
const height = this.height;
|
|
6354
6985
|
this.paneview = new Paneview(this.element, {
|
|
6355
6986
|
orientation: Orientation.VERTICAL,
|
|
6356
6987
|
descriptor: {
|
|
@@ -6406,7 +7037,7 @@ class PaneviewComponent extends Resizable {
|
|
|
6406
7037
|
}),
|
|
6407
7038
|
},
|
|
6408
7039
|
});
|
|
6409
|
-
this.layout(
|
|
7040
|
+
this.layout(width, height);
|
|
6410
7041
|
queue.forEach((f) => f());
|
|
6411
7042
|
this._onDidLayoutfromJSON.fire();
|
|
6412
7043
|
}
|
|
@@ -6789,7 +7420,7 @@ class ReactWatermarkPart {
|
|
|
6789
7420
|
}
|
|
6790
7421
|
}
|
|
6791
7422
|
|
|
6792
|
-
class
|
|
7423
|
+
class ReactHeaderActionsRendererPart {
|
|
6793
7424
|
get element() {
|
|
6794
7425
|
return this._element;
|
|
6795
7426
|
}
|
|
@@ -6826,6 +7457,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6826
7457
|
panels: this._group.model.panels,
|
|
6827
7458
|
activePanel: this._group.model.activePanel,
|
|
6828
7459
|
isGroupActive: this._group.api.isActive,
|
|
7460
|
+
group: this._group,
|
|
6829
7461
|
});
|
|
6830
7462
|
}
|
|
6831
7463
|
update(event) {
|
|
@@ -6859,7 +7491,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6859
7491
|
function createGroupControlElement(component, store) {
|
|
6860
7492
|
return component
|
|
6861
7493
|
? (groupPanel) => {
|
|
6862
|
-
return new
|
|
7494
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
6863
7495
|
}
|
|
6864
7496
|
: undefined;
|
|
6865
7497
|
}
|
|
@@ -6916,8 +7548,10 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
6916
7548
|
? { separatorBorder: 'transparent' }
|
|
6917
7549
|
: undefined,
|
|
6918
7550
|
showDndOverlay: props.showDndOverlay,
|
|
6919
|
-
|
|
7551
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7552
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
6920
7553
|
singleTabMode: props.singleTabMode,
|
|
7554
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
6921
7555
|
});
|
|
6922
7556
|
const { clientWidth, clientHeight } = domRef.current;
|
|
6923
7557
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -6976,6 +7610,14 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
6976
7610
|
frameworkTabComponents: props.tabComponents,
|
|
6977
7611
|
});
|
|
6978
7612
|
}, [props.tabComponents]);
|
|
7613
|
+
React.useEffect(() => {
|
|
7614
|
+
if (!dockviewRef.current) {
|
|
7615
|
+
return;
|
|
7616
|
+
}
|
|
7617
|
+
dockviewRef.current.updateOptions({
|
|
7618
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
7619
|
+
});
|
|
7620
|
+
}, [props.disableFloatingGroups]);
|
|
6979
7621
|
React.useEffect(() => {
|
|
6980
7622
|
if (!dockviewRef.current) {
|
|
6981
7623
|
return;
|
|
@@ -6997,9 +7639,17 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
6997
7639
|
return;
|
|
6998
7640
|
}
|
|
6999
7641
|
dockviewRef.current.updateOptions({
|
|
7000
|
-
|
|
7642
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
7643
|
+
});
|
|
7644
|
+
}, [props.rightHeaderActionsComponent]);
|
|
7645
|
+
React.useEffect(() => {
|
|
7646
|
+
if (!dockviewRef.current) {
|
|
7647
|
+
return;
|
|
7648
|
+
}
|
|
7649
|
+
dockviewRef.current.updateOptions({
|
|
7650
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7001
7651
|
});
|
|
7002
|
-
}, [props.
|
|
7652
|
+
}, [props.leftHeaderActionsComponent]);
|
|
7003
7653
|
return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
7004
7654
|
});
|
|
7005
7655
|
DockviewReact.displayName = 'DockviewComponent';
|
|
@@ -7018,6 +7668,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
7018
7668
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
7019
7669
|
PERFORMANCE OF THIS SOFTWARE.
|
|
7020
7670
|
***************************************************************************** */
|
|
7671
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
7672
|
+
|
|
7021
7673
|
|
|
7022
7674
|
function __rest(s, e) {
|
|
7023
7675
|
var t = {};
|
|
@@ -7029,7 +7681,12 @@ function __rest(s, e) {
|
|
|
7029
7681
|
t[p[i]] = s[p[i]];
|
|
7030
7682
|
}
|
|
7031
7683
|
return t;
|
|
7032
|
-
}
|
|
7684
|
+
}
|
|
7685
|
+
|
|
7686
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
7687
|
+
var e = new Error(message);
|
|
7688
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
7689
|
+
};
|
|
7033
7690
|
|
|
7034
7691
|
const CloseButton = () => (React.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
|
|
7035
7692
|
React.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" })));
|
|
@@ -7301,4 +7958,5 @@ const PaneviewReact = React.forwardRef((props, ref) => {
|
|
|
7301
7958
|
});
|
|
7302
7959
|
PaneviewReact.displayName = 'PaneviewComponent';
|
|
7303
7960
|
|
|
7304
|
-
export { BaseGrid, ContentContainer, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDefaultTab, DockviewDropTargets, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewReact, DraggablePaneviewPanel, Gridview, GridviewApi, GridviewComponent, GridviewPanel, GridviewReact, LayoutPriority, LocalSelectionTransfer, Orientation, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewReact, ReactPart, ReactPartContext, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, SplitviewReact, Tab, createComponent, directionToPosition, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRelativeLocation, indexInParent, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, isReactElement, orthogonal, positionToDirection, toTarget, usePortalsLifecycle
|
|
7961
|
+
export { BaseGrid, ContentContainer, DefaultDockviewDeserialzier, DefaultTab, DockviewApi, DockviewComponent, CompositeDisposable as DockviewCompositeDisposable, DockviewDefaultTab, DockviewDropTargets, Emitter as DockviewEmitter, Event as DockviewEvent, DockviewGroupPanel, DockviewGroupPanelModel, MutableDisposable as DockviewMutableDisposable, DockviewPanel, DockviewReact, DraggablePaneviewPanel, Gridview, GridviewApi, GridviewComponent, GridviewPanel, GridviewReact, LayoutPriority, LocalSelectionTransfer, Orientation, PaneFramework, PaneTransfer, PanelTransfer, Paneview, PaneviewApi, PaneviewComponent, PaneviewPanel, PaneviewReact, ReactPart, ReactPartContext, SashState, Sizing, Splitview, SplitviewApi, SplitviewComponent, SplitviewPanel, SplitviewReact, Tab, createComponent, directionToPosition, getDirectionOrientation, getGridLocation, getLocationOrientation, getPaneData, getPanelData, getRelativeLocation, indexInParent, isGridBranchNode, isGroupOptionsWithGroup, isGroupOptionsWithPanel, isPanelOptionsWithGroup, isPanelOptionsWithPanel, isReactElement, orthogonal, positionToDirection, toTarget, usePortalsLifecycle };
|
|
7962
|
+
//# sourceMappingURL=dockview.esm.js.map
|