dockview-react 4.3.1 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 4.3.1
3
+ * @version 4.4.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -3655,6 +3655,9 @@ class DockviewApi {
3655
3655
  get onDidPopoutGroupPositionChange() {
3656
3656
  return this.component.onDidPopoutGroupPositionChange;
3657
3657
  }
3658
+ get onDidOpenPopoutWindowFail() {
3659
+ return this.component.onDidOpenPopoutWindowFail;
3660
+ }
3658
3661
  /**
3659
3662
  * All panel objects.
3660
3663
  */
@@ -5023,7 +5026,7 @@ class Tab extends CompositeDisposable {
5023
5026
  this._element = document.createElement('div');
5024
5027
  this._element.className = 'dv-tab';
5025
5028
  this._element.tabIndex = 0;
5026
- this._element.draggable = true;
5029
+ this._element.draggable = !this.accessor.options.disableDnd;
5027
5030
  toggleClass(this.element, 'dv-inactive-tab', true);
5028
5031
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5029
5032
  this.dropTarget = new Droptarget(this._element, {
@@ -5071,6 +5074,9 @@ class Tab extends CompositeDisposable {
5071
5074
  this.content = part;
5072
5075
  this._element.appendChild(this.content.element);
5073
5076
  }
5077
+ updateDragAndDropState() {
5078
+ this._element.draggable = !this.accessor.options.disableDnd;
5079
+ }
5074
5080
  dispose() {
5075
5081
  super.dispose();
5076
5082
  }
@@ -5142,7 +5148,7 @@ class VoidContainer extends CompositeDisposable {
5142
5148
  this.onDragStart = this._onDragStart.event;
5143
5149
  this._element = document.createElement('div');
5144
5150
  this._element.className = 'dv-void-container';
5145
- this._element.draggable = true;
5151
+ this._element.draggable = !this.accessor.options.disableDnd;
5146
5152
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5147
5153
  this.accessor.doSetGroupActive(this.group);
5148
5154
  }));
@@ -5165,6 +5171,9 @@ class VoidContainer extends CompositeDisposable {
5165
5171
  this._onDrop.fire(event);
5166
5172
  }), this.dropTarget);
5167
5173
  }
5174
+ updateDragAndDropState() {
5175
+ this._element.draggable = !this.accessor.options.disableDnd;
5176
+ }
5168
5177
  }
5169
5178
 
5170
5179
  class Scrollbar extends CompositeDisposable {
@@ -5425,6 +5434,11 @@ class Tabs extends CompositeDisposable {
5425
5434
  .map((x) => x.value.panel.id);
5426
5435
  this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
5427
5436
  }
5437
+ updateDragAndDropState() {
5438
+ for (const tab of this._tabs) {
5439
+ tab.value.updateDragAndDropState();
5440
+ }
5441
+ }
5428
5442
  }
5429
5443
 
5430
5444
  const createSvgElementFromPath = (params) => {
@@ -5697,6 +5711,10 @@ class TabsContainer extends CompositeDisposable {
5697
5711
  });
5698
5712
  }));
5699
5713
  }
5714
+ updateDragAndDropState() {
5715
+ this.tabs.updateDragAndDropState();
5716
+ this.voidContainer.updateDragAndDropState();
5717
+ }
5700
5718
  }
5701
5719
 
5702
5720
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -6402,6 +6420,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
6402
6420
  }));
6403
6421
  }
6404
6422
  }
6423
+ updateDragAndDropState() {
6424
+ this.tabsContainer.updateDragAndDropState();
6425
+ }
6405
6426
  dispose() {
6406
6427
  var _a, _b, _c;
6407
6428
  super.dispose();
@@ -8234,6 +8255,8 @@ class DockviewComponent extends BaseGrid {
8234
8255
  this.onDidPopoutGroupSizeChange = this._onDidPopoutGroupSizeChange.event;
8235
8256
  this._onDidPopoutGroupPositionChange = new Emitter();
8236
8257
  this.onDidPopoutGroupPositionChange = this._onDidPopoutGroupPositionChange.event;
8258
+ this._onDidOpenPopoutWindowFail = new Emitter();
8259
+ this.onDidOpenPopoutWindowFail = this._onDidOpenPopoutWindowFail.event;
8237
8260
  this._onDidLayoutFromJSON = new Emitter();
8238
8261
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
8239
8262
  this._onDidActivePanelChange = new Emitter({ replay: true });
@@ -8298,7 +8321,7 @@ class DockviewComponent extends BaseGrid {
8298
8321
  if (options.debug) {
8299
8322
  this.addDisposables(new StrictEventsSequencing(this));
8300
8323
  }
8301
- this.addDisposables(this.rootDropTargetContainer, 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._onDidMaximizedGroupChange, this._onDidOptionsChange, this._onDidPopoutGroupSizeChange, this._onDidPopoutGroupPositionChange, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
8324
+ this.addDisposables(this.rootDropTargetContainer, 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._onDidMaximizedGroupChange, this._onDidOptionsChange, this._onDidPopoutGroupSizeChange, this._onDidPopoutGroupPositionChange, this._onDidOpenPopoutWindowFail, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
8302
8325
  this.updateWatermark();
8303
8326
  }), this.onDidAdd((event) => {
8304
8327
  if (!this._moving) {
@@ -8444,13 +8467,6 @@ class DockviewComponent extends BaseGrid {
8444
8467
  if (_window.isDisposed) {
8445
8468
  return false;
8446
8469
  }
8447
- if (popoutContainer === null) {
8448
- popoutWindowDisposable.dispose();
8449
- return false;
8450
- }
8451
- const gready = document.createElement('div');
8452
- gready.className = 'dv-overlay-render-container';
8453
- const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8454
8470
  const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
8455
8471
  ? options.referenceGroup
8456
8472
  : itemToPopout instanceof DockviewPanel
@@ -8458,7 +8474,7 @@ class DockviewComponent extends BaseGrid {
8458
8474
  : itemToPopout;
8459
8475
  const referenceLocation = itemToPopout.api.location.type;
8460
8476
  /**
8461
- * The group that is being added doesn't already exist within the DOM, the most likely occurance
8477
+ * The group that is being added doesn't already exist within the DOM, the most likely occurrence
8462
8478
  * of this case is when being called from the `fromJSON(...)` method
8463
8479
  */
8464
8480
  const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
@@ -8471,8 +8487,28 @@ class DockviewComponent extends BaseGrid {
8471
8487
  }
8472
8488
  else {
8473
8489
  group = this.createGroup({ id: groupId });
8474
- this._onDidAddGroup.fire(group);
8490
+ if (popoutContainer) {
8491
+ this._onDidAddGroup.fire(group);
8492
+ }
8493
+ }
8494
+ if (popoutContainer === null) {
8495
+ console.error('dockview: failed to create popout. perhaps you need to allow pop-ups for this website');
8496
+ popoutWindowDisposable.dispose();
8497
+ this._onDidOpenPopoutWindowFail.fire();
8498
+ // if the popout window was blocked, we need to move the group back to the reference group
8499
+ // and set it to visible
8500
+ this.movingLock(() => moveGroupWithoutDestroying({
8501
+ from: group,
8502
+ to: referenceGroup,
8503
+ }));
8504
+ if (!referenceGroup.api.isVisible) {
8505
+ referenceGroup.api.setVisible(true);
8506
+ }
8507
+ return false;
8475
8508
  }
8509
+ const gready = document.createElement('div');
8510
+ gready.className = 'dv-overlay-render-container';
8511
+ const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8476
8512
  group.model.renderContainer = overlayRenderContainer;
8477
8513
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
8478
8514
  let floatingBox;
@@ -8629,7 +8665,7 @@ class DockviewComponent extends BaseGrid {
8629
8665
  return true;
8630
8666
  })
8631
8667
  .catch((err) => {
8632
- console.error('dockview: failed to create popout window', err);
8668
+ console.error('dockview: failed to create popout.', err);
8633
8669
  return false;
8634
8670
  });
8635
8671
  }
@@ -8836,7 +8872,12 @@ class DockviewComponent extends BaseGrid {
8836
8872
  }
8837
8873
  }
8838
8874
  this.updateDropTargetModel(options);
8875
+ const oldDisableDnd = this.options.disableDnd;
8839
8876
  this._options = Object.assign(Object.assign({}, this.options), options);
8877
+ const newDisableDnd = this.options.disableDnd;
8878
+ if (oldDisableDnd !== newDisableDnd) {
8879
+ this.updateDragAndDropState();
8880
+ }
8840
8881
  if ('theme' in options) {
8841
8882
  this.updateTheme();
8842
8883
  }
@@ -8851,6 +8892,12 @@ class DockviewComponent extends BaseGrid {
8851
8892
  }
8852
8893
  }
8853
8894
  }
8895
+ updateDragAndDropState() {
8896
+ // Update draggable state for all tabs and void containers
8897
+ for (const group of this.groups) {
8898
+ group.model.updateDragAndDropState();
8899
+ }
8900
+ }
8854
8901
  focus() {
8855
8902
  var _a;
8856
8903
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();