dockview-core 1.8.2 → 1.8.4

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 (187) hide show
  1. package/dist/cjs/api/component.api.d.ts +8 -4
  2. package/dist/cjs/api/component.api.d.ts.map +1 -1
  3. package/dist/cjs/api/component.api.js +14 -0
  4. package/dist/cjs/api/component.api.js.map +1 -1
  5. package/dist/cjs/dnd/abstractDragHandler.d.ts +2 -2
  6. package/dist/cjs/dnd/abstractDragHandler.d.ts.map +1 -1
  7. package/dist/cjs/dnd/abstractDragHandler.js +16 -12
  8. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  9. package/dist/cjs/dnd/groupDragHandler.d.ts +4 -3
  10. package/dist/cjs/dnd/groupDragHandler.d.ts.map +1 -1
  11. package/dist/cjs/dnd/groupDragHandler.js +5 -4
  12. package/dist/cjs/dnd/groupDragHandler.js.map +1 -1
  13. package/dist/cjs/dnd/overlay.d.ts +6 -2
  14. package/dist/cjs/dnd/overlay.d.ts.map +1 -1
  15. package/dist/cjs/dnd/overlay.js +54 -23
  16. package/dist/cjs/dnd/overlay.js.map +1 -1
  17. package/dist/cjs/dockview/components/tab/tab.d.ts +7 -4
  18. package/dist/cjs/dockview/components/tab/tab.d.ts.map +1 -1
  19. package/dist/cjs/dockview/components/tab/tab.js +36 -28
  20. package/dist/cjs/dockview/components/tab/tab.js.map +1 -1
  21. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +19 -1
  22. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  23. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +42 -15
  24. package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
  25. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +2 -0
  26. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts.map +1 -1
  27. package/dist/cjs/dockview/components/titlebar/voidContainer.js +7 -3
  28. package/dist/cjs/dockview/components/titlebar/voidContainer.js.map +1 -1
  29. package/dist/cjs/dockview/dockviewComponent.d.ts +11 -4
  30. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  31. package/dist/cjs/dockview/dockviewComponent.js +288 -92
  32. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  33. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +4 -4
  34. package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -1
  35. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  36. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +11 -4
  37. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  38. package/dist/cjs/dockview/dockviewGroupPanelModel.js +28 -6
  39. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  40. package/dist/cjs/dockview/dockviewPanel.d.ts +1 -1
  41. package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -1
  42. package/dist/cjs/dockview/options.d.ts +9 -5
  43. package/dist/cjs/dockview/options.d.ts.map +1 -1
  44. package/dist/cjs/dockview/options.js.map +1 -1
  45. package/dist/cjs/gridview/baseComponentGridview.d.ts +1 -1
  46. package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -1
  47. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  48. package/dist/cjs/gridview/basePanelView.d.ts +4 -4
  49. package/dist/cjs/gridview/basePanelView.d.ts.map +1 -1
  50. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  51. package/dist/cjs/gridview/branchNode.d.ts.map +1 -1
  52. package/dist/cjs/gridview/branchNode.js +1 -0
  53. package/dist/cjs/gridview/branchNode.js.map +1 -1
  54. package/dist/cjs/gridview/gridview.d.ts.map +1 -1
  55. package/dist/cjs/gridview/gridview.js +8 -0
  56. package/dist/cjs/gridview/gridview.js.map +1 -1
  57. package/dist/cjs/gridview/gridviewComponent.d.ts +4 -4
  58. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
  59. package/dist/cjs/gridview/gridviewComponent.js +71 -39
  60. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  61. package/dist/cjs/index.d.ts +1 -0
  62. package/dist/cjs/index.d.ts.map +1 -1
  63. package/dist/cjs/index.js.map +1 -1
  64. package/dist/cjs/lifecycle.d.ts +0 -1
  65. package/dist/cjs/lifecycle.d.ts.map +1 -1
  66. package/dist/cjs/lifecycle.js +0 -32
  67. package/dist/cjs/lifecycle.js.map +1 -1
  68. package/dist/cjs/panel/types.d.ts +2 -2
  69. package/dist/cjs/panel/types.d.ts.map +1 -1
  70. package/dist/cjs/paneview/paneviewComponent.d.ts +5 -6
  71. package/dist/cjs/paneview/paneviewComponent.d.ts.map +1 -1
  72. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  73. package/dist/cjs/resizable.d.ts.map +1 -1
  74. package/dist/cjs/resizable.js +8 -0
  75. package/dist/cjs/resizable.js.map +1 -1
  76. package/dist/cjs/splitview/splitview.d.ts.map +1 -1
  77. package/dist/cjs/splitview/splitview.js +11 -1
  78. package/dist/cjs/splitview/splitview.js.map +1 -1
  79. package/dist/cjs/splitview/splitviewComponent.d.ts +4 -4
  80. package/dist/cjs/splitview/splitviewComponent.d.ts.map +1 -1
  81. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  82. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -1
  83. package/dist/dockview-core.amd.js +411 -186
  84. package/dist/dockview-core.amd.js.map +1 -1
  85. package/dist/dockview-core.amd.min.js +2 -2
  86. package/dist/dockview-core.amd.min.js.map +1 -1
  87. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  88. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  89. package/dist/dockview-core.amd.noStyle.js +411 -186
  90. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  91. package/dist/dockview-core.cjs.js +411 -186
  92. package/dist/dockview-core.cjs.js.map +1 -1
  93. package/dist/dockview-core.esm.js +411 -186
  94. package/dist/dockview-core.esm.js.map +1 -1
  95. package/dist/dockview-core.esm.min.js +2 -2
  96. package/dist/dockview-core.esm.min.js.map +1 -1
  97. package/dist/dockview-core.js +411 -186
  98. package/dist/dockview-core.js.map +1 -1
  99. package/dist/dockview-core.min.js +2 -2
  100. package/dist/dockview-core.min.js.map +1 -1
  101. package/dist/dockview-core.min.noStyle.js +2 -2
  102. package/dist/dockview-core.min.noStyle.js.map +1 -1
  103. package/dist/dockview-core.noStyle.js +411 -186
  104. package/dist/dockview-core.noStyle.js.map +1 -1
  105. package/dist/esm/api/component.api.d.ts +8 -4
  106. package/dist/esm/api/component.api.d.ts.map +1 -1
  107. package/dist/esm/api/component.api.js +6 -0
  108. package/dist/esm/api/component.api.js.map +1 -1
  109. package/dist/esm/dnd/abstractDragHandler.d.ts +2 -2
  110. package/dist/esm/dnd/abstractDragHandler.d.ts.map +1 -1
  111. package/dist/esm/dnd/abstractDragHandler.js +16 -12
  112. package/dist/esm/dnd/abstractDragHandler.js.map +1 -1
  113. package/dist/esm/dnd/groupDragHandler.d.ts +4 -3
  114. package/dist/esm/dnd/groupDragHandler.d.ts.map +1 -1
  115. package/dist/esm/dnd/groupDragHandler.js +5 -4
  116. package/dist/esm/dnd/groupDragHandler.js.map +1 -1
  117. package/dist/esm/dnd/overlay.d.ts +6 -2
  118. package/dist/esm/dnd/overlay.d.ts.map +1 -1
  119. package/dist/esm/dnd/overlay.js +46 -23
  120. package/dist/esm/dnd/overlay.js.map +1 -1
  121. package/dist/esm/dockview/components/tab/tab.d.ts +7 -4
  122. package/dist/esm/dockview/components/tab/tab.d.ts.map +1 -1
  123. package/dist/esm/dockview/components/tab/tab.js +32 -24
  124. package/dist/esm/dockview/components/tab/tab.js.map +1 -1
  125. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +19 -1
  126. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  127. package/dist/esm/dockview/components/titlebar/tabsContainer.js +42 -15
  128. package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -1
  129. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +2 -0
  130. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts.map +1 -1
  131. package/dist/esm/dockview/components/titlebar/voidContainer.js +7 -3
  132. package/dist/esm/dockview/components/titlebar/voidContainer.js.map +1 -1
  133. package/dist/esm/dockview/dockviewComponent.d.ts +11 -4
  134. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  135. package/dist/esm/dockview/dockviewComponent.js +204 -59
  136. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  137. package/dist/esm/dockview/dockviewGroupPanel.d.ts +4 -4
  138. package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -1
  139. package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -1
  140. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +11 -4
  141. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  142. package/dist/esm/dockview/dockviewGroupPanelModel.js +28 -6
  143. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  144. package/dist/esm/dockview/dockviewPanel.d.ts +1 -1
  145. package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -1
  146. package/dist/esm/dockview/options.d.ts +9 -5
  147. package/dist/esm/dockview/options.d.ts.map +1 -1
  148. package/dist/esm/dockview/options.js.map +1 -1
  149. package/dist/esm/gridview/baseComponentGridview.d.ts +1 -1
  150. package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -1
  151. package/dist/esm/gridview/baseComponentGridview.js.map +1 -1
  152. package/dist/esm/gridview/basePanelView.d.ts +4 -4
  153. package/dist/esm/gridview/basePanelView.d.ts.map +1 -1
  154. package/dist/esm/gridview/basePanelView.js.map +1 -1
  155. package/dist/esm/gridview/branchNode.d.ts.map +1 -1
  156. package/dist/esm/gridview/branchNode.js +1 -0
  157. package/dist/esm/gridview/branchNode.js.map +1 -1
  158. package/dist/esm/gridview/gridview.d.ts.map +1 -1
  159. package/dist/esm/gridview/gridview.js +8 -0
  160. package/dist/esm/gridview/gridview.js.map +1 -1
  161. package/dist/esm/gridview/gridviewComponent.d.ts +4 -4
  162. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
  163. package/dist/esm/gridview/gridviewComponent.js +56 -35
  164. package/dist/esm/gridview/gridviewComponent.js.map +1 -1
  165. package/dist/esm/index.d.ts +1 -0
  166. package/dist/esm/index.d.ts.map +1 -1
  167. package/dist/esm/index.js.map +1 -1
  168. package/dist/esm/lifecycle.d.ts +0 -1
  169. package/dist/esm/lifecycle.d.ts.map +1 -1
  170. package/dist/esm/lifecycle.js +0 -3
  171. package/dist/esm/lifecycle.js.map +1 -1
  172. package/dist/esm/panel/types.d.ts +2 -2
  173. package/dist/esm/panel/types.d.ts.map +1 -1
  174. package/dist/esm/paneview/paneviewComponent.d.ts +5 -6
  175. package/dist/esm/paneview/paneviewComponent.d.ts.map +1 -1
  176. package/dist/esm/paneview/paneviewComponent.js.map +1 -1
  177. package/dist/esm/resizable.d.ts.map +1 -1
  178. package/dist/esm/resizable.js +8 -0
  179. package/dist/esm/resizable.js.map +1 -1
  180. package/dist/esm/splitview/splitview.d.ts.map +1 -1
  181. package/dist/esm/splitview/splitview.js +11 -1
  182. package/dist/esm/splitview/splitview.js.map +1 -1
  183. package/dist/esm/splitview/splitviewComponent.d.ts +4 -4
  184. package/dist/esm/splitview/splitviewComponent.d.ts.map +1 -1
  185. package/dist/esm/splitview/splitviewComponent.js.map +1 -1
  186. package/dist/esm/splitview/splitviewPanel.d.ts +1 -1
  187. package/package.json +3 -4
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.8.2
3
+ * @version 1.8.4
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -270,9 +270,6 @@ class CompositeDisposable {
270
270
  get isDisposed() {
271
271
  return this._isDisposed;
272
272
  }
273
- static from(...args) {
274
- return new CompositeDisposable(...args);
275
- }
276
273
  constructor(...args) {
277
274
  this._isDisposed = false;
278
275
  this._disposables = args;
@@ -901,7 +898,17 @@ class Splitview {
901
898
  size = typeof size === 'number' ? size : item.size;
902
899
  size = clamp(size, item.minimumSize, item.maximumSize);
903
900
  item.size = size;
904
- this.relayout([index]);
901
+ const indexes = range(this.viewItems.length).filter((i) => i !== index);
902
+ const lowPriorityIndexes = [
903
+ ...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
904
+ index,
905
+ ];
906
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
907
+ /**
908
+ * add this view we are changing to the low-index list since we have determined the size
909
+ * here and don't want it changed
910
+ */
911
+ this.relayout([...lowPriorityIndexes, index], highPriorityIndexes);
905
912
  }
906
913
  addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
907
914
  const container = document.createElement('div');
@@ -1658,6 +1665,7 @@ class BranchNode extends CompositeDisposable {
1658
1665
  orientation: this.orientation,
1659
1666
  descriptor,
1660
1667
  proportionalLayout,
1668
+ styles,
1661
1669
  });
1662
1670
  }
1663
1671
  this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
@@ -2169,6 +2177,14 @@ class Gridview {
2169
2177
  const child = sibling.children[i];
2170
2178
  grandParent.addChild(child, child.size, parentIndex + i);
2171
2179
  }
2180
+ /**
2181
+ * clean down the branch node since we need to dipose of it and
2182
+ * when .dispose() it called on a branch it will dispose of any
2183
+ * views it is holding onto.
2184
+ */
2185
+ while (sibling.children.length > 0) {
2186
+ sibling.removeChild(0);
2187
+ }
2172
2188
  }
2173
2189
  else {
2174
2190
  // otherwise create a new leaf node and add that to the grandparent
@@ -2476,6 +2492,12 @@ class DockviewApi {
2476
2492
  get onDidDrop() {
2477
2493
  return this.component.onDidDrop;
2478
2494
  }
2495
+ get onWillDragGroup() {
2496
+ return this.component.onWillDragGroup;
2497
+ }
2498
+ get onWillDragPanel() {
2499
+ return this.component.onWillDragPanel;
2500
+ }
2479
2501
  get panels() {
2480
2502
  return this.component.panels;
2481
2503
  }
@@ -2938,7 +2960,7 @@ class DragHandler extends CompositeDisposable {
2938
2960
  }
2939
2961
  configure() {
2940
2962
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2941
- if (this.isCancelled(event)) {
2963
+ if (event.defaultPrevented || this.isCancelled(event)) {
2942
2964
  event.preventDefault();
2943
2965
  return;
2944
2966
  }
@@ -2958,19 +2980,23 @@ class DragHandler extends CompositeDisposable {
2958
2980
  }
2959
2981
  this.el.classList.add('dv-dragged');
2960
2982
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2961
- this.dataDisposable.value = this.getData(event.dataTransfer);
2983
+ this.dataDisposable.value = this.getData(event);
2984
+ this._onDragStart.fire(event);
2962
2985
  if (event.dataTransfer) {
2963
2986
  event.dataTransfer.effectAllowed = 'move';
2964
- /**
2965
- * Although this is not used by dockview many third party dnd libraries will check
2966
- * dataTransfer.types to determine valid drag events.
2967
- *
2968
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2969
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2970
- * dnd logic. You can see the code at
2971
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2972
- */
2973
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2987
+ const hasData = event.dataTransfer.items.length > 0;
2988
+ if (!hasData) {
2989
+ /**
2990
+ * Although this is not used by dockview many third party dnd libraries will check
2991
+ * dataTransfer.types to determine valid drag events.
2992
+ *
2993
+ * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2994
+ * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2995
+ * dnd logic. You can see the code at
2996
+ * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2997
+ */
2998
+ event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2999
+ }
2974
3000
  }
2975
3001
  }), addDisposableListener(this.el, 'dragend', () => {
2976
3002
  this.pointerEventsDisposable.dispose();
@@ -2979,44 +3005,45 @@ class DragHandler extends CompositeDisposable {
2979
3005
  }
2980
3006
  }
2981
3007
 
3008
+ class TabDragHandler extends DragHandler {
3009
+ constructor(element, accessor, group, panel) {
3010
+ super(element);
3011
+ this.accessor = accessor;
3012
+ this.group = group;
3013
+ this.panel = panel;
3014
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
3015
+ }
3016
+ getData(event) {
3017
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
3018
+ return {
3019
+ dispose: () => {
3020
+ this.panelTransfer.clearData(PanelTransfer.prototype);
3021
+ },
3022
+ };
3023
+ }
3024
+ }
2982
3025
  class Tab extends CompositeDisposable {
2983
3026
  get element() {
2984
3027
  return this._element;
2985
3028
  }
2986
- constructor(panelId, accessor, group) {
3029
+ constructor(panel, accessor, group) {
2987
3030
  super();
2988
- this.panelId = panelId;
3031
+ this.panel = panel;
2989
3032
  this.accessor = accessor;
2990
3033
  this.group = group;
3034
+ this.content = undefined;
2991
3035
  this._onChanged = new Emitter();
2992
3036
  this.onChanged = this._onChanged.event;
2993
3037
  this._onDropped = new Emitter();
2994
3038
  this.onDrop = this._onDropped.event;
3039
+ this._onDragStart = new Emitter();
3040
+ this.onDragStart = this._onDragStart.event;
2995
3041
  this._element = document.createElement('div');
2996
3042
  this._element.className = 'tab';
2997
3043
  this._element.tabIndex = 0;
2998
3044
  this._element.draggable = true;
2999
3045
  toggleClass(this.element, 'inactive-tab', true);
3000
- this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
3001
- constructor() {
3002
- super(...arguments);
3003
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3004
- }
3005
- getData() {
3006
- this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
3007
- return {
3008
- dispose: () => {
3009
- this.panelTransfer.clearData(PanelTransfer.prototype);
3010
- },
3011
- };
3012
- }
3013
- })(this._element));
3014
- this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
3015
- if (event.defaultPrevented) {
3016
- return;
3017
- }
3018
- this._onChanged.fire(event);
3019
- }));
3046
+ const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3020
3047
  this.droptarget = new Droptarget(this._element, {
3021
3048
  acceptedTargetZones: ['center'],
3022
3049
  canDisplayOverlay: (event, position) => {
@@ -3030,12 +3057,19 @@ class Tab extends CompositeDisposable {
3030
3057
  // don't allow group move to drop on self
3031
3058
  return false;
3032
3059
  }
3033
- return this.panelId !== data.panelId;
3060
+ return this.panel.id !== data.panelId;
3034
3061
  }
3035
3062
  return this.group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Tab);
3036
3063
  },
3037
3064
  });
3038
- this.addDisposables(this.droptarget.onDrop((event) => {
3065
+ this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3066
+ this._onDragStart.fire(event);
3067
+ }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3068
+ if (event.defaultPrevented) {
3069
+ return;
3070
+ }
3071
+ this._onChanged.fire(event);
3072
+ }), this.droptarget.onDrop((event) => {
3039
3073
  this._onDropped.fire(event);
3040
3074
  }), this.droptarget);
3041
3075
  }
@@ -3067,9 +3101,9 @@ function addGhostImage(dataTransfer, ghostElement) {
3067
3101
  }
3068
3102
 
3069
3103
  class GroupDragHandler extends DragHandler {
3070
- constructor(element, accessorId, group) {
3104
+ constructor(element, accessor, group) {
3071
3105
  super(element);
3072
- this.accessorId = accessorId;
3106
+ this.accessor = accessor;
3073
3107
  this.group = group;
3074
3108
  this.panelTransfer = LocalSelectionTransfer.getInstance();
3075
3109
  this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
@@ -3089,8 +3123,9 @@ class GroupDragHandler extends DragHandler {
3089
3123
  }
3090
3124
  return false;
3091
3125
  }
3092
- getData(dataTransfer) {
3093
- this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
3126
+ getData(dragEvent) {
3127
+ const dataTransfer = dragEvent.dataTransfer;
3128
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3094
3129
  const style = window.getComputedStyle(this.el);
3095
3130
  const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3096
3131
  const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
@@ -3125,14 +3160,16 @@ class VoidContainer extends CompositeDisposable {
3125
3160
  this.group = group;
3126
3161
  this._onDrop = new Emitter();
3127
3162
  this.onDrop = this._onDrop.event;
3163
+ this._onDragStart = new Emitter();
3164
+ this.onDragStart = this._onDragStart.event;
3128
3165
  this._element = document.createElement('div');
3129
3166
  this._element.className = 'void-container';
3130
3167
  this._element.tabIndex = 0;
3131
3168
  this._element.draggable = true;
3132
- this.addDisposables(this._onDrop, addDisposableListener(this._element, 'click', () => {
3169
+ this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3133
3170
  this.accessor.doSetGroupActive(this.group);
3134
3171
  }));
3135
- const handler = new GroupDragHandler(this._element, accessor.id, group);
3172
+ const handler = new GroupDragHandler(this._element, accessor, group);
3136
3173
  this.voidDropTarget = new Droptarget(this._element, {
3137
3174
  acceptedTargetZones: ['center'],
3138
3175
  canDisplayOverlay: (event, position) => {
@@ -3150,7 +3187,9 @@ class VoidContainer extends CompositeDisposable {
3150
3187
  return group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3151
3188
  },
3152
3189
  });
3153
- this.addDisposables(handler, this.voidDropTarget.onDrop((event) => {
3190
+ this.addDisposables(handler, handler.onDragStart((event) => {
3191
+ this._onDragStart.fire(event);
3192
+ }), this.voidDropTarget.onDrop((event) => {
3154
3193
  this._onDrop.fire(event);
3155
3194
  }), this.voidDropTarget);
3156
3195
  }
@@ -3158,7 +3197,7 @@ class VoidContainer extends CompositeDisposable {
3158
3197
 
3159
3198
  class TabsContainer extends CompositeDisposable {
3160
3199
  get panels() {
3161
- return this.tabs.map((_) => _.value.panelId);
3200
+ return this.tabs.map((_) => _.value.panel.id);
3162
3201
  }
3163
3202
  get size() {
3164
3203
  return this.tabs.length;
@@ -3204,6 +3243,19 @@ class TabsContainer extends CompositeDisposable {
3204
3243
  this.leftActions = element;
3205
3244
  }
3206
3245
  }
3246
+ setPrefixActionsElement(element) {
3247
+ if (this.preActions === element) {
3248
+ return;
3249
+ }
3250
+ if (this.preActions) {
3251
+ this.preActions.remove();
3252
+ this.preActions = undefined;
3253
+ }
3254
+ if (element) {
3255
+ this.preActionsContainer.appendChild(element);
3256
+ this.preActions = element;
3257
+ }
3258
+ }
3207
3259
  get element() {
3208
3260
  return this._element;
3209
3261
  }
@@ -3212,7 +3264,7 @@ class TabsContainer extends CompositeDisposable {
3212
3264
  this.tabs[this.selectedIndex].value === tab);
3213
3265
  }
3214
3266
  indexOf(id) {
3215
- return this.tabs.findIndex((tab) => tab.value.panelId === id);
3267
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
3216
3268
  }
3217
3269
  constructor(accessor, group) {
3218
3270
  super();
@@ -3223,7 +3275,11 @@ class TabsContainer extends CompositeDisposable {
3223
3275
  this._hidden = false;
3224
3276
  this._onDrop = new Emitter();
3225
3277
  this.onDrop = this._onDrop.event;
3226
- this.addDisposables(this._onDrop);
3278
+ this._onTabDragStart = new Emitter();
3279
+ this.onTabDragStart = this._onTabDragStart.event;
3280
+ this._onGroupDragStart = new Emitter();
3281
+ this.onGroupDragStart = this._onGroupDragStart.event;
3282
+ this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3227
3283
  this._element = document.createElement('div');
3228
3284
  this._element.className = 'tabs-and-actions-container';
3229
3285
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
@@ -3240,14 +3296,22 @@ class TabsContainer extends CompositeDisposable {
3240
3296
  this.rightActionsContainer.className = 'right-actions-container';
3241
3297
  this.leftActionsContainer = document.createElement('div');
3242
3298
  this.leftActionsContainer.className = 'left-actions-container';
3299
+ this.preActionsContainer = document.createElement('div');
3300
+ this.preActionsContainer.className = 'pre-actions-container';
3243
3301
  this.tabContainer = document.createElement('div');
3244
3302
  this.tabContainer.className = 'tabs-container';
3245
3303
  this.voidContainer = new VoidContainer(this.accessor, this.group);
3304
+ this._element.appendChild(this.preActionsContainer);
3246
3305
  this._element.appendChild(this.tabContainer);
3247
3306
  this._element.appendChild(this.leftActionsContainer);
3248
3307
  this._element.appendChild(this.voidContainer.element);
3249
3308
  this._element.appendChild(this.rightActionsContainer);
3250
- this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
3309
+ this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
3310
+ this._onGroupDragStart.fire({
3311
+ nativeEvent: event,
3312
+ group: this.group,
3313
+ });
3314
+ }), this.voidContainer.onDrop((event) => {
3251
3315
  this._onDrop.fire({
3252
3316
  event: event.nativeEvent,
3253
3317
  index: this.tabs.length,
@@ -3293,7 +3357,7 @@ class TabsContainer extends CompositeDisposable {
3293
3357
  }
3294
3358
  }
3295
3359
  delete(id) {
3296
- const index = this.tabs.findIndex((tab) => tab.value.panelId === id);
3360
+ const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
3297
3361
  const tabToRemove = this.tabs.splice(index, 1)[0];
3298
3362
  const { value, disposable } = tabToRemove;
3299
3363
  disposable.dispose();
@@ -3302,21 +3366,23 @@ class TabsContainer extends CompositeDisposable {
3302
3366
  }
3303
3367
  setActivePanel(panel) {
3304
3368
  this.tabs.forEach((tab) => {
3305
- const isActivePanel = panel.id === tab.value.panelId;
3369
+ const isActivePanel = panel.id === tab.value.panel.id;
3306
3370
  tab.value.setActive(isActivePanel);
3307
3371
  });
3308
3372
  }
3309
3373
  openPanel(panel, index = this.tabs.length) {
3310
3374
  var _a;
3311
- if (this.tabs.find((tab) => tab.value.panelId === panel.id)) {
3375
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
3312
3376
  return;
3313
3377
  }
3314
- const tabToAdd = new Tab(panel.id, this.accessor, this.group);
3378
+ const tab = new Tab(panel, this.accessor, this.group);
3315
3379
  if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
3316
3380
  throw new Error('invalid header component');
3317
3381
  }
3318
- tabToAdd.setContent(panel.view.tab);
3319
- const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
3382
+ tab.setContent(panel.view.tab);
3383
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3384
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
3385
+ }), tab.onChanged((event) => {
3320
3386
  var _a;
3321
3387
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3322
3388
  const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
@@ -3324,8 +3390,8 @@ class TabsContainer extends CompositeDisposable {
3324
3390
  !isFloatingWithOnePanel &&
3325
3391
  event.shiftKey) {
3326
3392
  event.preventDefault();
3327
- const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
3328
- const { top, left } = tabToAdd.element.getBoundingClientRect();
3393
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
3394
+ const { top, left } = tab.element.getBoundingClientRect();
3329
3395
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3330
3396
  this.accessor.addFloatingGroup(panel, {
3331
3397
  x: left - rootLeft,
@@ -3342,13 +3408,13 @@ class TabsContainer extends CompositeDisposable {
3342
3408
  this.group.model.openPanel(panel, {
3343
3409
  skipFocus: alreadyFocused,
3344
3410
  });
3345
- }), tabToAdd.onDrop((event) => {
3411
+ }), tab.onDrop((event) => {
3346
3412
  this._onDrop.fire({
3347
3413
  event: event.nativeEvent,
3348
- index: this.tabs.findIndex((x) => x.value === tabToAdd),
3414
+ index: this.tabs.findIndex((x) => x.value === tab),
3349
3415
  });
3350
3416
  }));
3351
- const value = { value: tabToAdd, disposable };
3417
+ const value = { value: tab, disposable };
3352
3418
  this.addTab(value, index);
3353
3419
  }
3354
3420
  closePanel(panel) {
@@ -3376,7 +3442,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3376
3442
  }
3377
3443
  set locked(value) {
3378
3444
  this._locked = value;
3379
- toggleClass(this.container, 'locked-groupview', value);
3445
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
3380
3446
  }
3381
3447
  get isActive() {
3382
3448
  return this._isGroupActive;
@@ -3433,6 +3499,10 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3433
3499
  this.onMove = this._onMove.event;
3434
3500
  this._onDidDrop = new Emitter();
3435
3501
  this.onDidDrop = this._onDidDrop.event;
3502
+ this._onTabDragStart = new Emitter();
3503
+ this.onTabDragStart = this._onTabDragStart.event;
3504
+ this._onGroupDragStart = new Emitter();
3505
+ this.onGroupDragStart = this._onGroupDragStart.event;
3436
3506
  this._onDidAddPanel = new Emitter();
3437
3507
  this.onDidAddPanel = this._onDidAddPanel.event;
3438
3508
  this._onDidRemovePanel = new Emitter();
@@ -3445,7 +3515,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3445
3515
  this.dropTarget = new Droptarget(this.contentContainer.element, {
3446
3516
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3447
3517
  canDisplayOverlay: (event, position) => {
3448
- if (this.locked && position === 'center') {
3518
+ if (this.locked === 'no-drop-target' ||
3519
+ (this.locked && position === 'center')) {
3449
3520
  return false;
3450
3521
  }
3451
3522
  const data = getPanelData();
@@ -3471,8 +3542,12 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3471
3542
  });
3472
3543
  container.append(this.tabsContainer.element, this.contentContainer.element);
3473
3544
  this.header.hidden = !!options.hideHeader;
3474
- this.locked = !!options.locked;
3475
- this.addDisposables(this.tabsContainer.onDrop((event) => {
3545
+ this.locked = options.locked || false;
3546
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
3547
+ this._onTabDragStart.fire(event);
3548
+ }), this.tabsContainer.onGroupDragStart((event) => {
3549
+ this._onGroupDragStart.fire(event);
3550
+ }), this.tabsContainer.onDrop((event) => {
3476
3551
  this.handleDropEvent(event.event, 'center', event.index);
3477
3552
  }), this.contentContainer.onDidFocus(() => {
3478
3553
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3516,6 +3591,16 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3516
3591
  });
3517
3592
  this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
3518
3593
  }
3594
+ if (this.accessor.options.createPrefixHeaderActionsElement) {
3595
+ this._prefixHeaderActions =
3596
+ this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
3597
+ this.addDisposables(this._prefixHeaderActions);
3598
+ this._prefixHeaderActions.init({
3599
+ containerApi: new DockviewApi(this.accessor),
3600
+ api: this.groupPanel.api,
3601
+ });
3602
+ this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
3603
+ }
3519
3604
  }
3520
3605
  indexOf(panel) {
3521
3606
  return this.tabsContainer.indexOf(panel.id);
@@ -3527,8 +3612,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3527
3612
  activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
3528
3613
  id: this.id,
3529
3614
  };
3530
- if (this.locked) {
3531
- result.locked = true;
3615
+ if (this.locked !== false) {
3616
+ result.locked = this.locked;
3532
3617
  }
3533
3618
  if (this.header.hidden) {
3534
3619
  result.hideHeader = true;
@@ -3778,6 +3863,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3778
3863
  return false;
3779
3864
  }
3780
3865
  handleDropEvent(event, position, index) {
3866
+ if (this.locked === 'no-drop-target') {
3867
+ return;
3868
+ }
3781
3869
  const data = getPanelData();
3782
3870
  if (data && data.viewId === this.accessor.id) {
3783
3871
  if (data.panelId === null) {
@@ -3855,6 +3943,14 @@ class Resizable extends CompositeDisposable {
3855
3943
  */
3856
3944
  return;
3857
3945
  }
3946
+ if (!document.body.contains(this._element)) {
3947
+ /**
3948
+ * since the event is dispatched through requestAnimationFrame there is a small chance
3949
+ * the component is no longer attached to the DOM, if that is the case the dimensions
3950
+ * are mostly likely all zero and meaningless. we should skip this case.
3951
+ */
3952
+ return;
3953
+ }
3858
3954
  const { width, height } = entry.contentRect;
3859
3955
  this.layout(width, height);
3860
3956
  }));
@@ -5235,6 +5331,12 @@ const bringElementToFront = (() => {
5235
5331
  return pushToTop;
5236
5332
  })();
5237
5333
  class Overlay extends CompositeDisposable {
5334
+ set minimumInViewportWidth(value) {
5335
+ this.options.minimumInViewportWidth = value;
5336
+ }
5337
+ set minimumInViewportHeight(value) {
5338
+ this.options.minimumInViewportHeight = value;
5339
+ }
5238
5340
  constructor(options) {
5239
5341
  super();
5240
5342
  this.options = options;
@@ -5280,9 +5382,11 @@ class Overlay extends CompositeDisposable {
5280
5382
  const overlayRect = this._element.getBoundingClientRect();
5281
5383
  // region: ensure bounds within allowable limits
5282
5384
  // a minimum width of minimumViewportWidth must be inside the viewport
5283
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5385
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5284
5386
  // a minimum height of minimumViewportHeight must be inside the viewport
5285
- const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
5387
+ const yOffset = typeof this.options.minimumInViewportHeight === 'number'
5388
+ ? Math.max(0, this.getMinimumHeight(overlayRect.height))
5389
+ : 0;
5286
5390
  const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5287
5391
  const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5288
5392
  this._element.style.left = `${left}px`;
@@ -5328,9 +5432,10 @@ class Overlay extends CompositeDisposable {
5328
5432
  y: e.clientY - overlayRect.top,
5329
5433
  };
5330
5434
  }
5331
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5332
- const yOffset = Math.max(0, overlayRect.height -
5333
- this.options.minimumInViewportHeight);
5435
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5436
+ const yOffset = Math.max(0, this.options.minimumInViewportHeight
5437
+ ? this.getMinimumHeight(overlayRect.height)
5438
+ : 0);
5334
5439
  const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5335
5440
  const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5336
5441
  this.setBounds({ top, left });
@@ -5404,14 +5509,11 @@ class Overlay extends CompositeDisposable {
5404
5509
  let height = undefined;
5405
5510
  let left = undefined;
5406
5511
  let width = undefined;
5407
- const minimumInViewportHeight = this.options.minimumInViewportHeight;
5408
- const minimumInViewportWidth = this.options.minimumInViewportWidth;
5409
- function moveTop() {
5512
+ const moveTop = () => {
5410
5513
  top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
5411
5514
  startPosition.originalHeight >
5412
5515
  containerRect.height
5413
- ? containerRect.height -
5414
- minimumInViewportHeight
5516
+ ? this.getMinimumHeight(containerRect.height)
5415
5517
  : Math.max(0, startPosition.originalY +
5416
5518
  startPosition.originalHeight -
5417
5519
  Overlay.MINIMUM_HEIGHT));
@@ -5419,21 +5521,23 @@ class Overlay extends CompositeDisposable {
5419
5521
  startPosition.originalY +
5420
5522
  startPosition.originalHeight -
5421
5523
  top;
5422
- }
5423
- function moveBottom() {
5524
+ };
5525
+ const moveBottom = () => {
5424
5526
  top =
5425
5527
  startPosition.originalY -
5426
5528
  startPosition.originalHeight;
5427
- height = clamp(y - top, top < 0
5428
- ? -top + minimumInViewportHeight
5529
+ height = clamp(y - top, top < 0 &&
5530
+ typeof this.options
5531
+ .minimumInViewportHeight === 'number'
5532
+ ? -top +
5533
+ this.options.minimumInViewportHeight
5429
5534
  : Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
5430
- }
5431
- function moveLeft() {
5535
+ };
5536
+ const moveLeft = () => {
5432
5537
  left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
5433
5538
  startPosition.originalWidth >
5434
5539
  containerRect.width
5435
- ? containerRect.width -
5436
- minimumInViewportWidth
5540
+ ? this.getMinimumWidth(containerRect.width)
5437
5541
  : Math.max(0, startPosition.originalX +
5438
5542
  startPosition.originalWidth -
5439
5543
  Overlay.MINIMUM_WIDTH));
@@ -5441,15 +5545,18 @@ class Overlay extends CompositeDisposable {
5441
5545
  startPosition.originalX +
5442
5546
  startPosition.originalWidth -
5443
5547
  left;
5444
- }
5445
- function moveRight() {
5548
+ };
5549
+ const moveRight = () => {
5446
5550
  left =
5447
5551
  startPosition.originalX -
5448
5552
  startPosition.originalWidth;
5449
- width = clamp(x - left, left < 0
5450
- ? -left + minimumInViewportWidth
5553
+ width = clamp(x - left, left < 0 &&
5554
+ typeof this.options
5555
+ .minimumInViewportWidth === 'number'
5556
+ ? -left +
5557
+ this.options.minimumInViewportWidth
5451
5558
  : Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
5452
- }
5559
+ };
5453
5560
  switch (direction) {
5454
5561
  case 'top':
5455
5562
  moveTop();
@@ -5493,6 +5600,18 @@ class Overlay extends CompositeDisposable {
5493
5600
  }));
5494
5601
  }));
5495
5602
  }
5603
+ getMinimumWidth(width) {
5604
+ if (typeof this.options.minimumInViewportWidth === 'number') {
5605
+ return width - this.options.minimumInViewportWidth;
5606
+ }
5607
+ return 0;
5608
+ }
5609
+ getMinimumHeight(height) {
5610
+ if (typeof this.options.minimumInViewportHeight === 'number') {
5611
+ return height - this.options.minimumInViewportHeight;
5612
+ }
5613
+ return height;
5614
+ }
5496
5615
  dispose() {
5497
5616
  this._element.remove();
5498
5617
  super.dispose();
@@ -5513,6 +5632,7 @@ class DockviewFloatingGroupPanel extends CompositeDisposable {
5513
5632
  }
5514
5633
  }
5515
5634
 
5635
+ const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
5516
5636
  class DockviewComponent extends BaseGrid {
5517
5637
  get orientation() {
5518
5638
  return this.gridview.orientation;
@@ -5543,6 +5663,10 @@ class DockviewComponent extends BaseGrid {
5543
5663
  this.nextGroupId = sequentialNumberGenerator();
5544
5664
  this._deserializer = new DefaultDockviewDeserialzier(this);
5545
5665
  this.watermark = null;
5666
+ this._onWillDragPanel = new Emitter();
5667
+ this.onWillDragPanel = this._onWillDragPanel.event;
5668
+ this._onWillDragGroup = new Emitter();
5669
+ this.onWillDragGroup = this._onWillDragGroup.event;
5546
5670
  this._onDidDrop = new Emitter();
5547
5671
  this.onDidDrop = this._onDidDrop.event;
5548
5672
  this._onDidRemovePanel = new Emitter();
@@ -5555,7 +5679,7 @@ class DockviewComponent extends BaseGrid {
5555
5679
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5556
5680
  this.floatingGroups = [];
5557
5681
  toggleClass(this.gridview.element, 'dv-dockview', true);
5558
- this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5682
+ this.addDisposables(this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5559
5683
  this.updateWatermark();
5560
5684
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
5561
5685
  this._bufferOnDidLayoutChange.fire();
@@ -5628,7 +5752,7 @@ class DockviewComponent extends BaseGrid {
5628
5752
  this.updateWatermark();
5629
5753
  }
5630
5754
  addFloatingGroup(item, coord, options) {
5631
- var _a, _b;
5755
+ var _a, _b, _c, _d, _e, _f;
5632
5756
  let group;
5633
5757
  if (item instanceof DockviewPanel) {
5634
5758
  group = this.createGroup();
@@ -5656,8 +5780,12 @@ class DockviewComponent extends BaseGrid {
5656
5780
  width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
5657
5781
  left: overlayLeft,
5658
5782
  top: overlayTop,
5659
- minimumInViewportWidth: 100,
5660
- minimumInViewportHeight: 100,
5783
+ minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
5784
+ ? undefined
5785
+ : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5786
+ minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
5787
+ ? undefined
5788
+ : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5661
5789
  });
5662
5790
  const el = group.element.querySelector('.void-container');
5663
5791
  if (!el) {
@@ -5728,12 +5856,37 @@ class DockviewComponent extends BaseGrid {
5728
5856
  }
5729
5857
  }
5730
5858
  updateOptions(options) {
5859
+ var _a, _b;
5731
5860
  const hasOrientationChanged = typeof options.orientation === 'string' &&
5732
5861
  this.gridview.orientation !== options.orientation;
5862
+ const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
5863
+ options.floatingGroupBounds !== this.options.floatingGroupBounds;
5733
5864
  this._options = Object.assign(Object.assign({}, this.options), options);
5734
5865
  if (hasOrientationChanged) {
5735
5866
  this.gridview.orientation = options.orientation;
5736
5867
  }
5868
+ if (hasFloatingGroupOptionsChanged) {
5869
+ for (const group of this.floatingGroups) {
5870
+ switch (this.options.floatingGroupBounds) {
5871
+ case 'boundedWithinViewport':
5872
+ group.overlay.minimumInViewportHeight = undefined;
5873
+ group.overlay.minimumInViewportWidth = undefined;
5874
+ break;
5875
+ case undefined:
5876
+ group.overlay.minimumInViewportHeight =
5877
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5878
+ group.overlay.minimumInViewportWidth =
5879
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5880
+ break;
5881
+ default:
5882
+ group.overlay.minimumInViewportHeight =
5883
+ (_a = this.options.floatingGroupBounds) === null || _a === void 0 ? void 0 : _a.minimumHeightWithinViewport;
5884
+ group.overlay.minimumInViewportWidth =
5885
+ (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport;
5886
+ }
5887
+ group.overlay.setBounds({});
5888
+ }
5889
+ }
5737
5890
  this.layout(this.gridview.width, this.gridview.height, true);
5738
5891
  }
5739
5892
  layout(width, height, forceResize) {
@@ -5826,61 +5979,114 @@ class DockviewComponent extends BaseGrid {
5826
5979
  fromJSON(data) {
5827
5980
  var _a;
5828
5981
  this.clear();
5982
+ if (typeof data !== 'object' || data === null) {
5983
+ throw new Error('serialized layout must be a non-null object');
5984
+ }
5829
5985
  const { grid, panels, activeGroup } = data;
5830
5986
  if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
5831
5987
  throw new Error('root must be of type branch');
5832
5988
  }
5833
- // take note of the existing dimensions
5834
- const width = this.width;
5835
- const height = this.height;
5836
- const createGroupFromSerializedState = (data) => {
5837
- const { id, locked, hideHeader, views, activeView } = data;
5838
- const group = this.createGroup({
5839
- id,
5840
- locked: !!locked,
5841
- hideHeader: !!hideHeader,
5842
- });
5843
- this._onDidAddGroup.fire(group);
5844
- for (const child of views) {
5845
- const panel = this._deserializer.fromJSON(panels[child], group);
5846
- const isActive = typeof activeView === 'string' && activeView === panel.id;
5847
- group.model.openPanel(panel, {
5848
- skipSetPanelActive: !isActive,
5849
- skipSetGroupActive: true,
5989
+ try {
5990
+ // take note of the existing dimensions
5991
+ const width = this.width;
5992
+ const height = this.height;
5993
+ const createGroupFromSerializedState = (data) => {
5994
+ const { id, locked, hideHeader, views, activeView } = data;
5995
+ if (typeof id !== 'string') {
5996
+ throw new Error('group id must be of type string');
5997
+ }
5998
+ const group = this.createGroup({
5999
+ id,
6000
+ locked: !!locked,
6001
+ hideHeader: !!hideHeader,
5850
6002
  });
6003
+ const createdPanels = [];
6004
+ for (const child of views) {
6005
+ /**
6006
+ * Run the deserializer step seperately since this may fail to due corrupted external state.
6007
+ * In running this section first we avoid firing lots of 'add' events in the event of a failure
6008
+ * due to a corruption of input data.
6009
+ */
6010
+ const panel = this._deserializer.fromJSON(panels[child], group);
6011
+ createdPanels.push(panel);
6012
+ }
6013
+ this._onDidAddGroup.fire(group);
6014
+ for (let i = 0; i < views.length; i++) {
6015
+ const panel = createdPanels[i];
6016
+ const isActive = typeof activeView === 'string' &&
6017
+ activeView === panel.id;
6018
+ group.model.openPanel(panel, {
6019
+ skipSetPanelActive: !isActive,
6020
+ skipSetGroupActive: true,
6021
+ });
6022
+ }
6023
+ if (!group.activePanel && group.panels.length > 0) {
6024
+ group.model.openPanel(group.panels[group.panels.length - 1], {
6025
+ skipSetGroupActive: true,
6026
+ });
6027
+ }
6028
+ return group;
6029
+ };
6030
+ this.gridview.deserialize(grid, {
6031
+ fromJSON: (node) => {
6032
+ return createGroupFromSerializedState(node.data);
6033
+ },
6034
+ });
6035
+ this.layout(width, height, true);
6036
+ const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
6037
+ for (const serializedFloatingGroup of serializedFloatingGroups) {
6038
+ const { data, position } = serializedFloatingGroup;
6039
+ const group = createGroupFromSerializedState(data);
6040
+ this.addFloatingGroup(group, {
6041
+ x: position.left,
6042
+ y: position.top,
6043
+ height: position.height,
6044
+ width: position.width,
6045
+ }, { skipRemoveGroup: true, inDragMode: false });
6046
+ }
6047
+ for (const floatingGroup of this.floatingGroups) {
6048
+ floatingGroup.overlay.setBounds();
6049
+ }
6050
+ if (typeof activeGroup === 'string') {
6051
+ const panel = this.getPanel(activeGroup);
6052
+ if (panel) {
6053
+ this.doSetGroupActive(panel);
6054
+ }
5851
6055
  }
5852
- if (!group.activePanel && group.panels.length > 0) {
5853
- group.model.openPanel(group.panels[group.panels.length - 1], {
5854
- skipSetGroupActive: true,
5855
- });
6056
+ }
6057
+ catch (err) {
6058
+ /**
6059
+ * Takes all the successfully created groups and remove all of their panels.
6060
+ */
6061
+ for (const group of this.groups) {
6062
+ for (const panel of group.panels) {
6063
+ this.removePanel(panel, {
6064
+ removeEmptyGroup: false,
6065
+ skipDispose: false,
6066
+ });
6067
+ }
5856
6068
  }
5857
- return group;
5858
- };
5859
- this.gridview.deserialize(grid, {
5860
- fromJSON: (node) => {
5861
- return createGroupFromSerializedState(node.data);
5862
- },
5863
- });
5864
- this.layout(width, height, true);
5865
- const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
5866
- for (const serializedFloatingGroup of serializedFloatingGroups) {
5867
- const { data, position } = serializedFloatingGroup;
5868
- const group = createGroupFromSerializedState(data);
5869
- this.addFloatingGroup(group, {
5870
- x: position.left,
5871
- y: position.top,
5872
- height: position.height,
5873
- width: position.width,
5874
- }, { skipRemoveGroup: true, inDragMode: false });
5875
- }
5876
- for (const floatingGroup of this.floatingGroups) {
5877
- floatingGroup.overlay.setBounds();
5878
- }
5879
- if (typeof activeGroup === 'string') {
5880
- const panel = this.getPanel(activeGroup);
5881
- if (panel) {
5882
- this.doSetGroupActive(panel);
6069
+ /**
6070
+ * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
6071
+ * the underlying HTMLElement existing in the Gridview.
6072
+ */
6073
+ for (const group of this.groups) {
6074
+ group.dispose();
6075
+ this._groups.delete(group.id);
6076
+ this._onDidRemoveGroup.fire(group);
5883
6077
  }
6078
+ // iterate over a reassigned array since original array will be modified
6079
+ for (const floatingGroup of [...this.floatingGroups]) {
6080
+ floatingGroup.dispose();
6081
+ }
6082
+ // fires clean-up events and clears the underlying HTML gridview.
6083
+ this.clear();
6084
+ /**
6085
+ * even though we have cleaned-up we still want to inform the caller of their error
6086
+ * and we'll do this through re-throwing the original error since afterall you would
6087
+ * expect trying to load a corrupted layout to result in an error and not silently fail...
6088
+ */
6089
+ throw err;
5884
6090
  }
5885
6091
  this._onDidLayoutFromJSON.fire();
5886
6092
  }
@@ -6094,6 +6300,7 @@ class DockviewComponent extends BaseGrid {
6094
6300
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
6095
6301
  floatingGroup.group.dispose();
6096
6302
  this._groups.delete(group.id);
6303
+ // TODO: fire group removed event?
6097
6304
  }
6098
6305
  floatingGroup.dispose();
6099
6306
  return floatingGroup.group;
@@ -6216,7 +6423,11 @@ class DockviewComponent extends BaseGrid {
6216
6423
  const view = new DockviewGroupPanel(this, id, options);
6217
6424
  view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
6218
6425
  if (!this._groups.has(view.id)) {
6219
- const disposable = new CompositeDisposable(view.model.onMove((event) => {
6426
+ const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
6427
+ this._onWillDragPanel.fire(event);
6428
+ }), view.model.onGroupDragStart((event) => {
6429
+ this._onWillDragGroup.fire(event);
6430
+ }), view.model.onMove((event) => {
6220
6431
  const { groupId, itemId, target, index } = event;
6221
6432
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
6222
6433
  }), view.model.onDidDrop((event) => {
@@ -6255,13 +6466,6 @@ class DockviewComponent extends BaseGrid {
6255
6466
  var _a;
6256
6467
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
6257
6468
  }
6258
- dispose() {
6259
- this._onDidActivePanelChange.dispose();
6260
- this._onDidAddPanel.dispose();
6261
- this._onDidRemovePanel.dispose();
6262
- this._onDidLayoutFromJSON.dispose();
6263
- super.dispose();
6264
- }
6265
6469
  }
6266
6470
 
6267
6471
  class GridviewComponent extends BaseGrid {
@@ -6337,43 +6541,64 @@ class GridviewComponent extends BaseGrid {
6337
6541
  fromJSON(serializedGridview) {
6338
6542
  this.clear();
6339
6543
  const { grid, activePanel } = serializedGridview;
6340
- const queue = [];
6341
- // take note of the existing dimensions
6342
- const width = this.width;
6343
- const height = this.height;
6344
- this.gridview.deserialize(grid, {
6345
- fromJSON: (node) => {
6346
- const { data } = node;
6347
- const view = createComponent(data.id, data.component, this.options.components || {}, this.options.frameworkComponents || {}, this.options.frameworkComponentFactory
6348
- ? {
6349
- createComponent: this.options.frameworkComponentFactory
6350
- .createComponent,
6351
- }
6352
- : undefined);
6353
- queue.push(() => view.init({
6354
- params: data.params,
6355
- minimumWidth: data.minimumWidth,
6356
- maximumWidth: data.maximumWidth,
6357
- minimumHeight: data.minimumHeight,
6358
- maximumHeight: data.maximumHeight,
6359
- priority: data.priority,
6360
- snap: !!data.snap,
6361
- accessor: this,
6362
- isVisible: node.visible,
6363
- }));
6364
- this._onDidAddGroup.fire(view);
6365
- this.registerPanel(view);
6366
- return view;
6367
- },
6368
- });
6369
- this.layout(width, height, true);
6370
- queue.forEach((f) => f());
6371
- if (typeof activePanel === 'string') {
6372
- const panel = this.getPanel(activePanel);
6373
- if (panel) {
6374
- this.doSetGroupActive(panel);
6544
+ try {
6545
+ const queue = [];
6546
+ // take note of the existing dimensions
6547
+ const width = this.width;
6548
+ const height = this.height;
6549
+ this.gridview.deserialize(grid, {
6550
+ fromJSON: (node) => {
6551
+ const { data } = node;
6552
+ const view = createComponent(data.id, data.component, this.options.components || {}, this.options.frameworkComponents || {}, this.options.frameworkComponentFactory
6553
+ ? {
6554
+ createComponent: this.options.frameworkComponentFactory
6555
+ .createComponent,
6556
+ }
6557
+ : undefined);
6558
+ queue.push(() => view.init({
6559
+ params: data.params,
6560
+ minimumWidth: data.minimumWidth,
6561
+ maximumWidth: data.maximumWidth,
6562
+ minimumHeight: data.minimumHeight,
6563
+ maximumHeight: data.maximumHeight,
6564
+ priority: data.priority,
6565
+ snap: !!data.snap,
6566
+ accessor: this,
6567
+ isVisible: node.visible,
6568
+ }));
6569
+ this._onDidAddGroup.fire(view);
6570
+ this.registerPanel(view);
6571
+ return view;
6572
+ },
6573
+ });
6574
+ this.layout(width, height, true);
6575
+ queue.forEach((f) => f());
6576
+ if (typeof activePanel === 'string') {
6577
+ const panel = this.getPanel(activePanel);
6578
+ if (panel) {
6579
+ this.doSetGroupActive(panel);
6580
+ }
6375
6581
  }
6376
6582
  }
6583
+ catch (err) {
6584
+ /**
6585
+ * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
6586
+ * the underlying HTMLElement existing in the Gridview.
6587
+ */
6588
+ for (const group of this.groups) {
6589
+ group.dispose();
6590
+ this._groups.delete(group.id);
6591
+ this._onDidRemoveGroup.fire(group);
6592
+ }
6593
+ // fires clean-up events and clears the underlying HTML gridview.
6594
+ this.clear();
6595
+ /**
6596
+ * even though we have cleaned-up we still want to inform the caller of their error
6597
+ * and we'll do this through re-throwing the original error since afterall you would
6598
+ * expect trying to load a corrupted layout to result in an error and not silently fail...
6599
+ */
6600
+ throw err;
6601
+ }
6377
6602
  this._onDidLayoutfromJSON.fire();
6378
6603
  }
6379
6604
  clear() {