dockview 1.12.0 → 1.13.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/dist/cjs/dockview/defaultTab.d.ts +1 -1
- package/dist/cjs/dockview/dockview.d.ts +12 -40
- package/dist/cjs/dockview/dockview.js +102 -112
- package/dist/cjs/dockview/headerActionsRenderer.d.ts +3 -13
- package/dist/cjs/dockview/headerActionsRenderer.js +4 -14
- package/dist/cjs/dockview/reactContentPart.d.ts +2 -3
- package/dist/cjs/dockview/reactHeaderPart.d.ts +1 -2
- package/dist/cjs/dockview/reactWatermarkPart.d.ts +1 -6
- package/dist/cjs/dockview/reactWatermarkPart.js +0 -5
- package/dist/cjs/gridview/gridview.d.ts +2 -2
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/paneview/paneview.d.ts +3 -3
- package/dist/cjs/splitview/splitview.d.ts +2 -2
- package/dist/cjs/types.d.ts +0 -4
- package/dist/dockview.amd.js +2072 -2054
- package/dist/dockview.amd.js.map +1 -1
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.js.map +1 -1
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.min.noStyle.js.map +1 -1
- package/dist/dockview.amd.noStyle.js +2072 -2054
- package/dist/dockview.amd.noStyle.js.map +1 -1
- package/dist/dockview.cjs.js +2072 -2054
- package/dist/dockview.cjs.js.map +1 -1
- package/dist/dockview.esm.js +2071 -2055
- package/dist/dockview.esm.js.map +1 -1
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.esm.min.js.map +1 -1
- package/dist/dockview.js +2072 -2054
- package/dist/dockview.js.map +1 -1
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.js.map +1 -1
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.min.noStyle.js.map +1 -1
- package/dist/dockview.noStyle.js +2072 -2054
- package/dist/dockview.noStyle.js.map +1 -1
- package/dist/esm/dockview/defaultTab.d.ts +1 -1
- package/dist/esm/dockview/dockview.d.ts +12 -40
- package/dist/esm/dockview/dockview.js +93 -114
- package/dist/esm/dockview/headerActionsRenderer.d.ts +3 -13
- package/dist/esm/dockview/headerActionsRenderer.js +4 -10
- package/dist/esm/dockview/reactContentPart.d.ts +2 -3
- package/dist/esm/dockview/reactHeaderPart.d.ts +1 -2
- package/dist/esm/dockview/reactWatermarkPart.d.ts +1 -6
- package/dist/esm/dockview/reactWatermarkPart.js +0 -5
- package/dist/esm/gridview/gridview.d.ts +2 -2
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/paneview/paneview.d.ts +3 -3
- package/dist/esm/splitview/splitview.d.ts +2 -2
- package/dist/esm/types.d.ts +0 -4
- package/package.json +3 -3
package/dist/dockview.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.
|
|
3
|
+
* @version 1.13.0
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -2471,6 +2471,261 @@ class Gridview {
|
|
|
2471
2471
|
}
|
|
2472
2472
|
}
|
|
2473
2473
|
|
|
2474
|
+
class Resizable extends CompositeDisposable {
|
|
2475
|
+
get element() {
|
|
2476
|
+
return this._element;
|
|
2477
|
+
}
|
|
2478
|
+
get disableResizing() {
|
|
2479
|
+
return this._disableResizing;
|
|
2480
|
+
}
|
|
2481
|
+
set disableResizing(value) {
|
|
2482
|
+
this._disableResizing = value;
|
|
2483
|
+
}
|
|
2484
|
+
constructor(parentElement, disableResizing = false) {
|
|
2485
|
+
super();
|
|
2486
|
+
this._disableResizing = disableResizing;
|
|
2487
|
+
this._element = parentElement;
|
|
2488
|
+
this.addDisposables(watchElementResize(this._element, (entry) => {
|
|
2489
|
+
if (this.isDisposed) {
|
|
2490
|
+
/**
|
|
2491
|
+
* resize is delayed through requestAnimationFrame so there is a small chance
|
|
2492
|
+
* the component has already been disposed of
|
|
2493
|
+
*/
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
if (this.disableResizing) {
|
|
2497
|
+
return;
|
|
2498
|
+
}
|
|
2499
|
+
if (!this._element.offsetParent) {
|
|
2500
|
+
/**
|
|
2501
|
+
* offsetParent === null is equivalent to display: none being set on the element or one
|
|
2502
|
+
* of it's parents. In the display: none case the size will become (0, 0) which we do
|
|
2503
|
+
* not want to propagate.
|
|
2504
|
+
*
|
|
2505
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
|
|
2506
|
+
*
|
|
2507
|
+
* You could use checkVisibility() but at the time of writing it's not supported across
|
|
2508
|
+
* all Browsers
|
|
2509
|
+
*
|
|
2510
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
|
|
2511
|
+
*/
|
|
2512
|
+
return;
|
|
2513
|
+
}
|
|
2514
|
+
if (!isInDocument(this._element)) {
|
|
2515
|
+
/**
|
|
2516
|
+
* since the event is dispatched through requestAnimationFrame there is a small chance
|
|
2517
|
+
* the component is no longer attached to the DOM, if that is the case the dimensions
|
|
2518
|
+
* are mostly likely all zero and meaningless. we should skip this case.
|
|
2519
|
+
*/
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
const { width, height } = entry.contentRect;
|
|
2523
|
+
this.layout(width, height);
|
|
2524
|
+
}));
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
const nextLayoutId$1 = sequentialNumberGenerator();
|
|
2529
|
+
function toTarget(direction) {
|
|
2530
|
+
switch (direction) {
|
|
2531
|
+
case 'left':
|
|
2532
|
+
return 'left';
|
|
2533
|
+
case 'right':
|
|
2534
|
+
return 'right';
|
|
2535
|
+
case 'above':
|
|
2536
|
+
return 'top';
|
|
2537
|
+
case 'below':
|
|
2538
|
+
return 'bottom';
|
|
2539
|
+
case 'within':
|
|
2540
|
+
default:
|
|
2541
|
+
return 'center';
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
class BaseGrid extends Resizable {
|
|
2545
|
+
get id() {
|
|
2546
|
+
return this._id;
|
|
2547
|
+
}
|
|
2548
|
+
get size() {
|
|
2549
|
+
return this._groups.size;
|
|
2550
|
+
}
|
|
2551
|
+
get groups() {
|
|
2552
|
+
return Array.from(this._groups.values()).map((_) => _.value);
|
|
2553
|
+
}
|
|
2554
|
+
get width() {
|
|
2555
|
+
return this.gridview.width;
|
|
2556
|
+
}
|
|
2557
|
+
get height() {
|
|
2558
|
+
return this.gridview.height;
|
|
2559
|
+
}
|
|
2560
|
+
get minimumHeight() {
|
|
2561
|
+
return this.gridview.minimumHeight;
|
|
2562
|
+
}
|
|
2563
|
+
get maximumHeight() {
|
|
2564
|
+
return this.gridview.maximumHeight;
|
|
2565
|
+
}
|
|
2566
|
+
get minimumWidth() {
|
|
2567
|
+
return this.gridview.minimumWidth;
|
|
2568
|
+
}
|
|
2569
|
+
get maximumWidth() {
|
|
2570
|
+
return this.gridview.maximumWidth;
|
|
2571
|
+
}
|
|
2572
|
+
get activeGroup() {
|
|
2573
|
+
return this._activeGroup;
|
|
2574
|
+
}
|
|
2575
|
+
get locked() {
|
|
2576
|
+
return this.gridview.locked;
|
|
2577
|
+
}
|
|
2578
|
+
set locked(value) {
|
|
2579
|
+
this.gridview.locked = value;
|
|
2580
|
+
}
|
|
2581
|
+
constructor(options) {
|
|
2582
|
+
super(document.createElement('div'), options.disableAutoResizing);
|
|
2583
|
+
this._id = nextLayoutId$1.next();
|
|
2584
|
+
this._groups = new Map();
|
|
2585
|
+
this._onDidLayoutChange = new Emitter();
|
|
2586
|
+
this.onDidLayoutChange = this._onDidLayoutChange.event;
|
|
2587
|
+
this._onDidRemove = new Emitter();
|
|
2588
|
+
this.onDidRemove = this._onDidRemove.event;
|
|
2589
|
+
this._onDidAdd = new Emitter();
|
|
2590
|
+
this.onDidAdd = this._onDidAdd.event;
|
|
2591
|
+
this._onDidActiveChange = new Emitter();
|
|
2592
|
+
this.onDidActiveChange = this._onDidActiveChange.event;
|
|
2593
|
+
this._bufferOnDidLayoutChange = new TickDelayedEvent();
|
|
2594
|
+
this.element.style.height = '100%';
|
|
2595
|
+
this.element.style.width = '100%';
|
|
2596
|
+
options.parentElement.appendChild(this.element);
|
|
2597
|
+
this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
|
|
2598
|
+
this.gridview.locked = !!options.locked;
|
|
2599
|
+
this.element.appendChild(this.gridview.element);
|
|
2600
|
+
this.layout(0, 0, true); // set some elements height/widths
|
|
2601
|
+
this.addDisposables(Disposable.from(() => {
|
|
2602
|
+
var _a;
|
|
2603
|
+
(_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
|
|
2604
|
+
}), this.gridview.onDidChange(() => {
|
|
2605
|
+
this._bufferOnDidLayoutChange.fire();
|
|
2606
|
+
}), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
|
|
2607
|
+
this._bufferOnDidLayoutChange.fire();
|
|
2608
|
+
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
2609
|
+
this._onDidLayoutChange.fire();
|
|
2610
|
+
}), this._bufferOnDidLayoutChange);
|
|
2611
|
+
}
|
|
2612
|
+
setVisible(panel, visible) {
|
|
2613
|
+
this.gridview.setViewVisible(getGridLocation(panel.element), visible);
|
|
2614
|
+
this._onDidLayoutChange.fire();
|
|
2615
|
+
}
|
|
2616
|
+
isVisible(panel) {
|
|
2617
|
+
return this.gridview.isViewVisible(getGridLocation(panel.element));
|
|
2618
|
+
}
|
|
2619
|
+
maximizeGroup(panel) {
|
|
2620
|
+
this.gridview.maximizeView(panel);
|
|
2621
|
+
this.doSetGroupActive(panel);
|
|
2622
|
+
}
|
|
2623
|
+
isMaximizedGroup(panel) {
|
|
2624
|
+
return this.gridview.maximizedView() === panel;
|
|
2625
|
+
}
|
|
2626
|
+
exitMaximizedGroup() {
|
|
2627
|
+
this.gridview.exitMaximizedView();
|
|
2628
|
+
}
|
|
2629
|
+
hasMaximizedGroup() {
|
|
2630
|
+
return this.gridview.hasMaximizedView();
|
|
2631
|
+
}
|
|
2632
|
+
get onDidMaximizedGroupChange() {
|
|
2633
|
+
return this.gridview.onDidMaximizedNodeChange;
|
|
2634
|
+
}
|
|
2635
|
+
doAddGroup(group, location = [0], size) {
|
|
2636
|
+
this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
|
|
2637
|
+
this._onDidAdd.fire(group);
|
|
2638
|
+
}
|
|
2639
|
+
doRemoveGroup(group, options) {
|
|
2640
|
+
if (!this._groups.has(group.id)) {
|
|
2641
|
+
throw new Error('invalid operation');
|
|
2642
|
+
}
|
|
2643
|
+
const item = this._groups.get(group.id);
|
|
2644
|
+
const view = this.gridview.remove(group, exports.Sizing.Distribute);
|
|
2645
|
+
if (item && !(options === null || options === void 0 ? void 0 : options.skipDispose)) {
|
|
2646
|
+
item.disposable.dispose();
|
|
2647
|
+
item.value.dispose();
|
|
2648
|
+
this._groups.delete(group.id);
|
|
2649
|
+
this._onDidRemove.fire(group);
|
|
2650
|
+
}
|
|
2651
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
|
|
2652
|
+
const groups = Array.from(this._groups.values());
|
|
2653
|
+
this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
|
|
2654
|
+
}
|
|
2655
|
+
return view;
|
|
2656
|
+
}
|
|
2657
|
+
getPanel(id) {
|
|
2658
|
+
var _a;
|
|
2659
|
+
return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
|
|
2660
|
+
}
|
|
2661
|
+
doSetGroupActive(group) {
|
|
2662
|
+
if (this._activeGroup === group) {
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
if (this._activeGroup) {
|
|
2666
|
+
this._activeGroup.setActive(false);
|
|
2667
|
+
}
|
|
2668
|
+
if (group) {
|
|
2669
|
+
group.setActive(true);
|
|
2670
|
+
}
|
|
2671
|
+
this._activeGroup = group;
|
|
2672
|
+
this._onDidActiveChange.fire(group);
|
|
2673
|
+
}
|
|
2674
|
+
removeGroup(group) {
|
|
2675
|
+
this.doRemoveGroup(group);
|
|
2676
|
+
}
|
|
2677
|
+
moveToNext(options) {
|
|
2678
|
+
var _a;
|
|
2679
|
+
if (!options) {
|
|
2680
|
+
options = {};
|
|
2681
|
+
}
|
|
2682
|
+
if (!options.group) {
|
|
2683
|
+
if (!this.activeGroup) {
|
|
2684
|
+
return;
|
|
2685
|
+
}
|
|
2686
|
+
options.group = this.activeGroup;
|
|
2687
|
+
}
|
|
2688
|
+
const location = getGridLocation(options.group.element);
|
|
2689
|
+
const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
2690
|
+
this.doSetGroupActive(next);
|
|
2691
|
+
}
|
|
2692
|
+
moveToPrevious(options) {
|
|
2693
|
+
var _a;
|
|
2694
|
+
if (!options) {
|
|
2695
|
+
options = {};
|
|
2696
|
+
}
|
|
2697
|
+
if (!options.group) {
|
|
2698
|
+
if (!this.activeGroup) {
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
options.group = this.activeGroup;
|
|
2702
|
+
}
|
|
2703
|
+
const location = getGridLocation(options.group.element);
|
|
2704
|
+
const next = (_a = this.gridview.previous(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
2705
|
+
this.doSetGroupActive(next);
|
|
2706
|
+
}
|
|
2707
|
+
layout(width, height, forceResize) {
|
|
2708
|
+
const different = forceResize !== null && forceResize !== void 0 ? forceResize : (width !== this.width || height !== this.height);
|
|
2709
|
+
if (!different) {
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2712
|
+
this.gridview.element.style.height = `${height}px`;
|
|
2713
|
+
this.gridview.element.style.width = `${width}px`;
|
|
2714
|
+
this.gridview.layout(width, height);
|
|
2715
|
+
}
|
|
2716
|
+
dispose() {
|
|
2717
|
+
this._onDidActiveChange.dispose();
|
|
2718
|
+
this._onDidAdd.dispose();
|
|
2719
|
+
this._onDidRemove.dispose();
|
|
2720
|
+
this._onDidLayoutChange.dispose();
|
|
2721
|
+
for (const group of this.groups) {
|
|
2722
|
+
group.dispose();
|
|
2723
|
+
}
|
|
2724
|
+
this.gridview.dispose();
|
|
2725
|
+
super.dispose();
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2474
2729
|
class SplitviewApi {
|
|
2475
2730
|
/**
|
|
2476
2731
|
* The minimum size the component can reach where size is measured in the direction of orientation provided.
|
|
@@ -3013,6 +3268,9 @@ class DockviewApi {
|
|
|
3013
3268
|
get onWillDragPanel() {
|
|
3014
3269
|
return this.component.onWillDragPanel;
|
|
3015
3270
|
}
|
|
3271
|
+
get onUnhandledDragOverEvent() {
|
|
3272
|
+
return this.component.onUnhandledDragOverEvent;
|
|
3273
|
+
}
|
|
3016
3274
|
/**
|
|
3017
3275
|
* All panel objects.
|
|
3018
3276
|
*/
|
|
@@ -3150,6 +3408,67 @@ class DockviewApi {
|
|
|
3150
3408
|
}
|
|
3151
3409
|
}
|
|
3152
3410
|
|
|
3411
|
+
class DragHandler extends CompositeDisposable {
|
|
3412
|
+
constructor(el) {
|
|
3413
|
+
super();
|
|
3414
|
+
this.el = el;
|
|
3415
|
+
this.dataDisposable = new MutableDisposable();
|
|
3416
|
+
this.pointerEventsDisposable = new MutableDisposable();
|
|
3417
|
+
this._onDragStart = new Emitter();
|
|
3418
|
+
this.onDragStart = this._onDragStart.event;
|
|
3419
|
+
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
3420
|
+
this.configure();
|
|
3421
|
+
}
|
|
3422
|
+
isCancelled(_event) {
|
|
3423
|
+
return false;
|
|
3424
|
+
}
|
|
3425
|
+
configure() {
|
|
3426
|
+
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
3427
|
+
if (event.defaultPrevented || this.isCancelled(event)) {
|
|
3428
|
+
event.preventDefault();
|
|
3429
|
+
return;
|
|
3430
|
+
}
|
|
3431
|
+
const iframes = [
|
|
3432
|
+
...getElementsByTagName('iframe'),
|
|
3433
|
+
...getElementsByTagName('webview'),
|
|
3434
|
+
];
|
|
3435
|
+
this.pointerEventsDisposable.value = {
|
|
3436
|
+
dispose: () => {
|
|
3437
|
+
for (const iframe of iframes) {
|
|
3438
|
+
iframe.style.pointerEvents = 'auto';
|
|
3439
|
+
}
|
|
3440
|
+
},
|
|
3441
|
+
};
|
|
3442
|
+
for (const iframe of iframes) {
|
|
3443
|
+
iframe.style.pointerEvents = 'none';
|
|
3444
|
+
}
|
|
3445
|
+
this.el.classList.add('dv-dragged');
|
|
3446
|
+
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
3447
|
+
this.dataDisposable.value = this.getData(event);
|
|
3448
|
+
this._onDragStart.fire(event);
|
|
3449
|
+
if (event.dataTransfer) {
|
|
3450
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
3451
|
+
const hasData = event.dataTransfer.items.length > 0;
|
|
3452
|
+
if (!hasData) {
|
|
3453
|
+
/**
|
|
3454
|
+
* Although this is not used by dockview many third party dnd libraries will check
|
|
3455
|
+
* dataTransfer.types to determine valid drag events.
|
|
3456
|
+
*
|
|
3457
|
+
* For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
|
|
3458
|
+
* through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
|
|
3459
|
+
* dnd logic. You can see the code at
|
|
3460
|
+
* https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
|
|
3461
|
+
*/
|
|
3462
|
+
event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
}), addDisposableListener(this.el, 'dragend', () => {
|
|
3466
|
+
this.pointerEventsDisposable.dispose();
|
|
3467
|
+
this.dataDisposable.dispose();
|
|
3468
|
+
}));
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3153
3472
|
class DragAndDropObserver extends CompositeDisposable {
|
|
3154
3473
|
constructor(element, callbacks) {
|
|
3155
3474
|
super();
|
|
@@ -3294,6 +3613,10 @@ class Droptarget extends CompositeDisposable {
|
|
|
3294
3613
|
this.removeDropTarget();
|
|
3295
3614
|
return;
|
|
3296
3615
|
}
|
|
3616
|
+
if (!this.options.canDisplayOverlay(e, quadrant)) {
|
|
3617
|
+
this.removeDropTarget();
|
|
3618
|
+
return;
|
|
3619
|
+
}
|
|
3297
3620
|
const willShowOverlayEvent = new WillShowOverlayEvent({
|
|
3298
3621
|
nativeEvent: e,
|
|
3299
3622
|
position: quadrant,
|
|
@@ -3307,16 +3630,6 @@ class Droptarget extends CompositeDisposable {
|
|
|
3307
3630
|
this.removeDropTarget();
|
|
3308
3631
|
return;
|
|
3309
3632
|
}
|
|
3310
|
-
if (typeof this.options.canDisplayOverlay === 'boolean') {
|
|
3311
|
-
if (!this.options.canDisplayOverlay) {
|
|
3312
|
-
this.removeDropTarget();
|
|
3313
|
-
return;
|
|
3314
|
-
}
|
|
3315
|
-
}
|
|
3316
|
-
else if (!this.options.canDisplayOverlay(e, quadrant)) {
|
|
3317
|
-
this.removeDropTarget();
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
3633
|
this.markAsUsed(e);
|
|
3321
3634
|
if (!this.targetElement) {
|
|
3322
3635
|
this.targetElement = document.createElement('div');
|
|
@@ -3507,2023 +3820,1758 @@ function calculateQuadrantAsPixels(overlayType, x, y, width, height, threshold)
|
|
|
3507
3820
|
return 'center';
|
|
3508
3821
|
}
|
|
3509
3822
|
|
|
3510
|
-
class
|
|
3511
|
-
|
|
3512
|
-
return this._element;
|
|
3513
|
-
}
|
|
3514
|
-
constructor(accessor, group) {
|
|
3823
|
+
class WillFocusEvent extends DockviewEvent {
|
|
3824
|
+
constructor() {
|
|
3515
3825
|
super();
|
|
3516
|
-
this.accessor = accessor;
|
|
3517
|
-
this.group = group;
|
|
3518
|
-
this.disposable = new MutableDisposable();
|
|
3519
|
-
this._onDidFocus = new Emitter();
|
|
3520
|
-
this.onDidFocus = this._onDidFocus.event;
|
|
3521
|
-
this._onDidBlur = new Emitter();
|
|
3522
|
-
this.onDidBlur = this._onDidBlur.event;
|
|
3523
|
-
this._element = document.createElement('div');
|
|
3524
|
-
this._element.className = 'content-container';
|
|
3525
|
-
this._element.tabIndex = -1;
|
|
3526
|
-
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
3527
|
-
this.dropTarget = new Droptarget(this.element, {
|
|
3528
|
-
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
3529
|
-
canDisplayOverlay: (event, position) => {
|
|
3530
|
-
if (this.group.locked === 'no-drop-target' ||
|
|
3531
|
-
(this.group.locked && position === 'center')) {
|
|
3532
|
-
return false;
|
|
3533
|
-
}
|
|
3534
|
-
const data = getPanelData();
|
|
3535
|
-
if (!data &&
|
|
3536
|
-
event.shiftKey &&
|
|
3537
|
-
this.group.location.type !== 'floating') {
|
|
3538
|
-
return false;
|
|
3539
|
-
}
|
|
3540
|
-
if (data && data.viewId === this.accessor.id) {
|
|
3541
|
-
if (data.groupId === this.group.id) {
|
|
3542
|
-
if (position === 'center') {
|
|
3543
|
-
// don't allow to drop on self for center position
|
|
3544
|
-
return false;
|
|
3545
|
-
}
|
|
3546
|
-
if (data.panelId === null) {
|
|
3547
|
-
// don't allow group move to drop anywhere on self
|
|
3548
|
-
return false;
|
|
3549
|
-
}
|
|
3550
|
-
}
|
|
3551
|
-
const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
|
|
3552
|
-
data.groupId === this.group.id;
|
|
3553
|
-
return !groupHasOnePanelAndIsActiveDragElement;
|
|
3554
|
-
}
|
|
3555
|
-
return this.group.canDisplayOverlay(event, position, 'content');
|
|
3556
|
-
},
|
|
3557
|
-
});
|
|
3558
|
-
this.addDisposables(this.dropTarget);
|
|
3559
3826
|
}
|
|
3560
|
-
|
|
3561
|
-
|
|
3827
|
+
}
|
|
3828
|
+
/**
|
|
3829
|
+
* A core api implementation that should be used across all panel-like objects
|
|
3830
|
+
*/
|
|
3831
|
+
class PanelApiImpl extends CompositeDisposable {
|
|
3832
|
+
get isFocused() {
|
|
3833
|
+
return this._isFocused;
|
|
3562
3834
|
}
|
|
3563
|
-
|
|
3564
|
-
this.
|
|
3835
|
+
get isActive() {
|
|
3836
|
+
return this._isActive;
|
|
3565
3837
|
}
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
(this.panel && this.group.isPanelActive(this.panel));
|
|
3569
|
-
if (this.panel &&
|
|
3570
|
-
this.panel.view.content.element.parentElement === this._element) {
|
|
3571
|
-
/**
|
|
3572
|
-
* If the currently attached panel is mounted directly to the content then remove it
|
|
3573
|
-
*/
|
|
3574
|
-
this._element.removeChild(this.panel.view.content.element);
|
|
3575
|
-
}
|
|
3576
|
-
this.panel = panel;
|
|
3577
|
-
let container;
|
|
3578
|
-
switch (panel.api.renderer) {
|
|
3579
|
-
case 'onlyWhenVisible':
|
|
3580
|
-
this.group.renderContainer.detatch(panel);
|
|
3581
|
-
if (this.panel) {
|
|
3582
|
-
if (doRender) {
|
|
3583
|
-
this._element.appendChild(this.panel.view.content.element);
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
container = this._element;
|
|
3587
|
-
break;
|
|
3588
|
-
case 'always':
|
|
3589
|
-
if (panel.view.content.element.parentElement === this._element) {
|
|
3590
|
-
this._element.removeChild(panel.view.content.element);
|
|
3591
|
-
}
|
|
3592
|
-
container = this.group.renderContainer.attach({
|
|
3593
|
-
panel,
|
|
3594
|
-
referenceContainer: this,
|
|
3595
|
-
});
|
|
3596
|
-
break;
|
|
3597
|
-
}
|
|
3598
|
-
if (doRender) {
|
|
3599
|
-
const _onDidFocus = panel.view.content.onDidFocus;
|
|
3600
|
-
const _onDidBlur = panel.view.content.onDidBlur;
|
|
3601
|
-
const focusTracker = trackFocus(container);
|
|
3602
|
-
const disposable = new CompositeDisposable();
|
|
3603
|
-
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
3604
|
-
if (_onDidFocus) {
|
|
3605
|
-
disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
|
|
3606
|
-
}
|
|
3607
|
-
if (_onDidBlur) {
|
|
3608
|
-
disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
|
|
3609
|
-
}
|
|
3610
|
-
this.disposable.value = disposable;
|
|
3611
|
-
}
|
|
3838
|
+
get isVisible() {
|
|
3839
|
+
return this._isVisible;
|
|
3612
3840
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
return;
|
|
3616
|
-
}
|
|
3617
|
-
this.renderPanel(panel);
|
|
3841
|
+
get width() {
|
|
3842
|
+
return this._width;
|
|
3618
3843
|
}
|
|
3619
|
-
|
|
3620
|
-
|
|
3844
|
+
get height() {
|
|
3845
|
+
return this._height;
|
|
3621
3846
|
}
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
this.
|
|
3847
|
+
constructor(id, component) {
|
|
3848
|
+
super();
|
|
3849
|
+
this.id = id;
|
|
3850
|
+
this.component = component;
|
|
3851
|
+
this._isFocused = false;
|
|
3852
|
+
this._isActive = false;
|
|
3853
|
+
this._isVisible = true;
|
|
3854
|
+
this._width = 0;
|
|
3855
|
+
this._height = 0;
|
|
3856
|
+
this._parameters = {};
|
|
3857
|
+
this.panelUpdatesDisposable = new MutableDisposable();
|
|
3858
|
+
this._onDidDimensionChange = new Emitter();
|
|
3859
|
+
this.onDidDimensionsChange = this._onDidDimensionChange.event;
|
|
3860
|
+
this._onDidChangeFocus = new Emitter();
|
|
3861
|
+
this.onDidFocusChange = this._onDidChangeFocus.event;
|
|
3862
|
+
//
|
|
3863
|
+
this._onWillFocus = new Emitter();
|
|
3864
|
+
this.onWillFocus = this._onWillFocus.event;
|
|
3865
|
+
//
|
|
3866
|
+
this._onDidVisibilityChange = new Emitter();
|
|
3867
|
+
this.onDidVisibilityChange = this._onDidVisibilityChange.event;
|
|
3868
|
+
this._onWillVisibilityChange = new Emitter();
|
|
3869
|
+
this.onWillVisibilityChange = this._onWillVisibilityChange.event;
|
|
3870
|
+
this._onDidActiveChange = new Emitter();
|
|
3871
|
+
this.onDidActiveChange = this._onDidActiveChange.event;
|
|
3872
|
+
this._onActiveChange = new Emitter();
|
|
3873
|
+
this.onActiveChange = this._onActiveChange.event;
|
|
3874
|
+
this._onDidParametersChange = new Emitter();
|
|
3875
|
+
this.onDidParametersChange = this._onDidParametersChange.event;
|
|
3876
|
+
this.addDisposables(this.onDidFocusChange((event) => {
|
|
3877
|
+
this._isFocused = event.isFocused;
|
|
3878
|
+
}), this.onDidActiveChange((event) => {
|
|
3879
|
+
this._isActive = event.isActive;
|
|
3880
|
+
}), this.onDidVisibilityChange((event) => {
|
|
3881
|
+
this._isVisible = event.isVisible;
|
|
3882
|
+
}), this.onDidDimensionsChange((event) => {
|
|
3883
|
+
this._width = event.width;
|
|
3884
|
+
this._height = event.height;
|
|
3885
|
+
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
|
|
3630
3886
|
}
|
|
3631
|
-
|
|
3632
|
-
this.
|
|
3633
|
-
|
|
3887
|
+
getParameters() {
|
|
3888
|
+
return this._parameters;
|
|
3889
|
+
}
|
|
3890
|
+
initialize(panel) {
|
|
3891
|
+
this.panelUpdatesDisposable.value = this._onDidParametersChange.event((parameters) => {
|
|
3892
|
+
this._parameters = parameters;
|
|
3893
|
+
panel.update({
|
|
3894
|
+
params: parameters,
|
|
3895
|
+
});
|
|
3896
|
+
});
|
|
3897
|
+
}
|
|
3898
|
+
setVisible(isVisible) {
|
|
3899
|
+
this._onWillVisibilityChange.fire({ isVisible });
|
|
3900
|
+
}
|
|
3901
|
+
setActive() {
|
|
3902
|
+
this._onActiveChange.fire();
|
|
3903
|
+
}
|
|
3904
|
+
updateParameters(parameters) {
|
|
3905
|
+
this._onDidParametersChange.fire(parameters);
|
|
3634
3906
|
}
|
|
3635
3907
|
}
|
|
3636
3908
|
|
|
3637
|
-
class
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
this.
|
|
3642
|
-
this.
|
|
3643
|
-
|
|
3644
|
-
this.
|
|
3645
|
-
|
|
3646
|
-
|
|
3909
|
+
class SplitviewPanelApiImpl extends PanelApiImpl {
|
|
3910
|
+
//
|
|
3911
|
+
constructor(id, component) {
|
|
3912
|
+
super(id, component);
|
|
3913
|
+
this._onDidConstraintsChangeInternal = new Emitter();
|
|
3914
|
+
this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
|
|
3915
|
+
//
|
|
3916
|
+
this._onDidConstraintsChange = new Emitter({
|
|
3917
|
+
replay: true,
|
|
3918
|
+
});
|
|
3919
|
+
this.onDidConstraintsChange = this._onDidConstraintsChange.event;
|
|
3920
|
+
//
|
|
3921
|
+
this._onDidSizeChange = new Emitter();
|
|
3922
|
+
this.onDidSizeChange = this._onDidSizeChange.event;
|
|
3923
|
+
this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
|
|
3647
3924
|
}
|
|
3648
|
-
|
|
3649
|
-
|
|
3925
|
+
setConstraints(value) {
|
|
3926
|
+
this._onDidConstraintsChangeInternal.fire(value);
|
|
3650
3927
|
}
|
|
3651
|
-
|
|
3652
|
-
this.
|
|
3653
|
-
if (event.defaultPrevented || this.isCancelled(event)) {
|
|
3654
|
-
event.preventDefault();
|
|
3655
|
-
return;
|
|
3656
|
-
}
|
|
3657
|
-
const iframes = [
|
|
3658
|
-
...getElementsByTagName('iframe'),
|
|
3659
|
-
...getElementsByTagName('webview'),
|
|
3660
|
-
];
|
|
3661
|
-
this.pointerEventsDisposable.value = {
|
|
3662
|
-
dispose: () => {
|
|
3663
|
-
for (const iframe of iframes) {
|
|
3664
|
-
iframe.style.pointerEvents = 'auto';
|
|
3665
|
-
}
|
|
3666
|
-
},
|
|
3667
|
-
};
|
|
3668
|
-
for (const iframe of iframes) {
|
|
3669
|
-
iframe.style.pointerEvents = 'none';
|
|
3670
|
-
}
|
|
3671
|
-
this.el.classList.add('dv-dragged');
|
|
3672
|
-
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
3673
|
-
this.dataDisposable.value = this.getData(event);
|
|
3674
|
-
this._onDragStart.fire(event);
|
|
3675
|
-
if (event.dataTransfer) {
|
|
3676
|
-
event.dataTransfer.effectAllowed = 'move';
|
|
3677
|
-
const hasData = event.dataTransfer.items.length > 0;
|
|
3678
|
-
if (!hasData) {
|
|
3679
|
-
/**
|
|
3680
|
-
* Although this is not used by dockview many third party dnd libraries will check
|
|
3681
|
-
* dataTransfer.types to determine valid drag events.
|
|
3682
|
-
*
|
|
3683
|
-
* For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
|
|
3684
|
-
* through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
|
|
3685
|
-
* dnd logic. You can see the code at
|
|
3686
|
-
* https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
|
|
3687
|
-
*/
|
|
3688
|
-
event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
|
|
3689
|
-
}
|
|
3690
|
-
}
|
|
3691
|
-
}), addDisposableListener(this.el, 'dragend', () => {
|
|
3692
|
-
this.pointerEventsDisposable.dispose();
|
|
3693
|
-
this.dataDisposable.dispose();
|
|
3694
|
-
}));
|
|
3928
|
+
setSize(event) {
|
|
3929
|
+
this._onDidSizeChange.fire(event);
|
|
3695
3930
|
}
|
|
3696
3931
|
}
|
|
3697
3932
|
|
|
3698
|
-
class
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
this.accessor = accessor;
|
|
3702
|
-
this.group = group;
|
|
3703
|
-
this.panel = panel;
|
|
3704
|
-
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
3933
|
+
class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
|
|
3934
|
+
set pane(pane) {
|
|
3935
|
+
this._pane = pane;
|
|
3705
3936
|
}
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
};
|
|
3937
|
+
constructor(id, component) {
|
|
3938
|
+
super(id, component);
|
|
3939
|
+
this._onDidExpansionChange = new Emitter({
|
|
3940
|
+
replay: true,
|
|
3941
|
+
});
|
|
3942
|
+
this.onDidExpansionChange = this._onDidExpansionChange.event;
|
|
3943
|
+
this._onMouseEnter = new Emitter({});
|
|
3944
|
+
this.onMouseEnter = this._onMouseEnter.event;
|
|
3945
|
+
this._onMouseLeave = new Emitter({});
|
|
3946
|
+
this.onMouseLeave = this._onMouseLeave.event;
|
|
3947
|
+
this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
|
|
3948
|
+
}
|
|
3949
|
+
setExpanded(isExpanded) {
|
|
3950
|
+
var _a;
|
|
3951
|
+
(_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
|
|
3952
|
+
}
|
|
3953
|
+
get isExpanded() {
|
|
3954
|
+
var _a;
|
|
3955
|
+
return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
|
|
3713
3956
|
}
|
|
3714
3957
|
}
|
|
3715
|
-
|
|
3958
|
+
|
|
3959
|
+
class BasePanelView extends CompositeDisposable {
|
|
3716
3960
|
get element() {
|
|
3717
3961
|
return this._element;
|
|
3718
3962
|
}
|
|
3719
|
-
|
|
3963
|
+
get width() {
|
|
3964
|
+
return this._width;
|
|
3965
|
+
}
|
|
3966
|
+
get height() {
|
|
3967
|
+
return this._height;
|
|
3968
|
+
}
|
|
3969
|
+
get params() {
|
|
3970
|
+
var _a;
|
|
3971
|
+
return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
|
|
3972
|
+
}
|
|
3973
|
+
constructor(id, component, api) {
|
|
3720
3974
|
super();
|
|
3721
|
-
this.
|
|
3722
|
-
this.
|
|
3723
|
-
this.
|
|
3724
|
-
this.
|
|
3725
|
-
this.
|
|
3726
|
-
this.onChanged = this._onChanged.event;
|
|
3727
|
-
this._onDropped = new Emitter();
|
|
3728
|
-
this.onDrop = this._onDropped.event;
|
|
3729
|
-
this._onDragStart = new Emitter();
|
|
3730
|
-
this.onDragStart = this._onDragStart.event;
|
|
3975
|
+
this.id = id;
|
|
3976
|
+
this.component = component;
|
|
3977
|
+
this.api = api;
|
|
3978
|
+
this._height = 0;
|
|
3979
|
+
this._width = 0;
|
|
3731
3980
|
this._element = document.createElement('div');
|
|
3732
|
-
this._element.
|
|
3733
|
-
this._element.
|
|
3734
|
-
this._element.
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
this.
|
|
3756
|
-
|
|
3757
|
-
this.
|
|
3758
|
-
|
|
3759
|
-
if (event.defaultPrevented) {
|
|
3760
|
-
return;
|
|
3981
|
+
this._element.tabIndex = -1;
|
|
3982
|
+
this._element.style.outline = 'none';
|
|
3983
|
+
this._element.style.height = '100%';
|
|
3984
|
+
this._element.style.width = '100%';
|
|
3985
|
+
this._element.style.overflow = 'hidden';
|
|
3986
|
+
const focusTracker = trackFocus(this._element);
|
|
3987
|
+
this.addDisposables(this.api, focusTracker.onDidFocus(() => {
|
|
3988
|
+
this.api._onDidChangeFocus.fire({ isFocused: true });
|
|
3989
|
+
}), focusTracker.onDidBlur(() => {
|
|
3990
|
+
this.api._onDidChangeFocus.fire({ isFocused: false });
|
|
3991
|
+
}), focusTracker);
|
|
3992
|
+
}
|
|
3993
|
+
focus() {
|
|
3994
|
+
const event = new WillFocusEvent();
|
|
3995
|
+
this.api._onWillFocus.fire(event);
|
|
3996
|
+
if (event.defaultPrevented) {
|
|
3997
|
+
return;
|
|
3998
|
+
}
|
|
3999
|
+
this._element.focus();
|
|
4000
|
+
}
|
|
4001
|
+
layout(width, height) {
|
|
4002
|
+
this._width = width;
|
|
4003
|
+
this._height = height;
|
|
4004
|
+
this.api._onDidDimensionChange.fire({ width, height });
|
|
4005
|
+
if (this.part) {
|
|
4006
|
+
if (this._params) {
|
|
4007
|
+
this.part.update(this._params.params);
|
|
3761
4008
|
}
|
|
3762
|
-
|
|
3763
|
-
}), this.dropTarget.onDrop((event) => {
|
|
3764
|
-
this._onDropped.fire(event);
|
|
3765
|
-
}), this.dropTarget);
|
|
4009
|
+
}
|
|
3766
4010
|
}
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
4011
|
+
init(parameters) {
|
|
4012
|
+
this._params = parameters;
|
|
4013
|
+
this.part = this.getComponent();
|
|
3770
4014
|
}
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
4015
|
+
update(event) {
|
|
4016
|
+
var _a, _b;
|
|
4017
|
+
// merge the new parameters with the existing parameters
|
|
4018
|
+
this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
|
|
4019
|
+
/**
|
|
4020
|
+
* delete new keys that have a value of undefined,
|
|
4021
|
+
* allow values of null
|
|
4022
|
+
*/
|
|
4023
|
+
for (const key of Object.keys(event.params)) {
|
|
4024
|
+
if (event.params[key] === undefined) {
|
|
4025
|
+
delete this._params.params[key];
|
|
4026
|
+
}
|
|
3774
4027
|
}
|
|
3775
|
-
|
|
3776
|
-
this.
|
|
4028
|
+
// update the view with the updated props
|
|
4029
|
+
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
|
|
4030
|
+
}
|
|
4031
|
+
toJSON() {
|
|
4032
|
+
var _a, _b;
|
|
4033
|
+
const params = (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
|
|
4034
|
+
return {
|
|
4035
|
+
id: this.id,
|
|
4036
|
+
component: this.component,
|
|
4037
|
+
params: Object.keys(params).length > 0 ? params : undefined,
|
|
4038
|
+
};
|
|
3777
4039
|
}
|
|
3778
4040
|
dispose() {
|
|
4041
|
+
var _a;
|
|
4042
|
+
this.api.dispose();
|
|
4043
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
3779
4044
|
super.dispose();
|
|
3780
4045
|
}
|
|
3781
4046
|
}
|
|
3782
4047
|
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
document.body.appendChild(ghostElement);
|
|
3787
|
-
dataTransfer.setDragImage(ghostElement, 0, 0);
|
|
3788
|
-
setTimeout(() => {
|
|
3789
|
-
removeClasses(ghostElement, 'dv-dragged');
|
|
3790
|
-
ghostElement.remove();
|
|
3791
|
-
}, 0);
|
|
3792
|
-
}
|
|
3793
|
-
|
|
3794
|
-
class GroupDragHandler extends DragHandler {
|
|
3795
|
-
constructor(element, accessor, group) {
|
|
3796
|
-
super(element);
|
|
3797
|
-
this.accessor = accessor;
|
|
3798
|
-
this.group = group;
|
|
3799
|
-
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
3800
|
-
this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
|
|
3801
|
-
if (e.shiftKey) {
|
|
3802
|
-
/**
|
|
3803
|
-
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
3804
|
-
* but we also need to stop any group overlay drag events from occuring
|
|
3805
|
-
* Use a custom event marker that can be checked by the overlay drag events
|
|
3806
|
-
*/
|
|
3807
|
-
quasiPreventDefault(e);
|
|
3808
|
-
}
|
|
3809
|
-
}, true));
|
|
4048
|
+
class PaneviewPanel extends BasePanelView {
|
|
4049
|
+
set orientation(value) {
|
|
4050
|
+
this._orientation = value;
|
|
3810
4051
|
}
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
return true;
|
|
3814
|
-
}
|
|
3815
|
-
return false;
|
|
4052
|
+
get orientation() {
|
|
4053
|
+
return this._orientation;
|
|
3816
4054
|
}
|
|
3817
|
-
|
|
3818
|
-
const
|
|
3819
|
-
|
|
3820
|
-
const
|
|
3821
|
-
|
|
3822
|
-
const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
|
|
3823
|
-
if (dataTransfer) {
|
|
3824
|
-
const ghostElement = document.createElement('div');
|
|
3825
|
-
ghostElement.style.backgroundColor = bgColor;
|
|
3826
|
-
ghostElement.style.color = color;
|
|
3827
|
-
ghostElement.style.padding = '2px 8px';
|
|
3828
|
-
ghostElement.style.height = '24px';
|
|
3829
|
-
ghostElement.style.fontSize = '11px';
|
|
3830
|
-
ghostElement.style.lineHeight = '20px';
|
|
3831
|
-
ghostElement.style.borderRadius = '12px';
|
|
3832
|
-
ghostElement.style.position = 'absolute';
|
|
3833
|
-
ghostElement.textContent = `Multiple Panels (${this.group.size})`;
|
|
3834
|
-
addGhostImage(dataTransfer, ghostElement);
|
|
3835
|
-
}
|
|
3836
|
-
return {
|
|
3837
|
-
dispose: () => {
|
|
3838
|
-
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
3839
|
-
},
|
|
3840
|
-
};
|
|
4055
|
+
get minimumSize() {
|
|
4056
|
+
const headerSize = this.headerSize;
|
|
4057
|
+
const expanded = this.isExpanded();
|
|
4058
|
+
const minimumBodySize = expanded ? this._minimumBodySize : 0;
|
|
4059
|
+
return headerSize + minimumBodySize;
|
|
3841
4060
|
}
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
return
|
|
4061
|
+
get maximumSize() {
|
|
4062
|
+
const headerSize = this.headerSize;
|
|
4063
|
+
const expanded = this.isExpanded();
|
|
4064
|
+
const maximumBodySize = expanded ? this._maximumBodySize : 0;
|
|
4065
|
+
return headerSize + maximumBodySize;
|
|
3847
4066
|
}
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
this.accessor = accessor;
|
|
3851
|
-
this.group = group;
|
|
3852
|
-
this._onDrop = new Emitter();
|
|
3853
|
-
this.onDrop = this._onDrop.event;
|
|
3854
|
-
this._onDragStart = new Emitter();
|
|
3855
|
-
this.onDragStart = this._onDragStart.event;
|
|
3856
|
-
this._element = document.createElement('div');
|
|
3857
|
-
this._element.className = 'void-container';
|
|
3858
|
-
this._element.tabIndex = 0;
|
|
3859
|
-
this._element.draggable = true;
|
|
3860
|
-
this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
|
|
3861
|
-
this.accessor.doSetGroupActive(this.group);
|
|
3862
|
-
}));
|
|
3863
|
-
const handler = new GroupDragHandler(this._element, accessor, group);
|
|
3864
|
-
this.dropTraget = new Droptarget(this._element, {
|
|
3865
|
-
acceptedTargetZones: ['center'],
|
|
3866
|
-
canDisplayOverlay: (event, position) => {
|
|
3867
|
-
var _a;
|
|
3868
|
-
const data = getPanelData();
|
|
3869
|
-
if (data && this.accessor.id === data.viewId) {
|
|
3870
|
-
if (data.panelId === null &&
|
|
3871
|
-
data.groupId === this.group.id) {
|
|
3872
|
-
// don't allow group move to drop on self
|
|
3873
|
-
return false;
|
|
3874
|
-
}
|
|
3875
|
-
// don't show the overlay if the tab being dragged is the last panel of this group
|
|
3876
|
-
return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
|
|
3877
|
-
}
|
|
3878
|
-
return group.model.canDisplayOverlay(event, position, 'header_space');
|
|
3879
|
-
},
|
|
3880
|
-
});
|
|
3881
|
-
this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
|
|
3882
|
-
this.addDisposables(handler, handler.onDragStart((event) => {
|
|
3883
|
-
this._onDragStart.fire(event);
|
|
3884
|
-
}), this.dropTraget.onDrop((event) => {
|
|
3885
|
-
this._onDrop.fire(event);
|
|
3886
|
-
}), this.dropTraget);
|
|
4067
|
+
get size() {
|
|
4068
|
+
return this._size;
|
|
3887
4069
|
}
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
class TabsContainer extends CompositeDisposable {
|
|
3891
|
-
get panels() {
|
|
3892
|
-
return this.tabs.map((_) => _.value.panel.id);
|
|
4070
|
+
get orthogonalSize() {
|
|
4071
|
+
return this._orthogonalSize;
|
|
3893
4072
|
}
|
|
3894
|
-
|
|
3895
|
-
|
|
4073
|
+
set orthogonalSize(size) {
|
|
4074
|
+
this._orthogonalSize = size;
|
|
3896
4075
|
}
|
|
3897
|
-
get
|
|
3898
|
-
return this.
|
|
4076
|
+
get minimumBodySize() {
|
|
4077
|
+
return this._minimumBodySize;
|
|
3899
4078
|
}
|
|
3900
|
-
set
|
|
3901
|
-
this.
|
|
3902
|
-
this.element.style.display = value ? 'none' : '';
|
|
4079
|
+
set minimumBodySize(value) {
|
|
4080
|
+
this._minimumBodySize = typeof value === 'number' ? value : 0;
|
|
3903
4081
|
}
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
this.element.style.display = '';
|
|
3907
|
-
}
|
|
4082
|
+
get maximumBodySize() {
|
|
4083
|
+
return this._maximumBodySize;
|
|
3908
4084
|
}
|
|
3909
|
-
|
|
3910
|
-
this.
|
|
4085
|
+
set maximumBodySize(value) {
|
|
4086
|
+
this._maximumBodySize =
|
|
4087
|
+
typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
|
|
3911
4088
|
}
|
|
3912
|
-
|
|
3913
|
-
|
|
4089
|
+
get headerVisible() {
|
|
4090
|
+
return this._headerVisible;
|
|
4091
|
+
}
|
|
4092
|
+
set headerVisible(value) {
|
|
4093
|
+
this._headerVisible = value;
|
|
4094
|
+
this.header.style.display = value ? '' : 'none';
|
|
4095
|
+
}
|
|
4096
|
+
constructor(id, component, headerComponent, orientation, isExpanded, isHeaderVisible) {
|
|
4097
|
+
super(id, component, new PaneviewPanelApiImpl(id, component));
|
|
4098
|
+
this.headerComponent = headerComponent;
|
|
4099
|
+
this._onDidChangeExpansionState = new Emitter({ replay: true });
|
|
4100
|
+
this.onDidChangeExpansionState = this._onDidChangeExpansionState.event;
|
|
4101
|
+
this._onDidChange = new Emitter();
|
|
4102
|
+
this.onDidChange = this._onDidChange.event;
|
|
4103
|
+
this.headerSize = 22;
|
|
4104
|
+
this._orthogonalSize = 0;
|
|
4105
|
+
this._size = 0;
|
|
4106
|
+
this._minimumBodySize = 100;
|
|
4107
|
+
this._maximumBodySize = Number.POSITIVE_INFINITY;
|
|
4108
|
+
this._isExpanded = false;
|
|
4109
|
+
this.expandedSize = 0;
|
|
4110
|
+
this.api.pane = this; // TODO cannot use 'this' before 'super'
|
|
4111
|
+
this.api.initialize(this);
|
|
4112
|
+
this._isExpanded = isExpanded;
|
|
4113
|
+
this._headerVisible = isHeaderVisible;
|
|
4114
|
+
this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
|
|
4115
|
+
this._orientation = orientation;
|
|
4116
|
+
this.element.classList.add('pane');
|
|
4117
|
+
this.addDisposables(this.api.onWillVisibilityChange((event) => {
|
|
4118
|
+
const { isVisible } = event;
|
|
4119
|
+
const { accessor } = this._params;
|
|
4120
|
+
accessor.setVisible(this, isVisible);
|
|
4121
|
+
}), this.api.onDidSizeChange((event) => {
|
|
4122
|
+
this._onDidChange.fire({ size: event.size });
|
|
4123
|
+
}), addDisposableListener(this.element, 'mouseenter', (ev) => {
|
|
4124
|
+
this.api._onMouseEnter.fire(ev);
|
|
4125
|
+
}), addDisposableListener(this.element, 'mouseleave', (ev) => {
|
|
4126
|
+
this.api._onMouseLeave.fire(ev);
|
|
4127
|
+
}));
|
|
4128
|
+
this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
|
|
4129
|
+
this.api._onDidExpansionChange.fire({
|
|
4130
|
+
isExpanded: isPanelExpanded,
|
|
4131
|
+
});
|
|
4132
|
+
}), this.api.onDidFocusChange((e) => {
|
|
4133
|
+
if (!this.header) {
|
|
4134
|
+
return;
|
|
4135
|
+
}
|
|
4136
|
+
if (e.isFocused) {
|
|
4137
|
+
addClasses(this.header, 'focused');
|
|
4138
|
+
}
|
|
4139
|
+
else {
|
|
4140
|
+
removeClasses(this.header, 'focused');
|
|
4141
|
+
}
|
|
4142
|
+
}));
|
|
4143
|
+
this.renderOnce();
|
|
4144
|
+
}
|
|
4145
|
+
setVisible(isVisible) {
|
|
4146
|
+
this.api._onDidVisibilityChange.fire({ isVisible });
|
|
4147
|
+
}
|
|
4148
|
+
setActive(isActive) {
|
|
4149
|
+
this.api._onDidActiveChange.fire({ isActive });
|
|
4150
|
+
}
|
|
4151
|
+
isExpanded() {
|
|
4152
|
+
return this._isExpanded;
|
|
4153
|
+
}
|
|
4154
|
+
setExpanded(expanded) {
|
|
4155
|
+
if (this._isExpanded === expanded) {
|
|
3914
4156
|
return;
|
|
3915
4157
|
}
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
this.
|
|
4158
|
+
this._isExpanded = expanded;
|
|
4159
|
+
if (expanded) {
|
|
4160
|
+
if (this.animationTimer) {
|
|
4161
|
+
clearTimeout(this.animationTimer);
|
|
4162
|
+
}
|
|
4163
|
+
if (this.body) {
|
|
4164
|
+
this.element.appendChild(this.body);
|
|
4165
|
+
}
|
|
3919
4166
|
}
|
|
3920
|
-
|
|
3921
|
-
this.
|
|
3922
|
-
|
|
4167
|
+
else {
|
|
4168
|
+
this.animationTimer = setTimeout(() => {
|
|
4169
|
+
var _a;
|
|
4170
|
+
(_a = this.body) === null || _a === void 0 ? void 0 : _a.remove();
|
|
4171
|
+
}, 200);
|
|
3923
4172
|
}
|
|
4173
|
+
this._onDidChange.fire(expanded ? { size: this.width } : {});
|
|
4174
|
+
this._onDidChangeExpansionState.fire(expanded);
|
|
3924
4175
|
}
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
if (element) {
|
|
3934
|
-
this.leftActionsContainer.appendChild(element);
|
|
3935
|
-
this.leftActions = element;
|
|
4176
|
+
layout(size, orthogonalSize) {
|
|
4177
|
+
this._size = size;
|
|
4178
|
+
this._orthogonalSize = orthogonalSize;
|
|
4179
|
+
const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
|
|
4180
|
+
? [size, orthogonalSize]
|
|
4181
|
+
: [orthogonalSize, size];
|
|
4182
|
+
if (this.isExpanded()) {
|
|
4183
|
+
this.expandedSize = width;
|
|
3936
4184
|
}
|
|
4185
|
+
super.layout(width, height);
|
|
3937
4186
|
}
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
4187
|
+
init(parameters) {
|
|
4188
|
+
var _a, _b;
|
|
4189
|
+
super.init(parameters);
|
|
4190
|
+
if (typeof parameters.minimumBodySize === 'number') {
|
|
4191
|
+
this.minimumBodySize = parameters.minimumBodySize;
|
|
3941
4192
|
}
|
|
3942
|
-
if (
|
|
3943
|
-
this.
|
|
3944
|
-
this.preActions = undefined;
|
|
4193
|
+
if (typeof parameters.maximumBodySize === 'number') {
|
|
4194
|
+
this.maximumBodySize = parameters.maximumBodySize;
|
|
3945
4195
|
}
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
4196
|
+
this.bodyPart = this.getBodyComponent();
|
|
4197
|
+
this.headerPart = this.getHeaderComponent();
|
|
4198
|
+
this.bodyPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
|
|
4199
|
+
this.headerPart.init(Object.assign(Object.assign({}, parameters), { api: this.api }));
|
|
4200
|
+
(_a = this.body) === null || _a === void 0 ? void 0 : _a.append(this.bodyPart.element);
|
|
4201
|
+
(_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
|
|
4202
|
+
if (typeof parameters.isExpanded === 'boolean') {
|
|
4203
|
+
this.setExpanded(parameters.isExpanded);
|
|
3949
4204
|
}
|
|
3950
4205
|
}
|
|
3951
|
-
|
|
3952
|
-
|
|
4206
|
+
toJSON() {
|
|
4207
|
+
const params = this._params;
|
|
4208
|
+
return Object.assign(Object.assign({}, super.toJSON()), { headerComponent: this.headerComponent, title: params.title });
|
|
3953
4209
|
}
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
4210
|
+
renderOnce() {
|
|
4211
|
+
this.header = document.createElement('div');
|
|
4212
|
+
this.header.tabIndex = 0;
|
|
4213
|
+
this.header.className = 'pane-header';
|
|
4214
|
+
this.header.style.height = `${this.headerSize}px`;
|
|
4215
|
+
this.header.style.lineHeight = `${this.headerSize}px`;
|
|
4216
|
+
this.header.style.minHeight = `${this.headerSize}px`;
|
|
4217
|
+
this.header.style.maxHeight = `${this.headerSize}px`;
|
|
4218
|
+
this.element.appendChild(this.header);
|
|
4219
|
+
this.body = document.createElement('div');
|
|
4220
|
+
this.body.className = 'pane-body';
|
|
4221
|
+
this.element.appendChild(this.body);
|
|
3957
4222
|
}
|
|
3958
|
-
|
|
3959
|
-
|
|
4223
|
+
// TODO slightly hacky by-pass of the component to create a body and header component
|
|
4224
|
+
getComponent() {
|
|
4225
|
+
return {
|
|
4226
|
+
update: (params) => {
|
|
4227
|
+
var _a, _b;
|
|
4228
|
+
(_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
|
|
4229
|
+
(_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
|
|
4230
|
+
},
|
|
4231
|
+
dispose: () => {
|
|
4232
|
+
var _a, _b;
|
|
4233
|
+
(_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4234
|
+
(_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
4235
|
+
},
|
|
4236
|
+
};
|
|
3960
4237
|
}
|
|
3961
|
-
|
|
3962
|
-
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4240
|
+
class DraggablePaneviewPanel extends PaneviewPanel {
|
|
4241
|
+
constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
|
|
4242
|
+
super(id, component, headerComponent, orientation, isExpanded, true);
|
|
3963
4243
|
this.accessor = accessor;
|
|
3964
|
-
this.
|
|
3965
|
-
this.
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
this._onDrop = new Emitter();
|
|
3969
|
-
this.onDrop = this._onDrop.event;
|
|
3970
|
-
this._onTabDragStart = new Emitter();
|
|
3971
|
-
this.onTabDragStart = this._onTabDragStart.event;
|
|
3972
|
-
this._onGroupDragStart = new Emitter();
|
|
3973
|
-
this.onGroupDragStart = this._onGroupDragStart.event;
|
|
3974
|
-
this._onWillShowOverlay = new Emitter();
|
|
3975
|
-
this.onWillShowOverlay = this._onWillShowOverlay.event;
|
|
3976
|
-
this._element = document.createElement('div');
|
|
3977
|
-
this._element.className = 'tabs-and-actions-container';
|
|
3978
|
-
toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
|
|
3979
|
-
this.rightActionsContainer = document.createElement('div');
|
|
3980
|
-
this.rightActionsContainer.className = 'right-actions-container';
|
|
3981
|
-
this.leftActionsContainer = document.createElement('div');
|
|
3982
|
-
this.leftActionsContainer.className = 'left-actions-container';
|
|
3983
|
-
this.preActionsContainer = document.createElement('div');
|
|
3984
|
-
this.preActionsContainer.className = 'pre-actions-container';
|
|
3985
|
-
this.tabContainer = document.createElement('div');
|
|
3986
|
-
this.tabContainer.className = 'tabs-container';
|
|
3987
|
-
this.voidContainer = new VoidContainer(this.accessor, this.group);
|
|
3988
|
-
this._element.appendChild(this.preActionsContainer);
|
|
3989
|
-
this._element.appendChild(this.tabContainer);
|
|
3990
|
-
this._element.appendChild(this.leftActionsContainer);
|
|
3991
|
-
this._element.appendChild(this.voidContainer.element);
|
|
3992
|
-
this._element.appendChild(this.rightActionsContainer);
|
|
3993
|
-
this.addDisposables(this.accessor.onDidAddPanel((e) => {
|
|
3994
|
-
if (e.api.group === this.group) {
|
|
3995
|
-
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
3996
|
-
}
|
|
3997
|
-
}), this.accessor.onDidRemovePanel((e) => {
|
|
3998
|
-
if (e.api.group === this.group) {
|
|
3999
|
-
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
4000
|
-
}
|
|
4001
|
-
}), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
|
|
4002
|
-
this._onGroupDragStart.fire({
|
|
4003
|
-
nativeEvent: event,
|
|
4004
|
-
group: this.group,
|
|
4005
|
-
});
|
|
4006
|
-
}), this.voidContainer.onDrop((event) => {
|
|
4007
|
-
this._onDrop.fire({
|
|
4008
|
-
event: event.nativeEvent,
|
|
4009
|
-
index: this.tabs.length,
|
|
4010
|
-
});
|
|
4011
|
-
}), this.voidContainer.onWillShowOverlay((event) => {
|
|
4012
|
-
this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
|
|
4013
|
-
kind: 'header_space',
|
|
4014
|
-
panel: this.group.activePanel,
|
|
4015
|
-
api: this.accessor.api,
|
|
4016
|
-
group: this.group,
|
|
4017
|
-
getData: getPanelData,
|
|
4018
|
-
}));
|
|
4019
|
-
}), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
|
|
4020
|
-
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
4021
|
-
if (isFloatingGroupsEnabled &&
|
|
4022
|
-
event.shiftKey &&
|
|
4023
|
-
this.group.api.location.type !== 'floating') {
|
|
4024
|
-
event.preventDefault();
|
|
4025
|
-
const { top, left } = this.element.getBoundingClientRect();
|
|
4026
|
-
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
4027
|
-
this.accessor.addFloatingGroup(this.group, {
|
|
4028
|
-
x: left - rootLeft + 20,
|
|
4029
|
-
y: top - rootTop + 20,
|
|
4030
|
-
}, { inDragMode: true });
|
|
4031
|
-
}
|
|
4032
|
-
}), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
|
|
4033
|
-
if (event.defaultPrevented) {
|
|
4034
|
-
return;
|
|
4035
|
-
}
|
|
4036
|
-
const isLeftClick = event.button === 0;
|
|
4037
|
-
if (isLeftClick) {
|
|
4038
|
-
this.accessor.doSetGroupActive(this.group);
|
|
4039
|
-
}
|
|
4040
|
-
}));
|
|
4041
|
-
}
|
|
4042
|
-
setActive(_isGroupActive) {
|
|
4043
|
-
// noop
|
|
4044
|
-
}
|
|
4045
|
-
addTab(tab, index = this.tabs.length) {
|
|
4046
|
-
if (index < 0 || index > this.tabs.length) {
|
|
4047
|
-
throw new Error('invalid location');
|
|
4048
|
-
}
|
|
4049
|
-
this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
|
|
4050
|
-
this.tabs = [
|
|
4051
|
-
...this.tabs.slice(0, index),
|
|
4052
|
-
tab,
|
|
4053
|
-
...this.tabs.slice(index),
|
|
4054
|
-
];
|
|
4055
|
-
if (this.selectedIndex < 0) {
|
|
4056
|
-
this.selectedIndex = index;
|
|
4244
|
+
this._onDidDrop = new Emitter();
|
|
4245
|
+
this.onDidDrop = this._onDidDrop.event;
|
|
4246
|
+
if (!disableDnd) {
|
|
4247
|
+
this.initDragFeatures();
|
|
4057
4248
|
}
|
|
4058
4249
|
}
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
4062
|
-
const { value, disposable } = tabToRemove;
|
|
4063
|
-
disposable.dispose();
|
|
4064
|
-
value.dispose();
|
|
4065
|
-
value.element.remove();
|
|
4066
|
-
}
|
|
4067
|
-
setActivePanel(panel) {
|
|
4068
|
-
this.tabs.forEach((tab) => {
|
|
4069
|
-
const isActivePanel = panel.id === tab.value.panel.id;
|
|
4070
|
-
tab.value.setActive(isActivePanel);
|
|
4071
|
-
});
|
|
4072
|
-
}
|
|
4073
|
-
openPanel(panel, index = this.tabs.length) {
|
|
4074
|
-
var _a;
|
|
4075
|
-
if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
|
|
4250
|
+
initDragFeatures() {
|
|
4251
|
+
if (!this.header) {
|
|
4076
4252
|
return;
|
|
4077
4253
|
}
|
|
4078
|
-
const
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
if (isFloatingGroupsEnabled &&
|
|
4090
|
-
!isFloatingWithOnePanel &&
|
|
4091
|
-
event.shiftKey) {
|
|
4092
|
-
event.preventDefault();
|
|
4093
|
-
const panel = this.accessor.getGroupPanel(tab.panel.id);
|
|
4094
|
-
const { top, left } = tab.element.getBoundingClientRect();
|
|
4095
|
-
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
4096
|
-
this.accessor.addFloatingGroup(panel, {
|
|
4097
|
-
x: left - rootLeft,
|
|
4098
|
-
y: top - rootTop,
|
|
4099
|
-
}, { inDragMode: true });
|
|
4100
|
-
return;
|
|
4101
|
-
}
|
|
4102
|
-
const isLeftClick = event.button === 0;
|
|
4103
|
-
if (!isLeftClick || event.defaultPrevented) {
|
|
4104
|
-
return;
|
|
4105
|
-
}
|
|
4106
|
-
if (this.group.activePanel !== panel) {
|
|
4107
|
-
this.group.model.openPanel(panel);
|
|
4254
|
+
const id = this.id;
|
|
4255
|
+
const accessorId = this.accessor.id;
|
|
4256
|
+
this.header.draggable = true;
|
|
4257
|
+
this.handler = new (class PaneDragHandler extends DragHandler {
|
|
4258
|
+
getData() {
|
|
4259
|
+
LocalSelectionTransfer.getInstance().setData([new PaneTransfer(accessorId, id)], PaneTransfer.prototype);
|
|
4260
|
+
return {
|
|
4261
|
+
dispose: () => {
|
|
4262
|
+
LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
|
|
4263
|
+
},
|
|
4264
|
+
};
|
|
4108
4265
|
}
|
|
4109
|
-
})
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
dispose() {
|
|
4130
|
-
super.dispose();
|
|
4131
|
-
for (const { value, disposable } of this.tabs) {
|
|
4132
|
-
disposable.dispose();
|
|
4133
|
-
value.dispose();
|
|
4134
|
-
}
|
|
4135
|
-
this.tabs = [];
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
|
|
4139
|
-
class DockviewDidDropEvent extends DockviewEvent {
|
|
4140
|
-
get nativeEvent() {
|
|
4141
|
-
return this.options.nativeEvent;
|
|
4142
|
-
}
|
|
4143
|
-
get position() {
|
|
4144
|
-
return this.options.position;
|
|
4145
|
-
}
|
|
4146
|
-
get panel() {
|
|
4147
|
-
return this.options.panel;
|
|
4148
|
-
}
|
|
4149
|
-
get group() {
|
|
4150
|
-
return this.options.group;
|
|
4151
|
-
}
|
|
4152
|
-
get api() {
|
|
4153
|
-
return this.options.api;
|
|
4154
|
-
}
|
|
4155
|
-
constructor(options) {
|
|
4156
|
-
super();
|
|
4157
|
-
this.options = options;
|
|
4158
|
-
}
|
|
4159
|
-
getData() {
|
|
4160
|
-
return this.options.getData();
|
|
4161
|
-
}
|
|
4162
|
-
}
|
|
4163
|
-
class DockviewWillDropEvent extends DockviewDidDropEvent {
|
|
4164
|
-
get kind() {
|
|
4165
|
-
return this._kind;
|
|
4166
|
-
}
|
|
4167
|
-
constructor(options) {
|
|
4168
|
-
super(options);
|
|
4169
|
-
this._kind = options.kind;
|
|
4170
|
-
}
|
|
4171
|
-
}
|
|
4172
|
-
class WillShowOverlayLocationEvent {
|
|
4173
|
-
get kind() {
|
|
4174
|
-
return this.options.kind;
|
|
4175
|
-
}
|
|
4176
|
-
get nativeEvent() {
|
|
4177
|
-
return this.event.nativeEvent;
|
|
4178
|
-
}
|
|
4179
|
-
get position() {
|
|
4180
|
-
return this.event.position;
|
|
4181
|
-
}
|
|
4182
|
-
get defaultPrevented() {
|
|
4183
|
-
return this.event.defaultPrevented;
|
|
4184
|
-
}
|
|
4185
|
-
get panel() {
|
|
4186
|
-
return this.options.panel;
|
|
4187
|
-
}
|
|
4188
|
-
get api() {
|
|
4189
|
-
return this.options.api;
|
|
4190
|
-
}
|
|
4191
|
-
get group() {
|
|
4192
|
-
return this.options.group;
|
|
4193
|
-
}
|
|
4194
|
-
preventDefault() {
|
|
4195
|
-
this.event.preventDefault();
|
|
4196
|
-
}
|
|
4197
|
-
getData() {
|
|
4198
|
-
return this.options.getData();
|
|
4199
|
-
}
|
|
4200
|
-
constructor(event, options) {
|
|
4201
|
-
this.event = event;
|
|
4202
|
-
this.options = options;
|
|
4203
|
-
}
|
|
4204
|
-
}
|
|
4205
|
-
class DockviewGroupPanelModel extends CompositeDisposable {
|
|
4206
|
-
get element() {
|
|
4207
|
-
throw new Error('not supported');
|
|
4208
|
-
}
|
|
4209
|
-
get activePanel() {
|
|
4210
|
-
return this._activePanel;
|
|
4211
|
-
}
|
|
4212
|
-
get locked() {
|
|
4213
|
-
return this._locked;
|
|
4214
|
-
}
|
|
4215
|
-
set locked(value) {
|
|
4216
|
-
this._locked = value;
|
|
4217
|
-
toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
|
|
4218
|
-
}
|
|
4219
|
-
get isActive() {
|
|
4220
|
-
return this._isGroupActive;
|
|
4221
|
-
}
|
|
4222
|
-
get panels() {
|
|
4223
|
-
return this._panels;
|
|
4224
|
-
}
|
|
4225
|
-
get size() {
|
|
4226
|
-
return this._panels.length;
|
|
4227
|
-
}
|
|
4228
|
-
get isEmpty() {
|
|
4229
|
-
return this._panels.length === 0;
|
|
4230
|
-
}
|
|
4231
|
-
get hasWatermark() {
|
|
4232
|
-
return !!(this.watermark && this.container.contains(this.watermark.element));
|
|
4233
|
-
}
|
|
4234
|
-
get header() {
|
|
4235
|
-
return this.tabsContainer;
|
|
4236
|
-
}
|
|
4237
|
-
get isContentFocused() {
|
|
4238
|
-
if (!document.activeElement) {
|
|
4239
|
-
return false;
|
|
4240
|
-
}
|
|
4241
|
-
return isAncestor(document.activeElement, this.contentContainer.element);
|
|
4242
|
-
}
|
|
4243
|
-
get location() {
|
|
4244
|
-
return this._location;
|
|
4245
|
-
}
|
|
4246
|
-
set location(value) {
|
|
4247
|
-
this._location = value;
|
|
4248
|
-
toggleClass(this.container, 'dv-groupview-floating', false);
|
|
4249
|
-
toggleClass(this.container, 'dv-groupview-popout', false);
|
|
4250
|
-
switch (value.type) {
|
|
4251
|
-
case 'grid':
|
|
4252
|
-
this.contentContainer.dropTarget.setTargetZones([
|
|
4253
|
-
'top',
|
|
4254
|
-
'bottom',
|
|
4255
|
-
'left',
|
|
4256
|
-
'right',
|
|
4257
|
-
'center',
|
|
4258
|
-
]);
|
|
4259
|
-
break;
|
|
4260
|
-
case 'floating':
|
|
4261
|
-
this.contentContainer.dropTarget.setTargetZones(['center']);
|
|
4262
|
-
this.contentContainer.dropTarget.setTargetZones(value
|
|
4263
|
-
? ['center']
|
|
4264
|
-
: ['top', 'bottom', 'left', 'right', 'center']);
|
|
4265
|
-
toggleClass(this.container, 'dv-groupview-floating', true);
|
|
4266
|
-
break;
|
|
4267
|
-
case 'popout':
|
|
4268
|
-
this.contentContainer.dropTarget.setTargetZones(['center']);
|
|
4269
|
-
toggleClass(this.container, 'dv-groupview-popout', true);
|
|
4270
|
-
break;
|
|
4271
|
-
}
|
|
4272
|
-
this.groupPanel.api._onDidLocationChange.fire({
|
|
4273
|
-
location: this.location,
|
|
4274
|
-
});
|
|
4275
|
-
}
|
|
4276
|
-
constructor(container, accessor, id, options, groupPanel) {
|
|
4277
|
-
var _a;
|
|
4278
|
-
super();
|
|
4279
|
-
this.container = container;
|
|
4280
|
-
this.accessor = accessor;
|
|
4281
|
-
this.id = id;
|
|
4282
|
-
this.options = options;
|
|
4283
|
-
this.groupPanel = groupPanel;
|
|
4284
|
-
this._isGroupActive = false;
|
|
4285
|
-
this._locked = false;
|
|
4286
|
-
this._location = { type: 'grid' };
|
|
4287
|
-
this.mostRecentlyUsed = [];
|
|
4288
|
-
this._onDidChange = new Emitter();
|
|
4289
|
-
this.onDidChange = this._onDidChange.event;
|
|
4290
|
-
this._width = 0;
|
|
4291
|
-
this._height = 0;
|
|
4292
|
-
this._panels = [];
|
|
4293
|
-
this._panelDisposables = new Map();
|
|
4294
|
-
this._onMove = new Emitter();
|
|
4295
|
-
this.onMove = this._onMove.event;
|
|
4296
|
-
this._onDidDrop = new Emitter();
|
|
4297
|
-
this.onDidDrop = this._onDidDrop.event;
|
|
4298
|
-
this._onWillDrop = new Emitter();
|
|
4299
|
-
this.onWillDrop = this._onWillDrop.event;
|
|
4300
|
-
this._onWillShowOverlay = new Emitter();
|
|
4301
|
-
this.onWillShowOverlay = this._onWillShowOverlay.event;
|
|
4302
|
-
this._onTabDragStart = new Emitter();
|
|
4303
|
-
this.onTabDragStart = this._onTabDragStart.event;
|
|
4304
|
-
this._onGroupDragStart = new Emitter();
|
|
4305
|
-
this.onGroupDragStart = this._onGroupDragStart.event;
|
|
4306
|
-
this._onDidAddPanel = new Emitter();
|
|
4307
|
-
this.onDidAddPanel = this._onDidAddPanel.event;
|
|
4308
|
-
this._onDidPanelTitleChange = new Emitter();
|
|
4309
|
-
this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
|
|
4310
|
-
this._onDidPanelParametersChange = new Emitter();
|
|
4311
|
-
this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
|
|
4312
|
-
this._onDidRemovePanel = new Emitter();
|
|
4313
|
-
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
4314
|
-
this._onDidActivePanelChange = new Emitter();
|
|
4315
|
-
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
4316
|
-
this._overwriteRenderContainer = null;
|
|
4317
|
-
toggleClass(this.container, 'groupview', true);
|
|
4318
|
-
this._api = new DockviewApi(this.accessor);
|
|
4319
|
-
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
|
4320
|
-
this.contentContainer = new ContentContainer(this.accessor, this);
|
|
4321
|
-
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
4322
|
-
this.header.hidden = !!options.hideHeader;
|
|
4323
|
-
this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
|
|
4324
|
-
this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
|
|
4325
|
-
this._onTabDragStart.fire(event);
|
|
4326
|
-
}), this.tabsContainer.onGroupDragStart((event) => {
|
|
4327
|
-
this._onGroupDragStart.fire(event);
|
|
4328
|
-
}), this.tabsContainer.onDrop((event) => {
|
|
4329
|
-
this.handleDropEvent('header', event.event, 'center', event.index);
|
|
4330
|
-
}), this.contentContainer.onDidFocus(() => {
|
|
4331
|
-
this.accessor.doSetGroupActive(this.groupPanel);
|
|
4332
|
-
}), this.contentContainer.onDidBlur(() => {
|
|
4333
|
-
// noop
|
|
4334
|
-
}), this.contentContainer.dropTarget.onDrop((event) => {
|
|
4335
|
-
this.handleDropEvent('content', event.nativeEvent, event.position);
|
|
4336
|
-
}), this.tabsContainer.onWillShowOverlay((event) => {
|
|
4337
|
-
this._onWillShowOverlay.fire(event);
|
|
4338
|
-
}), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
|
|
4339
|
-
this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
|
|
4340
|
-
kind: 'content',
|
|
4341
|
-
panel: this.activePanel,
|
|
4342
|
-
api: this._api,
|
|
4343
|
-
group: this.groupPanel,
|
|
4344
|
-
getData: getPanelData,
|
|
4345
|
-
}));
|
|
4346
|
-
}), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
|
|
4347
|
-
}
|
|
4348
|
-
focusContent() {
|
|
4349
|
-
this.contentContainer.element.focus();
|
|
4350
|
-
}
|
|
4351
|
-
set renderContainer(value) {
|
|
4352
|
-
this.panels.forEach((panel) => {
|
|
4353
|
-
this.renderContainer.detatch(panel);
|
|
4354
|
-
});
|
|
4355
|
-
this._overwriteRenderContainer = value;
|
|
4356
|
-
this.panels.forEach((panel) => {
|
|
4357
|
-
this.rerender(panel);
|
|
4358
|
-
});
|
|
4359
|
-
}
|
|
4360
|
-
get renderContainer() {
|
|
4361
|
-
var _a;
|
|
4362
|
-
return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
|
|
4363
|
-
}
|
|
4364
|
-
initialize() {
|
|
4365
|
-
if (this.options.panels) {
|
|
4366
|
-
this.options.panels.forEach((panel) => {
|
|
4367
|
-
this.doAddPanel(panel);
|
|
4368
|
-
});
|
|
4369
|
-
}
|
|
4370
|
-
if (this.options.activePanel) {
|
|
4371
|
-
this.openPanel(this.options.activePanel);
|
|
4372
|
-
}
|
|
4373
|
-
// must be run after the constructor otherwise this.parent may not be
|
|
4374
|
-
// correctly initialized
|
|
4375
|
-
this.setActive(this.isActive, true);
|
|
4376
|
-
this.updateContainer();
|
|
4377
|
-
if (this.accessor.options.createRightHeaderActionsElement) {
|
|
4378
|
-
this._rightHeaderActions =
|
|
4379
|
-
this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
|
|
4380
|
-
this.addDisposables(this._rightHeaderActions);
|
|
4381
|
-
this._rightHeaderActions.init({
|
|
4382
|
-
containerApi: this._api,
|
|
4383
|
-
api: this.groupPanel.api,
|
|
4384
|
-
});
|
|
4385
|
-
this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
|
|
4386
|
-
}
|
|
4387
|
-
if (this.accessor.options.createLeftHeaderActionsElement) {
|
|
4388
|
-
this._leftHeaderActions =
|
|
4389
|
-
this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
|
|
4390
|
-
this.addDisposables(this._leftHeaderActions);
|
|
4391
|
-
this._leftHeaderActions.init({
|
|
4392
|
-
containerApi: this._api,
|
|
4393
|
-
api: this.groupPanel.api,
|
|
4394
|
-
});
|
|
4395
|
-
this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
|
|
4396
|
-
}
|
|
4397
|
-
if (this.accessor.options.createPrefixHeaderActionsElement) {
|
|
4398
|
-
this._prefixHeaderActions =
|
|
4399
|
-
this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
|
|
4400
|
-
this.addDisposables(this._prefixHeaderActions);
|
|
4401
|
-
this._prefixHeaderActions.init({
|
|
4402
|
-
containerApi: this._api,
|
|
4403
|
-
api: this.groupPanel.api,
|
|
4404
|
-
});
|
|
4405
|
-
this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
|
|
4406
|
-
}
|
|
4407
|
-
}
|
|
4408
|
-
rerender(panel) {
|
|
4409
|
-
this.contentContainer.renderPanel(panel, { asActive: false });
|
|
4410
|
-
}
|
|
4411
|
-
indexOf(panel) {
|
|
4412
|
-
return this.tabsContainer.indexOf(panel.id);
|
|
4413
|
-
}
|
|
4414
|
-
toJSON() {
|
|
4415
|
-
var _a;
|
|
4416
|
-
const result = {
|
|
4417
|
-
views: this.tabsContainer.panels,
|
|
4418
|
-
activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
|
|
4419
|
-
id: this.id,
|
|
4420
|
-
};
|
|
4421
|
-
if (this.locked !== false) {
|
|
4422
|
-
result.locked = this.locked;
|
|
4423
|
-
}
|
|
4424
|
-
if (this.header.hidden) {
|
|
4425
|
-
result.hideHeader = true;
|
|
4426
|
-
}
|
|
4427
|
-
return result;
|
|
4428
|
-
}
|
|
4429
|
-
moveToNext(options) {
|
|
4430
|
-
if (!options) {
|
|
4431
|
-
options = {};
|
|
4432
|
-
}
|
|
4433
|
-
if (!options.panel) {
|
|
4434
|
-
options.panel = this.activePanel;
|
|
4435
|
-
}
|
|
4436
|
-
const index = options.panel ? this.panels.indexOf(options.panel) : -1;
|
|
4437
|
-
let normalizedIndex;
|
|
4438
|
-
if (index < this.panels.length - 1) {
|
|
4439
|
-
normalizedIndex = index + 1;
|
|
4440
|
-
}
|
|
4441
|
-
else if (!options.suppressRoll) {
|
|
4442
|
-
normalizedIndex = 0;
|
|
4443
|
-
}
|
|
4444
|
-
else {
|
|
4445
|
-
return;
|
|
4446
|
-
}
|
|
4447
|
-
this.openPanel(this.panels[normalizedIndex]);
|
|
4448
|
-
}
|
|
4449
|
-
moveToPrevious(options) {
|
|
4450
|
-
if (!options) {
|
|
4451
|
-
options = {};
|
|
4452
|
-
}
|
|
4453
|
-
if (!options.panel) {
|
|
4454
|
-
options.panel = this.activePanel;
|
|
4455
|
-
}
|
|
4456
|
-
if (!options.panel) {
|
|
4457
|
-
return;
|
|
4458
|
-
}
|
|
4459
|
-
const index = this.panels.indexOf(options.panel);
|
|
4460
|
-
let normalizedIndex;
|
|
4461
|
-
if (index > 0) {
|
|
4462
|
-
normalizedIndex = index - 1;
|
|
4463
|
-
}
|
|
4464
|
-
else if (!options.suppressRoll) {
|
|
4465
|
-
normalizedIndex = this.panels.length - 1;
|
|
4466
|
-
}
|
|
4467
|
-
else {
|
|
4468
|
-
return;
|
|
4469
|
-
}
|
|
4470
|
-
this.openPanel(this.panels[normalizedIndex]);
|
|
4471
|
-
}
|
|
4472
|
-
containsPanel(panel) {
|
|
4473
|
-
return this.panels.includes(panel);
|
|
4474
|
-
}
|
|
4475
|
-
init(_params) {
|
|
4476
|
-
//noop
|
|
4477
|
-
}
|
|
4478
|
-
update(_params) {
|
|
4479
|
-
//noop
|
|
4480
|
-
}
|
|
4481
|
-
focus() {
|
|
4482
|
-
var _a;
|
|
4483
|
-
(_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
|
|
4484
|
-
}
|
|
4485
|
-
openPanel(panel, options = {}) {
|
|
4486
|
-
/**
|
|
4487
|
-
* set the panel group
|
|
4488
|
-
* add the panel
|
|
4489
|
-
* check if group active
|
|
4490
|
-
* check if panel active
|
|
4491
|
-
*/
|
|
4492
|
-
if (typeof options.index !== 'number' ||
|
|
4493
|
-
options.index > this.panels.length) {
|
|
4494
|
-
options.index = this.panels.length;
|
|
4495
|
-
}
|
|
4496
|
-
const skipSetActive = !!options.skipSetActive;
|
|
4497
|
-
// ensure the group is updated before we fire any events
|
|
4498
|
-
panel.updateParentGroup(this.groupPanel, {
|
|
4499
|
-
skipSetActive: options.skipSetActive,
|
|
4500
|
-
});
|
|
4501
|
-
this.doAddPanel(panel, options.index, {
|
|
4502
|
-
skipSetActive: skipSetActive,
|
|
4503
|
-
});
|
|
4504
|
-
if (this._activePanel === panel) {
|
|
4505
|
-
this.contentContainer.renderPanel(panel, { asActive: true });
|
|
4506
|
-
return;
|
|
4507
|
-
}
|
|
4508
|
-
if (!skipSetActive) {
|
|
4509
|
-
this.doSetActivePanel(panel);
|
|
4510
|
-
}
|
|
4511
|
-
if (!options.skipSetGroupActive) {
|
|
4512
|
-
this.accessor.doSetGroupActive(this.groupPanel);
|
|
4513
|
-
}
|
|
4514
|
-
if (!options.skipSetActive) {
|
|
4515
|
-
this.updateContainer();
|
|
4516
|
-
}
|
|
4517
|
-
}
|
|
4518
|
-
removePanel(groupItemOrId, options = {
|
|
4519
|
-
skipSetActive: false,
|
|
4520
|
-
}) {
|
|
4521
|
-
const id = typeof groupItemOrId === 'string'
|
|
4522
|
-
? groupItemOrId
|
|
4523
|
-
: groupItemOrId.id;
|
|
4524
|
-
const panelToRemove = this._panels.find((panel) => panel.id === id);
|
|
4525
|
-
if (!panelToRemove) {
|
|
4526
|
-
throw new Error('invalid operation');
|
|
4527
|
-
}
|
|
4528
|
-
return this._removePanel(panelToRemove, options);
|
|
4529
|
-
}
|
|
4530
|
-
closeAllPanels() {
|
|
4531
|
-
if (this.panels.length > 0) {
|
|
4532
|
-
// take a copy since we will be edting the array as we iterate through
|
|
4533
|
-
const arrPanelCpy = [...this.panels];
|
|
4534
|
-
for (const panel of arrPanelCpy) {
|
|
4535
|
-
this.doClose(panel);
|
|
4536
|
-
}
|
|
4537
|
-
}
|
|
4538
|
-
else {
|
|
4539
|
-
this.accessor.removeGroup(this.groupPanel);
|
|
4540
|
-
}
|
|
4541
|
-
}
|
|
4542
|
-
closePanel(panel) {
|
|
4543
|
-
this.doClose(panel);
|
|
4544
|
-
}
|
|
4545
|
-
doClose(panel) {
|
|
4546
|
-
this.accessor.removePanel(panel);
|
|
4547
|
-
}
|
|
4548
|
-
isPanelActive(panel) {
|
|
4549
|
-
return this._activePanel === panel;
|
|
4550
|
-
}
|
|
4551
|
-
updateActions(element) {
|
|
4552
|
-
this.tabsContainer.setRightActionsElement(element);
|
|
4553
|
-
}
|
|
4554
|
-
setActive(isGroupActive, force = false) {
|
|
4555
|
-
if (!force && this.isActive === isGroupActive) {
|
|
4556
|
-
return;
|
|
4557
|
-
}
|
|
4558
|
-
this._isGroupActive = isGroupActive;
|
|
4559
|
-
toggleClass(this.container, 'active-group', isGroupActive);
|
|
4560
|
-
toggleClass(this.container, 'inactive-group', !isGroupActive);
|
|
4561
|
-
this.tabsContainer.setActive(this.isActive);
|
|
4562
|
-
if (!this._activePanel && this.panels.length > 0) {
|
|
4563
|
-
this.doSetActivePanel(this.panels[0]);
|
|
4564
|
-
}
|
|
4565
|
-
this.updateContainer();
|
|
4566
|
-
}
|
|
4567
|
-
layout(width, height) {
|
|
4568
|
-
var _a;
|
|
4569
|
-
this._width = width;
|
|
4570
|
-
this._height = height;
|
|
4571
|
-
this.contentContainer.layout(this._width, this._height);
|
|
4572
|
-
if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
|
|
4573
|
-
this._activePanel.layout(this._width, this._height);
|
|
4574
|
-
}
|
|
4575
|
-
}
|
|
4576
|
-
_removePanel(panel, options) {
|
|
4577
|
-
const isActivePanel = this._activePanel === panel;
|
|
4578
|
-
this.doRemovePanel(panel);
|
|
4579
|
-
if (isActivePanel && this.panels.length > 0) {
|
|
4580
|
-
const nextPanel = this.mostRecentlyUsed[0];
|
|
4581
|
-
this.openPanel(nextPanel, {
|
|
4582
|
-
skipSetActive: options.skipSetActive,
|
|
4583
|
-
skipSetGroupActive: options.skipSetActiveGroup,
|
|
4584
|
-
});
|
|
4585
|
-
}
|
|
4586
|
-
if (this._activePanel && this.panels.length === 0) {
|
|
4587
|
-
this.doSetActivePanel(undefined);
|
|
4588
|
-
}
|
|
4589
|
-
if (!options.skipSetActive) {
|
|
4590
|
-
this.updateContainer();
|
|
4591
|
-
}
|
|
4592
|
-
return panel;
|
|
4593
|
-
}
|
|
4594
|
-
doRemovePanel(panel) {
|
|
4595
|
-
const index = this.panels.indexOf(panel);
|
|
4596
|
-
if (this._activePanel === panel) {
|
|
4597
|
-
this.contentContainer.closePanel();
|
|
4598
|
-
}
|
|
4599
|
-
this.tabsContainer.delete(panel.id);
|
|
4600
|
-
this._panels.splice(index, 1);
|
|
4601
|
-
if (this.mostRecentlyUsed.includes(panel)) {
|
|
4602
|
-
this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
|
|
4603
|
-
}
|
|
4604
|
-
const disposable = this._panelDisposables.get(panel.id);
|
|
4605
|
-
if (disposable) {
|
|
4606
|
-
disposable.dispose();
|
|
4607
|
-
this._panelDisposables.delete(panel.id);
|
|
4608
|
-
}
|
|
4609
|
-
this._onDidRemovePanel.fire({ panel });
|
|
4610
|
-
}
|
|
4611
|
-
doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
|
|
4612
|
-
const existingPanel = this._panels.indexOf(panel);
|
|
4613
|
-
const hasExistingPanel = existingPanel > -1;
|
|
4614
|
-
this.tabsContainer.show();
|
|
4615
|
-
this.contentContainer.show();
|
|
4616
|
-
this.tabsContainer.openPanel(panel, index);
|
|
4617
|
-
if (!options.skipSetActive) {
|
|
4618
|
-
this.contentContainer.openPanel(panel);
|
|
4619
|
-
}
|
|
4620
|
-
if (hasExistingPanel) {
|
|
4621
|
-
// TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
|
|
4622
|
-
return;
|
|
4623
|
-
}
|
|
4624
|
-
this.updateMru(panel);
|
|
4625
|
-
this.panels.splice(index, 0, panel);
|
|
4626
|
-
this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
|
|
4627
|
-
this._onDidAddPanel.fire({ panel });
|
|
4628
|
-
}
|
|
4629
|
-
doSetActivePanel(panel) {
|
|
4630
|
-
if (this._activePanel === panel) {
|
|
4631
|
-
return;
|
|
4632
|
-
}
|
|
4633
|
-
this._activePanel = panel;
|
|
4634
|
-
if (panel) {
|
|
4635
|
-
this.tabsContainer.setActivePanel(panel);
|
|
4636
|
-
panel.layout(this._width, this._height);
|
|
4637
|
-
this.updateMru(panel);
|
|
4638
|
-
this._onDidActivePanelChange.fire({
|
|
4639
|
-
panel,
|
|
4640
|
-
});
|
|
4641
|
-
}
|
|
4642
|
-
}
|
|
4643
|
-
updateMru(panel) {
|
|
4644
|
-
if (this.mostRecentlyUsed.includes(panel)) {
|
|
4645
|
-
this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
|
|
4646
|
-
}
|
|
4647
|
-
this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
|
|
4648
|
-
}
|
|
4649
|
-
updateContainer() {
|
|
4650
|
-
var _a, _b;
|
|
4651
|
-
toggleClass(this.container, 'empty', this.isEmpty);
|
|
4652
|
-
this.panels.forEach((panel) => panel.runEvents());
|
|
4653
|
-
if (this.isEmpty && !this.watermark) {
|
|
4654
|
-
const watermark = this.accessor.createWatermarkComponent();
|
|
4655
|
-
watermark.init({
|
|
4656
|
-
containerApi: this._api,
|
|
4657
|
-
group: this.groupPanel,
|
|
4658
|
-
});
|
|
4659
|
-
this.watermark = watermark;
|
|
4660
|
-
addDisposableListener(this.watermark.element, 'click', () => {
|
|
4661
|
-
if (!this.isActive) {
|
|
4662
|
-
this.accessor.doSetGroupActive(this.groupPanel);
|
|
4266
|
+
})(this.header);
|
|
4267
|
+
this.target = new Droptarget(this.element, {
|
|
4268
|
+
acceptedTargetZones: ['top', 'bottom'],
|
|
4269
|
+
overlayModel: {
|
|
4270
|
+
activationSize: { type: 'percentage', value: 50 },
|
|
4271
|
+
},
|
|
4272
|
+
canDisplayOverlay: (event) => {
|
|
4273
|
+
const data = getPaneData();
|
|
4274
|
+
if (data) {
|
|
4275
|
+
if (data.paneId !== this.id &&
|
|
4276
|
+
data.viewId === this.accessor.id) {
|
|
4277
|
+
return true;
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
if (this.accessor.options.showDndOverlay) {
|
|
4281
|
+
return this.accessor.options.showDndOverlay({
|
|
4282
|
+
nativeEvent: event,
|
|
4283
|
+
getData: getPaneData,
|
|
4284
|
+
panel: this,
|
|
4285
|
+
});
|
|
4663
4286
|
}
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
this.watermark.element.remove();
|
|
4671
|
-
(_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4672
|
-
this.watermark = undefined;
|
|
4673
|
-
this.tabsContainer.show();
|
|
4674
|
-
}
|
|
4675
|
-
}
|
|
4676
|
-
canDisplayOverlay(event, position, target) {
|
|
4677
|
-
// custom overlay handler
|
|
4678
|
-
if (this.accessor.options.showDndOverlay) {
|
|
4679
|
-
return this.accessor.options.showDndOverlay({
|
|
4680
|
-
nativeEvent: event,
|
|
4681
|
-
target,
|
|
4682
|
-
group: this.accessor.getPanel(this.id),
|
|
4683
|
-
position,
|
|
4684
|
-
getData: getPanelData,
|
|
4685
|
-
});
|
|
4686
|
-
}
|
|
4687
|
-
return false;
|
|
4287
|
+
return false;
|
|
4288
|
+
},
|
|
4289
|
+
});
|
|
4290
|
+
this.addDisposables(this._onDidDrop, this.handler, this.target, this.target.onDrop((event) => {
|
|
4291
|
+
this.onDrop(event);
|
|
4292
|
+
}));
|
|
4688
4293
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4294
|
+
onDrop(event) {
|
|
4295
|
+
const data = getPaneData();
|
|
4296
|
+
if (!data || data.viewId !== this.accessor.id) {
|
|
4297
|
+
// if there is no local drag event for this panel
|
|
4298
|
+
// or if the drag event was creating by another Paneview instance
|
|
4299
|
+
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
|
|
4691
4300
|
return;
|
|
4692
4301
|
}
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
}
|
|
4700
|
-
}
|
|
4701
|
-
const panel = typeof index === 'number' ? this.panels[index] : undefined;
|
|
4702
|
-
const willDropEvent = new DockviewWillDropEvent({
|
|
4703
|
-
nativeEvent: event,
|
|
4704
|
-
position,
|
|
4705
|
-
panel,
|
|
4706
|
-
getData: () => getPanelData(),
|
|
4707
|
-
kind: getKind(),
|
|
4708
|
-
group: this.groupPanel,
|
|
4709
|
-
api: this._api,
|
|
4710
|
-
});
|
|
4711
|
-
this._onWillDrop.fire(willDropEvent);
|
|
4712
|
-
if (willDropEvent.defaultPrevented) {
|
|
4302
|
+
const containerApi = this._params
|
|
4303
|
+
.containerApi;
|
|
4304
|
+
const panelId = data.paneId;
|
|
4305
|
+
const existingPanel = containerApi.getPanel(panelId);
|
|
4306
|
+
if (!existingPanel) {
|
|
4307
|
+
// if the panel doesn't exist
|
|
4308
|
+
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, getData: getPaneData, api: new PaneviewApi(this.accessor) }));
|
|
4713
4309
|
return;
|
|
4714
4310
|
}
|
|
4715
|
-
const
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
this._onMove.fire({
|
|
4721
|
-
target: position,
|
|
4722
|
-
groupId: groupId,
|
|
4723
|
-
index,
|
|
4724
|
-
});
|
|
4725
|
-
return;
|
|
4726
|
-
}
|
|
4727
|
-
const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
|
|
4728
|
-
if (fromSameGroup && this.tabsContainer.size === 1) {
|
|
4729
|
-
return;
|
|
4730
|
-
}
|
|
4731
|
-
const { groupId, panelId } = data;
|
|
4732
|
-
const isSameGroup = this.id === groupId;
|
|
4733
|
-
if (isSameGroup && !position) {
|
|
4734
|
-
const oldIndex = this.tabsContainer.indexOf(panelId);
|
|
4735
|
-
if (oldIndex === index) {
|
|
4736
|
-
return;
|
|
4737
|
-
}
|
|
4738
|
-
}
|
|
4739
|
-
this._onMove.fire({
|
|
4740
|
-
target: position,
|
|
4741
|
-
groupId: data.groupId,
|
|
4742
|
-
itemId: data.panelId,
|
|
4743
|
-
index,
|
|
4744
|
-
});
|
|
4745
|
-
}
|
|
4746
|
-
else {
|
|
4747
|
-
this._onDidDrop.fire(new DockviewDidDropEvent({
|
|
4748
|
-
nativeEvent: event,
|
|
4749
|
-
position,
|
|
4750
|
-
panel,
|
|
4751
|
-
getData: () => getPanelData(),
|
|
4752
|
-
group: this.groupPanel,
|
|
4753
|
-
api: this._api,
|
|
4754
|
-
}));
|
|
4311
|
+
const allPanels = containerApi.panels;
|
|
4312
|
+
const fromIndex = allPanels.indexOf(existingPanel);
|
|
4313
|
+
let toIndex = containerApi.panels.indexOf(this);
|
|
4314
|
+
if (event.position === 'left' || event.position === 'top') {
|
|
4315
|
+
toIndex = Math.max(0, toIndex - 1);
|
|
4755
4316
|
}
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
(_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
4762
|
-
this.watermark = undefined;
|
|
4763
|
-
for (const panel of this.panels) {
|
|
4764
|
-
panel.dispose();
|
|
4317
|
+
if (event.position === 'right' || event.position === 'bottom') {
|
|
4318
|
+
if (fromIndex > toIndex) {
|
|
4319
|
+
toIndex++;
|
|
4320
|
+
}
|
|
4321
|
+
toIndex = Math.min(allPanels.length - 1, toIndex);
|
|
4765
4322
|
}
|
|
4766
|
-
|
|
4767
|
-
this.contentContainer.dispose();
|
|
4323
|
+
containerApi.movePanel(fromIndex, toIndex);
|
|
4768
4324
|
}
|
|
4769
4325
|
}
|
|
4770
4326
|
|
|
4771
|
-
class
|
|
4327
|
+
class ContentContainer extends CompositeDisposable {
|
|
4772
4328
|
get element() {
|
|
4773
4329
|
return this._element;
|
|
4774
4330
|
}
|
|
4775
|
-
|
|
4776
|
-
|
|
4331
|
+
constructor(accessor, group) {
|
|
4332
|
+
super();
|
|
4333
|
+
this.accessor = accessor;
|
|
4334
|
+
this.group = group;
|
|
4335
|
+
this.disposable = new MutableDisposable();
|
|
4336
|
+
this._onDidFocus = new Emitter();
|
|
4337
|
+
this.onDidFocus = this._onDidFocus.event;
|
|
4338
|
+
this._onDidBlur = new Emitter();
|
|
4339
|
+
this.onDidBlur = this._onDidBlur.event;
|
|
4340
|
+
this._element = document.createElement('div');
|
|
4341
|
+
this._element.className = 'content-container';
|
|
4342
|
+
this._element.tabIndex = -1;
|
|
4343
|
+
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
4344
|
+
this.dropTarget = new Droptarget(this.element, {
|
|
4345
|
+
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
4346
|
+
canDisplayOverlay: (event, position) => {
|
|
4347
|
+
if (this.group.locked === 'no-drop-target' ||
|
|
4348
|
+
(this.group.locked && position === 'center')) {
|
|
4349
|
+
return false;
|
|
4350
|
+
}
|
|
4351
|
+
const data = getPanelData();
|
|
4352
|
+
if (!data &&
|
|
4353
|
+
event.shiftKey &&
|
|
4354
|
+
this.group.location.type !== 'floating') {
|
|
4355
|
+
return false;
|
|
4356
|
+
}
|
|
4357
|
+
if (data && data.viewId === this.accessor.id) {
|
|
4358
|
+
if (data.groupId === this.group.id) {
|
|
4359
|
+
if (position === 'center') {
|
|
4360
|
+
// don't allow to drop on self for center position
|
|
4361
|
+
return false;
|
|
4362
|
+
}
|
|
4363
|
+
if (data.panelId === null) {
|
|
4364
|
+
// don't allow group move to drop anywhere on self
|
|
4365
|
+
return false;
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
|
|
4369
|
+
data.groupId === this.group.id;
|
|
4370
|
+
return !groupHasOnePanelAndIsActiveDragElement;
|
|
4371
|
+
}
|
|
4372
|
+
return this.group.canDisplayOverlay(event, position, 'content');
|
|
4373
|
+
},
|
|
4374
|
+
});
|
|
4375
|
+
this.addDisposables(this.dropTarget);
|
|
4777
4376
|
}
|
|
4778
|
-
|
|
4779
|
-
this.
|
|
4377
|
+
show() {
|
|
4378
|
+
this.element.style.display = '';
|
|
4780
4379
|
}
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
this.
|
|
4821
|
-
}
|
|
4380
|
+
hide() {
|
|
4381
|
+
this.element.style.display = 'none';
|
|
4382
|
+
}
|
|
4383
|
+
renderPanel(panel, options = { asActive: true }) {
|
|
4384
|
+
const doRender = options.asActive ||
|
|
4385
|
+
(this.panel && this.group.isPanelActive(this.panel));
|
|
4386
|
+
if (this.panel &&
|
|
4387
|
+
this.panel.view.content.element.parentElement === this._element) {
|
|
4388
|
+
/**
|
|
4389
|
+
* If the currently attached panel is mounted directly to the content then remove it
|
|
4390
|
+
*/
|
|
4391
|
+
this._element.removeChild(this.panel.view.content.element);
|
|
4392
|
+
}
|
|
4393
|
+
this.panel = panel;
|
|
4394
|
+
let container;
|
|
4395
|
+
switch (panel.api.renderer) {
|
|
4396
|
+
case 'onlyWhenVisible':
|
|
4397
|
+
this.group.renderContainer.detatch(panel);
|
|
4398
|
+
if (this.panel) {
|
|
4399
|
+
if (doRender) {
|
|
4400
|
+
this._element.appendChild(this.panel.view.content.element);
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
container = this._element;
|
|
4404
|
+
break;
|
|
4405
|
+
case 'always':
|
|
4406
|
+
if (panel.view.content.element.parentElement === this._element) {
|
|
4407
|
+
this._element.removeChild(panel.view.content.element);
|
|
4408
|
+
}
|
|
4409
|
+
container = this.group.renderContainer.attach({
|
|
4410
|
+
panel,
|
|
4411
|
+
referenceContainer: this,
|
|
4412
|
+
});
|
|
4413
|
+
break;
|
|
4414
|
+
}
|
|
4415
|
+
if (doRender) {
|
|
4416
|
+
const focusTracker = trackFocus(container);
|
|
4417
|
+
const disposable = new CompositeDisposable();
|
|
4418
|
+
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
4419
|
+
this.disposable.value = disposable;
|
|
4420
|
+
}
|
|
4822
4421
|
}
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
case 'left':
|
|
4829
|
-
return 'left';
|
|
4830
|
-
case 'right':
|
|
4831
|
-
return 'right';
|
|
4832
|
-
case 'above':
|
|
4833
|
-
return 'top';
|
|
4834
|
-
case 'below':
|
|
4835
|
-
return 'bottom';
|
|
4836
|
-
case 'within':
|
|
4837
|
-
default:
|
|
4838
|
-
return 'center';
|
|
4422
|
+
openPanel(panel) {
|
|
4423
|
+
if (this.panel === panel) {
|
|
4424
|
+
return;
|
|
4425
|
+
}
|
|
4426
|
+
this.renderPanel(panel);
|
|
4839
4427
|
}
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
get id() {
|
|
4843
|
-
return this._id;
|
|
4428
|
+
layout(_width, _height) {
|
|
4429
|
+
// noop
|
|
4844
4430
|
}
|
|
4845
|
-
|
|
4846
|
-
|
|
4431
|
+
closePanel() {
|
|
4432
|
+
var _a;
|
|
4433
|
+
if (this.panel) {
|
|
4434
|
+
if (this.panel.api.renderer === 'onlyWhenVisible') {
|
|
4435
|
+
(_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
this.panel = undefined;
|
|
4847
4439
|
}
|
|
4848
|
-
|
|
4849
|
-
|
|
4440
|
+
dispose() {
|
|
4441
|
+
this.disposable.dispose();
|
|
4442
|
+
super.dispose();
|
|
4850
4443
|
}
|
|
4851
|
-
|
|
4852
|
-
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
class TabDragHandler extends DragHandler {
|
|
4447
|
+
constructor(element, accessor, group, panel) {
|
|
4448
|
+
super(element);
|
|
4449
|
+
this.accessor = accessor;
|
|
4450
|
+
this.group = group;
|
|
4451
|
+
this.panel = panel;
|
|
4452
|
+
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
4853
4453
|
}
|
|
4854
|
-
|
|
4855
|
-
|
|
4454
|
+
getData(event) {
|
|
4455
|
+
this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
|
|
4456
|
+
return {
|
|
4457
|
+
dispose: () => {
|
|
4458
|
+
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
4459
|
+
},
|
|
4460
|
+
};
|
|
4856
4461
|
}
|
|
4857
|
-
|
|
4858
|
-
|
|
4462
|
+
}
|
|
4463
|
+
class Tab extends CompositeDisposable {
|
|
4464
|
+
get element() {
|
|
4465
|
+
return this._element;
|
|
4859
4466
|
}
|
|
4860
|
-
|
|
4861
|
-
|
|
4467
|
+
constructor(panel, accessor, group) {
|
|
4468
|
+
super();
|
|
4469
|
+
this.panel = panel;
|
|
4470
|
+
this.accessor = accessor;
|
|
4471
|
+
this.group = group;
|
|
4472
|
+
this.content = undefined;
|
|
4473
|
+
this._onChanged = new Emitter();
|
|
4474
|
+
this.onChanged = this._onChanged.event;
|
|
4475
|
+
this._onDropped = new Emitter();
|
|
4476
|
+
this.onDrop = this._onDropped.event;
|
|
4477
|
+
this._onDragStart = new Emitter();
|
|
4478
|
+
this.onDragStart = this._onDragStart.event;
|
|
4479
|
+
this._element = document.createElement('div');
|
|
4480
|
+
this._element.className = 'tab';
|
|
4481
|
+
this._element.tabIndex = 0;
|
|
4482
|
+
this._element.draggable = true;
|
|
4483
|
+
toggleClass(this.element, 'inactive-tab', true);
|
|
4484
|
+
const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
|
|
4485
|
+
this.dropTarget = new Droptarget(this._element, {
|
|
4486
|
+
acceptedTargetZones: ['center'],
|
|
4487
|
+
canDisplayOverlay: (event, position) => {
|
|
4488
|
+
if (this.group.locked) {
|
|
4489
|
+
return false;
|
|
4490
|
+
}
|
|
4491
|
+
const data = getPanelData();
|
|
4492
|
+
if (data && this.accessor.id === data.viewId) {
|
|
4493
|
+
if (data.panelId === null &&
|
|
4494
|
+
data.groupId === this.group.id) {
|
|
4495
|
+
// don't allow group move to drop on self
|
|
4496
|
+
return false;
|
|
4497
|
+
}
|
|
4498
|
+
return this.panel.id !== data.panelId;
|
|
4499
|
+
}
|
|
4500
|
+
return this.group.model.canDisplayOverlay(event, position, 'tab');
|
|
4501
|
+
},
|
|
4502
|
+
});
|
|
4503
|
+
this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
|
|
4504
|
+
this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
|
|
4505
|
+
this._onDragStart.fire(event);
|
|
4506
|
+
}), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
|
|
4507
|
+
if (event.defaultPrevented) {
|
|
4508
|
+
return;
|
|
4509
|
+
}
|
|
4510
|
+
this._onChanged.fire(event);
|
|
4511
|
+
}), this.dropTarget.onDrop((event) => {
|
|
4512
|
+
this._onDropped.fire(event);
|
|
4513
|
+
}), this.dropTarget);
|
|
4862
4514
|
}
|
|
4863
|
-
|
|
4864
|
-
|
|
4515
|
+
setActive(isActive) {
|
|
4516
|
+
toggleClass(this.element, 'active-tab', isActive);
|
|
4517
|
+
toggleClass(this.element, 'inactive-tab', !isActive);
|
|
4865
4518
|
}
|
|
4866
|
-
|
|
4867
|
-
|
|
4519
|
+
setContent(part) {
|
|
4520
|
+
if (this.content) {
|
|
4521
|
+
this._element.removeChild(this.content.element);
|
|
4522
|
+
}
|
|
4523
|
+
this.content = part;
|
|
4524
|
+
this._element.appendChild(this.content.element);
|
|
4868
4525
|
}
|
|
4869
|
-
|
|
4870
|
-
|
|
4526
|
+
dispose() {
|
|
4527
|
+
super.dispose();
|
|
4871
4528
|
}
|
|
4872
|
-
|
|
4873
|
-
|
|
4529
|
+
}
|
|
4530
|
+
|
|
4531
|
+
function addGhostImage(dataTransfer, ghostElement) {
|
|
4532
|
+
// class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
|
|
4533
|
+
addClasses(ghostElement, 'dv-dragged');
|
|
4534
|
+
document.body.appendChild(ghostElement);
|
|
4535
|
+
dataTransfer.setDragImage(ghostElement, 0, 0);
|
|
4536
|
+
setTimeout(() => {
|
|
4537
|
+
removeClasses(ghostElement, 'dv-dragged');
|
|
4538
|
+
ghostElement.remove();
|
|
4539
|
+
}, 0);
|
|
4540
|
+
}
|
|
4541
|
+
|
|
4542
|
+
class GroupDragHandler extends DragHandler {
|
|
4543
|
+
constructor(element, accessor, group) {
|
|
4544
|
+
super(element);
|
|
4545
|
+
this.accessor = accessor;
|
|
4546
|
+
this.group = group;
|
|
4547
|
+
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
4548
|
+
this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
|
|
4549
|
+
if (e.shiftKey) {
|
|
4550
|
+
/**
|
|
4551
|
+
* You cannot call e.preventDefault() because that will prevent drag events from firing
|
|
4552
|
+
* but we also need to stop any group overlay drag events from occuring
|
|
4553
|
+
* Use a custom event marker that can be checked by the overlay drag events
|
|
4554
|
+
*/
|
|
4555
|
+
quasiPreventDefault(e);
|
|
4556
|
+
}
|
|
4557
|
+
}, true));
|
|
4874
4558
|
}
|
|
4875
|
-
|
|
4876
|
-
this.
|
|
4559
|
+
isCancelled(_event) {
|
|
4560
|
+
if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
|
|
4561
|
+
return true;
|
|
4562
|
+
}
|
|
4563
|
+
return false;
|
|
4877
4564
|
}
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
this.
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
}
|
|
4902
|
-
this._bufferOnDidLayoutChange.fire();
|
|
4903
|
-
}), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
|
|
4904
|
-
this._bufferOnDidLayoutChange.fire();
|
|
4905
|
-
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
4906
|
-
this._onDidLayoutChange.fire();
|
|
4907
|
-
}), this._bufferOnDidLayoutChange);
|
|
4565
|
+
getData(dragEvent) {
|
|
4566
|
+
const dataTransfer = dragEvent.dataTransfer;
|
|
4567
|
+
this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
|
|
4568
|
+
const style = window.getComputedStyle(this.el);
|
|
4569
|
+
const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
|
|
4570
|
+
const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
|
|
4571
|
+
if (dataTransfer) {
|
|
4572
|
+
const ghostElement = document.createElement('div');
|
|
4573
|
+
ghostElement.style.backgroundColor = bgColor;
|
|
4574
|
+
ghostElement.style.color = color;
|
|
4575
|
+
ghostElement.style.padding = '2px 8px';
|
|
4576
|
+
ghostElement.style.height = '24px';
|
|
4577
|
+
ghostElement.style.fontSize = '11px';
|
|
4578
|
+
ghostElement.style.lineHeight = '20px';
|
|
4579
|
+
ghostElement.style.borderRadius = '12px';
|
|
4580
|
+
ghostElement.style.position = 'absolute';
|
|
4581
|
+
ghostElement.textContent = `Multiple Panels (${this.group.size})`;
|
|
4582
|
+
addGhostImage(dataTransfer, ghostElement);
|
|
4583
|
+
}
|
|
4584
|
+
return {
|
|
4585
|
+
dispose: () => {
|
|
4586
|
+
this.panelTransfer.clearData(PanelTransfer.prototype);
|
|
4587
|
+
},
|
|
4588
|
+
};
|
|
4908
4589
|
}
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4592
|
+
class VoidContainer extends CompositeDisposable {
|
|
4593
|
+
get element() {
|
|
4594
|
+
return this._element;
|
|
4912
4595
|
}
|
|
4913
|
-
|
|
4914
|
-
|
|
4596
|
+
constructor(accessor, group) {
|
|
4597
|
+
super();
|
|
4598
|
+
this.accessor = accessor;
|
|
4599
|
+
this.group = group;
|
|
4600
|
+
this._onDrop = new Emitter();
|
|
4601
|
+
this.onDrop = this._onDrop.event;
|
|
4602
|
+
this._onDragStart = new Emitter();
|
|
4603
|
+
this.onDragStart = this._onDragStart.event;
|
|
4604
|
+
this._element = document.createElement('div');
|
|
4605
|
+
this._element.className = 'void-container';
|
|
4606
|
+
this._element.tabIndex = 0;
|
|
4607
|
+
this._element.draggable = true;
|
|
4608
|
+
this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
|
|
4609
|
+
this.accessor.doSetGroupActive(this.group);
|
|
4610
|
+
}));
|
|
4611
|
+
const handler = new GroupDragHandler(this._element, accessor, group);
|
|
4612
|
+
this.dropTraget = new Droptarget(this._element, {
|
|
4613
|
+
acceptedTargetZones: ['center'],
|
|
4614
|
+
canDisplayOverlay: (event, position) => {
|
|
4615
|
+
var _a;
|
|
4616
|
+
const data = getPanelData();
|
|
4617
|
+
if (data && this.accessor.id === data.viewId) {
|
|
4618
|
+
if (data.panelId === null &&
|
|
4619
|
+
data.groupId === this.group.id) {
|
|
4620
|
+
// don't allow group move to drop on self
|
|
4621
|
+
return false;
|
|
4622
|
+
}
|
|
4623
|
+
// don't show the overlay if the tab being dragged is the last panel of this group
|
|
4624
|
+
return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
|
|
4625
|
+
}
|
|
4626
|
+
return group.model.canDisplayOverlay(event, position, 'header_space');
|
|
4627
|
+
},
|
|
4628
|
+
});
|
|
4629
|
+
this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
|
|
4630
|
+
this.addDisposables(handler, handler.onDragStart((event) => {
|
|
4631
|
+
this._onDragStart.fire(event);
|
|
4632
|
+
}), this.dropTraget.onDrop((event) => {
|
|
4633
|
+
this._onDrop.fire(event);
|
|
4634
|
+
}), this.dropTraget);
|
|
4915
4635
|
}
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4636
|
+
}
|
|
4637
|
+
|
|
4638
|
+
class TabsContainer extends CompositeDisposable {
|
|
4639
|
+
get panels() {
|
|
4640
|
+
return this.tabs.map((_) => _.value.panel.id);
|
|
4919
4641
|
}
|
|
4920
|
-
|
|
4921
|
-
return this.
|
|
4642
|
+
get size() {
|
|
4643
|
+
return this.tabs.length;
|
|
4922
4644
|
}
|
|
4923
|
-
|
|
4924
|
-
this.
|
|
4645
|
+
get hidden() {
|
|
4646
|
+
return this._hidden;
|
|
4925
4647
|
}
|
|
4926
|
-
|
|
4927
|
-
|
|
4648
|
+
set hidden(value) {
|
|
4649
|
+
this._hidden = value;
|
|
4650
|
+
this.element.style.display = value ? 'none' : '';
|
|
4928
4651
|
}
|
|
4929
|
-
|
|
4930
|
-
|
|
4652
|
+
show() {
|
|
4653
|
+
if (!this.hidden) {
|
|
4654
|
+
this.element.style.display = '';
|
|
4655
|
+
}
|
|
4931
4656
|
}
|
|
4932
|
-
|
|
4933
|
-
this.
|
|
4934
|
-
this._onDidAdd.fire(group);
|
|
4657
|
+
hide() {
|
|
4658
|
+
this._element.style.display = 'none';
|
|
4935
4659
|
}
|
|
4936
|
-
|
|
4937
|
-
if (
|
|
4938
|
-
|
|
4660
|
+
setRightActionsElement(element) {
|
|
4661
|
+
if (this.rightActions === element) {
|
|
4662
|
+
return;
|
|
4939
4663
|
}
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
item.disposable.dispose();
|
|
4944
|
-
item.value.dispose();
|
|
4945
|
-
this._groups.delete(group.id);
|
|
4946
|
-
this._onDidRemove.fire(group);
|
|
4664
|
+
if (this.rightActions) {
|
|
4665
|
+
this.rightActions.remove();
|
|
4666
|
+
this.rightActions = undefined;
|
|
4947
4667
|
}
|
|
4948
|
-
if (
|
|
4949
|
-
|
|
4950
|
-
this.
|
|
4668
|
+
if (element) {
|
|
4669
|
+
this.rightActionsContainer.appendChild(element);
|
|
4670
|
+
this.rightActions = element;
|
|
4951
4671
|
}
|
|
4952
|
-
return view;
|
|
4953
4672
|
}
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4673
|
+
setLeftActionsElement(element) {
|
|
4674
|
+
if (this.leftActions === element) {
|
|
4675
|
+
return;
|
|
4676
|
+
}
|
|
4677
|
+
if (this.leftActions) {
|
|
4678
|
+
this.leftActions.remove();
|
|
4679
|
+
this.leftActions = undefined;
|
|
4680
|
+
}
|
|
4681
|
+
if (element) {
|
|
4682
|
+
this.leftActionsContainer.appendChild(element);
|
|
4683
|
+
this.leftActions = element;
|
|
4684
|
+
}
|
|
4957
4685
|
}
|
|
4958
|
-
|
|
4959
|
-
if (this.
|
|
4686
|
+
setPrefixActionsElement(element) {
|
|
4687
|
+
if (this.preActions === element) {
|
|
4960
4688
|
return;
|
|
4961
4689
|
}
|
|
4962
|
-
if (this.
|
|
4963
|
-
this.
|
|
4690
|
+
if (this.preActions) {
|
|
4691
|
+
this.preActions.remove();
|
|
4692
|
+
this.preActions = undefined;
|
|
4964
4693
|
}
|
|
4965
|
-
if (
|
|
4966
|
-
|
|
4694
|
+
if (element) {
|
|
4695
|
+
this.preActionsContainer.appendChild(element);
|
|
4696
|
+
this.preActions = element;
|
|
4967
4697
|
}
|
|
4968
|
-
this._activeGroup = group;
|
|
4969
|
-
this._onDidActiveChange.fire(group);
|
|
4970
4698
|
}
|
|
4971
|
-
|
|
4972
|
-
this.
|
|
4699
|
+
get element() {
|
|
4700
|
+
return this._element;
|
|
4973
4701
|
}
|
|
4974
|
-
|
|
4702
|
+
isActive(tab) {
|
|
4703
|
+
return (this.selectedIndex > -1 &&
|
|
4704
|
+
this.tabs[this.selectedIndex].value === tab);
|
|
4705
|
+
}
|
|
4706
|
+
indexOf(id) {
|
|
4707
|
+
return this.tabs.findIndex((tab) => tab.value.panel.id === id);
|
|
4708
|
+
}
|
|
4709
|
+
constructor(accessor, group) {
|
|
4710
|
+
super();
|
|
4711
|
+
this.accessor = accessor;
|
|
4712
|
+
this.group = group;
|
|
4713
|
+
this.tabs = [];
|
|
4714
|
+
this.selectedIndex = -1;
|
|
4715
|
+
this._hidden = false;
|
|
4716
|
+
this._onDrop = new Emitter();
|
|
4717
|
+
this.onDrop = this._onDrop.event;
|
|
4718
|
+
this._onTabDragStart = new Emitter();
|
|
4719
|
+
this.onTabDragStart = this._onTabDragStart.event;
|
|
4720
|
+
this._onGroupDragStart = new Emitter();
|
|
4721
|
+
this.onGroupDragStart = this._onGroupDragStart.event;
|
|
4722
|
+
this._onWillShowOverlay = new Emitter();
|
|
4723
|
+
this.onWillShowOverlay = this._onWillShowOverlay.event;
|
|
4724
|
+
this._element = document.createElement('div');
|
|
4725
|
+
this._element.className = 'tabs-and-actions-container';
|
|
4726
|
+
toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
|
|
4727
|
+
this.rightActionsContainer = document.createElement('div');
|
|
4728
|
+
this.rightActionsContainer.className = 'right-actions-container';
|
|
4729
|
+
this.leftActionsContainer = document.createElement('div');
|
|
4730
|
+
this.leftActionsContainer.className = 'left-actions-container';
|
|
4731
|
+
this.preActionsContainer = document.createElement('div');
|
|
4732
|
+
this.preActionsContainer.className = 'pre-actions-container';
|
|
4733
|
+
this.tabContainer = document.createElement('div');
|
|
4734
|
+
this.tabContainer.className = 'tabs-container';
|
|
4735
|
+
this.voidContainer = new VoidContainer(this.accessor, this.group);
|
|
4736
|
+
this._element.appendChild(this.preActionsContainer);
|
|
4737
|
+
this._element.appendChild(this.tabContainer);
|
|
4738
|
+
this._element.appendChild(this.leftActionsContainer);
|
|
4739
|
+
this._element.appendChild(this.voidContainer.element);
|
|
4740
|
+
this._element.appendChild(this.rightActionsContainer);
|
|
4741
|
+
this.addDisposables(this.accessor.onDidAddPanel((e) => {
|
|
4742
|
+
if (e.api.group === this.group) {
|
|
4743
|
+
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
4744
|
+
}
|
|
4745
|
+
}), this.accessor.onDidRemovePanel((e) => {
|
|
4746
|
+
if (e.api.group === this.group) {
|
|
4747
|
+
toggleClass(this._element, 'dv-single-tab', this.size === 1);
|
|
4748
|
+
}
|
|
4749
|
+
}), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
|
|
4750
|
+
this._onGroupDragStart.fire({
|
|
4751
|
+
nativeEvent: event,
|
|
4752
|
+
group: this.group,
|
|
4753
|
+
});
|
|
4754
|
+
}), this.voidContainer.onDrop((event) => {
|
|
4755
|
+
this._onDrop.fire({
|
|
4756
|
+
event: event.nativeEvent,
|
|
4757
|
+
index: this.tabs.length,
|
|
4758
|
+
});
|
|
4759
|
+
}), this.voidContainer.onWillShowOverlay((event) => {
|
|
4760
|
+
this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
|
|
4761
|
+
kind: 'header_space',
|
|
4762
|
+
panel: this.group.activePanel,
|
|
4763
|
+
api: this.accessor.api,
|
|
4764
|
+
group: this.group,
|
|
4765
|
+
getData: getPanelData,
|
|
4766
|
+
}));
|
|
4767
|
+
}), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
|
|
4768
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
4769
|
+
if (isFloatingGroupsEnabled &&
|
|
4770
|
+
event.shiftKey &&
|
|
4771
|
+
this.group.api.location.type !== 'floating') {
|
|
4772
|
+
event.preventDefault();
|
|
4773
|
+
const { top, left } = this.element.getBoundingClientRect();
|
|
4774
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
4775
|
+
this.accessor.addFloatingGroup(this.group, {
|
|
4776
|
+
x: left - rootLeft + 20,
|
|
4777
|
+
y: top - rootTop + 20,
|
|
4778
|
+
}, { inDragMode: true });
|
|
4779
|
+
}
|
|
4780
|
+
}), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
|
|
4781
|
+
if (event.defaultPrevented) {
|
|
4782
|
+
return;
|
|
4783
|
+
}
|
|
4784
|
+
const isLeftClick = event.button === 0;
|
|
4785
|
+
if (isLeftClick) {
|
|
4786
|
+
this.accessor.doSetGroupActive(this.group);
|
|
4787
|
+
}
|
|
4788
|
+
}));
|
|
4789
|
+
}
|
|
4790
|
+
setActive(_isGroupActive) {
|
|
4791
|
+
// noop
|
|
4792
|
+
}
|
|
4793
|
+
addTab(tab, index = this.tabs.length) {
|
|
4794
|
+
if (index < 0 || index > this.tabs.length) {
|
|
4795
|
+
throw new Error('invalid location');
|
|
4796
|
+
}
|
|
4797
|
+
this.tabContainer.insertBefore(tab.value.element, this.tabContainer.children[index]);
|
|
4798
|
+
this.tabs = [
|
|
4799
|
+
...this.tabs.slice(0, index),
|
|
4800
|
+
tab,
|
|
4801
|
+
...this.tabs.slice(index),
|
|
4802
|
+
];
|
|
4803
|
+
if (this.selectedIndex < 0) {
|
|
4804
|
+
this.selectedIndex = index;
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
delete(id) {
|
|
4808
|
+
const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
|
|
4809
|
+
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
4810
|
+
const { value, disposable } = tabToRemove;
|
|
4811
|
+
disposable.dispose();
|
|
4812
|
+
value.dispose();
|
|
4813
|
+
value.element.remove();
|
|
4814
|
+
}
|
|
4815
|
+
setActivePanel(panel) {
|
|
4816
|
+
this.tabs.forEach((tab) => {
|
|
4817
|
+
const isActivePanel = panel.id === tab.value.panel.id;
|
|
4818
|
+
tab.value.setActive(isActivePanel);
|
|
4819
|
+
});
|
|
4820
|
+
}
|
|
4821
|
+
openPanel(panel, index = this.tabs.length) {
|
|
4975
4822
|
var _a;
|
|
4976
|
-
if (
|
|
4977
|
-
|
|
4823
|
+
if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
|
|
4824
|
+
return;
|
|
4978
4825
|
}
|
|
4979
|
-
|
|
4980
|
-
|
|
4826
|
+
const tab = new Tab(panel, this.accessor, this.group);
|
|
4827
|
+
if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
|
|
4828
|
+
throw new Error('invalid header component');
|
|
4829
|
+
}
|
|
4830
|
+
tab.setContent(panel.view.tab);
|
|
4831
|
+
const disposable = new CompositeDisposable(tab.onDragStart((event) => {
|
|
4832
|
+
this._onTabDragStart.fire({ nativeEvent: event, panel });
|
|
4833
|
+
}), tab.onChanged((event) => {
|
|
4834
|
+
const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
|
|
4835
|
+
const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
|
|
4836
|
+
this.size === 1;
|
|
4837
|
+
if (isFloatingGroupsEnabled &&
|
|
4838
|
+
!isFloatingWithOnePanel &&
|
|
4839
|
+
event.shiftKey) {
|
|
4840
|
+
event.preventDefault();
|
|
4841
|
+
const panel = this.accessor.getGroupPanel(tab.panel.id);
|
|
4842
|
+
const { top, left } = tab.element.getBoundingClientRect();
|
|
4843
|
+
const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
|
|
4844
|
+
this.accessor.addFloatingGroup(panel, {
|
|
4845
|
+
x: left - rootLeft,
|
|
4846
|
+
y: top - rootTop,
|
|
4847
|
+
}, { inDragMode: true });
|
|
4981
4848
|
return;
|
|
4982
4849
|
}
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
const location = getGridLocation(options.group.element);
|
|
4986
|
-
const next = (_a = this.gridview.next(location)) === null || _a === void 0 ? void 0 : _a.view;
|
|
4987
|
-
this.doSetGroupActive(next);
|
|
4988
|
-
}
|
|
4989
|
-
moveToPrevious(options) {
|
|
4990
|
-
var _a;
|
|
4991
|
-
if (!options) {
|
|
4992
|
-
options = {};
|
|
4993
|
-
}
|
|
4994
|
-
if (!options.group) {
|
|
4995
|
-
if (!this.activeGroup) {
|
|
4850
|
+
const isLeftClick = event.button === 0;
|
|
4851
|
+
if (!isLeftClick || event.defaultPrevented) {
|
|
4996
4852
|
return;
|
|
4997
4853
|
}
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
4854
|
+
if (this.group.activePanel !== panel) {
|
|
4855
|
+
this.group.model.openPanel(panel);
|
|
4856
|
+
}
|
|
4857
|
+
}), tab.onDrop((event) => {
|
|
4858
|
+
this._onDrop.fire({
|
|
4859
|
+
event: event.nativeEvent,
|
|
4860
|
+
index: this.tabs.findIndex((x) => x.value === tab),
|
|
4861
|
+
});
|
|
4862
|
+
}), tab.onWillShowOverlay((event) => {
|
|
4863
|
+
this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
|
|
4864
|
+
kind: 'tab',
|
|
4865
|
+
panel: this.group.activePanel,
|
|
4866
|
+
api: this.accessor.api,
|
|
4867
|
+
group: this.group,
|
|
4868
|
+
getData: getPanelData,
|
|
4869
|
+
}));
|
|
4870
|
+
}));
|
|
4871
|
+
const value = { value: tab, disposable };
|
|
4872
|
+
this.addTab(value, index);
|
|
5003
4873
|
}
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
if (!different) {
|
|
5007
|
-
return;
|
|
5008
|
-
}
|
|
5009
|
-
this.gridview.element.style.height = `${height}px`;
|
|
5010
|
-
this.gridview.element.style.width = `${width}px`;
|
|
5011
|
-
this.gridview.layout(width, height);
|
|
4874
|
+
closePanel(panel) {
|
|
4875
|
+
this.delete(panel.id);
|
|
5012
4876
|
}
|
|
5013
4877
|
dispose() {
|
|
5014
|
-
this._onDidActiveChange.dispose();
|
|
5015
|
-
this._onDidAdd.dispose();
|
|
5016
|
-
this._onDidRemove.dispose();
|
|
5017
|
-
this._onDidLayoutChange.dispose();
|
|
5018
|
-
for (const group of this.groups) {
|
|
5019
|
-
group.dispose();
|
|
5020
|
-
}
|
|
5021
|
-
this.gridview.dispose();
|
|
5022
4878
|
super.dispose();
|
|
4879
|
+
for (const { value, disposable } of this.tabs) {
|
|
4880
|
+
disposable.dispose();
|
|
4881
|
+
value.dispose();
|
|
4882
|
+
}
|
|
4883
|
+
this.tabs = [];
|
|
5023
4884
|
}
|
|
5024
4885
|
}
|
|
5025
4886
|
|
|
5026
|
-
class
|
|
5027
|
-
|
|
5028
|
-
|
|
4887
|
+
class DockviewUnhandledDragOverEvent {
|
|
4888
|
+
get isAccepted() {
|
|
4889
|
+
return this._isAccepted;
|
|
4890
|
+
}
|
|
4891
|
+
constructor(nativeEvent, target, position, getData, group) {
|
|
4892
|
+
this.nativeEvent = nativeEvent;
|
|
4893
|
+
this.target = target;
|
|
4894
|
+
this.position = position;
|
|
4895
|
+
this.getData = getData;
|
|
4896
|
+
this.group = group;
|
|
4897
|
+
this._isAccepted = false;
|
|
4898
|
+
}
|
|
4899
|
+
accept() {
|
|
4900
|
+
this._isAccepted = true;
|
|
5029
4901
|
}
|
|
5030
4902
|
}
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
4903
|
+
const PROPERTY_KEYS = (() => {
|
|
4904
|
+
/**
|
|
4905
|
+
* by readong the keys from an empty value object TypeScript will error
|
|
4906
|
+
* when we add or remove new properties to `DockviewOptions`
|
|
4907
|
+
*/
|
|
4908
|
+
const properties = {
|
|
4909
|
+
disableAutoResizing: undefined,
|
|
4910
|
+
hideBorders: undefined,
|
|
4911
|
+
singleTabMode: undefined,
|
|
4912
|
+
disableFloatingGroups: undefined,
|
|
4913
|
+
floatingGroupBounds: undefined,
|
|
4914
|
+
popoutUrl: undefined,
|
|
4915
|
+
defaultRenderer: undefined,
|
|
4916
|
+
debug: undefined,
|
|
4917
|
+
rootOverlayModel: undefined,
|
|
4918
|
+
locked: undefined,
|
|
4919
|
+
disableDnd: undefined,
|
|
4920
|
+
};
|
|
4921
|
+
return Object.keys(properties);
|
|
4922
|
+
})();
|
|
4923
|
+
function isPanelOptionsWithPanel(data) {
|
|
4924
|
+
if (data.referencePanel) {
|
|
4925
|
+
return true;
|
|
5037
4926
|
}
|
|
5038
|
-
|
|
5039
|
-
|
|
4927
|
+
return false;
|
|
4928
|
+
}
|
|
4929
|
+
function isPanelOptionsWithGroup(data) {
|
|
4930
|
+
if (data.referenceGroup) {
|
|
4931
|
+
return true;
|
|
5040
4932
|
}
|
|
5041
|
-
|
|
5042
|
-
|
|
4933
|
+
return false;
|
|
4934
|
+
}
|
|
4935
|
+
function isGroupOptionsWithPanel(data) {
|
|
4936
|
+
if (data.referencePanel) {
|
|
4937
|
+
return true;
|
|
5043
4938
|
}
|
|
5044
|
-
|
|
5045
|
-
|
|
4939
|
+
return false;
|
|
4940
|
+
}
|
|
4941
|
+
function isGroupOptionsWithGroup(data) {
|
|
4942
|
+
if (data.referenceGroup) {
|
|
4943
|
+
return true;
|
|
5046
4944
|
}
|
|
5047
|
-
|
|
5048
|
-
|
|
4945
|
+
return false;
|
|
4946
|
+
}
|
|
4947
|
+
|
|
4948
|
+
class DockviewDidDropEvent extends DockviewEvent {
|
|
4949
|
+
get nativeEvent() {
|
|
4950
|
+
return this.options.nativeEvent;
|
|
5049
4951
|
}
|
|
5050
|
-
|
|
4952
|
+
get position() {
|
|
4953
|
+
return this.options.position;
|
|
4954
|
+
}
|
|
4955
|
+
get panel() {
|
|
4956
|
+
return this.options.panel;
|
|
4957
|
+
}
|
|
4958
|
+
get group() {
|
|
4959
|
+
return this.options.group;
|
|
4960
|
+
}
|
|
4961
|
+
get api() {
|
|
4962
|
+
return this.options.api;
|
|
4963
|
+
}
|
|
4964
|
+
constructor(options) {
|
|
5051
4965
|
super();
|
|
5052
|
-
this.
|
|
5053
|
-
this.component = component;
|
|
5054
|
-
this._isFocused = false;
|
|
5055
|
-
this._isActive = false;
|
|
5056
|
-
this._isVisible = true;
|
|
5057
|
-
this._width = 0;
|
|
5058
|
-
this._height = 0;
|
|
5059
|
-
this._parameters = {};
|
|
5060
|
-
this.panelUpdatesDisposable = new MutableDisposable();
|
|
5061
|
-
this._onDidDimensionChange = new Emitter();
|
|
5062
|
-
this.onDidDimensionsChange = this._onDidDimensionChange.event;
|
|
5063
|
-
this._onDidChangeFocus = new Emitter();
|
|
5064
|
-
this.onDidFocusChange = this._onDidChangeFocus.event;
|
|
5065
|
-
//
|
|
5066
|
-
this._onWillFocus = new Emitter();
|
|
5067
|
-
this.onWillFocus = this._onWillFocus.event;
|
|
5068
|
-
//
|
|
5069
|
-
this._onDidVisibilityChange = new Emitter();
|
|
5070
|
-
this.onDidVisibilityChange = this._onDidVisibilityChange.event;
|
|
5071
|
-
this._onWillVisibilityChange = new Emitter();
|
|
5072
|
-
this.onWillVisibilityChange = this._onWillVisibilityChange.event;
|
|
5073
|
-
this._onDidActiveChange = new Emitter();
|
|
5074
|
-
this.onDidActiveChange = this._onDidActiveChange.event;
|
|
5075
|
-
this._onActiveChange = new Emitter();
|
|
5076
|
-
this.onActiveChange = this._onActiveChange.event;
|
|
5077
|
-
this._onDidParametersChange = new Emitter();
|
|
5078
|
-
this.onDidParametersChange = this._onDidParametersChange.event;
|
|
5079
|
-
this.addDisposables(this.onDidFocusChange((event) => {
|
|
5080
|
-
this._isFocused = event.isFocused;
|
|
5081
|
-
}), this.onDidActiveChange((event) => {
|
|
5082
|
-
this._isActive = event.isActive;
|
|
5083
|
-
}), this.onDidVisibilityChange((event) => {
|
|
5084
|
-
this._isVisible = event.isVisible;
|
|
5085
|
-
}), this.onDidDimensionsChange((event) => {
|
|
5086
|
-
this._width = event.width;
|
|
5087
|
-
this._height = event.height;
|
|
5088
|
-
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onWillFocus, this._onWillVisibilityChange, this._onDidParametersChange);
|
|
4966
|
+
this.options = options;
|
|
5089
4967
|
}
|
|
5090
|
-
|
|
5091
|
-
return this.
|
|
4968
|
+
getData() {
|
|
4969
|
+
return this.options.getData();
|
|
5092
4970
|
}
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
params: parameters,
|
|
5098
|
-
});
|
|
5099
|
-
});
|
|
4971
|
+
}
|
|
4972
|
+
class DockviewWillDropEvent extends DockviewDidDropEvent {
|
|
4973
|
+
get kind() {
|
|
4974
|
+
return this._kind;
|
|
5100
4975
|
}
|
|
5101
|
-
|
|
5102
|
-
|
|
4976
|
+
constructor(options) {
|
|
4977
|
+
super(options);
|
|
4978
|
+
this._kind = options.kind;
|
|
5103
4979
|
}
|
|
5104
|
-
|
|
5105
|
-
|
|
4980
|
+
}
|
|
4981
|
+
class WillShowOverlayLocationEvent {
|
|
4982
|
+
get kind() {
|
|
4983
|
+
return this.options.kind;
|
|
5106
4984
|
}
|
|
5107
|
-
|
|
5108
|
-
this.
|
|
4985
|
+
get nativeEvent() {
|
|
4986
|
+
return this.event.nativeEvent;
|
|
4987
|
+
}
|
|
4988
|
+
get position() {
|
|
4989
|
+
return this.event.position;
|
|
4990
|
+
}
|
|
4991
|
+
get defaultPrevented() {
|
|
4992
|
+
return this.event.defaultPrevented;
|
|
4993
|
+
}
|
|
4994
|
+
get panel() {
|
|
4995
|
+
return this.options.panel;
|
|
4996
|
+
}
|
|
4997
|
+
get api() {
|
|
4998
|
+
return this.options.api;
|
|
4999
|
+
}
|
|
5000
|
+
get group() {
|
|
5001
|
+
return this.options.group;
|
|
5002
|
+
}
|
|
5003
|
+
preventDefault() {
|
|
5004
|
+
this.event.preventDefault();
|
|
5005
|
+
}
|
|
5006
|
+
getData() {
|
|
5007
|
+
return this.options.getData();
|
|
5008
|
+
}
|
|
5009
|
+
constructor(event, options) {
|
|
5010
|
+
this.event = event;
|
|
5011
|
+
this.options = options;
|
|
5109
5012
|
}
|
|
5110
5013
|
}
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
constructor(id, component) {
|
|
5115
|
-
super(id, component);
|
|
5116
|
-
this._onDidConstraintsChangeInternal = new Emitter();
|
|
5117
|
-
this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
|
|
5118
|
-
//
|
|
5119
|
-
this._onDidConstraintsChange = new Emitter({
|
|
5120
|
-
replay: true,
|
|
5121
|
-
});
|
|
5122
|
-
this.onDidConstraintsChange = this._onDidConstraintsChange.event;
|
|
5123
|
-
//
|
|
5124
|
-
this._onDidSizeChange = new Emitter();
|
|
5125
|
-
this.onDidSizeChange = this._onDidSizeChange.event;
|
|
5126
|
-
this.addDisposables(this._onDidConstraintsChangeInternal, this._onDidConstraintsChange, this._onDidSizeChange);
|
|
5014
|
+
class DockviewGroupPanelModel extends CompositeDisposable {
|
|
5015
|
+
get element() {
|
|
5016
|
+
throw new Error('not supported');
|
|
5127
5017
|
}
|
|
5128
|
-
|
|
5129
|
-
this.
|
|
5018
|
+
get activePanel() {
|
|
5019
|
+
return this._activePanel;
|
|
5020
|
+
}
|
|
5021
|
+
get locked() {
|
|
5022
|
+
return this._locked;
|
|
5023
|
+
}
|
|
5024
|
+
set locked(value) {
|
|
5025
|
+
this._locked = value;
|
|
5026
|
+
toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
|
|
5027
|
+
}
|
|
5028
|
+
get isActive() {
|
|
5029
|
+
return this._isGroupActive;
|
|
5130
5030
|
}
|
|
5131
|
-
|
|
5132
|
-
this.
|
|
5031
|
+
get panels() {
|
|
5032
|
+
return this._panels;
|
|
5133
5033
|
}
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
class PaneviewPanelApiImpl extends SplitviewPanelApiImpl {
|
|
5137
|
-
set pane(pane) {
|
|
5138
|
-
this._pane = pane;
|
|
5034
|
+
get size() {
|
|
5035
|
+
return this._panels.length;
|
|
5139
5036
|
}
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
this._onDidExpansionChange = new Emitter({
|
|
5143
|
-
replay: true,
|
|
5144
|
-
});
|
|
5145
|
-
this.onDidExpansionChange = this._onDidExpansionChange.event;
|
|
5146
|
-
this._onMouseEnter = new Emitter({});
|
|
5147
|
-
this.onMouseEnter = this._onMouseEnter.event;
|
|
5148
|
-
this._onMouseLeave = new Emitter({});
|
|
5149
|
-
this.onMouseLeave = this._onMouseLeave.event;
|
|
5150
|
-
this.addDisposables(this._onDidExpansionChange, this._onMouseEnter, this._onMouseLeave);
|
|
5037
|
+
get isEmpty() {
|
|
5038
|
+
return this._panels.length === 0;
|
|
5151
5039
|
}
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
(_a = this._pane) === null || _a === void 0 ? void 0 : _a.setExpanded(isExpanded);
|
|
5040
|
+
get hasWatermark() {
|
|
5041
|
+
return !!(this.watermark && this.container.contains(this.watermark.element));
|
|
5155
5042
|
}
|
|
5156
|
-
get
|
|
5157
|
-
|
|
5158
|
-
return !!((_a = this._pane) === null || _a === void 0 ? void 0 : _a.isExpanded());
|
|
5043
|
+
get header() {
|
|
5044
|
+
return this.tabsContainer;
|
|
5159
5045
|
}
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
return this.
|
|
5046
|
+
get isContentFocused() {
|
|
5047
|
+
if (!document.activeElement) {
|
|
5048
|
+
return false;
|
|
5049
|
+
}
|
|
5050
|
+
return isAncestor(document.activeElement, this.contentContainer.element);
|
|
5165
5051
|
}
|
|
5166
|
-
get
|
|
5167
|
-
return this.
|
|
5052
|
+
get location() {
|
|
5053
|
+
return this._location;
|
|
5168
5054
|
}
|
|
5169
|
-
|
|
5170
|
-
|
|
5055
|
+
set location(value) {
|
|
5056
|
+
this._location = value;
|
|
5057
|
+
toggleClass(this.container, 'dv-groupview-floating', false);
|
|
5058
|
+
toggleClass(this.container, 'dv-groupview-popout', false);
|
|
5059
|
+
switch (value.type) {
|
|
5060
|
+
case 'grid':
|
|
5061
|
+
this.contentContainer.dropTarget.setTargetZones([
|
|
5062
|
+
'top',
|
|
5063
|
+
'bottom',
|
|
5064
|
+
'left',
|
|
5065
|
+
'right',
|
|
5066
|
+
'center',
|
|
5067
|
+
]);
|
|
5068
|
+
break;
|
|
5069
|
+
case 'floating':
|
|
5070
|
+
this.contentContainer.dropTarget.setTargetZones(['center']);
|
|
5071
|
+
this.contentContainer.dropTarget.setTargetZones(value
|
|
5072
|
+
? ['center']
|
|
5073
|
+
: ['top', 'bottom', 'left', 'right', 'center']);
|
|
5074
|
+
toggleClass(this.container, 'dv-groupview-floating', true);
|
|
5075
|
+
break;
|
|
5076
|
+
case 'popout':
|
|
5077
|
+
this.contentContainer.dropTarget.setTargetZones(['center']);
|
|
5078
|
+
toggleClass(this.container, 'dv-groupview-popout', true);
|
|
5079
|
+
break;
|
|
5080
|
+
}
|
|
5081
|
+
this.groupPanel.api._onDidLocationChange.fire({
|
|
5082
|
+
location: this.location,
|
|
5083
|
+
});
|
|
5171
5084
|
}
|
|
5172
|
-
|
|
5085
|
+
constructor(container, accessor, id, options, groupPanel) {
|
|
5173
5086
|
var _a;
|
|
5174
|
-
return (_a = this._params) === null || _a === void 0 ? void 0 : _a.params;
|
|
5175
|
-
}
|
|
5176
|
-
constructor(id, component, api) {
|
|
5177
5087
|
super();
|
|
5088
|
+
this.container = container;
|
|
5089
|
+
this.accessor = accessor;
|
|
5178
5090
|
this.id = id;
|
|
5179
|
-
this.
|
|
5180
|
-
this.
|
|
5181
|
-
this.
|
|
5091
|
+
this.options = options;
|
|
5092
|
+
this.groupPanel = groupPanel;
|
|
5093
|
+
this._isGroupActive = false;
|
|
5094
|
+
this._locked = false;
|
|
5095
|
+
this._location = { type: 'grid' };
|
|
5096
|
+
this.mostRecentlyUsed = [];
|
|
5097
|
+
this._onDidChange = new Emitter();
|
|
5098
|
+
this.onDidChange = this._onDidChange.event;
|
|
5182
5099
|
this._width = 0;
|
|
5183
|
-
this.
|
|
5184
|
-
this.
|
|
5185
|
-
this.
|
|
5186
|
-
this.
|
|
5187
|
-
this.
|
|
5188
|
-
this.
|
|
5189
|
-
|
|
5190
|
-
this.
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5100
|
+
this._height = 0;
|
|
5101
|
+
this._panels = [];
|
|
5102
|
+
this._panelDisposables = new Map();
|
|
5103
|
+
this._onMove = new Emitter();
|
|
5104
|
+
this.onMove = this._onMove.event;
|
|
5105
|
+
this._onDidDrop = new Emitter();
|
|
5106
|
+
this.onDidDrop = this._onDidDrop.event;
|
|
5107
|
+
this._onWillDrop = new Emitter();
|
|
5108
|
+
this.onWillDrop = this._onWillDrop.event;
|
|
5109
|
+
this._onWillShowOverlay = new Emitter();
|
|
5110
|
+
this.onWillShowOverlay = this._onWillShowOverlay.event;
|
|
5111
|
+
this._onTabDragStart = new Emitter();
|
|
5112
|
+
this.onTabDragStart = this._onTabDragStart.event;
|
|
5113
|
+
this._onGroupDragStart = new Emitter();
|
|
5114
|
+
this.onGroupDragStart = this._onGroupDragStart.event;
|
|
5115
|
+
this._onDidAddPanel = new Emitter();
|
|
5116
|
+
this.onDidAddPanel = this._onDidAddPanel.event;
|
|
5117
|
+
this._onDidPanelTitleChange = new Emitter();
|
|
5118
|
+
this.onDidPanelTitleChange = this._onDidPanelTitleChange.event;
|
|
5119
|
+
this._onDidPanelParametersChange = new Emitter();
|
|
5120
|
+
this.onDidPanelParametersChange = this._onDidPanelParametersChange.event;
|
|
5121
|
+
this._onDidRemovePanel = new Emitter();
|
|
5122
|
+
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
5123
|
+
this._onDidActivePanelChange = new Emitter();
|
|
5124
|
+
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
5125
|
+
this._onUnhandledDragOverEvent = new Emitter();
|
|
5126
|
+
this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
|
|
5127
|
+
this._overwriteRenderContainer = null;
|
|
5128
|
+
toggleClass(this.container, 'groupview', true);
|
|
5129
|
+
this._api = new DockviewApi(this.accessor);
|
|
5130
|
+
this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
|
|
5131
|
+
this.contentContainer = new ContentContainer(this.accessor, this);
|
|
5132
|
+
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
5133
|
+
this.header.hidden = !!options.hideHeader;
|
|
5134
|
+
this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
|
|
5135
|
+
this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
|
|
5136
|
+
this._onTabDragStart.fire(event);
|
|
5137
|
+
}), this.tabsContainer.onGroupDragStart((event) => {
|
|
5138
|
+
this._onGroupDragStart.fire(event);
|
|
5139
|
+
}), this.tabsContainer.onDrop((event) => {
|
|
5140
|
+
this.handleDropEvent('header', event.event, 'center', event.index);
|
|
5141
|
+
}), this.contentContainer.onDidFocus(() => {
|
|
5142
|
+
this.accessor.doSetGroupActive(this.groupPanel);
|
|
5143
|
+
}), this.contentContainer.onDidBlur(() => {
|
|
5144
|
+
// noop
|
|
5145
|
+
}), this.contentContainer.dropTarget.onDrop((event) => {
|
|
5146
|
+
this.handleDropEvent('content', event.nativeEvent, event.position);
|
|
5147
|
+
}), this.tabsContainer.onWillShowOverlay((event) => {
|
|
5148
|
+
this._onWillShowOverlay.fire(event);
|
|
5149
|
+
}), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
|
|
5150
|
+
this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
|
|
5151
|
+
kind: 'content',
|
|
5152
|
+
panel: this.activePanel,
|
|
5153
|
+
api: this._api,
|
|
5154
|
+
group: this.groupPanel,
|
|
5155
|
+
getData: getPanelData,
|
|
5156
|
+
}));
|
|
5157
|
+
}), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange, this._onUnhandledDragOverEvent);
|
|
5195
5158
|
}
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
this.api._onWillFocus.fire(event);
|
|
5199
|
-
if (event.defaultPrevented) {
|
|
5200
|
-
return;
|
|
5201
|
-
}
|
|
5202
|
-
this._element.focus();
|
|
5159
|
+
focusContent() {
|
|
5160
|
+
this.contentContainer.element.focus();
|
|
5203
5161
|
}
|
|
5204
|
-
|
|
5205
|
-
this.
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
}
|
|
5162
|
+
set renderContainer(value) {
|
|
5163
|
+
this.panels.forEach((panel) => {
|
|
5164
|
+
this.renderContainer.detatch(panel);
|
|
5165
|
+
});
|
|
5166
|
+
this._overwriteRenderContainer = value;
|
|
5167
|
+
this.panels.forEach((panel) => {
|
|
5168
|
+
this.rerender(panel);
|
|
5169
|
+
});
|
|
5213
5170
|
}
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
this.
|
|
5171
|
+
get renderContainer() {
|
|
5172
|
+
var _a;
|
|
5173
|
+
return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
|
|
5217
5174
|
}
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
* delete new keys that have a value of undefined,
|
|
5224
|
-
* allow values of null
|
|
5225
|
-
*/
|
|
5226
|
-
for (const key of Object.keys(event.params)) {
|
|
5227
|
-
if (event.params[key] === undefined) {
|
|
5228
|
-
delete this._params.params[key];
|
|
5229
|
-
}
|
|
5175
|
+
initialize() {
|
|
5176
|
+
if (this.options.panels) {
|
|
5177
|
+
this.options.panels.forEach((panel) => {
|
|
5178
|
+
this.doAddPanel(panel);
|
|
5179
|
+
});
|
|
5230
5180
|
}
|
|
5231
|
-
|
|
5232
|
-
|
|
5181
|
+
if (this.options.activePanel) {
|
|
5182
|
+
this.openPanel(this.options.activePanel);
|
|
5183
|
+
}
|
|
5184
|
+
// must be run after the constructor otherwise this.parent may not be
|
|
5185
|
+
// correctly initialized
|
|
5186
|
+
this.setActive(this.isActive, true);
|
|
5187
|
+
this.updateContainer();
|
|
5188
|
+
if (this.accessor.options.createRightHeaderActionComponent) {
|
|
5189
|
+
this._rightHeaderActions =
|
|
5190
|
+
this.accessor.options.createRightHeaderActionComponent(this.groupPanel);
|
|
5191
|
+
this.addDisposables(this._rightHeaderActions);
|
|
5192
|
+
this._rightHeaderActions.init({
|
|
5193
|
+
containerApi: this._api,
|
|
5194
|
+
api: this.groupPanel.api,
|
|
5195
|
+
group: this.groupPanel,
|
|
5196
|
+
});
|
|
5197
|
+
this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
|
|
5198
|
+
}
|
|
5199
|
+
if (this.accessor.options.createLeftHeaderActionComponent) {
|
|
5200
|
+
this._leftHeaderActions =
|
|
5201
|
+
this.accessor.options.createLeftHeaderActionComponent(this.groupPanel);
|
|
5202
|
+
this.addDisposables(this._leftHeaderActions);
|
|
5203
|
+
this._leftHeaderActions.init({
|
|
5204
|
+
containerApi: this._api,
|
|
5205
|
+
api: this.groupPanel.api,
|
|
5206
|
+
group: this.groupPanel,
|
|
5207
|
+
});
|
|
5208
|
+
this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
|
|
5209
|
+
}
|
|
5210
|
+
if (this.accessor.options.createPrefixHeaderActionComponent) {
|
|
5211
|
+
this._prefixHeaderActions =
|
|
5212
|
+
this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel);
|
|
5213
|
+
this.addDisposables(this._prefixHeaderActions);
|
|
5214
|
+
this._prefixHeaderActions.init({
|
|
5215
|
+
containerApi: this._api,
|
|
5216
|
+
api: this.groupPanel.api,
|
|
5217
|
+
group: this.groupPanel,
|
|
5218
|
+
});
|
|
5219
|
+
this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
rerender(panel) {
|
|
5223
|
+
this.contentContainer.renderPanel(panel, { asActive: false });
|
|
5224
|
+
}
|
|
5225
|
+
indexOf(panel) {
|
|
5226
|
+
return this.tabsContainer.indexOf(panel.id);
|
|
5233
5227
|
}
|
|
5234
5228
|
toJSON() {
|
|
5235
|
-
var _a
|
|
5236
|
-
const
|
|
5237
|
-
|
|
5229
|
+
var _a;
|
|
5230
|
+
const result = {
|
|
5231
|
+
views: this.tabsContainer.panels,
|
|
5232
|
+
activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
|
|
5238
5233
|
id: this.id,
|
|
5239
|
-
component: this.component,
|
|
5240
|
-
params: Object.keys(params).length > 0 ? params : undefined,
|
|
5241
5234
|
};
|
|
5235
|
+
if (this.locked !== false) {
|
|
5236
|
+
result.locked = this.locked;
|
|
5237
|
+
}
|
|
5238
|
+
if (this.header.hidden) {
|
|
5239
|
+
result.hideHeader = true;
|
|
5240
|
+
}
|
|
5241
|
+
return result;
|
|
5242
5242
|
}
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
}
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5243
|
+
moveToNext(options) {
|
|
5244
|
+
if (!options) {
|
|
5245
|
+
options = {};
|
|
5246
|
+
}
|
|
5247
|
+
if (!options.panel) {
|
|
5248
|
+
options.panel = this.activePanel;
|
|
5249
|
+
}
|
|
5250
|
+
const index = options.panel ? this.panels.indexOf(options.panel) : -1;
|
|
5251
|
+
let normalizedIndex;
|
|
5252
|
+
if (index < this.panels.length - 1) {
|
|
5253
|
+
normalizedIndex = index + 1;
|
|
5254
|
+
}
|
|
5255
|
+
else if (!options.suppressRoll) {
|
|
5256
|
+
normalizedIndex = 0;
|
|
5257
|
+
}
|
|
5258
|
+
else {
|
|
5259
|
+
return;
|
|
5260
|
+
}
|
|
5261
|
+
this.openPanel(this.panels[normalizedIndex]);
|
|
5254
5262
|
}
|
|
5255
|
-
|
|
5256
|
-
|
|
5263
|
+
moveToPrevious(options) {
|
|
5264
|
+
if (!options) {
|
|
5265
|
+
options = {};
|
|
5266
|
+
}
|
|
5267
|
+
if (!options.panel) {
|
|
5268
|
+
options.panel = this.activePanel;
|
|
5269
|
+
}
|
|
5270
|
+
if (!options.panel) {
|
|
5271
|
+
return;
|
|
5272
|
+
}
|
|
5273
|
+
const index = this.panels.indexOf(options.panel);
|
|
5274
|
+
let normalizedIndex;
|
|
5275
|
+
if (index > 0) {
|
|
5276
|
+
normalizedIndex = index - 1;
|
|
5277
|
+
}
|
|
5278
|
+
else if (!options.suppressRoll) {
|
|
5279
|
+
normalizedIndex = this.panels.length - 1;
|
|
5280
|
+
}
|
|
5281
|
+
else {
|
|
5282
|
+
return;
|
|
5283
|
+
}
|
|
5284
|
+
this.openPanel(this.panels[normalizedIndex]);
|
|
5257
5285
|
}
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
const expanded = this.isExpanded();
|
|
5261
|
-
const minimumBodySize = expanded ? this._minimumBodySize : 0;
|
|
5262
|
-
return headerSize + minimumBodySize;
|
|
5286
|
+
containsPanel(panel) {
|
|
5287
|
+
return this.panels.includes(panel);
|
|
5263
5288
|
}
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
const expanded = this.isExpanded();
|
|
5267
|
-
const maximumBodySize = expanded ? this._maximumBodySize : 0;
|
|
5268
|
-
return headerSize + maximumBodySize;
|
|
5289
|
+
init(_params) {
|
|
5290
|
+
//noop
|
|
5269
5291
|
}
|
|
5270
|
-
|
|
5271
|
-
|
|
5292
|
+
update(_params) {
|
|
5293
|
+
//noop
|
|
5272
5294
|
}
|
|
5273
|
-
|
|
5274
|
-
|
|
5295
|
+
focus() {
|
|
5296
|
+
var _a;
|
|
5297
|
+
(_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5275
5298
|
}
|
|
5276
|
-
|
|
5277
|
-
|
|
5299
|
+
openPanel(panel, options = {}) {
|
|
5300
|
+
/**
|
|
5301
|
+
* set the panel group
|
|
5302
|
+
* add the panel
|
|
5303
|
+
* check if group active
|
|
5304
|
+
* check if panel active
|
|
5305
|
+
*/
|
|
5306
|
+
if (typeof options.index !== 'number' ||
|
|
5307
|
+
options.index > this.panels.length) {
|
|
5308
|
+
options.index = this.panels.length;
|
|
5309
|
+
}
|
|
5310
|
+
const skipSetActive = !!options.skipSetActive;
|
|
5311
|
+
// ensure the group is updated before we fire any events
|
|
5312
|
+
panel.updateParentGroup(this.groupPanel, {
|
|
5313
|
+
skipSetActive: options.skipSetActive,
|
|
5314
|
+
});
|
|
5315
|
+
this.doAddPanel(panel, options.index, {
|
|
5316
|
+
skipSetActive: skipSetActive,
|
|
5317
|
+
});
|
|
5318
|
+
if (this._activePanel === panel) {
|
|
5319
|
+
this.contentContainer.renderPanel(panel, { asActive: true });
|
|
5320
|
+
return;
|
|
5321
|
+
}
|
|
5322
|
+
if (!skipSetActive) {
|
|
5323
|
+
this.doSetActivePanel(panel);
|
|
5324
|
+
}
|
|
5325
|
+
if (!options.skipSetGroupActive) {
|
|
5326
|
+
this.accessor.doSetGroupActive(this.groupPanel);
|
|
5327
|
+
}
|
|
5328
|
+
if (!options.skipSetActive) {
|
|
5329
|
+
this.updateContainer();
|
|
5330
|
+
}
|
|
5278
5331
|
}
|
|
5279
|
-
|
|
5280
|
-
|
|
5332
|
+
removePanel(groupItemOrId, options = {
|
|
5333
|
+
skipSetActive: false,
|
|
5334
|
+
}) {
|
|
5335
|
+
const id = typeof groupItemOrId === 'string'
|
|
5336
|
+
? groupItemOrId
|
|
5337
|
+
: groupItemOrId.id;
|
|
5338
|
+
const panelToRemove = this._panels.find((panel) => panel.id === id);
|
|
5339
|
+
if (!panelToRemove) {
|
|
5340
|
+
throw new Error('invalid operation');
|
|
5341
|
+
}
|
|
5342
|
+
return this._removePanel(panelToRemove, options);
|
|
5281
5343
|
}
|
|
5282
|
-
|
|
5283
|
-
this.
|
|
5344
|
+
closeAllPanels() {
|
|
5345
|
+
if (this.panels.length > 0) {
|
|
5346
|
+
// take a copy since we will be edting the array as we iterate through
|
|
5347
|
+
const arrPanelCpy = [...this.panels];
|
|
5348
|
+
for (const panel of arrPanelCpy) {
|
|
5349
|
+
this.doClose(panel);
|
|
5350
|
+
}
|
|
5351
|
+
}
|
|
5352
|
+
else {
|
|
5353
|
+
this.accessor.removeGroup(this.groupPanel);
|
|
5354
|
+
}
|
|
5284
5355
|
}
|
|
5285
|
-
|
|
5286
|
-
|
|
5356
|
+
closePanel(panel) {
|
|
5357
|
+
this.doClose(panel);
|
|
5287
5358
|
}
|
|
5288
|
-
|
|
5289
|
-
this.
|
|
5290
|
-
typeof value === 'number' ? value : Number.POSITIVE_INFINITY;
|
|
5359
|
+
doClose(panel) {
|
|
5360
|
+
this.accessor.removePanel(panel);
|
|
5291
5361
|
}
|
|
5292
|
-
|
|
5293
|
-
return this.
|
|
5362
|
+
isPanelActive(panel) {
|
|
5363
|
+
return this._activePanel === panel;
|
|
5294
5364
|
}
|
|
5295
|
-
|
|
5296
|
-
this.
|
|
5297
|
-
this.header.style.display = value ? '' : 'none';
|
|
5365
|
+
updateActions(element) {
|
|
5366
|
+
this.tabsContainer.setRightActionsElement(element);
|
|
5298
5367
|
}
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
this.
|
|
5304
|
-
this.
|
|
5305
|
-
this.
|
|
5306
|
-
this.
|
|
5307
|
-
this.
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
this.
|
|
5311
|
-
this._isExpanded = false;
|
|
5312
|
-
this.expandedSize = 0;
|
|
5313
|
-
this.api.pane = this; // TODO cannot use 'this' before 'super'
|
|
5314
|
-
this.api.initialize(this);
|
|
5315
|
-
this._isExpanded = isExpanded;
|
|
5316
|
-
this._headerVisible = isHeaderVisible;
|
|
5317
|
-
this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
|
|
5318
|
-
this._orientation = orientation;
|
|
5319
|
-
this.element.classList.add('pane');
|
|
5320
|
-
this.addDisposables(this.api.onWillVisibilityChange((event) => {
|
|
5321
|
-
const { isVisible } = event;
|
|
5322
|
-
const { accessor } = this._params;
|
|
5323
|
-
accessor.setVisible(this, isVisible);
|
|
5324
|
-
}), this.api.onDidSizeChange((event) => {
|
|
5325
|
-
this._onDidChange.fire({ size: event.size });
|
|
5326
|
-
}), addDisposableListener(this.element, 'mouseenter', (ev) => {
|
|
5327
|
-
this.api._onMouseEnter.fire(ev);
|
|
5328
|
-
}), addDisposableListener(this.element, 'mouseleave', (ev) => {
|
|
5329
|
-
this.api._onMouseLeave.fire(ev);
|
|
5330
|
-
}));
|
|
5331
|
-
this.addDisposables(this._onDidChangeExpansionState, this.onDidChangeExpansionState((isPanelExpanded) => {
|
|
5332
|
-
this.api._onDidExpansionChange.fire({
|
|
5333
|
-
isExpanded: isPanelExpanded,
|
|
5334
|
-
});
|
|
5335
|
-
}), this.api.onDidFocusChange((e) => {
|
|
5336
|
-
if (!this.header) {
|
|
5337
|
-
return;
|
|
5338
|
-
}
|
|
5339
|
-
if (e.isFocused) {
|
|
5340
|
-
addClasses(this.header, 'focused');
|
|
5341
|
-
}
|
|
5342
|
-
else {
|
|
5343
|
-
removeClasses(this.header, 'focused');
|
|
5344
|
-
}
|
|
5345
|
-
}));
|
|
5346
|
-
this.renderOnce();
|
|
5368
|
+
setActive(isGroupActive, force = false) {
|
|
5369
|
+
if (!force && this.isActive === isGroupActive) {
|
|
5370
|
+
return;
|
|
5371
|
+
}
|
|
5372
|
+
this._isGroupActive = isGroupActive;
|
|
5373
|
+
toggleClass(this.container, 'active-group', isGroupActive);
|
|
5374
|
+
toggleClass(this.container, 'inactive-group', !isGroupActive);
|
|
5375
|
+
this.tabsContainer.setActive(this.isActive);
|
|
5376
|
+
if (!this._activePanel && this.panels.length > 0) {
|
|
5377
|
+
this.doSetActivePanel(this.panels[0]);
|
|
5378
|
+
}
|
|
5379
|
+
this.updateContainer();
|
|
5347
5380
|
}
|
|
5348
|
-
|
|
5349
|
-
|
|
5381
|
+
layout(width, height) {
|
|
5382
|
+
var _a;
|
|
5383
|
+
this._width = width;
|
|
5384
|
+
this._height = height;
|
|
5385
|
+
this.contentContainer.layout(this._width, this._height);
|
|
5386
|
+
if ((_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.layout) {
|
|
5387
|
+
this._activePanel.layout(this._width, this._height);
|
|
5388
|
+
}
|
|
5350
5389
|
}
|
|
5351
|
-
|
|
5352
|
-
this.
|
|
5390
|
+
_removePanel(panel, options) {
|
|
5391
|
+
const isActivePanel = this._activePanel === panel;
|
|
5392
|
+
this.doRemovePanel(panel);
|
|
5393
|
+
if (isActivePanel && this.panels.length > 0) {
|
|
5394
|
+
const nextPanel = this.mostRecentlyUsed[0];
|
|
5395
|
+
this.openPanel(nextPanel, {
|
|
5396
|
+
skipSetActive: options.skipSetActive,
|
|
5397
|
+
skipSetGroupActive: options.skipSetActiveGroup,
|
|
5398
|
+
});
|
|
5399
|
+
}
|
|
5400
|
+
if (this._activePanel && this.panels.length === 0) {
|
|
5401
|
+
this.doSetActivePanel(undefined);
|
|
5402
|
+
}
|
|
5403
|
+
if (!options.skipSetActive) {
|
|
5404
|
+
this.updateContainer();
|
|
5405
|
+
}
|
|
5406
|
+
return panel;
|
|
5353
5407
|
}
|
|
5354
|
-
|
|
5355
|
-
|
|
5408
|
+
doRemovePanel(panel) {
|
|
5409
|
+
const index = this.panels.indexOf(panel);
|
|
5410
|
+
if (this._activePanel === panel) {
|
|
5411
|
+
this.contentContainer.closePanel();
|
|
5412
|
+
}
|
|
5413
|
+
this.tabsContainer.delete(panel.id);
|
|
5414
|
+
this._panels.splice(index, 1);
|
|
5415
|
+
if (this.mostRecentlyUsed.includes(panel)) {
|
|
5416
|
+
const index = this.mostRecentlyUsed.indexOf(panel);
|
|
5417
|
+
this.mostRecentlyUsed.splice(index, 1);
|
|
5418
|
+
}
|
|
5419
|
+
const disposable = this._panelDisposables.get(panel.id);
|
|
5420
|
+
if (disposable) {
|
|
5421
|
+
disposable.dispose();
|
|
5422
|
+
this._panelDisposables.delete(panel.id);
|
|
5423
|
+
}
|
|
5424
|
+
this._onDidRemovePanel.fire({ panel });
|
|
5356
5425
|
}
|
|
5357
|
-
|
|
5358
|
-
|
|
5426
|
+
doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
|
|
5427
|
+
const existingPanel = this._panels.indexOf(panel);
|
|
5428
|
+
const hasExistingPanel = existingPanel > -1;
|
|
5429
|
+
this.tabsContainer.show();
|
|
5430
|
+
this.contentContainer.show();
|
|
5431
|
+
this.tabsContainer.openPanel(panel, index);
|
|
5432
|
+
if (!options.skipSetActive) {
|
|
5433
|
+
this.contentContainer.openPanel(panel);
|
|
5434
|
+
}
|
|
5435
|
+
if (hasExistingPanel) {
|
|
5436
|
+
// TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
|
|
5359
5437
|
return;
|
|
5360
5438
|
}
|
|
5361
|
-
this.
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5439
|
+
this.updateMru(panel);
|
|
5440
|
+
this.panels.splice(index, 0, panel);
|
|
5441
|
+
this._panelDisposables.set(panel.id, new CompositeDisposable(panel.api.onDidTitleChange((event) => this._onDidPanelTitleChange.fire(event)), panel.api.onDidParametersChange((event) => this._onDidPanelParametersChange.fire(event))));
|
|
5442
|
+
this._onDidAddPanel.fire({ panel });
|
|
5443
|
+
}
|
|
5444
|
+
doSetActivePanel(panel) {
|
|
5445
|
+
if (this._activePanel === panel) {
|
|
5446
|
+
return;
|
|
5369
5447
|
}
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5448
|
+
this._activePanel = panel;
|
|
5449
|
+
if (panel) {
|
|
5450
|
+
this.tabsContainer.setActivePanel(panel);
|
|
5451
|
+
panel.layout(this._width, this._height);
|
|
5452
|
+
this.updateMru(panel);
|
|
5453
|
+
this._onDidActivePanelChange.fire({
|
|
5454
|
+
panel,
|
|
5455
|
+
});
|
|
5375
5456
|
}
|
|
5376
|
-
this._onDidChange.fire(expanded ? { size: this.width } : {});
|
|
5377
|
-
this._onDidChangeExpansionState.fire(expanded);
|
|
5378
5457
|
}
|
|
5379
|
-
|
|
5380
|
-
this.
|
|
5381
|
-
|
|
5382
|
-
const [width, height] = this.orientation === exports.Orientation.HORIZONTAL
|
|
5383
|
-
? [size, orthogonalSize]
|
|
5384
|
-
: [orthogonalSize, size];
|
|
5385
|
-
if (this.isExpanded()) {
|
|
5386
|
-
this.expandedSize = width;
|
|
5458
|
+
updateMru(panel) {
|
|
5459
|
+
if (this.mostRecentlyUsed.includes(panel)) {
|
|
5460
|
+
this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(panel), 1);
|
|
5387
5461
|
}
|
|
5388
|
-
|
|
5462
|
+
this.mostRecentlyUsed = [panel, ...this.mostRecentlyUsed];
|
|
5389
5463
|
}
|
|
5390
|
-
|
|
5464
|
+
updateContainer() {
|
|
5391
5465
|
var _a, _b;
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5466
|
+
toggleClass(this.container, 'empty', this.isEmpty);
|
|
5467
|
+
this.panels.forEach((panel) => panel.runEvents());
|
|
5468
|
+
if (this.isEmpty && !this.watermark) {
|
|
5469
|
+
const watermark = this.accessor.createWatermarkComponent();
|
|
5470
|
+
watermark.init({
|
|
5471
|
+
containerApi: this._api,
|
|
5472
|
+
group: this.groupPanel,
|
|
5473
|
+
});
|
|
5474
|
+
this.watermark = watermark;
|
|
5475
|
+
addDisposableListener(this.watermark.element, 'click', () => {
|
|
5476
|
+
if (!this.isActive) {
|
|
5477
|
+
this.accessor.doSetGroupActive(this.groupPanel);
|
|
5478
|
+
}
|
|
5479
|
+
});
|
|
5480
|
+
this.tabsContainer.hide();
|
|
5481
|
+
this.contentContainer.element.appendChild(this.watermark.element);
|
|
5482
|
+
this.watermark.updateParentGroup(this.groupPanel, true);
|
|
5398
5483
|
}
|
|
5399
|
-
this.
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
(_b = this.header) === null || _b === void 0 ? void 0 : _b.append(this.headerPart.element);
|
|
5405
|
-
if (typeof parameters.isExpanded === 'boolean') {
|
|
5406
|
-
this.setExpanded(parameters.isExpanded);
|
|
5484
|
+
if (!this.isEmpty && this.watermark) {
|
|
5485
|
+
this.watermark.element.remove();
|
|
5486
|
+
(_b = (_a = this.watermark).dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
5487
|
+
this.watermark = undefined;
|
|
5488
|
+
this.tabsContainer.show();
|
|
5407
5489
|
}
|
|
5408
5490
|
}
|
|
5409
|
-
|
|
5410
|
-
const
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
renderOnce() {
|
|
5414
|
-
this.header = document.createElement('div');
|
|
5415
|
-
this.header.tabIndex = 0;
|
|
5416
|
-
this.header.className = 'pane-header';
|
|
5417
|
-
this.header.style.height = `${this.headerSize}px`;
|
|
5418
|
-
this.header.style.lineHeight = `${this.headerSize}px`;
|
|
5419
|
-
this.header.style.minHeight = `${this.headerSize}px`;
|
|
5420
|
-
this.header.style.maxHeight = `${this.headerSize}px`;
|
|
5421
|
-
this.element.appendChild(this.header);
|
|
5422
|
-
this.body = document.createElement('div');
|
|
5423
|
-
this.body.className = 'pane-body';
|
|
5424
|
-
this.element.appendChild(this.body);
|
|
5425
|
-
}
|
|
5426
|
-
// TODO slightly hacky by-pass of the component to create a body and header component
|
|
5427
|
-
getComponent() {
|
|
5428
|
-
return {
|
|
5429
|
-
update: (params) => {
|
|
5430
|
-
var _a, _b;
|
|
5431
|
-
(_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.update({ params });
|
|
5432
|
-
(_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.update({ params });
|
|
5433
|
-
},
|
|
5434
|
-
dispose: () => {
|
|
5435
|
-
var _a, _b;
|
|
5436
|
-
(_a = this.bodyPart) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
5437
|
-
(_b = this.headerPart) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
5438
|
-
},
|
|
5439
|
-
};
|
|
5440
|
-
}
|
|
5441
|
-
}
|
|
5442
|
-
|
|
5443
|
-
class DraggablePaneviewPanel extends PaneviewPanel {
|
|
5444
|
-
constructor(accessor, id, component, headerComponent, orientation, isExpanded, disableDnd) {
|
|
5445
|
-
super(id, component, headerComponent, orientation, isExpanded, true);
|
|
5446
|
-
this.accessor = accessor;
|
|
5447
|
-
this._onDidDrop = new Emitter();
|
|
5448
|
-
this.onDidDrop = this._onDidDrop.event;
|
|
5449
|
-
if (!disableDnd) {
|
|
5450
|
-
this.initDragFeatures();
|
|
5451
|
-
}
|
|
5491
|
+
canDisplayOverlay(event, position, target) {
|
|
5492
|
+
const firedEvent = new DockviewUnhandledDragOverEvent(event, target, position, getPanelData, this.accessor.getPanel(this.id));
|
|
5493
|
+
this._onUnhandledDragOverEvent.fire(firedEvent);
|
|
5494
|
+
return firedEvent.isAccepted;
|
|
5452
5495
|
}
|
|
5453
|
-
|
|
5454
|
-
if (
|
|
5496
|
+
handleDropEvent(type, event, position, index) {
|
|
5497
|
+
if (this.locked === 'no-drop-target') {
|
|
5455
5498
|
return;
|
|
5456
5499
|
}
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
return {
|
|
5464
|
-
dispose: () => {
|
|
5465
|
-
LocalSelectionTransfer.getInstance().clearData(PaneTransfer.prototype);
|
|
5466
|
-
},
|
|
5467
|
-
};
|
|
5500
|
+
function getKind() {
|
|
5501
|
+
switch (type) {
|
|
5502
|
+
case 'header':
|
|
5503
|
+
return typeof index === 'number' ? 'tab' : 'header_space';
|
|
5504
|
+
case 'content':
|
|
5505
|
+
return 'content';
|
|
5468
5506
|
}
|
|
5469
|
-
}
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
data.viewId === this.accessor.id) {
|
|
5480
|
-
return true;
|
|
5481
|
-
}
|
|
5482
|
-
}
|
|
5483
|
-
if (this.accessor.options.showDndOverlay) {
|
|
5484
|
-
return this.accessor.options.showDndOverlay({
|
|
5485
|
-
nativeEvent: event,
|
|
5486
|
-
getData: getPaneData,
|
|
5487
|
-
panel: this,
|
|
5488
|
-
});
|
|
5489
|
-
}
|
|
5490
|
-
return false;
|
|
5491
|
-
},
|
|
5507
|
+
}
|
|
5508
|
+
const panel = typeof index === 'number' ? this.panels[index] : undefined;
|
|
5509
|
+
const willDropEvent = new DockviewWillDropEvent({
|
|
5510
|
+
nativeEvent: event,
|
|
5511
|
+
position,
|
|
5512
|
+
panel,
|
|
5513
|
+
getData: () => getPanelData(),
|
|
5514
|
+
kind: getKind(),
|
|
5515
|
+
group: this.groupPanel,
|
|
5516
|
+
api: this._api,
|
|
5492
5517
|
});
|
|
5493
|
-
this.
|
|
5494
|
-
|
|
5495
|
-
}));
|
|
5496
|
-
}
|
|
5497
|
-
onDrop(event) {
|
|
5498
|
-
const data = getPaneData();
|
|
5499
|
-
if (!data || data.viewId !== this.accessor.id) {
|
|
5500
|
-
// if there is no local drag event for this panel
|
|
5501
|
-
// or if the drag event was creating by another Paneview instance
|
|
5502
|
-
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { panel: this, api: new PaneviewApi(this.accessor), getData: getPaneData }));
|
|
5518
|
+
this._onWillDrop.fire(willDropEvent);
|
|
5519
|
+
if (willDropEvent.defaultPrevented) {
|
|
5503
5520
|
return;
|
|
5504
5521
|
}
|
|
5505
|
-
const
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5522
|
+
const data = getPanelData();
|
|
5523
|
+
if (data && data.viewId === this.accessor.id) {
|
|
5524
|
+
if (data.panelId === null) {
|
|
5525
|
+
// this is a group move dnd event
|
|
5526
|
+
const { groupId } = data;
|
|
5527
|
+
this._onMove.fire({
|
|
5528
|
+
target: position,
|
|
5529
|
+
groupId: groupId,
|
|
5530
|
+
index,
|
|
5531
|
+
});
|
|
5532
|
+
return;
|
|
5533
|
+
}
|
|
5534
|
+
const fromSameGroup = this.tabsContainer.indexOf(data.panelId) !== -1;
|
|
5535
|
+
if (fromSameGroup && this.tabsContainer.size === 1) {
|
|
5536
|
+
return;
|
|
5537
|
+
}
|
|
5538
|
+
const { groupId, panelId } = data;
|
|
5539
|
+
const isSameGroup = this.id === groupId;
|
|
5540
|
+
if (isSameGroup && !position) {
|
|
5541
|
+
const oldIndex = this.tabsContainer.indexOf(panelId);
|
|
5542
|
+
if (oldIndex === index) {
|
|
5543
|
+
return;
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
this._onMove.fire({
|
|
5547
|
+
target: position,
|
|
5548
|
+
groupId: data.groupId,
|
|
5549
|
+
itemId: data.panelId,
|
|
5550
|
+
index,
|
|
5551
|
+
});
|
|
5513
5552
|
}
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5553
|
+
else {
|
|
5554
|
+
this._onDidDrop.fire(new DockviewDidDropEvent({
|
|
5555
|
+
nativeEvent: event,
|
|
5556
|
+
position,
|
|
5557
|
+
panel,
|
|
5558
|
+
getData: () => getPanelData(),
|
|
5559
|
+
group: this.groupPanel,
|
|
5560
|
+
api: this._api,
|
|
5561
|
+
}));
|
|
5519
5562
|
}
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5563
|
+
}
|
|
5564
|
+
dispose() {
|
|
5565
|
+
var _a, _b, _c;
|
|
5566
|
+
super.dispose();
|
|
5567
|
+
(_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
|
|
5568
|
+
(_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
5569
|
+
this.watermark = undefined;
|
|
5570
|
+
for (const panel of this.panels) {
|
|
5571
|
+
panel.dispose();
|
|
5525
5572
|
}
|
|
5526
|
-
|
|
5573
|
+
this.tabsContainer.dispose();
|
|
5574
|
+
this.contentContainer.dispose();
|
|
5527
5575
|
}
|
|
5528
5576
|
}
|
|
5529
5577
|
|
|
@@ -5710,9 +5758,12 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
5710
5758
|
constructor(id, accessor) {
|
|
5711
5759
|
super(id, '__dockviewgroup__');
|
|
5712
5760
|
this.accessor = accessor;
|
|
5761
|
+
this._mutableDisposable = new MutableDisposable();
|
|
5713
5762
|
this._onDidLocationChange = new Emitter();
|
|
5714
5763
|
this.onDidLocationChange = this._onDidLocationChange.event;
|
|
5715
|
-
this.
|
|
5764
|
+
this._onDidActivePanelChange = new Emitter();
|
|
5765
|
+
this.onDidActivePanelChange = this._onDidActivePanelChange.event;
|
|
5766
|
+
this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._mutableDisposable);
|
|
5716
5767
|
}
|
|
5717
5768
|
close() {
|
|
5718
5769
|
if (!this._group) {
|
|
@@ -5770,6 +5821,19 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
5770
5821
|
}
|
|
5771
5822
|
initialize(group) {
|
|
5772
5823
|
this._group = group;
|
|
5824
|
+
/**
|
|
5825
|
+
* TODO: Annoying initialization order caveat
|
|
5826
|
+
*
|
|
5827
|
+
* Due to the order on initialization we know that the model isn't defined until later in the same stack-frame of setup.
|
|
5828
|
+
* By queuing a microtask we can ensure the setup is completed within the same stack-frame, but after everything else has
|
|
5829
|
+
* finished ensuring the `model` is defined.
|
|
5830
|
+
*/
|
|
5831
|
+
queueMicrotask(() => {
|
|
5832
|
+
this._mutableDisposable.value =
|
|
5833
|
+
this._group.model.onDidActivePanelChange((event) => {
|
|
5834
|
+
this._onDidActivePanelChange.fire(event);
|
|
5835
|
+
});
|
|
5836
|
+
});
|
|
5773
5837
|
}
|
|
5774
5838
|
}
|
|
5775
5839
|
|
|
@@ -5830,31 +5894,6 @@ class DockviewGroupPanel extends GridviewPanel {
|
|
|
5830
5894
|
}
|
|
5831
5895
|
}
|
|
5832
5896
|
|
|
5833
|
-
function isPanelOptionsWithPanel(data) {
|
|
5834
|
-
if (data.referencePanel) {
|
|
5835
|
-
return true;
|
|
5836
|
-
}
|
|
5837
|
-
return false;
|
|
5838
|
-
}
|
|
5839
|
-
function isPanelOptionsWithGroup(data) {
|
|
5840
|
-
if (data.referenceGroup) {
|
|
5841
|
-
return true;
|
|
5842
|
-
}
|
|
5843
|
-
return false;
|
|
5844
|
-
}
|
|
5845
|
-
function isGroupOptionsWithPanel(data) {
|
|
5846
|
-
if (data.referencePanel) {
|
|
5847
|
-
return true;
|
|
5848
|
-
}
|
|
5849
|
-
return false;
|
|
5850
|
-
}
|
|
5851
|
-
function isGroupOptionsWithGroup(data) {
|
|
5852
|
-
if (data.referenceGroup) {
|
|
5853
|
-
return true;
|
|
5854
|
-
}
|
|
5855
|
-
return false;
|
|
5856
|
-
}
|
|
5857
|
-
|
|
5858
5897
|
class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
5859
5898
|
get location() {
|
|
5860
5899
|
return this.group.api.location;
|
|
@@ -6222,7 +6261,7 @@ class DockviewPanelModel {
|
|
|
6222
6261
|
this._tab = this.createTabComponent(this.id, tabComponent);
|
|
6223
6262
|
}
|
|
6224
6263
|
init(params) {
|
|
6225
|
-
this.content.init(
|
|
6264
|
+
this.content.init(params);
|
|
6226
6265
|
this.tab.init(params);
|
|
6227
6266
|
}
|
|
6228
6267
|
updateParentGroup(_group, _isPanelVisible) {
|
|
@@ -6243,20 +6282,29 @@ class DockviewPanelModel {
|
|
|
6243
6282
|
(_d = (_c = this.tab).dispose) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
6244
6283
|
}
|
|
6245
6284
|
createContentComponent(id, componentName) {
|
|
6246
|
-
|
|
6247
|
-
|
|
6285
|
+
return this.accessor.options.createComponent({
|
|
6286
|
+
id,
|
|
6287
|
+
name: componentName,
|
|
6288
|
+
});
|
|
6248
6289
|
}
|
|
6249
6290
|
createTabComponent(id, componentName) {
|
|
6250
|
-
|
|
6251
|
-
if (
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6291
|
+
const name = componentName !== null && componentName !== void 0 ? componentName : this.accessor.options.defaultTabComponent;
|
|
6292
|
+
if (name) {
|
|
6293
|
+
if (this.accessor.options.createTabComponent) {
|
|
6294
|
+
const component = this.accessor.options.createTabComponent({
|
|
6295
|
+
id,
|
|
6296
|
+
name,
|
|
6297
|
+
});
|
|
6298
|
+
if (component) {
|
|
6299
|
+
return component;
|
|
6300
|
+
}
|
|
6301
|
+
else {
|
|
6302
|
+
return new DefaultTab();
|
|
6303
|
+
}
|
|
6304
|
+
}
|
|
6305
|
+
console.warn(`dockview: tabComponent '${componentName}' was not found. falling back to the default tab.`);
|
|
6259
6306
|
}
|
|
6307
|
+
return new DefaultTab();
|
|
6260
6308
|
}
|
|
6261
6309
|
}
|
|
6262
6310
|
|
|
@@ -6993,11 +7041,13 @@ class DockviewComponent extends BaseGrid {
|
|
|
6993
7041
|
return this._api;
|
|
6994
7042
|
}
|
|
6995
7043
|
constructor(options) {
|
|
6996
|
-
var _a
|
|
7044
|
+
var _a;
|
|
6997
7045
|
super({
|
|
6998
7046
|
proportionalLayout: true,
|
|
6999
|
-
orientation:
|
|
7000
|
-
styles: options.
|
|
7047
|
+
orientation: exports.Orientation.HORIZONTAL,
|
|
7048
|
+
styles: options.hideBorders
|
|
7049
|
+
? { separatorBorder: 'transparent' }
|
|
7050
|
+
: undefined,
|
|
7001
7051
|
parentElement: options.parentElement,
|
|
7002
7052
|
disableAutoResizing: options.disableAutoResizing,
|
|
7003
7053
|
locked: options.locked,
|
|
@@ -7015,6 +7065,8 @@ class DockviewComponent extends BaseGrid {
|
|
|
7015
7065
|
this.onWillDrop = this._onWillDrop.event;
|
|
7016
7066
|
this._onWillShowOverlay = new Emitter();
|
|
7017
7067
|
this.onWillShowOverlay = this._onWillShowOverlay.event;
|
|
7068
|
+
this._onUnhandledDragOverEvent = new Emitter();
|
|
7069
|
+
this.onUnhandledDragOverEvent = this._onUnhandledDragOverEvent.event;
|
|
7018
7070
|
this._onDidRemovePanel = new Emitter();
|
|
7019
7071
|
this.onDidRemovePanel = this._onDidRemovePanel.event;
|
|
7020
7072
|
this._onDidAddPanel = new Emitter();
|
|
@@ -7040,7 +7092,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
7040
7092
|
this.overlayRenderContainer = new OverlayRenderContainer(gready);
|
|
7041
7093
|
toggleClass(this.gridview.element, 'dv-dockview', true);
|
|
7042
7094
|
toggleClass(this.element, 'dv-debug', !!options.debug);
|
|
7043
|
-
this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
|
|
7095
|
+
this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this.onDidAdd((event) => {
|
|
7044
7096
|
if (!this._moving) {
|
|
7045
7097
|
this._onDidAddGroup.fire(event);
|
|
7046
7098
|
}
|
|
@@ -7067,22 +7119,6 @@ class DockviewComponent extends BaseGrid {
|
|
|
7067
7119
|
}
|
|
7068
7120
|
}));
|
|
7069
7121
|
this._options = options;
|
|
7070
|
-
if (!this.options.components) {
|
|
7071
|
-
this.options.components = {};
|
|
7072
|
-
}
|
|
7073
|
-
if (!this.options.frameworkComponents) {
|
|
7074
|
-
this.options.frameworkComponents = {};
|
|
7075
|
-
}
|
|
7076
|
-
if (!this.options.frameworkTabComponents) {
|
|
7077
|
-
this.options.frameworkTabComponents = {};
|
|
7078
|
-
}
|
|
7079
|
-
if (!this.options.tabComponents) {
|
|
7080
|
-
this.options.tabComponents = {};
|
|
7081
|
-
}
|
|
7082
|
-
if (!this.options.watermarkComponent &&
|
|
7083
|
-
!this.options.watermarkFrameworkComponent) {
|
|
7084
|
-
this.options.watermarkComponent = Watermark;
|
|
7085
|
-
}
|
|
7086
7122
|
this._rootDropTarget = new Droptarget(this.element, {
|
|
7087
7123
|
canDisplayOverlay: (event, position) => {
|
|
7088
7124
|
const data = getPanelData();
|
|
@@ -7097,26 +7133,20 @@ class DockviewComponent extends BaseGrid {
|
|
|
7097
7133
|
}
|
|
7098
7134
|
return true;
|
|
7099
7135
|
}
|
|
7100
|
-
if (this.
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
return false;
|
|
7108
|
-
}
|
|
7109
|
-
return this.options.showDndOverlay({
|
|
7110
|
-
nativeEvent: event,
|
|
7111
|
-
position: position,
|
|
7112
|
-
target: 'edge',
|
|
7113
|
-
getData: getPanelData,
|
|
7114
|
-
});
|
|
7136
|
+
if (position === 'center' && this.gridview.length !== 0) {
|
|
7137
|
+
/**
|
|
7138
|
+
* for external events only show the four-corner drag overlays, disable
|
|
7139
|
+
* the center position so that external drag events can fall through to the group
|
|
7140
|
+
* and panel drop target handlers
|
|
7141
|
+
*/
|
|
7142
|
+
return false;
|
|
7115
7143
|
}
|
|
7116
|
-
|
|
7144
|
+
const firedEvent = new DockviewUnhandledDragOverEvent(event, 'edge', position, getPanelData);
|
|
7145
|
+
this._onUnhandledDragOverEvent.fire(firedEvent);
|
|
7146
|
+
return firedEvent.isAccepted;
|
|
7117
7147
|
},
|
|
7118
7148
|
acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
|
|
7119
|
-
overlayModel: (
|
|
7149
|
+
overlayModel: (_a = this.options.rootOverlayModel) !== null && _a !== void 0 ? _a : DEFAULT_ROOT_OVERLAY_MODEL,
|
|
7120
7150
|
});
|
|
7121
7151
|
this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
|
|
7122
7152
|
if (this.gridview.length > 0 && event.position === 'center') {
|
|
@@ -7340,7 +7370,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
7340
7370
|
skipDispose: true,
|
|
7341
7371
|
skipSetActiveGroup: true,
|
|
7342
7372
|
}));
|
|
7343
|
-
group.model.openPanel(item, { skipSetGroupActive: true });
|
|
7373
|
+
this.movingLock(() => group.model.openPanel(item, { skipSetGroupActive: true }));
|
|
7344
7374
|
}
|
|
7345
7375
|
else {
|
|
7346
7376
|
group = item;
|
|
@@ -7413,7 +7443,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
7413
7443
|
// this is either a resize or a move
|
|
7414
7444
|
// to inform the panels .layout(...) the group with it's current size
|
|
7415
7445
|
// don't care about resize since the above watcher handles that
|
|
7416
|
-
group.layout(group.
|
|
7446
|
+
group.layout(group.width, group.height);
|
|
7417
7447
|
}), overlay.onDidChangeEnd(() => {
|
|
7418
7448
|
this._bufferOnDidLayoutChange.fire();
|
|
7419
7449
|
}), group.onDidChange((event) => {
|
|
@@ -7468,16 +7498,11 @@ class DockviewComponent extends BaseGrid {
|
|
|
7468
7498
|
}
|
|
7469
7499
|
updateOptions(options) {
|
|
7470
7500
|
var _a, _b;
|
|
7471
|
-
const
|
|
7472
|
-
this.gridview.orientation !== options.orientation;
|
|
7473
|
-
const changed_floatingGroupBounds = options.floatingGroupBounds !== undefined &&
|
|
7501
|
+
const changed_floatingGroupBounds = 'floatingGroupBounds' in options &&
|
|
7474
7502
|
options.floatingGroupBounds !== this.options.floatingGroupBounds;
|
|
7475
|
-
const changed_rootOverlayOptions =
|
|
7503
|
+
const changed_rootOverlayOptions = 'rootOverlayModel' in options &&
|
|
7476
7504
|
options.rootOverlayModel !== this.options.rootOverlayModel;
|
|
7477
7505
|
this._options = Object.assign(Object.assign({}, this.options), options);
|
|
7478
|
-
if (changed_orientation) {
|
|
7479
|
-
this.gridview.orientation = options.orientation;
|
|
7480
|
-
}
|
|
7481
7506
|
if (changed_floatingGroupBounds) {
|
|
7482
7507
|
for (const group of this._floatingGroups) {
|
|
7483
7508
|
switch (this.options.floatingGroupBounds) {
|
|
@@ -7765,7 +7790,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
7765
7790
|
? this.getGroupPanel(options.position.referencePanel)
|
|
7766
7791
|
: options.position.referencePanel;
|
|
7767
7792
|
if (!referencePanel) {
|
|
7768
|
-
throw new Error(`referencePanel ${options.position.referencePanel} does not exist`);
|
|
7793
|
+
throw new Error(`referencePanel '${options.position.referencePanel}' does not exist`);
|
|
7769
7794
|
}
|
|
7770
7795
|
referenceGroup = this.findGroup(referencePanel);
|
|
7771
7796
|
}
|
|
@@ -7775,14 +7800,19 @@ class DockviewComponent extends BaseGrid {
|
|
|
7775
7800
|
? (_a = this._groups.get(options.position.referenceGroup)) === null || _a === void 0 ? void 0 : _a.value
|
|
7776
7801
|
: options.position.referenceGroup;
|
|
7777
7802
|
if (!referenceGroup) {
|
|
7778
|
-
throw new Error(`
|
|
7803
|
+
throw new Error(`referenceGroup '${options.position.referenceGroup}' does not exist`);
|
|
7779
7804
|
}
|
|
7780
7805
|
}
|
|
7781
7806
|
else {
|
|
7782
7807
|
const group = this.orthogonalize(directionToPosition(options.position.direction));
|
|
7783
7808
|
const panel = this.createPanel(options, group);
|
|
7784
|
-
group.model.openPanel(panel
|
|
7785
|
-
|
|
7809
|
+
group.model.openPanel(panel, {
|
|
7810
|
+
skipSetActive: options.inactive,
|
|
7811
|
+
skipSetGroupActive: options.inactive,
|
|
7812
|
+
});
|
|
7813
|
+
if (!options.inactive) {
|
|
7814
|
+
this.doSetGroupAndPanelActive(group);
|
|
7815
|
+
}
|
|
7786
7816
|
return panel;
|
|
7787
7817
|
}
|
|
7788
7818
|
}
|
|
@@ -7805,43 +7835,64 @@ class DockviewComponent extends BaseGrid {
|
|
|
7805
7835
|
skipActiveGroup: true,
|
|
7806
7836
|
});
|
|
7807
7837
|
panel = this.createPanel(options, group);
|
|
7808
|
-
group.model.openPanel(panel
|
|
7838
|
+
group.model.openPanel(panel, {
|
|
7839
|
+
skipSetActive: options.inactive,
|
|
7840
|
+
skipSetGroupActive: options.inactive,
|
|
7841
|
+
});
|
|
7809
7842
|
}
|
|
7810
7843
|
else if (referenceGroup.api.location.type === 'floating' ||
|
|
7811
7844
|
target === 'center') {
|
|
7812
7845
|
panel = this.createPanel(options, referenceGroup);
|
|
7813
|
-
referenceGroup.model.openPanel(panel
|
|
7814
|
-
|
|
7846
|
+
referenceGroup.model.openPanel(panel, {
|
|
7847
|
+
skipSetActive: options.inactive,
|
|
7848
|
+
skipSetGroupActive: options.inactive,
|
|
7849
|
+
});
|
|
7850
|
+
if (!options.inactive) {
|
|
7851
|
+
this.doSetGroupAndPanelActive(referenceGroup);
|
|
7852
|
+
}
|
|
7815
7853
|
}
|
|
7816
7854
|
else {
|
|
7817
7855
|
const location = getGridLocation(referenceGroup.element);
|
|
7818
7856
|
const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
|
|
7819
7857
|
const group = this.createGroupAtLocation(relativeLocation);
|
|
7820
7858
|
panel = this.createPanel(options, group);
|
|
7821
|
-
group.model.openPanel(panel
|
|
7822
|
-
|
|
7859
|
+
group.model.openPanel(panel, {
|
|
7860
|
+
skipSetActive: options.inactive,
|
|
7861
|
+
skipSetGroupActive: options.inactive,
|
|
7862
|
+
});
|
|
7863
|
+
if (!options.inactive) {
|
|
7864
|
+
this.doSetGroupAndPanelActive(group);
|
|
7865
|
+
}
|
|
7823
7866
|
}
|
|
7824
7867
|
}
|
|
7825
7868
|
else if (options.floating) {
|
|
7826
7869
|
const group = this.createGroup();
|
|
7827
7870
|
this._onDidAddGroup.fire(group);
|
|
7828
|
-
const
|
|
7871
|
+
const coordinates = typeof options.floating === 'object' &&
|
|
7829
7872
|
options.floating !== null
|
|
7830
7873
|
? options.floating
|
|
7831
7874
|
: {};
|
|
7832
|
-
this.addFloatingGroup(group,
|
|
7875
|
+
this.addFloatingGroup(group, coordinates, {
|
|
7833
7876
|
inDragMode: false,
|
|
7834
7877
|
skipRemoveGroup: true,
|
|
7835
7878
|
skipActiveGroup: true,
|
|
7836
7879
|
});
|
|
7837
7880
|
panel = this.createPanel(options, group);
|
|
7838
|
-
group.model.openPanel(panel
|
|
7881
|
+
group.model.openPanel(panel, {
|
|
7882
|
+
skipSetActive: options.inactive,
|
|
7883
|
+
skipSetGroupActive: options.inactive,
|
|
7884
|
+
});
|
|
7839
7885
|
}
|
|
7840
7886
|
else {
|
|
7841
7887
|
const group = this.createGroupAtLocation();
|
|
7842
7888
|
panel = this.createPanel(options, group);
|
|
7843
|
-
group.model.openPanel(panel
|
|
7844
|
-
|
|
7889
|
+
group.model.openPanel(panel, {
|
|
7890
|
+
skipSetActive: options.inactive,
|
|
7891
|
+
skipSetGroupActive: options.inactive,
|
|
7892
|
+
});
|
|
7893
|
+
if (!options.inactive) {
|
|
7894
|
+
this.doSetGroupAndPanelActive(group);
|
|
7895
|
+
}
|
|
7845
7896
|
}
|
|
7846
7897
|
return panel;
|
|
7847
7898
|
}
|
|
@@ -7865,12 +7916,10 @@ class DockviewComponent extends BaseGrid {
|
|
|
7865
7916
|
}
|
|
7866
7917
|
}
|
|
7867
7918
|
createWatermarkComponent() {
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
? { 'watermark-name': this.options.watermarkFrameworkComponent }
|
|
7873
|
-
: {}, (_a = this.options.frameworkComponentFactory) === null || _a === void 0 ? void 0 : _a.watermark);
|
|
7919
|
+
if (this.options.createWatermarkComponent) {
|
|
7920
|
+
return this.options.createWatermarkComponent();
|
|
7921
|
+
}
|
|
7922
|
+
return new Watermark();
|
|
7874
7923
|
}
|
|
7875
7924
|
updateWatermark() {
|
|
7876
7925
|
var _a, _b;
|
|
@@ -8251,6 +8300,8 @@ class DockviewComponent extends BaseGrid {
|
|
|
8251
8300
|
return;
|
|
8252
8301
|
}
|
|
8253
8302
|
this._onWillShowOverlay.fire(event);
|
|
8303
|
+
}), view.model.onUnhandledDragOverEvent((event) => {
|
|
8304
|
+
this._onUnhandledDragOverEvent.fire(event);
|
|
8254
8305
|
}), view.model.onDidAddPanel((event) => {
|
|
8255
8306
|
if (this._moving) {
|
|
8256
8307
|
return;
|
|
@@ -9496,11 +9547,6 @@ class ReactWatermarkPart {
|
|
|
9496
9547
|
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
9497
9548
|
group: parameters.group,
|
|
9498
9549
|
containerApi: parameters.containerApi,
|
|
9499
|
-
close: () => {
|
|
9500
|
-
if (parameters.group) {
|
|
9501
|
-
parameters.containerApi.removeGroup(parameters.group);
|
|
9502
|
-
}
|
|
9503
|
-
},
|
|
9504
9550
|
});
|
|
9505
9551
|
}
|
|
9506
9552
|
focus() {
|
|
@@ -9532,9 +9578,6 @@ class ReactHeaderActionsRendererPart {
|
|
|
9532
9578
|
get part() {
|
|
9533
9579
|
return this._part;
|
|
9534
9580
|
}
|
|
9535
|
-
get group() {
|
|
9536
|
-
return this._group;
|
|
9537
|
-
}
|
|
9538
9581
|
constructor(component, reactPortalStore, _group) {
|
|
9539
9582
|
this.component = component;
|
|
9540
9583
|
this.reactPortalStore = reactPortalStore;
|
|
@@ -9545,9 +9588,6 @@ class ReactHeaderActionsRendererPart {
|
|
|
9545
9588
|
this._element.style.height = '100%';
|
|
9546
9589
|
this._element.style.width = '100%';
|
|
9547
9590
|
}
|
|
9548
|
-
focus() {
|
|
9549
|
-
// TODO
|
|
9550
|
-
}
|
|
9551
9591
|
init(parameters) {
|
|
9552
9592
|
this.mutableDisposable.value = new CompositeDisposable(this._group.model.onDidAddPanel(() => {
|
|
9553
9593
|
this.updatePanels();
|
|
@@ -9567,15 +9607,15 @@ class ReactHeaderActionsRendererPart {
|
|
|
9567
9607
|
group: this._group,
|
|
9568
9608
|
});
|
|
9569
9609
|
}
|
|
9570
|
-
update(event) {
|
|
9571
|
-
var _a;
|
|
9572
|
-
(_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
|
|
9573
|
-
}
|
|
9574
9610
|
dispose() {
|
|
9575
9611
|
var _a;
|
|
9576
9612
|
this.mutableDisposable.dispose();
|
|
9577
9613
|
(_a = this._part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
9578
9614
|
}
|
|
9615
|
+
update(event) {
|
|
9616
|
+
var _a;
|
|
9617
|
+
(_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
|
|
9618
|
+
}
|
|
9579
9619
|
updatePanels() {
|
|
9580
9620
|
this.update({ params: { panels: this._group.model.panels } });
|
|
9581
9621
|
}
|
|
@@ -9603,72 +9643,72 @@ function createGroupControlElement(component, store) {
|
|
|
9603
9643
|
: undefined;
|
|
9604
9644
|
}
|
|
9605
9645
|
const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
|
|
9646
|
+
function extractCoreOptions(props) {
|
|
9647
|
+
const coreOptions = PROPERTY_KEYS.reduce((obj, key) => {
|
|
9648
|
+
if (key in props) {
|
|
9649
|
+
obj[key] = props[key];
|
|
9650
|
+
}
|
|
9651
|
+
return obj;
|
|
9652
|
+
}, {});
|
|
9653
|
+
return coreOptions;
|
|
9654
|
+
}
|
|
9606
9655
|
const DockviewReact = React.forwardRef((props, ref) => {
|
|
9607
9656
|
const domRef = React.useRef(null);
|
|
9608
9657
|
const dockviewRef = React.useRef();
|
|
9609
9658
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
9610
9659
|
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
9660
|
+
const prevProps = React.useRef({});
|
|
9661
|
+
React.useEffect(() => {
|
|
9662
|
+
const changes = {};
|
|
9663
|
+
PROPERTY_KEYS.forEach((propKey) => {
|
|
9664
|
+
const key = propKey;
|
|
9665
|
+
const propValue = props[key];
|
|
9666
|
+
if (key in props && propValue !== prevProps.current[key]) {
|
|
9667
|
+
changes[key] = propValue;
|
|
9668
|
+
}
|
|
9669
|
+
});
|
|
9670
|
+
if (dockviewRef.current) {
|
|
9671
|
+
dockviewRef.current.updateOptions(changes);
|
|
9672
|
+
}
|
|
9673
|
+
prevProps.current = props;
|
|
9674
|
+
}, PROPERTY_KEYS.map((key) => props[key]));
|
|
9611
9675
|
React.useEffect(() => {
|
|
9612
9676
|
var _a;
|
|
9613
9677
|
if (!domRef.current) {
|
|
9614
|
-
return
|
|
9615
|
-
// noop
|
|
9616
|
-
};
|
|
9678
|
+
return;
|
|
9617
9679
|
}
|
|
9618
|
-
const factory = {
|
|
9619
|
-
content: {
|
|
9620
|
-
createComponent: (_id, componentId, component) => {
|
|
9621
|
-
return new ReactPanelContentPart(componentId, component, {
|
|
9622
|
-
addPortal,
|
|
9623
|
-
});
|
|
9624
|
-
},
|
|
9625
|
-
},
|
|
9626
|
-
tab: {
|
|
9627
|
-
createComponent: (_id, componentId, component) => {
|
|
9628
|
-
return new ReactPanelHeaderPart(componentId, component, {
|
|
9629
|
-
addPortal,
|
|
9630
|
-
});
|
|
9631
|
-
},
|
|
9632
|
-
},
|
|
9633
|
-
watermark: {
|
|
9634
|
-
createComponent: (_id, componentId, component) => {
|
|
9635
|
-
return new ReactWatermarkPart(componentId, component, {
|
|
9636
|
-
addPortal,
|
|
9637
|
-
});
|
|
9638
|
-
},
|
|
9639
|
-
},
|
|
9640
|
-
};
|
|
9641
9680
|
const frameworkTabComponents = (_a = props.tabComponents) !== null && _a !== void 0 ? _a : {};
|
|
9642
9681
|
if (props.defaultTabComponent) {
|
|
9643
9682
|
frameworkTabComponents[DEFAULT_REACT_TAB] =
|
|
9644
9683
|
props.defaultTabComponent;
|
|
9645
9684
|
}
|
|
9646
|
-
const
|
|
9685
|
+
const frameworkOptions = {
|
|
9686
|
+
createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
9687
|
+
createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
9688
|
+
createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
9689
|
+
createComponent: (options) => {
|
|
9690
|
+
return new ReactPanelContentPart(options.id, props.components[options.name], {
|
|
9691
|
+
addPortal,
|
|
9692
|
+
});
|
|
9693
|
+
},
|
|
9694
|
+
createTabComponent(options) {
|
|
9695
|
+
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
|
|
9696
|
+
addPortal,
|
|
9697
|
+
});
|
|
9698
|
+
},
|
|
9699
|
+
createWatermarkComponent: props.watermarkComponent
|
|
9700
|
+
? () => {
|
|
9701
|
+
return new ReactWatermarkPart('watermark', props.watermarkComponent, {
|
|
9702
|
+
addPortal,
|
|
9703
|
+
});
|
|
9704
|
+
}
|
|
9705
|
+
: undefined,
|
|
9647
9706
|
parentElement: domRef.current,
|
|
9648
|
-
frameworkComponentFactory: factory,
|
|
9649
|
-
frameworkComponents: props.components,
|
|
9650
|
-
disableAutoResizing: props.disableAutoResizing,
|
|
9651
|
-
frameworkTabComponents,
|
|
9652
|
-
watermarkFrameworkComponent: props.watermarkComponent,
|
|
9653
9707
|
defaultTabComponent: props.defaultTabComponent
|
|
9654
9708
|
? DEFAULT_REACT_TAB
|
|
9655
9709
|
: undefined,
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
: undefined,
|
|
9659
|
-
showDndOverlay: props.showDndOverlay,
|
|
9660
|
-
createLeftHeaderActionsElement: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
9661
|
-
createRightHeaderActionsElement: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
9662
|
-
createPrefixHeaderActionsElement: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
9663
|
-
singleTabMode: props.singleTabMode,
|
|
9664
|
-
disableFloatingGroups: props.disableFloatingGroups,
|
|
9665
|
-
floatingGroupBounds: props.floatingGroupBounds,
|
|
9666
|
-
defaultRenderer: props.defaultRenderer,
|
|
9667
|
-
debug: props.debug,
|
|
9668
|
-
rootOverlayModel: props.rootOverlayModel,
|
|
9669
|
-
locked: props.locked,
|
|
9670
|
-
disableDnd: props.disableDnd,
|
|
9671
|
-
});
|
|
9710
|
+
};
|
|
9711
|
+
const dockview = new DockviewComponent(Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
|
|
9672
9712
|
const { clientWidth, clientHeight } = domRef.current;
|
|
9673
9713
|
dockview.layout(clientWidth, clientHeight);
|
|
9674
9714
|
if (props.onReady) {
|
|
@@ -9679,20 +9719,6 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
9679
9719
|
dockview.dispose();
|
|
9680
9720
|
};
|
|
9681
9721
|
}, []);
|
|
9682
|
-
React.useEffect(() => {
|
|
9683
|
-
if (!dockviewRef.current) {
|
|
9684
|
-
return;
|
|
9685
|
-
}
|
|
9686
|
-
dockviewRef.current.locked = !!props.locked;
|
|
9687
|
-
}, [props.locked]);
|
|
9688
|
-
React.useEffect(() => {
|
|
9689
|
-
if (!dockviewRef.current) {
|
|
9690
|
-
return;
|
|
9691
|
-
}
|
|
9692
|
-
dockviewRef.current.updateOptions({
|
|
9693
|
-
disableDnd: props.disableDnd,
|
|
9694
|
-
});
|
|
9695
|
-
}, [props.disableDnd]);
|
|
9696
9722
|
React.useEffect(() => {
|
|
9697
9723
|
if (!dockviewRef.current) {
|
|
9698
9724
|
return () => {
|
|
@@ -9714,63 +9740,43 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
9714
9740
|
// noop
|
|
9715
9741
|
};
|
|
9716
9742
|
}
|
|
9717
|
-
const disposable = dockviewRef.current.
|
|
9718
|
-
|
|
9719
|
-
|
|
9743
|
+
const disposable = dockviewRef.current.onUnhandledDragOverEvent((event) => {
|
|
9744
|
+
var _a;
|
|
9745
|
+
if ((_a = props.showDndOverlay) === null || _a === void 0 ? void 0 : _a.call(props, event)) {
|
|
9746
|
+
event.accept();
|
|
9720
9747
|
}
|
|
9721
9748
|
});
|
|
9722
9749
|
return () => {
|
|
9723
9750
|
disposable.dispose();
|
|
9724
9751
|
};
|
|
9725
|
-
}, [props.onWillDrop]);
|
|
9726
|
-
React.useEffect(() => {
|
|
9727
|
-
if (!dockviewRef.current) {
|
|
9728
|
-
return;
|
|
9729
|
-
}
|
|
9730
|
-
dockviewRef.current.updateOptions({
|
|
9731
|
-
frameworkComponents: props.components,
|
|
9732
|
-
});
|
|
9733
|
-
}, [props.components]);
|
|
9734
|
-
React.useEffect(() => {
|
|
9735
|
-
if (!dockviewRef.current) {
|
|
9736
|
-
return;
|
|
9737
|
-
}
|
|
9738
|
-
dockviewRef.current.updateOptions({
|
|
9739
|
-
floatingGroupBounds: props.floatingGroupBounds,
|
|
9740
|
-
});
|
|
9741
|
-
}, [props.floatingGroupBounds]);
|
|
9742
|
-
React.useEffect(() => {
|
|
9743
|
-
if (!dockviewRef.current) {
|
|
9744
|
-
return;
|
|
9745
|
-
}
|
|
9746
|
-
dockviewRef.current.updateOptions({
|
|
9747
|
-
watermarkFrameworkComponent: props.watermarkComponent,
|
|
9748
|
-
});
|
|
9749
|
-
}, [props.watermarkComponent]);
|
|
9750
|
-
React.useEffect(() => {
|
|
9751
|
-
if (!dockviewRef.current) {
|
|
9752
|
-
return;
|
|
9753
|
-
}
|
|
9754
|
-
dockviewRef.current.updateOptions({
|
|
9755
|
-
showDndOverlay: props.showDndOverlay,
|
|
9756
|
-
});
|
|
9757
9752
|
}, [props.showDndOverlay]);
|
|
9758
9753
|
React.useEffect(() => {
|
|
9759
9754
|
if (!dockviewRef.current) {
|
|
9760
|
-
return
|
|
9755
|
+
return () => {
|
|
9756
|
+
// noop
|
|
9757
|
+
};
|
|
9761
9758
|
}
|
|
9762
|
-
dockviewRef.current.
|
|
9763
|
-
|
|
9759
|
+
const disposable = dockviewRef.current.onWillDrop((event) => {
|
|
9760
|
+
if (props.onWillDrop) {
|
|
9761
|
+
props.onWillDrop(event);
|
|
9762
|
+
}
|
|
9764
9763
|
});
|
|
9765
|
-
|
|
9764
|
+
return () => {
|
|
9765
|
+
disposable.dispose();
|
|
9766
|
+
};
|
|
9767
|
+
}, [props.onWillDrop]);
|
|
9766
9768
|
React.useEffect(() => {
|
|
9767
9769
|
if (!dockviewRef.current) {
|
|
9768
9770
|
return;
|
|
9769
9771
|
}
|
|
9770
9772
|
dockviewRef.current.updateOptions({
|
|
9771
|
-
|
|
9773
|
+
createComponent: (options) => {
|
|
9774
|
+
return new ReactPanelContentPart(options.id, props.components[options.name], {
|
|
9775
|
+
addPortal,
|
|
9776
|
+
});
|
|
9777
|
+
},
|
|
9772
9778
|
});
|
|
9773
|
-
}, [props.
|
|
9779
|
+
}, [props.components]);
|
|
9774
9780
|
React.useEffect(() => {
|
|
9775
9781
|
var _a;
|
|
9776
9782
|
if (!dockviewRef.current) {
|
|
@@ -9785,39 +9791,49 @@ const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
9785
9791
|
defaultTabComponent: props.defaultTabComponent
|
|
9786
9792
|
? DEFAULT_REACT_TAB
|
|
9787
9793
|
: undefined,
|
|
9788
|
-
|
|
9794
|
+
createTabComponent(options) {
|
|
9795
|
+
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
|
|
9796
|
+
addPortal,
|
|
9797
|
+
});
|
|
9798
|
+
},
|
|
9789
9799
|
});
|
|
9790
|
-
}, [props.defaultTabComponent]);
|
|
9800
|
+
}, [props.tabComponents, props.defaultTabComponent]);
|
|
9791
9801
|
React.useEffect(() => {
|
|
9792
9802
|
if (!dockviewRef.current) {
|
|
9793
9803
|
return;
|
|
9794
9804
|
}
|
|
9795
9805
|
dockviewRef.current.updateOptions({
|
|
9796
|
-
|
|
9806
|
+
createWatermarkComponent: props.watermarkComponent
|
|
9807
|
+
? () => {
|
|
9808
|
+
return new ReactWatermarkPart('watermark', props.watermarkComponent, {
|
|
9809
|
+
addPortal,
|
|
9810
|
+
});
|
|
9811
|
+
}
|
|
9812
|
+
: undefined,
|
|
9797
9813
|
});
|
|
9798
|
-
}, [props.
|
|
9814
|
+
}, [props.watermarkComponent]);
|
|
9799
9815
|
React.useEffect(() => {
|
|
9800
9816
|
if (!dockviewRef.current) {
|
|
9801
9817
|
return;
|
|
9802
9818
|
}
|
|
9803
9819
|
dockviewRef.current.updateOptions({
|
|
9804
|
-
|
|
9820
|
+
createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
9805
9821
|
});
|
|
9806
|
-
}, [props.
|
|
9822
|
+
}, [props.rightHeaderActionsComponent]);
|
|
9807
9823
|
React.useEffect(() => {
|
|
9808
9824
|
if (!dockviewRef.current) {
|
|
9809
9825
|
return;
|
|
9810
9826
|
}
|
|
9811
9827
|
dockviewRef.current.updateOptions({
|
|
9812
|
-
|
|
9828
|
+
createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
9813
9829
|
});
|
|
9814
|
-
}, [props.
|
|
9830
|
+
}, [props.leftHeaderActionsComponent]);
|
|
9815
9831
|
React.useEffect(() => {
|
|
9816
9832
|
if (!dockviewRef.current) {
|
|
9817
9833
|
return;
|
|
9818
9834
|
}
|
|
9819
9835
|
dockviewRef.current.updateOptions({
|
|
9820
|
-
|
|
9836
|
+
createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
9821
9837
|
});
|
|
9822
9838
|
}, [props.prefixHeaderActionsComponent]);
|
|
9823
9839
|
return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
@@ -10157,6 +10173,7 @@ exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
|
|
|
10157
10173
|
exports.DockviewMutableDisposable = MutableDisposable;
|
|
10158
10174
|
exports.DockviewPanel = DockviewPanel;
|
|
10159
10175
|
exports.DockviewReact = DockviewReact;
|
|
10176
|
+
exports.DockviewUnhandledDragOverEvent = DockviewUnhandledDragOverEvent;
|
|
10160
10177
|
exports.DockviewWillDropEvent = DockviewWillDropEvent;
|
|
10161
10178
|
exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
|
|
10162
10179
|
exports.Gridview = Gridview;
|
|
@@ -10165,6 +10182,7 @@ exports.GridviewComponent = GridviewComponent;
|
|
|
10165
10182
|
exports.GridviewPanel = GridviewPanel;
|
|
10166
10183
|
exports.GridviewReact = GridviewReact;
|
|
10167
10184
|
exports.LocalSelectionTransfer = LocalSelectionTransfer;
|
|
10185
|
+
exports.PROPERTY_KEYS = PROPERTY_KEYS;
|
|
10168
10186
|
exports.PaneFramework = PaneFramework;
|
|
10169
10187
|
exports.PaneTransfer = PaneTransfer;
|
|
10170
10188
|
exports.PanelTransfer = PanelTransfer;
|