dockview-react 4.3.0 → 4.4.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 4.3.0
3
+ * @version 4.4.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -220,7 +220,10 @@ class Emitter {
220
220
  return this._event;
221
221
  }
222
222
  fire(e) {
223
- this._last = e;
223
+ var _a;
224
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) {
225
+ this._last = e;
226
+ }
224
227
  for (const listener of this._listeners) {
225
228
  listener.callback(e);
226
229
  }
@@ -3652,6 +3655,9 @@ class DockviewApi {
3652
3655
  get onDidPopoutGroupPositionChange() {
3653
3656
  return this.component.onDidPopoutGroupPositionChange;
3654
3657
  }
3658
+ get onDidOpenPopoutWindowFail() {
3659
+ return this.component.onDidOpenPopoutWindowFail;
3660
+ }
3655
3661
  /**
3656
3662
  * All panel objects.
3657
3663
  */
@@ -8231,9 +8237,11 @@ class DockviewComponent extends BaseGrid {
8231
8237
  this.onDidPopoutGroupSizeChange = this._onDidPopoutGroupSizeChange.event;
8232
8238
  this._onDidPopoutGroupPositionChange = new Emitter();
8233
8239
  this.onDidPopoutGroupPositionChange = this._onDidPopoutGroupPositionChange.event;
8240
+ this._onDidOpenPopoutWindowFail = new Emitter();
8241
+ this.onDidOpenPopoutWindowFail = this._onDidOpenPopoutWindowFail.event;
8234
8242
  this._onDidLayoutFromJSON = new Emitter();
8235
8243
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
8236
- this._onDidActivePanelChange = new Emitter();
8244
+ this._onDidActivePanelChange = new Emitter({ replay: true });
8237
8245
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
8238
8246
  this._onDidMovePanel = new Emitter();
8239
8247
  this.onDidMovePanel = this._onDidMovePanel.event;
@@ -8295,7 +8303,7 @@ class DockviewComponent extends BaseGrid {
8295
8303
  if (options.debug) {
8296
8304
  this.addDisposables(new StrictEventsSequencing(this));
8297
8305
  }
8298
- 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(() => {
8306
+ 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(() => {
8299
8307
  this.updateWatermark();
8300
8308
  }), this.onDidAdd((event) => {
8301
8309
  if (!this._moving) {
@@ -8441,13 +8449,6 @@ class DockviewComponent extends BaseGrid {
8441
8449
  if (_window.isDisposed) {
8442
8450
  return false;
8443
8451
  }
8444
- if (popoutContainer === null) {
8445
- popoutWindowDisposable.dispose();
8446
- return false;
8447
- }
8448
- const gready = document.createElement('div');
8449
- gready.className = 'dv-overlay-render-container';
8450
- const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8451
8452
  const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
8452
8453
  ? options.referenceGroup
8453
8454
  : itemToPopout instanceof DockviewPanel
@@ -8455,7 +8456,7 @@ class DockviewComponent extends BaseGrid {
8455
8456
  : itemToPopout;
8456
8457
  const referenceLocation = itemToPopout.api.location.type;
8457
8458
  /**
8458
- * The group that is being added doesn't already exist within the DOM, the most likely occurance
8459
+ * The group that is being added doesn't already exist within the DOM, the most likely occurrence
8459
8460
  * of this case is when being called from the `fromJSON(...)` method
8460
8461
  */
8461
8462
  const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
@@ -8468,8 +8469,28 @@ class DockviewComponent extends BaseGrid {
8468
8469
  }
8469
8470
  else {
8470
8471
  group = this.createGroup({ id: groupId });
8471
- this._onDidAddGroup.fire(group);
8472
+ if (popoutContainer) {
8473
+ this._onDidAddGroup.fire(group);
8474
+ }
8472
8475
  }
8476
+ if (popoutContainer === null) {
8477
+ console.error('dockview: failed to create popout. perhaps you need to allow pop-ups for this website');
8478
+ popoutWindowDisposable.dispose();
8479
+ this._onDidOpenPopoutWindowFail.fire();
8480
+ // if the popout window was blocked, we need to move the group back to the reference group
8481
+ // and set it to visible
8482
+ this.movingLock(() => moveGroupWithoutDestroying({
8483
+ from: group,
8484
+ to: referenceGroup,
8485
+ }));
8486
+ if (!referenceGroup.api.isVisible) {
8487
+ referenceGroup.api.setVisible(true);
8488
+ }
8489
+ return false;
8490
+ }
8491
+ const gready = document.createElement('div');
8492
+ gready.className = 'dv-overlay-render-container';
8493
+ const overlayRenderContainer = new OverlayRenderContainer(gready, this);
8473
8494
  group.model.renderContainer = overlayRenderContainer;
8474
8495
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
8475
8496
  let floatingBox;
@@ -8626,7 +8647,7 @@ class DockviewComponent extends BaseGrid {
8626
8647
  return true;
8627
8648
  })
8628
8649
  .catch((err) => {
8629
- console.error('dockview: failed to create popout window', err);
8650
+ console.error('dockview: failed to create popout.', err);
8630
8651
  return false;
8631
8652
  });
8632
8653
  }