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
  */
@@ -3653,6 +3653,9 @@ class DockviewApi {
3653
3653
  get onDidPopoutGroupPositionChange() {
3654
3654
  return this.component.onDidPopoutGroupPositionChange;
3655
3655
  }
3656
+ get onDidOpenPopoutWindowFail() {
3657
+ return this.component.onDidOpenPopoutWindowFail;
3658
+ }
3656
3659
  /**
3657
3660
  * All panel objects.
3658
3661
  */
@@ -5021,7 +5024,7 @@ class Tab extends CompositeDisposable {
5021
5024
  this._element = document.createElement('div');
5022
5025
  this._element.className = 'dv-tab';
5023
5026
  this._element.tabIndex = 0;
5024
- this._element.draggable = true;
5027
+ this._element.draggable = !this.accessor.options.disableDnd;
5025
5028
  toggleClass(this.element, 'dv-inactive-tab', true);
5026
5029
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5027
5030
  this.dropTarget = new Droptarget(this._element, {
@@ -5069,6 +5072,9 @@ class Tab extends CompositeDisposable {
5069
5072
  this.content = part;
5070
5073
  this._element.appendChild(this.content.element);
5071
5074
  }
5075
+ updateDragAndDropState() {
5076
+ this._element.draggable = !this.accessor.options.disableDnd;
5077
+ }
5072
5078
  dispose() {
5073
5079
  super.dispose();
5074
5080
  }
@@ -5140,7 +5146,7 @@ class VoidContainer extends CompositeDisposable {
5140
5146
  this.onDragStart = this._onDragStart.event;
5141
5147
  this._element = document.createElement('div');
5142
5148
  this._element.className = 'dv-void-container';
5143
- this._element.draggable = true;
5149
+ this._element.draggable = !this.accessor.options.disableDnd;
5144
5150
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5145
5151
  this.accessor.doSetGroupActive(this.group);
5146
5152
  }));
@@ -5163,6 +5169,9 @@ class VoidContainer extends CompositeDisposable {
5163
5169
  this._onDrop.fire(event);
5164
5170
  }), this.dropTarget);
5165
5171
  }
5172
+ updateDragAndDropState() {
5173
+ this._element.draggable = !this.accessor.options.disableDnd;
5174
+ }
5166
5175
  }
5167
5176
 
5168
5177
  class Scrollbar extends CompositeDisposable {
@@ -5423,6 +5432,11 @@ class Tabs extends CompositeDisposable {
5423
5432
  .map((x) => x.value.panel.id);
5424
5433
  this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
5425
5434
  }
5435
+ updateDragAndDropState() {
5436
+ for (const tab of this._tabs) {
5437
+ tab.value.updateDragAndDropState();
5438
+ }
5439
+ }
5426
5440
  }
5427
5441
 
5428
5442
  const createSvgElementFromPath = (params) => {
@@ -5695,6 +5709,10 @@ class TabsContainer extends CompositeDisposable {
5695
5709
  });
5696
5710
  }));
5697
5711
  }
5712
+ updateDragAndDropState() {
5713
+ this.tabs.updateDragAndDropState();
5714
+ this.voidContainer.updateDragAndDropState();
5715
+ }
5698
5716
  }
5699
5717
 
5700
5718
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -6400,6 +6418,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
6400
6418
  }));
6401
6419
  }
6402
6420
  }
6421
+ updateDragAndDropState() {
6422
+ this.tabsContainer.updateDragAndDropState();
6423
+ }
6403
6424
  dispose() {
6404
6425
  var _a, _b, _c;
6405
6426
  super.dispose();
@@ -8232,6 +8253,8 @@ class DockviewComponent extends BaseGrid {
8232
8253
  this.onDidPopoutGroupSizeChange = this._onDidPopoutGroupSizeChange.event;
8233
8254
  this._onDidPopoutGroupPositionChange = new Emitter();
8234
8255
  this.onDidPopoutGroupPositionChange = this._onDidPopoutGroupPositionChange.event;
8256
+ this._onDidOpenPopoutWindowFail = new Emitter();
8257
+ this.onDidOpenPopoutWindowFail = this._onDidOpenPopoutWindowFail.event;
8235
8258
  this._onDidLayoutFromJSON = new Emitter();
8236
8259
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
8237
8260
  this._onDidActivePanelChange = new Emitter({ replay: true });
@@ -8296,7 +8319,7 @@ class DockviewComponent extends BaseGrid {
8296
8319
  if (options.debug) {
8297
8320
  this.addDisposables(new StrictEventsSequencing(this));
8298
8321
  }
8299
- 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(() => {
8322
+ 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(() => {
8300
8323
  this.updateWatermark();
8301
8324
  }), this.onDidAdd((event) => {
8302
8325
  if (!this._moving) {
@@ -8442,13 +8465,6 @@ class DockviewComponent extends BaseGrid {
8442
8465
  if (_window.isDisposed) {
8443
8466
  return false;
8444
8467
  }
8445
- if (popoutContainer === null) {
8446
- popoutWindowDisposable.dispose();
8447
- return false;
8448
- }
8449
- const gready = document.createElement('div');
8450
- gready.className = 'dv-overlay-render-container';
8451
- const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8452
8468
  const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
8453
8469
  ? options.referenceGroup
8454
8470
  : itemToPopout instanceof DockviewPanel
@@ -8456,7 +8472,7 @@ class DockviewComponent extends BaseGrid {
8456
8472
  : itemToPopout;
8457
8473
  const referenceLocation = itemToPopout.api.location.type;
8458
8474
  /**
8459
- * The group that is being added doesn't already exist within the DOM, the most likely occurance
8475
+ * The group that is being added doesn't already exist within the DOM, the most likely occurrence
8460
8476
  * of this case is when being called from the `fromJSON(...)` method
8461
8477
  */
8462
8478
  const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
@@ -8469,8 +8485,28 @@ class DockviewComponent extends BaseGrid {
8469
8485
  }
8470
8486
  else {
8471
8487
  group = this.createGroup({ id: groupId });
8472
- this._onDidAddGroup.fire(group);
8488
+ if (popoutContainer) {
8489
+ this._onDidAddGroup.fire(group);
8490
+ }
8491
+ }
8492
+ if (popoutContainer === null) {
8493
+ console.error('dockview: failed to create popout. perhaps you need to allow pop-ups for this website');
8494
+ popoutWindowDisposable.dispose();
8495
+ this._onDidOpenPopoutWindowFail.fire();
8496
+ // if the popout window was blocked, we need to move the group back to the reference group
8497
+ // and set it to visible
8498
+ this.movingLock(() => moveGroupWithoutDestroying({
8499
+ from: group,
8500
+ to: referenceGroup,
8501
+ }));
8502
+ if (!referenceGroup.api.isVisible) {
8503
+ referenceGroup.api.setVisible(true);
8504
+ }
8505
+ return false;
8473
8506
  }
8507
+ const gready = document.createElement('div');
8508
+ gready.className = 'dv-overlay-render-container';
8509
+ const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8474
8510
  group.model.renderContainer = overlayRenderContainer;
8475
8511
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
8476
8512
  let floatingBox;
@@ -8627,7 +8663,7 @@ class DockviewComponent extends BaseGrid {
8627
8663
  return true;
8628
8664
  })
8629
8665
  .catch((err) => {
8630
- console.error('dockview: failed to create popout window', err);
8666
+ console.error('dockview: failed to create popout.', err);
8631
8667
  return false;
8632
8668
  });
8633
8669
  }
@@ -8834,7 +8870,12 @@ class DockviewComponent extends BaseGrid {
8834
8870
  }
8835
8871
  }
8836
8872
  this.updateDropTargetModel(options);
8873
+ const oldDisableDnd = this.options.disableDnd;
8837
8874
  this._options = Object.assign(Object.assign({}, this.options), options);
8875
+ const newDisableDnd = this.options.disableDnd;
8876
+ if (oldDisableDnd !== newDisableDnd) {
8877
+ this.updateDragAndDropState();
8878
+ }
8838
8879
  if ('theme' in options) {
8839
8880
  this.updateTheme();
8840
8881
  }
@@ -8849,6 +8890,12 @@ class DockviewComponent extends BaseGrid {
8849
8890
  }
8850
8891
  }
8851
8892
  }
8893
+ updateDragAndDropState() {
8894
+ // Update draggable state for all tabs and void containers
8895
+ for (const group of this.groups) {
8896
+ group.model.updateDragAndDropState();
8897
+ }
8898
+ }
8852
8899
  focus() {
8853
8900
  var _a;
8854
8901
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();