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