dockview 1.10.0 → 1.10.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.
package/dist/dockview.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.10.0
3
+ * @version 1.10.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -1502,6 +1502,9 @@
1502
1502
  this._onDidChange.fire();
1503
1503
  }));
1504
1504
  }
1505
+ setViewVisible(index, visible) {
1506
+ this.splitview.setViewVisible(index, visible);
1507
+ }
1505
1508
  addPane(pane, size, index = this.splitview.length, skipLayout = false) {
1506
1509
  const disposable = pane.onDidChangeExpansionState(() => {
1507
1510
  this.setupAnimation();
@@ -3006,19 +3009,27 @@
3006
3009
  return this.component.onWillDrop;
3007
3010
  }
3008
3011
  /**
3012
+ * Invoked before an overlay is shown indicating a drop target.
3009
3013
  *
3014
+ * Calling `event.preventDefault()` will prevent the overlay being shown and prevent
3015
+ * the any subsequent drop event.
3010
3016
  */
3011
3017
  get onWillShowOverlay() {
3012
3018
  return this.component.onWillShowOverlay;
3013
3019
  }
3014
3020
  /**
3015
- * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
3021
+ * Invoked before a group is dragged.
3022
+ *
3023
+ * Calling `event.nativeEvent.preventDefault()` will prevent the group drag starting.
3024
+ *
3016
3025
  */
3017
3026
  get onWillDragGroup() {
3018
3027
  return this.component.onWillDragGroup;
3019
3028
  }
3020
3029
  /**
3021
- * Invoked before a panel is dragged. Exposed for custom Drag'n'Drop functionality.
3030
+ * Invoked before a panel is dragged.
3031
+ *
3032
+ * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
3022
3033
  */
3023
3034
  get onWillDragPanel() {
3024
3035
  return this.component.onWillDragPanel;
@@ -3562,7 +3573,7 @@
3562
3573
  data.groupId === this.group.id;
3563
3574
  return !groupHasOnePanelAndIsActiveDragElement;
3564
3575
  }
3565
- return this.group.canDisplayOverlay(event, position, 'panel');
3576
+ return this.group.canDisplayOverlay(event, position, 'content');
3566
3577
  },
3567
3578
  });
3568
3579
  this.addDisposables(this.dropTarget);
@@ -3885,7 +3896,7 @@
3885
3896
  // don't show the overlay if the tab being dragged is the last panel of this group
3886
3897
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3887
3898
  }
3888
- return group.model.canDisplayOverlay(event, position, 'panel');
3899
+ return group.model.canDisplayOverlay(event, position, 'header_space');
3889
3900
  },
3890
3901
  });
3891
3902
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
@@ -5014,9 +5025,6 @@
5014
5025
  get isVisible() {
5015
5026
  return this._isVisible;
5016
5027
  }
5017
- get isHidden() {
5018
- return this._isHidden;
5019
- }
5020
5028
  get width() {
5021
5029
  return this._width;
5022
5030
  }
@@ -5029,7 +5037,6 @@
5029
5037
  this._isFocused = false;
5030
5038
  this._isActive = false;
5031
5039
  this._isVisible = true;
5032
- this._isHidden = false;
5033
5040
  this._width = 0;
5034
5041
  this._height = 0;
5035
5042
  this.panelUpdatesDisposable = new MutableDisposable();
@@ -5043,8 +5050,8 @@
5043
5050
  //
5044
5051
  this._onDidVisibilityChange = new Emitter();
5045
5052
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5046
- this._onDidHiddenChange = new Emitter();
5047
- this.onDidHiddenChange = this._onDidHiddenChange.event;
5053
+ this._onWillVisibilityChange = new Emitter();
5054
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5048
5055
  this._onDidActiveChange = new Emitter();
5049
5056
  this.onDidActiveChange = this._onDidActiveChange.event;
5050
5057
  this._onActiveChange = new Emitter();
@@ -5057,12 +5064,10 @@
5057
5064
  this._isActive = event.isActive;
5058
5065
  }), this.onDidVisibilityChange((event) => {
5059
5066
  this._isVisible = event.isVisible;
5060
- }), this.onDidHiddenChange((event) => {
5061
- this._isHidden = event.isHidden;
5062
5067
  }), this.onDidDimensionsChange((event) => {
5063
5068
  this._width = event.width;
5064
5069
  this._height = event.height;
5065
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
5070
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onWillVisibilityChange, this._onUpdateParameters);
5066
5071
  }
5067
5072
  initialize(panel) {
5068
5073
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -5071,8 +5076,8 @@
5071
5076
  });
5072
5077
  });
5073
5078
  }
5074
- setHidden(isHidden) {
5075
- this._onDidHiddenChange.fire({ isHidden });
5079
+ setVisible(isVisible) {
5080
+ this._onWillVisibilityChange.fire({ isVisible });
5076
5081
  }
5077
5082
  setActive() {
5078
5083
  this._onActiveChange.fire();
@@ -5290,7 +5295,11 @@
5290
5295
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5291
5296
  this._orientation = orientation;
5292
5297
  this.element.classList.add('pane');
5293
- this.addDisposables(this.api.onDidSizeChange((event) => {
5298
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5299
+ const { isVisible } = event;
5300
+ const { accessor } = this._params;
5301
+ accessor.setVisible(this, isVisible);
5302
+ }), this.api.onDidSizeChange((event) => {
5294
5303
  this._onDidChange.fire({ size: event.size });
5295
5304
  }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5296
5305
  this.api._onMouseEnter.fire(ev);
@@ -5594,10 +5603,10 @@
5594
5603
  this._maximumHeight = options.maximumHeight;
5595
5604
  }
5596
5605
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5597
- this.addDisposables(this.api.onDidHiddenChange((event) => {
5598
- const { isHidden } = event;
5606
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5607
+ const { isVisible } = event;
5599
5608
  const { accessor } = this._params;
5600
- accessor.setVisible(this, !isHidden);
5609
+ accessor.setVisible(this, isVisible);
5601
5610
  }), this.api.onActiveChange(() => {
5602
5611
  const { accessor } = this._params;
5603
5612
  accessor.doSetGroupActive(this);
@@ -5838,32 +5847,11 @@
5838
5847
  return this.panel.renderer;
5839
5848
  }
5840
5849
  set group(value) {
5841
- const isOldGroupActive = this.isGroupActive;
5850
+ const oldGroup = this._group;
5842
5851
  if (this._group !== value) {
5843
5852
  this._group = value;
5844
5853
  this._onDidGroupChange.fire({});
5845
- let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5846
- this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5847
- if (this.group !== this.panel.group) {
5848
- return;
5849
- }
5850
- this._onDidLocationChange.fire(event);
5851
- }), this.group.api.onDidActiveChange(() => {
5852
- if (this.group !== this.panel.group) {
5853
- return;
5854
- }
5855
- if (_trackGroupActive !== this.isGroupActive) {
5856
- _trackGroupActive = this.isGroupActive;
5857
- this._onDidActiveGroupChange.fire({
5858
- isActive: this.isGroupActive,
5859
- });
5860
- }
5861
- }));
5862
- // if (this.isGroupActive !== isOldGroupActive) {
5863
- // this._onDidActiveGroupChange.fire({
5864
- // isActive: this.isGroupActive,
5865
- // });
5866
- // }
5854
+ this.setupGroupEventListeners(oldGroup);
5867
5855
  this._onDidLocationChange.fire({
5868
5856
  location: this.group.api.location,
5869
5857
  });
@@ -5889,6 +5877,7 @@
5889
5877
  this.groupEventsDisposable = new MutableDisposable();
5890
5878
  this.initialize(panel);
5891
5879
  this._group = group;
5880
+ this.setupGroupEventListeners();
5892
5881
  this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5893
5882
  }
5894
5883
  getWindow() {
@@ -5923,6 +5912,35 @@
5923
5912
  exitMaximized() {
5924
5913
  this.group.api.exitMaximized();
5925
5914
  }
5915
+ setupGroupEventListeners(previousGroup) {
5916
+ var _a;
5917
+ let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5918
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5919
+ if (!event.isVisible && this.isVisible) {
5920
+ this._onDidVisibilityChange.fire(event);
5921
+ }
5922
+ else if (event.isVisible &&
5923
+ !this.isVisible &&
5924
+ this.group.model.isPanelActive(this.panel)) {
5925
+ this._onDidVisibilityChange.fire(event);
5926
+ }
5927
+ }), this.group.api.onDidLocationChange((event) => {
5928
+ if (this.group !== this.panel.group) {
5929
+ return;
5930
+ }
5931
+ this._onDidLocationChange.fire(event);
5932
+ }), this.group.api.onDidActiveChange(() => {
5933
+ if (this.group !== this.panel.group) {
5934
+ return;
5935
+ }
5936
+ if (_trackGroupActive !== this.isGroupActive) {
5937
+ _trackGroupActive = this.isGroupActive;
5938
+ this._onDidActiveGroupChange.fire({
5939
+ isActive: this.isGroupActive,
5940
+ });
5941
+ }
5942
+ }));
5943
+ }
5926
5944
  }
5927
5945
 
5928
5946
  class DockviewPanel extends CompositeDisposable {
@@ -7080,7 +7098,15 @@
7080
7098
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7081
7099
  overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7082
7100
  });
7083
- this.addDisposables(this._rootDropTarget.onDrop((event) => {
7101
+ this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7102
+ if (this.gridview.length > 0 && event.position === 'center') {
7103
+ // option only available when no panels in primary grid
7104
+ return;
7105
+ }
7106
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7107
+ kind: 'edge',
7108
+ }));
7109
+ }), this._rootDropTarget.onDrop((event) => {
7084
7110
  var _a;
7085
7111
  const willDropEvent = new DockviewWillDropEvent({
7086
7112
  nativeEvent: event.nativeEvent,
@@ -7089,7 +7115,7 @@
7089
7115
  api: this._api,
7090
7116
  group: undefined,
7091
7117
  getData: getPanelData,
7092
- kind: 'content',
7118
+ kind: 'edge',
7093
7119
  });
7094
7120
  this._onWillDrop.fire(willDropEvent);
7095
7121
  if (willDropEvent.defaultPrevented) {
@@ -7145,7 +7171,7 @@
7145
7171
  const box = getBox();
7146
7172
  const groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId(); //item.id;
7147
7173
  if (itemToPopout.api.location.type === 'grid') {
7148
- itemToPopout.api.setHidden(true);
7174
+ itemToPopout.api.setVisible(false);
7149
7175
  }
7150
7176
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7151
7177
  theme !== null && theme !== void 0 ? theme : '', {
@@ -7196,7 +7222,7 @@
7196
7222
  }));
7197
7223
  switch (referenceLocation) {
7198
7224
  case 'grid':
7199
- referenceGroup.api.setHidden(true);
7225
+ referenceGroup.api.setVisible(false);
7200
7226
  break;
7201
7227
  case 'floating':
7202
7228
  case 'popout':
@@ -7250,8 +7276,8 @@
7250
7276
  from: group,
7251
7277
  to: referenceGroup,
7252
7278
  }));
7253
- if (referenceGroup.api.isHidden) {
7254
- referenceGroup.api.setHidden(false);
7279
+ if (!referenceGroup.api.isVisible) {
7280
+ referenceGroup.api.setVisible(true);
7255
7281
  }
7256
7282
  if (this.getPanel(group.id)) {
7257
7283
  this.doRemoveGroup(group, {
@@ -7824,7 +7850,7 @@
7824
7850
  }
7825
7851
  updateWatermark() {
7826
7852
  var _a, _b;
7827
- if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7853
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
7828
7854
  if (!this.watermark) {
7829
7855
  this.watermark = this.createWatermarkComponent();
7830
7856
  this.watermark.init({
@@ -8607,19 +8633,19 @@
8607
8633
  const index = this.panels.indexOf(panel);
8608
8634
  this.splitview.setViewVisible(index, visible);
8609
8635
  }
8610
- setActive(view, skipFocus) {
8611
- this._activePanel = view;
8636
+ setActive(panel, skipFocus) {
8637
+ this._activePanel = panel;
8612
8638
  this.panels
8613
- .filter((v) => v !== view)
8639
+ .filter((v) => v !== panel)
8614
8640
  .forEach((v) => {
8615
8641
  v.api._onDidActiveChange.fire({ isActive: false });
8616
8642
  if (!skipFocus) {
8617
8643
  v.focus();
8618
8644
  }
8619
8645
  });
8620
- view.api._onDidActiveChange.fire({ isActive: true });
8646
+ panel.api._onDidActiveChange.fire({ isActive: true });
8621
8647
  if (!skipFocus) {
8622
- view.focus();
8648
+ panel.focus();
8623
8649
  }
8624
8650
  }
8625
8651
  removePanel(panel, sizing) {
@@ -8918,6 +8944,10 @@
8918
8944
  });
8919
8945
  this.addDisposables(this._disposable);
8920
8946
  }
8947
+ setVisible(panel, visible) {
8948
+ const index = this.panels.indexOf(panel);
8949
+ this.paneview.setViewVisible(index, visible);
8950
+ }
8921
8951
  focus() {
8922
8952
  //noop
8923
8953
  }
@@ -8964,6 +8994,7 @@
8964
8994
  isExpanded: options.isExpanded,
8965
8995
  title: options.title,
8966
8996
  containerApi: new PaneviewApi(this),
8997
+ accessor: this,
8967
8998
  });
8968
8999
  this.paneview.addPane(view, size, index);
8969
9000
  view.orientation = this.paneview.orientation;
@@ -9063,6 +9094,7 @@
9063
9094
  title: data.title,
9064
9095
  isExpanded: !!view.expanded,
9065
9096
  containerApi: new PaneviewApi(this),
9097
+ accessor: this,
9066
9098
  });
9067
9099
  panel.orientation = this.paneview.orientation;
9068
9100
  });
@@ -9151,10 +9183,10 @@
9151
9183
  this._onDidChange = new Emitter();
9152
9184
  this.onDidChange = this._onDidChange.event;
9153
9185
  this.api.initialize(this);
9154
- this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9155
- const { isHidden } = event;
9186
+ this.addDisposables(this._onDidChange, this.api.onWillVisibilityChange((event) => {
9187
+ const { isVisible } = event;
9156
9188
  const { accessor } = this._params;
9157
- accessor.setVisible(this, !isHidden);
9189
+ accessor.setVisible(this, isVisible);
9158
9190
  }), this.api.onActiveChange(() => {
9159
9191
  const { accessor } = this._params;
9160
9192
  accessor.setActive(this);