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