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