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.esm.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
|
*/
|
|
@@ -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) {
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
if (this.rightActions) {
|
|
3187
|
+
this.rightActions.remove();
|
|
3188
|
+
this.rightActions = undefined;
|
|
3189
|
+
}
|
|
3190
|
+
if (element) {
|
|
3191
|
+
this.rightActionsContainer.appendChild(element);
|
|
3192
|
+
this.rightActions = element;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
setLeftActionsElement(element) {
|
|
3196
|
+
if (this.leftActions === element) {
|
|
3120
3197
|
return;
|
|
3121
3198
|
}
|
|
3122
|
-
if (this.
|
|
3123
|
-
this.
|
|
3124
|
-
this.
|
|
3199
|
+
if (this.leftActions) {
|
|
3200
|
+
this.leftActions.remove();
|
|
3201
|
+
this.leftActions = undefined;
|
|
3125
3202
|
}
|
|
3126
3203
|
if (element) {
|
|
3127
|
-
this.
|
|
3128
|
-
this.
|
|
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,9 +5585,22 @@ 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) {
|
|
5596
|
+
if (position === 'center') {
|
|
5597
|
+
/**
|
|
5598
|
+
* for external events only show the four-corner drag overlays, disable
|
|
5599
|
+
* the center position so that external drag events can fall through to the group
|
|
5600
|
+
* and panel drop target handlers
|
|
5601
|
+
*/
|
|
5602
|
+
return false;
|
|
5603
|
+
}
|
|
5134
5604
|
return this.options.showDndOverlay({
|
|
5135
5605
|
nativeEvent: event,
|
|
5136
5606
|
position: position,
|
|
@@ -5140,7 +5610,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5140
5610
|
}
|
|
5141
5611
|
return false;
|
|
5142
5612
|
},
|
|
5143
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
|
|
5613
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
5144
5614
|
overlayModel: {
|
|
5145
5615
|
activationSize: { type: 'pixels', value: 10 },
|
|
5146
5616
|
size: { type: 'pixels', value: 20 },
|
|
@@ -5158,6 +5628,75 @@ class DockviewComponent extends BaseGrid {
|
|
|
5158
5628
|
this._api = new DockviewApi(this);
|
|
5159
5629
|
this.updateWatermark();
|
|
5160
5630
|
}
|
|
5631
|
+
addFloatingGroup(item, coord, options) {
|
|
5632
|
+
var _a, _b;
|
|
5633
|
+
let group;
|
|
5634
|
+
if (item instanceof DockviewPanel) {
|
|
5635
|
+
group = this.createGroup();
|
|
5636
|
+
this.removePanel(item, {
|
|
5637
|
+
removeEmptyGroup: true,
|
|
5638
|
+
skipDispose: true,
|
|
5639
|
+
});
|
|
5640
|
+
group.model.openPanel(item);
|
|
5641
|
+
}
|
|
5642
|
+
else {
|
|
5643
|
+
group = item;
|
|
5644
|
+
const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
|
|
5645
|
+
options.skipRemoveGroup;
|
|
5646
|
+
if (!skip) {
|
|
5647
|
+
this.doRemoveGroup(item, { skipDispose: true });
|
|
5648
|
+
}
|
|
5649
|
+
}
|
|
5650
|
+
group.model.isFloating = true;
|
|
5651
|
+
const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
|
|
5652
|
+
const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
|
|
5653
|
+
const overlay = new Overlay({
|
|
5654
|
+
container: this.gridview.element,
|
|
5655
|
+
content: group.element,
|
|
5656
|
+
height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
|
|
5657
|
+
width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
|
|
5658
|
+
left: overlayLeft,
|
|
5659
|
+
top: overlayTop,
|
|
5660
|
+
minimumInViewportWidth: 100,
|
|
5661
|
+
minimumInViewportHeight: 100,
|
|
5662
|
+
});
|
|
5663
|
+
const el = group.element.querySelector('.void-container');
|
|
5664
|
+
if (!el) {
|
|
5665
|
+
throw new Error('failed to find drag handle');
|
|
5666
|
+
}
|
|
5667
|
+
overlay.setupDrag(el, {
|
|
5668
|
+
inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
|
|
5669
|
+
? options.inDragMode
|
|
5670
|
+
: false,
|
|
5671
|
+
});
|
|
5672
|
+
const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
|
|
5673
|
+
const disposable = watchElementResize(group.element, (entry) => {
|
|
5674
|
+
const { width, height } = entry.contentRect;
|
|
5675
|
+
group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
|
|
5676
|
+
});
|
|
5677
|
+
floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
|
|
5678
|
+
// this is either a resize or a move
|
|
5679
|
+
// to inform the panels .layout(...) the group with it's current size
|
|
5680
|
+
// don't care about resize since the above watcher handles that
|
|
5681
|
+
group.layout(group.height, group.width);
|
|
5682
|
+
}), overlay.onDidChangeEnd(() => {
|
|
5683
|
+
this._bufferOnDidLayoutChange.fire();
|
|
5684
|
+
}), group.onDidChange((event) => {
|
|
5685
|
+
overlay.setBounds({
|
|
5686
|
+
height: event === null || event === void 0 ? void 0 : event.height,
|
|
5687
|
+
width: event === null || event === void 0 ? void 0 : event.width,
|
|
5688
|
+
});
|
|
5689
|
+
}), {
|
|
5690
|
+
dispose: () => {
|
|
5691
|
+
disposable.dispose();
|
|
5692
|
+
group.model.isFloating = false;
|
|
5693
|
+
remove(this.floatingGroups, floatingGroupPanel);
|
|
5694
|
+
this.updateWatermark();
|
|
5695
|
+
},
|
|
5696
|
+
});
|
|
5697
|
+
this.floatingGroups.push(floatingGroupPanel);
|
|
5698
|
+
this.updateWatermark();
|
|
5699
|
+
}
|
|
5161
5700
|
orthogonalize(position) {
|
|
5162
5701
|
switch (position) {
|
|
5163
5702
|
case 'top':
|
|
@@ -5180,6 +5719,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5180
5719
|
switch (position) {
|
|
5181
5720
|
case 'top':
|
|
5182
5721
|
case 'left':
|
|
5722
|
+
case 'center':
|
|
5183
5723
|
return this.createGroupAtLocation([0]); // insert into first position
|
|
5184
5724
|
case 'bottom':
|
|
5185
5725
|
case 'right':
|
|
@@ -5197,6 +5737,15 @@ class DockviewComponent extends BaseGrid {
|
|
|
5197
5737
|
}
|
|
5198
5738
|
this.layout(this.gridview.width, this.gridview.height, true);
|
|
5199
5739
|
}
|
|
5740
|
+
layout(width, height, forceResize) {
|
|
5741
|
+
super.layout(width, height, forceResize);
|
|
5742
|
+
if (this.floatingGroups) {
|
|
5743
|
+
for (const floating of this.floatingGroups) {
|
|
5744
|
+
// ensure floting groups stay within visible boundaries
|
|
5745
|
+
floating.overlay.setBounds();
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5200
5749
|
focus() {
|
|
5201
5750
|
var _a;
|
|
5202
5751
|
(_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -5259,51 +5808,81 @@ class DockviewComponent extends BaseGrid {
|
|
|
5259
5808
|
collection[panel.id] = panel.toJSON();
|
|
5260
5809
|
return collection;
|
|
5261
5810
|
}, {});
|
|
5262
|
-
|
|
5811
|
+
const floats = this.floatingGroups.map((floatingGroup) => {
|
|
5812
|
+
return {
|
|
5813
|
+
data: floatingGroup.group.toJSON(),
|
|
5814
|
+
position: floatingGroup.overlay.toJSON(),
|
|
5815
|
+
};
|
|
5816
|
+
});
|
|
5817
|
+
const result = {
|
|
5263
5818
|
grid: data,
|
|
5264
5819
|
panels,
|
|
5265
5820
|
activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
|
|
5266
5821
|
};
|
|
5822
|
+
if (floats.length > 0) {
|
|
5823
|
+
result.floatingGroups = floats;
|
|
5824
|
+
}
|
|
5825
|
+
return result;
|
|
5267
5826
|
}
|
|
5268
5827
|
fromJSON(data) {
|
|
5828
|
+
var _a;
|
|
5269
5829
|
this.clear();
|
|
5270
5830
|
const { grid, panels, activeGroup } = data;
|
|
5271
5831
|
if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
|
|
5272
5832
|
throw new Error('root must be of type branch');
|
|
5273
5833
|
}
|
|
5834
|
+
// take note of the existing dimensions
|
|
5835
|
+
const width = this.width;
|
|
5836
|
+
const height = this.height;
|
|
5837
|
+
const createGroupFromSerializedState = (data) => {
|
|
5838
|
+
const { id, locked, hideHeader, views, activeView } = data;
|
|
5839
|
+
const group = this.createGroup({
|
|
5840
|
+
id,
|
|
5841
|
+
locked: !!locked,
|
|
5842
|
+
hideHeader: !!hideHeader,
|
|
5843
|
+
});
|
|
5844
|
+
this._onDidAddGroup.fire(group);
|
|
5845
|
+
for (const child of views) {
|
|
5846
|
+
const panel = this._deserializer.fromJSON(panels[child], group);
|
|
5847
|
+
const isActive = typeof activeView === 'string' && activeView === panel.id;
|
|
5848
|
+
group.model.openPanel(panel, {
|
|
5849
|
+
skipSetPanelActive: !isActive,
|
|
5850
|
+
skipSetGroupActive: true,
|
|
5851
|
+
});
|
|
5852
|
+
}
|
|
5853
|
+
if (!group.activePanel && group.panels.length > 0) {
|
|
5854
|
+
group.model.openPanel(group.panels[group.panels.length - 1], {
|
|
5855
|
+
skipSetGroupActive: true,
|
|
5856
|
+
});
|
|
5857
|
+
}
|
|
5858
|
+
return group;
|
|
5859
|
+
};
|
|
5274
5860
|
this.gridview.deserialize(grid, {
|
|
5275
5861
|
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;
|
|
5862
|
+
return createGroupFromSerializedState(node.data);
|
|
5298
5863
|
},
|
|
5299
5864
|
});
|
|
5865
|
+
this.layout(width, height, true);
|
|
5866
|
+
const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
|
|
5867
|
+
for (const serializedFloatingGroup of serializedFloatingGroups) {
|
|
5868
|
+
const { data, position } = serializedFloatingGroup;
|
|
5869
|
+
const group = createGroupFromSerializedState(data);
|
|
5870
|
+
this.addFloatingGroup(group, {
|
|
5871
|
+
x: position.left,
|
|
5872
|
+
y: position.top,
|
|
5873
|
+
height: position.height,
|
|
5874
|
+
width: position.width,
|
|
5875
|
+
}, { skipRemoveGroup: true, inDragMode: false });
|
|
5876
|
+
}
|
|
5877
|
+
for (const floatingGroup of this.floatingGroups) {
|
|
5878
|
+
floatingGroup.overlay.setBounds();
|
|
5879
|
+
}
|
|
5300
5880
|
if (typeof activeGroup === 'string') {
|
|
5301
5881
|
const panel = this.getPanel(activeGroup);
|
|
5302
5882
|
if (panel) {
|
|
5303
5883
|
this.doSetGroupActive(panel);
|
|
5304
5884
|
}
|
|
5305
5885
|
}
|
|
5306
|
-
this.gridview.layout(this.width, this.height);
|
|
5307
5886
|
this._onDidLayoutFromJSON.fire();
|
|
5308
5887
|
}
|
|
5309
5888
|
clear() {
|
|
@@ -5312,7 +5891,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5312
5891
|
const hasActivePanel = !!this.activePanel;
|
|
5313
5892
|
for (const group of groups) {
|
|
5314
5893
|
// remove the group will automatically remove the panels
|
|
5315
|
-
this.removeGroup(group, true);
|
|
5894
|
+
this.removeGroup(group, { skipActive: true });
|
|
5316
5895
|
}
|
|
5317
5896
|
if (hasActiveGroup) {
|
|
5318
5897
|
this.doSetGroupActive(undefined);
|
|
@@ -5334,6 +5913,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5334
5913
|
throw new Error(`panel with id ${options.id} already exists`);
|
|
5335
5914
|
}
|
|
5336
5915
|
let referenceGroup;
|
|
5916
|
+
if (options.position && options.floating) {
|
|
5917
|
+
throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
|
|
5918
|
+
}
|
|
5337
5919
|
if (options.position) {
|
|
5338
5920
|
if (isPanelOptionsWithPanel(options.position)) {
|
|
5339
5921
|
const referencePanel = typeof options.position.referencePanel === 'string'
|
|
@@ -5366,7 +5948,20 @@ class DockviewComponent extends BaseGrid {
|
|
|
5366
5948
|
let panel;
|
|
5367
5949
|
if (referenceGroup) {
|
|
5368
5950
|
const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
|
|
5369
|
-
if (
|
|
5951
|
+
if (options.floating) {
|
|
5952
|
+
const group = this.createGroup();
|
|
5953
|
+
panel = this.createPanel(options, group);
|
|
5954
|
+
group.model.openPanel(panel);
|
|
5955
|
+
const o = typeof options.floating === 'object' &&
|
|
5956
|
+
options.floating !== null
|
|
5957
|
+
? options.floating
|
|
5958
|
+
: {};
|
|
5959
|
+
this.addFloatingGroup(group, o, {
|
|
5960
|
+
inDragMode: false,
|
|
5961
|
+
skipRemoveGroup: true,
|
|
5962
|
+
});
|
|
5963
|
+
}
|
|
5964
|
+
else if (referenceGroup.api.isFloating || target === 'center') {
|
|
5370
5965
|
panel = this.createPanel(options, referenceGroup);
|
|
5371
5966
|
referenceGroup.model.openPanel(panel);
|
|
5372
5967
|
}
|
|
@@ -5378,6 +5973,19 @@ class DockviewComponent extends BaseGrid {
|
|
|
5378
5973
|
group.model.openPanel(panel);
|
|
5379
5974
|
}
|
|
5380
5975
|
}
|
|
5976
|
+
else if (options.floating) {
|
|
5977
|
+
const group = this.createGroup();
|
|
5978
|
+
panel = this.createPanel(options, group);
|
|
5979
|
+
group.model.openPanel(panel);
|
|
5980
|
+
const o = typeof options.floating === 'object' &&
|
|
5981
|
+
options.floating !== null
|
|
5982
|
+
? options.floating
|
|
5983
|
+
: {};
|
|
5984
|
+
this.addFloatingGroup(group, o, {
|
|
5985
|
+
inDragMode: false,
|
|
5986
|
+
skipRemoveGroup: true,
|
|
5987
|
+
});
|
|
5988
|
+
}
|
|
5381
5989
|
else {
|
|
5382
5990
|
const group = this.createGroupAtLocation();
|
|
5383
5991
|
panel = this.createPanel(options, group);
|
|
@@ -5394,7 +6002,9 @@ class DockviewComponent extends BaseGrid {
|
|
|
5394
6002
|
throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
|
|
5395
6003
|
}
|
|
5396
6004
|
group.model.removePanel(panel);
|
|
5397
|
-
|
|
6005
|
+
if (!options.skipDispose) {
|
|
6006
|
+
panel.dispose();
|
|
6007
|
+
}
|
|
5398
6008
|
if (group.size === 0 && options.removeEmptyGroup) {
|
|
5399
6009
|
this.removeGroup(group);
|
|
5400
6010
|
}
|
|
@@ -5409,7 +6019,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5409
6019
|
}
|
|
5410
6020
|
updateWatermark() {
|
|
5411
6021
|
var _a, _b;
|
|
5412
|
-
if (this.groups.length === 0) {
|
|
6022
|
+
if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
|
|
5413
6023
|
if (!this.watermark) {
|
|
5414
6024
|
this.watermark = this.createWatermarkComponent();
|
|
5415
6025
|
this.watermark.init({
|
|
@@ -5418,7 +6028,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5418
6028
|
const watermarkContainer = document.createElement('div');
|
|
5419
6029
|
watermarkContainer.className = 'dv-watermark-container';
|
|
5420
6030
|
watermarkContainer.appendChild(this.watermark.element);
|
|
5421
|
-
this.element.appendChild(watermarkContainer);
|
|
6031
|
+
this.gridview.element.appendChild(watermarkContainer);
|
|
5422
6032
|
}
|
|
5423
6033
|
}
|
|
5424
6034
|
else if (this.watermark) {
|
|
@@ -5468,15 +6078,28 @@ class DockviewComponent extends BaseGrid {
|
|
|
5468
6078
|
return group;
|
|
5469
6079
|
}
|
|
5470
6080
|
}
|
|
5471
|
-
removeGroup(group,
|
|
6081
|
+
removeGroup(group, options) {
|
|
6082
|
+
var _a;
|
|
5472
6083
|
const panels = [...group.panels]; // reassign since group panels will mutate
|
|
5473
6084
|
for (const panel of panels) {
|
|
5474
6085
|
this.removePanel(panel, {
|
|
5475
6086
|
removeEmptyGroup: false,
|
|
5476
|
-
skipDispose: false,
|
|
6087
|
+
skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
|
|
5477
6088
|
});
|
|
5478
6089
|
}
|
|
5479
|
-
|
|
6090
|
+
this.doRemoveGroup(group, options);
|
|
6091
|
+
}
|
|
6092
|
+
doRemoveGroup(group, options) {
|
|
6093
|
+
const floatingGroup = this.floatingGroups.find((_) => _.group === group);
|
|
6094
|
+
if (floatingGroup) {
|
|
6095
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
6096
|
+
floatingGroup.group.dispose();
|
|
6097
|
+
this._groups.delete(group.id);
|
|
6098
|
+
}
|
|
6099
|
+
floatingGroup.dispose();
|
|
6100
|
+
return floatingGroup.group;
|
|
6101
|
+
}
|
|
6102
|
+
return super.doRemoveGroup(group, options);
|
|
5480
6103
|
}
|
|
5481
6104
|
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5482
6105
|
var _a;
|
|
@@ -5507,25 +6130,26 @@ class DockviewComponent extends BaseGrid {
|
|
|
5507
6130
|
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5508
6131
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5509
6132
|
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);
|
|
6133
|
+
const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6134
|
+
if (!isFloating) {
|
|
6135
|
+
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
6136
|
+
const [sourceParentLocation, from] = tail(sourceLocation);
|
|
6137
|
+
if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
|
|
6138
|
+
// special case when 'swapping' two views within same grid location
|
|
6139
|
+
// if a group has one tab - we are essentially moving the 'group'
|
|
6140
|
+
// which is equivalent to swapping two views in this case
|
|
6141
|
+
this.gridview.moveView(sourceParentLocation, from, to);
|
|
6142
|
+
}
|
|
5528
6143
|
}
|
|
6144
|
+
// source group will become empty so delete the group
|
|
6145
|
+
const targetGroup = this.doRemoveGroup(sourceGroup, {
|
|
6146
|
+
skipActive: true,
|
|
6147
|
+
skipDispose: true,
|
|
6148
|
+
});
|
|
6149
|
+
// after deleting the group we need to re-evaulate the ref location
|
|
6150
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
6151
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
6152
|
+
this.doAddGroup(targetGroup, location);
|
|
5529
6153
|
}
|
|
5530
6154
|
else {
|
|
5531
6155
|
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
@@ -5554,7 +6178,13 @@ class DockviewComponent extends BaseGrid {
|
|
|
5554
6178
|
}
|
|
5555
6179
|
}
|
|
5556
6180
|
else {
|
|
5557
|
-
this.
|
|
6181
|
+
const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
|
|
6182
|
+
if (floatingGroup) {
|
|
6183
|
+
floatingGroup.dispose();
|
|
6184
|
+
}
|
|
6185
|
+
else {
|
|
6186
|
+
this.gridview.removeView(getGridLocation(sourceGroup.element));
|
|
6187
|
+
}
|
|
5558
6188
|
const referenceLocation = getGridLocation(referenceGroup.element);
|
|
5559
6189
|
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
|
|
5560
6190
|
this.gridview.addView(sourceGroup, Sizing.Distribute, dropLocation);
|
|
@@ -5709,6 +6339,9 @@ class GridviewComponent extends BaseGrid {
|
|
|
5709
6339
|
this.clear();
|
|
5710
6340
|
const { grid, activePanel } = serializedGridview;
|
|
5711
6341
|
const queue = [];
|
|
6342
|
+
// take note of the existing dimensions
|
|
6343
|
+
const width = this.width;
|
|
6344
|
+
const height = this.height;
|
|
5712
6345
|
this.gridview.deserialize(grid, {
|
|
5713
6346
|
fromJSON: (node) => {
|
|
5714
6347
|
const { data } = node;
|
|
@@ -5734,7 +6367,7 @@ class GridviewComponent extends BaseGrid {
|
|
|
5734
6367
|
return view;
|
|
5735
6368
|
},
|
|
5736
6369
|
});
|
|
5737
|
-
this.layout(
|
|
6370
|
+
this.layout(width, height, true);
|
|
5738
6371
|
queue.forEach((f) => f());
|
|
5739
6372
|
if (typeof activePanel === 'string') {
|
|
5740
6373
|
const panel = this.getPanel(activePanel);
|
|
@@ -6048,6 +6681,9 @@ class SplitviewComponent extends Resizable {
|
|
|
6048
6681
|
this.clear();
|
|
6049
6682
|
const { views, orientation, size, activeView } = serializedSplitview;
|
|
6050
6683
|
const queue = [];
|
|
6684
|
+
// take note of the existing dimensions
|
|
6685
|
+
const width = this.width;
|
|
6686
|
+
const height = this.height;
|
|
6051
6687
|
this.splitview = new Splitview(this.element, {
|
|
6052
6688
|
orientation,
|
|
6053
6689
|
proportionalLayout: this.options.proportionalLayout,
|
|
@@ -6084,7 +6720,7 @@ class SplitviewComponent extends Resizable {
|
|
|
6084
6720
|
}),
|
|
6085
6721
|
},
|
|
6086
6722
|
});
|
|
6087
|
-
this.layout(
|
|
6723
|
+
this.layout(width, height);
|
|
6088
6724
|
queue.forEach((f) => f());
|
|
6089
6725
|
if (typeof activeView === 'string') {
|
|
6090
6726
|
const panel = this.getPanel(activeView);
|
|
@@ -6351,6 +6987,9 @@ class PaneviewComponent extends Resizable {
|
|
|
6351
6987
|
this.clear();
|
|
6352
6988
|
const { views, size } = serializedPaneview;
|
|
6353
6989
|
const queue = [];
|
|
6990
|
+
// take note of the existing dimensions
|
|
6991
|
+
const width = this.width;
|
|
6992
|
+
const height = this.height;
|
|
6354
6993
|
this.paneview = new Paneview(this.element, {
|
|
6355
6994
|
orientation: Orientation.VERTICAL,
|
|
6356
6995
|
descriptor: {
|
|
@@ -6406,7 +7045,7 @@ class PaneviewComponent extends Resizable {
|
|
|
6406
7045
|
}),
|
|
6407
7046
|
},
|
|
6408
7047
|
});
|
|
6409
|
-
this.layout(
|
|
7048
|
+
this.layout(width, height);
|
|
6410
7049
|
queue.forEach((f) => f());
|
|
6411
7050
|
this._onDidLayoutfromJSON.fire();
|
|
6412
7051
|
}
|
|
@@ -6789,7 +7428,7 @@ class ReactWatermarkPart {
|
|
|
6789
7428
|
}
|
|
6790
7429
|
}
|
|
6791
7430
|
|
|
6792
|
-
class
|
|
7431
|
+
class ReactHeaderActionsRendererPart {
|
|
6793
7432
|
get element() {
|
|
6794
7433
|
return this._element;
|
|
6795
7434
|
}
|
|
@@ -6826,6 +7465,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6826
7465
|
panels: this._group.model.panels,
|
|
6827
7466
|
activePanel: this._group.model.activePanel,
|
|
6828
7467
|
isGroupActive: this._group.api.isActive,
|
|
7468
|
+
group: this._group,
|
|
6829
7469
|
});
|
|
6830
7470
|
}
|
|
6831
7471
|
update(event) {
|
|
@@ -6859,7 +7499,7 @@ class ReactGroupControlsRendererPart {
|
|
|
6859
7499
|
function createGroupControlElement(component, store) {
|
|
6860
7500
|
return component
|
|
6861
7501
|
? (groupPanel) => {
|
|
6862
|
-
return new
|
|
7502
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
6863
7503
|
}
|
|
6864
7504
|
: undefined;
|
|
6865
7505
|
}
|
|
@@ -6916,8 +7556,10 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
6916
7556
|
? { separatorBorder: 'transparent' }
|
|
6917
7557
|
: undefined,
|
|
6918
7558
|
showDndOverlay: props.showDndOverlay,
|
|
6919
|
-
|
|
7559
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7560
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
6920
7561
|
singleTabMode: props.singleTabMode,
|
|
7562
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
6921
7563
|
});
|
|
6922
7564
|
const { clientWidth, clientHeight } = domRef.current;
|
|
6923
7565
|
dockview.layout(clientWidth, clientHeight);
|
|
@@ -6976,6 +7618,14 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
6976
7618
|
frameworkTabComponents: props.tabComponents,
|
|
6977
7619
|
});
|
|
6978
7620
|
}, [props.tabComponents]);
|
|
7621
|
+
React.useEffect(() => {
|
|
7622
|
+
if (!dockviewRef.current) {
|
|
7623
|
+
return;
|
|
7624
|
+
}
|
|
7625
|
+
dockviewRef.current.updateOptions({
|
|
7626
|
+
disableFloatingGroups: props.disableFloatingGroups,
|
|
7627
|
+
});
|
|
7628
|
+
}, [props.disableFloatingGroups]);
|
|
6979
7629
|
React.useEffect(() => {
|
|
6980
7630
|
if (!dockviewRef.current) {
|
|
6981
7631
|
return;
|
|
@@ -6997,9 +7647,17 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
6997
7647
|
return;
|
|
6998
7648
|
}
|
|
6999
7649
|
dockviewRef.current.updateOptions({
|
|
7000
|
-
|
|
7650
|
+
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
7651
|
+
});
|
|
7652
|
+
}, [props.rightHeaderActionsComponent]);
|
|
7653
|
+
React.useEffect(() => {
|
|
7654
|
+
if (!dockviewRef.current) {
|
|
7655
|
+
return;
|
|
7656
|
+
}
|
|
7657
|
+
dockviewRef.current.updateOptions({
|
|
7658
|
+
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
7001
7659
|
});
|
|
7002
|
-
}, [props.
|
|
7660
|
+
}, [props.leftHeaderActionsComponent]);
|
|
7003
7661
|
return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
7004
7662
|
});
|
|
7005
7663
|
DockviewReact.displayName = 'DockviewComponent';
|
|
@@ -7018,6 +7676,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
7018
7676
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
7019
7677
|
PERFORMANCE OF THIS SOFTWARE.
|
|
7020
7678
|
***************************************************************************** */
|
|
7679
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
7680
|
+
|
|
7021
7681
|
|
|
7022
7682
|
function __rest(s, e) {
|
|
7023
7683
|
var t = {};
|
|
@@ -7029,7 +7689,12 @@ function __rest(s, e) {
|
|
|
7029
7689
|
t[p[i]] = s[p[i]];
|
|
7030
7690
|
}
|
|
7031
7691
|
return t;
|
|
7032
|
-
}
|
|
7692
|
+
}
|
|
7693
|
+
|
|
7694
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
7695
|
+
var e = new Error(message);
|
|
7696
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
7697
|
+
};
|
|
7033
7698
|
|
|
7034
7699
|
const CloseButton = () => (React.createElement("svg", { height: "11", width: "11", viewBox: "0 0 28 28", "aria-hidden": 'false', focusable: false, className: "dockview-svg" },
|
|
7035
7700
|
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 +7966,5 @@ const PaneviewReact = React.forwardRef((props, ref) => {
|
|
|
7301
7966
|
});
|
|
7302
7967
|
PaneviewReact.displayName = 'PaneviewComponent';
|
|
7303
7968
|
|
|
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
|
|
7969
|
+
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 };
|
|
7970
|
+
//# sourceMappingURL=dockview.esm.js.map
|