dockview-core 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.
Files changed (33) hide show
  1. package/dist/cjs/api/component.api.d.ts +1 -0
  2. package/dist/cjs/api/component.api.js +7 -0
  3. package/dist/cjs/dockview/dockviewComponent.d.ts +3 -0
  4. package/dist/cjs/dockview/dockviewComponent.js +29 -12
  5. package/dist/cjs/events.js +7 -4
  6. package/dist/dockview-core.amd.js +35 -14
  7. package/dist/dockview-core.amd.js.map +1 -1
  8. package/dist/dockview-core.amd.min.js +2 -2
  9. package/dist/dockview-core.amd.min.js.map +1 -1
  10. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  11. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  12. package/dist/dockview-core.amd.noStyle.js +35 -14
  13. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  14. package/dist/dockview-core.cjs.js +35 -14
  15. package/dist/dockview-core.cjs.js.map +1 -1
  16. package/dist/dockview-core.esm.js +35 -14
  17. package/dist/dockview-core.esm.js.map +1 -1
  18. package/dist/dockview-core.esm.min.js +2 -2
  19. package/dist/dockview-core.esm.min.js.map +1 -1
  20. package/dist/dockview-core.js +35 -14
  21. package/dist/dockview-core.js.map +1 -1
  22. package/dist/dockview-core.min.js +2 -2
  23. package/dist/dockview-core.min.js.map +1 -1
  24. package/dist/dockview-core.min.noStyle.js +2 -2
  25. package/dist/dockview-core.min.noStyle.js.map +1 -1
  26. package/dist/dockview-core.noStyle.js +35 -14
  27. package/dist/dockview-core.noStyle.js.map +1 -1
  28. package/dist/esm/api/component.api.d.ts +1 -0
  29. package/dist/esm/api/component.api.js +3 -0
  30. package/dist/esm/dockview/dockviewComponent.d.ts +3 -0
  31. package/dist/esm/dockview/dockviewComponent.js +27 -12
  32. package/dist/esm/events.js +4 -1
  33. package/package.json +1 -1
@@ -419,6 +419,7 @@ export declare class DockviewApi implements CommonApi<SerializedDockview> {
419
419
  get onUnhandledDragOverEvent(): Event<DockviewDndOverlayEvent>;
420
420
  get onDidPopoutGroupSizeChange(): Event<PopoutGroupChangeSizeEvent>;
421
421
  get onDidPopoutGroupPositionChange(): Event<PopoutGroupChangePositionEvent>;
422
+ get onDidOpenPopoutWindowFail(): Event<void>;
422
423
  /**
423
424
  * All panel objects.
424
425
  */
@@ -574,6 +574,9 @@ export class DockviewApi {
574
574
  get onDidPopoutGroupPositionChange() {
575
575
  return this.component.onDidPopoutGroupPositionChange;
576
576
  }
577
+ get onDidOpenPopoutWindowFail() {
578
+ return this.component.onDidOpenPopoutWindowFail;
579
+ }
577
580
  /**
578
581
  * All panel objects.
579
582
  */
@@ -140,6 +140,7 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
140
140
  readonly onDidMaximizedGroupChange: Event<DockviewMaximizedGroupChanged>;
141
141
  readonly onDidPopoutGroupSizeChange: Event<PopoutGroupChangeSizeEvent>;
142
142
  readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent>;
143
+ readonly onDidOpenPopoutWindowFail: Event<void>;
143
144
  readonly options: DockviewComponentOptions;
144
145
  updateOptions(options: DockviewOptions): void;
145
146
  moveGroupOrPanel(options: MoveGroupOrPanelOptions): void;
@@ -202,6 +203,8 @@ export declare class DockviewComponent extends BaseGrid<DockviewGroupPanel> impl
202
203
  readonly onDidPopoutGroupSizeChange: Event<PopoutGroupChangeSizeEvent>;
203
204
  private readonly _onDidPopoutGroupPositionChange;
204
205
  readonly onDidPopoutGroupPositionChange: Event<PopoutGroupChangePositionEvent>;
206
+ private readonly _onDidOpenPopoutWindowFail;
207
+ readonly onDidOpenPopoutWindowFail: Event<void>;
205
208
  private readonly _onDidLayoutFromJSON;
206
209
  readonly onDidLayoutFromJSON: Event<void>;
207
210
  private readonly _onDidActivePanelChange;
@@ -109,9 +109,11 @@ export class DockviewComponent extends BaseGrid {
109
109
  this.onDidPopoutGroupSizeChange = this._onDidPopoutGroupSizeChange.event;
110
110
  this._onDidPopoutGroupPositionChange = new Emitter();
111
111
  this.onDidPopoutGroupPositionChange = this._onDidPopoutGroupPositionChange.event;
112
+ this._onDidOpenPopoutWindowFail = new Emitter();
113
+ this.onDidOpenPopoutWindowFail = this._onDidOpenPopoutWindowFail.event;
112
114
  this._onDidLayoutFromJSON = new Emitter();
113
115
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
114
- this._onDidActivePanelChange = new Emitter();
116
+ this._onDidActivePanelChange = new Emitter({ replay: true });
115
117
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
116
118
  this._onDidMovePanel = new Emitter();
117
119
  this.onDidMovePanel = this._onDidMovePanel.event;
@@ -173,7 +175,7 @@ export class DockviewComponent extends BaseGrid {
173
175
  if (options.debug) {
174
176
  this.addDisposables(new StrictEventsSequencing(this));
175
177
  }
176
- 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(() => {
178
+ 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(() => {
177
179
  this.updateWatermark();
178
180
  }), this.onDidAdd((event) => {
179
181
  if (!this._moving) {
@@ -319,13 +321,6 @@ export class DockviewComponent extends BaseGrid {
319
321
  if (_window.isDisposed) {
320
322
  return false;
321
323
  }
322
- if (popoutContainer === null) {
323
- popoutWindowDisposable.dispose();
324
- return false;
325
- }
326
- const gready = document.createElement('div');
327
- gready.className = 'dv-overlay-render-container';
328
- const overlayRenderContainer = new OverlayRenderContainer(gready, this);
329
324
  const referenceGroup = (options === null || options === void 0 ? void 0 : options.referenceGroup)
330
325
  ? options.referenceGroup
331
326
  : itemToPopout instanceof DockviewPanel
@@ -333,7 +328,7 @@ export class DockviewComponent extends BaseGrid {
333
328
  : itemToPopout;
334
329
  const referenceLocation = itemToPopout.api.location.type;
335
330
  /**
336
- * The group that is being added doesn't already exist within the DOM, the most likely occurance
331
+ * The group that is being added doesn't already exist within the DOM, the most likely occurrence
337
332
  * of this case is when being called from the `fromJSON(...)` method
338
333
  */
339
334
  const isGroupAddedToDom = referenceGroup.element.parentElement !== null;
@@ -346,8 +341,28 @@ export class DockviewComponent extends BaseGrid {
346
341
  }
347
342
  else {
348
343
  group = this.createGroup({ id: groupId });
349
- this._onDidAddGroup.fire(group);
344
+ if (popoutContainer) {
345
+ this._onDidAddGroup.fire(group);
346
+ }
350
347
  }
348
+ if (popoutContainer === null) {
349
+ console.error('dockview: failed to create popout. perhaps you need to allow pop-ups for this website');
350
+ popoutWindowDisposable.dispose();
351
+ this._onDidOpenPopoutWindowFail.fire();
352
+ // if the popout window was blocked, we need to move the group back to the reference group
353
+ // and set it to visible
354
+ this.movingLock(() => moveGroupWithoutDestroying({
355
+ from: group,
356
+ to: referenceGroup,
357
+ }));
358
+ if (!referenceGroup.api.isVisible) {
359
+ referenceGroup.api.setVisible(true);
360
+ }
361
+ return false;
362
+ }
363
+ const gready = document.createElement('div');
364
+ gready.className = 'dv-overlay-render-container';
365
+ const overlayRenderContainer = new OverlayRenderContainer(gready, this);
351
366
  group.model.renderContainer = overlayRenderContainer;
352
367
  group.layout(_window.window.innerWidth, _window.window.innerHeight);
353
368
  let floatingBox;
@@ -504,7 +519,7 @@ export class DockviewComponent extends BaseGrid {
504
519
  return true;
505
520
  })
506
521
  .catch((err) => {
507
- console.error('dockview: failed to create popout window', err);
522
+ console.error('dockview: failed to create popout.', err);
508
523
  return false;
509
524
  });
510
525
  }
@@ -117,7 +117,10 @@ export class Emitter {
117
117
  return this._event;
118
118
  }
119
119
  fire(e) {
120
- this._last = e;
120
+ var _a;
121
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) {
122
+ this._last = e;
123
+ }
121
124
  for (const listener of this._listeners) {
122
125
  listener.callback(e);
123
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dockview-core",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "Zero dependency layout manager supporting tabs, grids and splitviews",
5
5
  "keywords": [
6
6
  "splitview",