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
  */
@@ -3626,6 +3626,9 @@
3626
3626
  get onDidPopoutGroupPositionChange() {
3627
3627
  return this.component.onDidPopoutGroupPositionChange;
3628
3628
  }
3629
+ get onDidOpenPopoutWindowFail() {
3630
+ return this.component.onDidOpenPopoutWindowFail;
3631
+ }
3629
3632
  /**
3630
3633
  * All panel objects.
3631
3634
  */
@@ -4994,7 +4997,7 @@
4994
4997
  this._element = document.createElement('div');
4995
4998
  this._element.className = 'dv-tab';
4996
4999
  this._element.tabIndex = 0;
4997
- this._element.draggable = true;
5000
+ this._element.draggable = !this.accessor.options.disableDnd;
4998
5001
  toggleClass(this.element, 'dv-inactive-tab', true);
4999
5002
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5000
5003
  this.dropTarget = new Droptarget(this._element, {
@@ -5042,6 +5045,9 @@
5042
5045
  this.content = part;
5043
5046
  this._element.appendChild(this.content.element);
5044
5047
  }
5048
+ updateDragAndDropState() {
5049
+ this._element.draggable = !this.accessor.options.disableDnd;
5050
+ }
5045
5051
  dispose() {
5046
5052
  super.dispose();
5047
5053
  }
@@ -5113,7 +5119,7 @@
5113
5119
  this.onDragStart = this._onDragStart.event;
5114
5120
  this._element = document.createElement('div');
5115
5121
  this._element.className = 'dv-void-container';
5116
- this._element.draggable = true;
5122
+ this._element.draggable = !this.accessor.options.disableDnd;
5117
5123
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5118
5124
  this.accessor.doSetGroupActive(this.group);
5119
5125
  }));
@@ -5136,6 +5142,9 @@
5136
5142
  this._onDrop.fire(event);
5137
5143
  }), this.dropTarget);
5138
5144
  }
5145
+ updateDragAndDropState() {
5146
+ this._element.draggable = !this.accessor.options.disableDnd;
5147
+ }
5139
5148
  }
5140
5149
 
5141
5150
  class Scrollbar extends CompositeDisposable {
@@ -5396,6 +5405,11 @@
5396
5405
  .map((x) => x.value.panel.id);
5397
5406
  this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
5398
5407
  }
5408
+ updateDragAndDropState() {
5409
+ for (const tab of this._tabs) {
5410
+ tab.value.updateDragAndDropState();
5411
+ }
5412
+ }
5399
5413
  }
5400
5414
 
5401
5415
  const createSvgElementFromPath = (params) => {
@@ -5668,6 +5682,10 @@
5668
5682
  });
5669
5683
  }));
5670
5684
  }
5685
+ updateDragAndDropState() {
5686
+ this.tabs.updateDragAndDropState();
5687
+ this.voidContainer.updateDragAndDropState();
5688
+ }
5671
5689
  }
5672
5690
 
5673
5691
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -6373,6 +6391,9 @@
6373
6391
  }));
6374
6392
  }
6375
6393
  }
6394
+ updateDragAndDropState() {
6395
+ this.tabsContainer.updateDragAndDropState();
6396
+ }
6376
6397
  dispose() {
6377
6398
  var _a, _b, _c;
6378
6399
  super.dispose();
@@ -8205,6 +8226,8 @@
8205
8226
  this.onDidPopoutGroupSizeChange = this._onDidPopoutGroupSizeChange.event;
8206
8227
  this._onDidPopoutGroupPositionChange = new Emitter();
8207
8228
  this.onDidPopoutGroupPositionChange = this._onDidPopoutGroupPositionChange.event;
8229
+ this._onDidOpenPopoutWindowFail = new Emitter();
8230
+ this.onDidOpenPopoutWindowFail = this._onDidOpenPopoutWindowFail.event;
8208
8231
  this._onDidLayoutFromJSON = new Emitter();
8209
8232
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
8210
8233
  this._onDidActivePanelChange = new Emitter({ replay: true });
@@ -8269,7 +8292,7 @@
8269
8292
  if (options.debug) {
8270
8293
  this.addDisposables(new StrictEventsSequencing(this));
8271
8294
  }
8272
- 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(() => {
8295
+ 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(() => {
8273
8296
  this.updateWatermark();
8274
8297
  }), this.onDidAdd((event) => {
8275
8298
  if (!this._moving) {
@@ -8415,13 +8438,6 @@
8415
8438
  if (_window.isDisposed) {
8416
8439
  return false;
8417
8440
  }
8418
- if (popoutContainer === null) {
8419
- popoutWindowDisposable.dispose();
8420
- return false;
8421
- }
8422
- const gready = document.createElement('div');
8423
- gready.className = 'dv-overlay-render-container';
8424
- const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8425
8441
  const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
8426
8442
  ? options.referenceGroup
8427
8443
  : itemToPopout instanceof DockviewPanel
@@ -8429,7 +8445,7 @@
8429
8445
  : itemToPopout;
8430
8446
  const referenceLocation = itemToPopout.api.location.type;
8431
8447
  /**
8432
- * The group that is being added doesn't already exist within the DOM, the most likely occurance
8448
+ * The group that is being added doesn't already exist within the DOM, the most likely occurrence
8433
8449
  * of this case is when being called from the `fromJSON(...)` method
8434
8450
  */
8435
8451
  const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
@@ -8442,8 +8458,28 @@
8442
8458
  }
8443
8459
  else {
8444
8460
  group = this.createGroup({ id: groupId });
8445
- this._onDidAddGroup.fire(group);
8461
+ if (popoutContainer) {
8462
+ this._onDidAddGroup.fire(group);
8463
+ }
8464
+ }
8465
+ if (popoutContainer === null) {
8466
+ console.error('dockview: failed to create popout. perhaps you need to allow pop-ups for this website');
8467
+ popoutWindowDisposable.dispose();
8468
+ this._onDidOpenPopoutWindowFail.fire();
8469
+ // if the popout window was blocked, we need to move the group back to the reference group
8470
+ // and set it to visible
8471
+ this.movingLock(() => moveGroupWithoutDestroying({
8472
+ from: group,
8473
+ to: referenceGroup,
8474
+ }));
8475
+ if (!referenceGroup.api.isVisible) {
8476
+ referenceGroup.api.setVisible(true);
8477
+ }
8478
+ return false;
8446
8479
  }
8480
+ const gready = document.createElement('div');
8481
+ gready.className = 'dv-overlay-render-container';
8482
+ const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8447
8483
  group.model.renderContainer = overlayRenderContainer;
8448
8484
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
8449
8485
  let floatingBox;
@@ -8600,7 +8636,7 @@
8600
8636
  return true;
8601
8637
  })
8602
8638
  .catch((err) => {
8603
- console.error('dockview: failed to create popout window', err);
8639
+ console.error('dockview: failed to create popout.', err);
8604
8640
  return false;
8605
8641
  });
8606
8642
  }
@@ -8807,7 +8843,12 @@
8807
8843
  }
8808
8844
  }
8809
8845
  this.updateDropTargetModel(options);
8846
+ const oldDisableDnd = this.options.disableDnd;
8810
8847
  this._options = Object.assign(Object.assign({}, this.options), options);
8848
+ const newDisableDnd = this.options.disableDnd;
8849
+ if (oldDisableDnd !== newDisableDnd) {
8850
+ this.updateDragAndDropState();
8851
+ }
8811
8852
  if ('theme' in options) {
8812
8853
  this.updateTheme();
8813
8854
  }
@@ -8822,6 +8863,12 @@
8822
8863
  }
8823
8864
  }
8824
8865
  }
8866
+ updateDragAndDropState() {
8867
+ // Update draggable state for all tabs and void containers
8868
+ for (const group of this.groups) {
8869
+ group.model.updateDragAndDropState();
8870
+ }
8871
+ }
8825
8872
  focus() {
8826
8873
  var _a;
8827
8874
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();