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.
@@ -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
  */
@@ -1472,6 +1472,9 @@
1472
1472
  this._onDidChange.fire();
1473
1473
  }));
1474
1474
  }
1475
+ setViewVisible(index, visible) {
1476
+ this.splitview.setViewVisible(index, visible);
1477
+ }
1475
1478
  addPane(pane, size, index = this.splitview.length, skipLayout = false) {
1476
1479
  const disposable = pane.onDidChangeExpansionState(() => {
1477
1480
  this.setupAnimation();
@@ -2976,19 +2979,27 @@
2976
2979
  return this.component.onWillDrop;
2977
2980
  }
2978
2981
  /**
2982
+ * Invoked before an overlay is shown indicating a drop target.
2979
2983
  *
2984
+ * Calling `event.preventDefault()` will prevent the overlay being shown and prevent
2985
+ * the any subsequent drop event.
2980
2986
  */
2981
2987
  get onWillShowOverlay() {
2982
2988
  return this.component.onWillShowOverlay;
2983
2989
  }
2984
2990
  /**
2985
- * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
2991
+ * Invoked before a group is dragged.
2992
+ *
2993
+ * Calling `event.nativeEvent.preventDefault()` will prevent the group drag starting.
2994
+ *
2986
2995
  */
2987
2996
  get onWillDragGroup() {
2988
2997
  return this.component.onWillDragGroup;
2989
2998
  }
2990
2999
  /**
2991
- * Invoked before a panel is dragged. Exposed for custom Drag'n'Drop functionality.
3000
+ * Invoked before a panel is dragged.
3001
+ *
3002
+ * Calling `event.nativeEvent.preventDefault()` will prevent the panel drag starting.
2992
3003
  */
2993
3004
  get onWillDragPanel() {
2994
3005
  return this.component.onWillDragPanel;
@@ -3532,7 +3543,7 @@
3532
3543
  data.groupId === this.group.id;
3533
3544
  return !groupHasOnePanelAndIsActiveDragElement;
3534
3545
  }
3535
- return this.group.canDisplayOverlay(event, position, 'panel');
3546
+ return this.group.canDisplayOverlay(event, position, 'content');
3536
3547
  },
3537
3548
  });
3538
3549
  this.addDisposables(this.dropTarget);
@@ -3855,7 +3866,7 @@
3855
3866
  // don't show the overlay if the tab being dragged is the last panel of this group
3856
3867
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3857
3868
  }
3858
- return group.model.canDisplayOverlay(event, position, 'panel');
3869
+ return group.model.canDisplayOverlay(event, position, 'header_space');
3859
3870
  },
3860
3871
  });
3861
3872
  this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
@@ -4984,9 +4995,6 @@
4984
4995
  get isVisible() {
4985
4996
  return this._isVisible;
4986
4997
  }
4987
- get isHidden() {
4988
- return this._isHidden;
4989
- }
4990
4998
  get width() {
4991
4999
  return this._width;
4992
5000
  }
@@ -4999,7 +5007,6 @@
4999
5007
  this._isFocused = false;
5000
5008
  this._isActive = false;
5001
5009
  this._isVisible = true;
5002
- this._isHidden = false;
5003
5010
  this._width = 0;
5004
5011
  this._height = 0;
5005
5012
  this.panelUpdatesDisposable = new MutableDisposable();
@@ -5013,8 +5020,8 @@
5013
5020
  //
5014
5021
  this._onDidVisibilityChange = new Emitter();
5015
5022
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
5016
- this._onDidHiddenChange = new Emitter();
5017
- this.onDidHiddenChange = this._onDidHiddenChange.event;
5023
+ this._onWillVisibilityChange = new Emitter();
5024
+ this.onWillVisibilityChange = this._onWillVisibilityChange.event;
5018
5025
  this._onDidActiveChange = new Emitter();
5019
5026
  this.onDidActiveChange = this._onDidActiveChange.event;
5020
5027
  this._onActiveChange = new Emitter();
@@ -5027,12 +5034,10 @@
5027
5034
  this._isActive = event.isActive;
5028
5035
  }), this.onDidVisibilityChange((event) => {
5029
5036
  this._isVisible = event.isVisible;
5030
- }), this.onDidHiddenChange((event) => {
5031
- this._isHidden = event.isHidden;
5032
5037
  }), this.onDidDimensionsChange((event) => {
5033
5038
  this._width = event.width;
5034
5039
  this._height = event.height;
5035
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
5040
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onWillVisibilityChange, this._onUpdateParameters);
5036
5041
  }
5037
5042
  initialize(panel) {
5038
5043
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -5041,8 +5046,8 @@
5041
5046
  });
5042
5047
  });
5043
5048
  }
5044
- setHidden(isHidden) {
5045
- this._onDidHiddenChange.fire({ isHidden });
5049
+ setVisible(isVisible) {
5050
+ this._onWillVisibilityChange.fire({ isVisible });
5046
5051
  }
5047
5052
  setActive() {
5048
5053
  this._onActiveChange.fire();
@@ -5260,7 +5265,11 @@
5260
5265
  this._onDidChangeExpansionState.fire(this.isExpanded()); // initialize value
5261
5266
  this._orientation = orientation;
5262
5267
  this.element.classList.add('pane');
5263
- this.addDisposables(this.api.onDidSizeChange((event) => {
5268
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5269
+ const { isVisible } = event;
5270
+ const { accessor } = this._params;
5271
+ accessor.setVisible(this, isVisible);
5272
+ }), this.api.onDidSizeChange((event) => {
5264
5273
  this._onDidChange.fire({ size: event.size });
5265
5274
  }), addDisposableListener(this.element, 'mouseenter', (ev) => {
5266
5275
  this.api._onMouseEnter.fire(ev);
@@ -5564,10 +5573,10 @@
5564
5573
  this._maximumHeight = options.maximumHeight;
5565
5574
  }
5566
5575
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5567
- this.addDisposables(this.api.onDidHiddenChange((event) => {
5568
- const { isHidden } = event;
5576
+ this.addDisposables(this.api.onWillVisibilityChange((event) => {
5577
+ const { isVisible } = event;
5569
5578
  const { accessor } = this._params;
5570
- accessor.setVisible(this, !isHidden);
5579
+ accessor.setVisible(this, isVisible);
5571
5580
  }), this.api.onActiveChange(() => {
5572
5581
  const { accessor } = this._params;
5573
5582
  accessor.doSetGroupActive(this);
@@ -5808,32 +5817,11 @@
5808
5817
  return this.panel.renderer;
5809
5818
  }
5810
5819
  set group(value) {
5811
- const isOldGroupActive = this.isGroupActive;
5820
+ const oldGroup = this._group;
5812
5821
  if (this._group !== value) {
5813
5822
  this._group = value;
5814
5823
  this._onDidGroupChange.fire({});
5815
- let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5816
- this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5817
- if (this.group !== this.panel.group) {
5818
- return;
5819
- }
5820
- this._onDidLocationChange.fire(event);
5821
- }), this.group.api.onDidActiveChange(() => {
5822
- if (this.group !== this.panel.group) {
5823
- return;
5824
- }
5825
- if (_trackGroupActive !== this.isGroupActive) {
5826
- _trackGroupActive = this.isGroupActive;
5827
- this._onDidActiveGroupChange.fire({
5828
- isActive: this.isGroupActive,
5829
- });
5830
- }
5831
- }));
5832
- // if (this.isGroupActive !== isOldGroupActive) {
5833
- // this._onDidActiveGroupChange.fire({
5834
- // isActive: this.isGroupActive,
5835
- // });
5836
- // }
5824
+ this.setupGroupEventListeners(oldGroup);
5837
5825
  this._onDidLocationChange.fire({
5838
5826
  location: this.group.api.location,
5839
5827
  });
@@ -5859,6 +5847,7 @@
5859
5847
  this.groupEventsDisposable = new MutableDisposable();
5860
5848
  this.initialize(panel);
5861
5849
  this._group = group;
5850
+ this.setupGroupEventListeners();
5862
5851
  this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5863
5852
  }
5864
5853
  getWindow() {
@@ -5893,6 +5882,35 @@
5893
5882
  exitMaximized() {
5894
5883
  this.group.api.exitMaximized();
5895
5884
  }
5885
+ setupGroupEventListeners(previousGroup) {
5886
+ var _a;
5887
+ let _trackGroupActive = (_a = previousGroup === null || previousGroup === void 0 ? void 0 : previousGroup.isActive) !== null && _a !== void 0 ? _a : false; // prevent duplicate events with same state
5888
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidVisibilityChange((event) => {
5889
+ if (!event.isVisible && this.isVisible) {
5890
+ this._onDidVisibilityChange.fire(event);
5891
+ }
5892
+ else if (event.isVisible &&
5893
+ !this.isVisible &&
5894
+ this.group.model.isPanelActive(this.panel)) {
5895
+ this._onDidVisibilityChange.fire(event);
5896
+ }
5897
+ }), this.group.api.onDidLocationChange((event) => {
5898
+ if (this.group !== this.panel.group) {
5899
+ return;
5900
+ }
5901
+ this._onDidLocationChange.fire(event);
5902
+ }), this.group.api.onDidActiveChange(() => {
5903
+ if (this.group !== this.panel.group) {
5904
+ return;
5905
+ }
5906
+ if (_trackGroupActive !== this.isGroupActive) {
5907
+ _trackGroupActive = this.isGroupActive;
5908
+ this._onDidActiveGroupChange.fire({
5909
+ isActive: this.isGroupActive,
5910
+ });
5911
+ }
5912
+ }));
5913
+ }
5896
5914
  }
5897
5915
 
5898
5916
  class DockviewPanel extends CompositeDisposable {
@@ -7050,7 +7068,15 @@
7050
7068
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
7051
7069
  overlayModel: (_b = this.options.rootOverlayModel) !== null && _b !== void 0 ? _b : DEFAULT_ROOT_OVERLAY_MODEL,
7052
7070
  });
7053
- this.addDisposables(this._rootDropTarget.onDrop((event) => {
7071
+ this.addDisposables(this._rootDropTarget, this._rootDropTarget.onWillShowOverlay((event) => {
7072
+ if (this.gridview.length > 0 && event.position === 'center') {
7073
+ // option only available when no panels in primary grid
7074
+ return;
7075
+ }
7076
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
7077
+ kind: 'edge',
7078
+ }));
7079
+ }), this._rootDropTarget.onDrop((event) => {
7054
7080
  var _a;
7055
7081
  const willDropEvent = new DockviewWillDropEvent({
7056
7082
  nativeEvent: event.nativeEvent,
@@ -7059,7 +7085,7 @@
7059
7085
  api: this._api,
7060
7086
  group: undefined,
7061
7087
  getData: getPanelData,
7062
- kind: 'content',
7088
+ kind: 'edge',
7063
7089
  });
7064
7090
  this._onWillDrop.fire(willDropEvent);
7065
7091
  if (willDropEvent.defaultPrevented) {
@@ -7115,7 +7141,7 @@
7115
7141
  const box = getBox();
7116
7142
  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;
7117
7143
  if (itemToPopout.api.location.type === 'grid') {
7118
- itemToPopout.api.setHidden(true);
7144
+ itemToPopout.api.setVisible(false);
7119
7145
  }
7120
7146
  const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7121
7147
  theme !== null && theme !== void 0 ? theme : '', {
@@ -7166,7 +7192,7 @@
7166
7192
  }));
7167
7193
  switch (referenceLocation) {
7168
7194
  case 'grid':
7169
- referenceGroup.api.setHidden(true);
7195
+ referenceGroup.api.setVisible(false);
7170
7196
  break;
7171
7197
  case 'floating':
7172
7198
  case 'popout':
@@ -7220,8 +7246,8 @@
7220
7246
  from: group,
7221
7247
  to: referenceGroup,
7222
7248
  }));
7223
- if (referenceGroup.api.isHidden) {
7224
- referenceGroup.api.setHidden(false);
7249
+ if (!referenceGroup.api.isVisible) {
7250
+ referenceGroup.api.setVisible(true);
7225
7251
  }
7226
7252
  if (this.getPanel(group.id)) {
7227
7253
  this.doRemoveGroup(group, {
@@ -7794,7 +7820,7 @@
7794
7820
  }
7795
7821
  updateWatermark() {
7796
7822
  var _a, _b;
7797
- if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7823
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && x.api.isVisible).length === 0) {
7798
7824
  if (!this.watermark) {
7799
7825
  this.watermark = this.createWatermarkComponent();
7800
7826
  this.watermark.init({
@@ -8577,19 +8603,19 @@
8577
8603
  const index = this.panels.indexOf(panel);
8578
8604
  this.splitview.setViewVisible(index, visible);
8579
8605
  }
8580
- setActive(view, skipFocus) {
8581
- this._activePanel = view;
8606
+ setActive(panel, skipFocus) {
8607
+ this._activePanel = panel;
8582
8608
  this.panels
8583
- .filter((v) => v !== view)
8609
+ .filter((v) => v !== panel)
8584
8610
  .forEach((v) => {
8585
8611
  v.api._onDidActiveChange.fire({ isActive: false });
8586
8612
  if (!skipFocus) {
8587
8613
  v.focus();
8588
8614
  }
8589
8615
  });
8590
- view.api._onDidActiveChange.fire({ isActive: true });
8616
+ panel.api._onDidActiveChange.fire({ isActive: true });
8591
8617
  if (!skipFocus) {
8592
- view.focus();
8618
+ panel.focus();
8593
8619
  }
8594
8620
  }
8595
8621
  removePanel(panel, sizing) {
@@ -8888,6 +8914,10 @@
8888
8914
  });
8889
8915
  this.addDisposables(this._disposable);
8890
8916
  }
8917
+ setVisible(panel, visible) {
8918
+ const index = this.panels.indexOf(panel);
8919
+ this.paneview.setViewVisible(index, visible);
8920
+ }
8891
8921
  focus() {
8892
8922
  //noop
8893
8923
  }
@@ -8934,6 +8964,7 @@
8934
8964
  isExpanded: options.isExpanded,
8935
8965
  title: options.title,
8936
8966
  containerApi: new PaneviewApi(this),
8967
+ accessor: this,
8937
8968
  });
8938
8969
  this.paneview.addPane(view, size, index);
8939
8970
  view.orientation = this.paneview.orientation;
@@ -9033,6 +9064,7 @@
9033
9064
  title: data.title,
9034
9065
  isExpanded: !!view.expanded,
9035
9066
  containerApi: new PaneviewApi(this),
9067
+ accessor: this,
9036
9068
  });
9037
9069
  panel.orientation = this.paneview.orientation;
9038
9070
  });
@@ -9121,10 +9153,10 @@
9121
9153
  this._onDidChange = new Emitter();
9122
9154
  this.onDidChange = this._onDidChange.event;
9123
9155
  this.api.initialize(this);
9124
- this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9125
- const { isHidden } = event;
9156
+ this.addDisposables(this._onDidChange, this.api.onWillVisibilityChange((event) => {
9157
+ const { isVisible } = event;
9126
9158
  const { accessor } = this._params;
9127
- accessor.setVisible(this, !isHidden);
9159
+ accessor.setVisible(this, isVisible);
9128
9160
  }), this.api.onActiveChange(() => {
9129
9161
  const { accessor } = this._params;
9130
9162
  accessor.setActive(this);