dockview 4.4.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 4.4.1
3
+ * @version 4.5.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -6665,23 +6665,24 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6665
6665
  : window;
6666
6666
  }
6667
6667
  moveTo(options) {
6668
- var _a, _b, _c;
6668
+ var _a, _b, _c, _d;
6669
6669
  if (!this._group) {
6670
6670
  throw new Error(NOT_INITIALIZED_MESSAGE);
6671
6671
  }
6672
6672
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6673
6673
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6674
- skipSetActive: true,
6674
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6675
6675
  });
6676
6676
  this.accessor.moveGroupOrPanel({
6677
6677
  from: { groupId: this._group.id },
6678
6678
  to: {
6679
6679
  group,
6680
6680
  position: options.group
6681
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6681
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6682
6682
  : 'center',
6683
6683
  index: options.index,
6684
6684
  },
6685
+ skipSetActive: options.skipSetActive,
6685
6686
  });
6686
6687
  }
6687
6688
  maximize() {
@@ -6913,6 +6914,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6913
6914
  : 'center',
6914
6915
  index: options.index,
6915
6916
  },
6917
+ skipSetActive: options.skipSetActive,
6916
6918
  });
6917
6919
  }
6918
6920
  setTitle(title) {
@@ -9482,6 +9484,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9482
9484
  group: destinationGroup,
9483
9485
  position: destinationTarget,
9484
9486
  },
9487
+ skipSetActive: options.skipSetActive,
9485
9488
  });
9486
9489
  return;
9487
9490
  }
@@ -9500,11 +9503,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9500
9503
  // remove the group and do not set a new group as active
9501
9504
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9502
9505
  }
9503
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9504
- index: destinationIndex,
9505
- skipSetGroupActive: true,
9506
- }));
9507
- this.doSetGroupAndPanelActive(destinationGroup);
9506
+ this.movingLock(() => {
9507
+ var _a;
9508
+ return destinationGroup.model.openPanel(removedPanel, {
9509
+ index: destinationIndex,
9510
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9511
+ skipSetGroupActive: true,
9512
+ });
9513
+ });
9514
+ if (!options.skipSetActive) {
9515
+ this.doSetGroupAndPanelActive(destinationGroup);
9516
+ }
9508
9517
  this._onDidMovePanel.fire({
9509
9518
  panel: removedPanel,
9510
9519
  from: sourceGroup,
@@ -9607,6 +9616,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9607
9616
  const target = options.to.position;
9608
9617
  if (target === 'center') {
9609
9618
  const activePanel = from.activePanel;
9619
+ const targetActivePanel = to.activePanel;
9610
9620
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9611
9621
  skipSetActive: true,
9612
9622
  })));
@@ -9616,12 +9626,23 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9616
9626
  this.movingLock(() => {
9617
9627
  for (const panel of panels) {
9618
9628
  to.model.openPanel(panel, {
9619
- skipSetActive: panel !== activePanel,
9629
+ skipSetActive: true, // Always skip setting panels active during move
9620
9630
  skipSetGroupActive: true,
9621
9631
  });
9622
9632
  }
9623
9633
  });
9624
- this.doSetGroupAndPanelActive(to);
9634
+ if (!options.skipSetActive) {
9635
+ // Make the moved panel (from the source group) active
9636
+ if (activePanel) {
9637
+ this.doSetGroupAndPanelActive(to);
9638
+ }
9639
+ }
9640
+ else if (targetActivePanel) {
9641
+ // Ensure the target group's original active panel remains active
9642
+ to.model.openPanel(targetActivePanel, {
9643
+ skipSetGroupActive: true
9644
+ });
9645
+ }
9625
9646
  }
9626
9647
  else {
9627
9648
  switch (from.api.location.type) {
@@ -9641,12 +9662,39 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9641
9662
  if (!selectedPopoutGroup) {
9642
9663
  throw new Error('failed to find popout group');
9643
9664
  }
9644
- selectedPopoutGroup.disposable.dispose();
9665
+ // Remove from popout groups list to prevent automatic restoration
9666
+ const index = this._popoutGroups.indexOf(selectedPopoutGroup);
9667
+ if (index >= 0) {
9668
+ this._popoutGroups.splice(index, 1);
9669
+ }
9670
+ // Clean up the reference group (ghost) if it exists and is hidden
9671
+ if (selectedPopoutGroup.referenceGroup) {
9672
+ const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9673
+ if (referenceGroup && !referenceGroup.api.isVisible) {
9674
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
9675
+ }
9676
+ }
9677
+ // Manually dispose the window without triggering restoration
9678
+ selectedPopoutGroup.window.dispose();
9679
+ // Update group's location and containers for target
9680
+ if (to.api.location.type === 'grid') {
9681
+ from.model.renderContainer = this.overlayRenderContainer;
9682
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9683
+ from.model.location = { type: 'grid' };
9684
+ }
9685
+ else if (to.api.location.type === 'floating') {
9686
+ from.model.renderContainer = this.overlayRenderContainer;
9687
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9688
+ from.model.location = { type: 'floating' };
9689
+ }
9690
+ break;
9645
9691
  }
9646
9692
  }
9647
- if (from.api.location.type !== 'popout') {
9693
+ // For moves to grid locations
9694
+ if (to.api.location.type === 'grid') {
9648
9695
  const referenceLocation = getGridLocation(to.element);
9649
9696
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9697
+ // Add to grid for all moves targeting grid location
9650
9698
  let size;
9651
9699
  switch (this.gridview.orientation) {
9652
9700
  case exports.Orientation.VERTICAL:
@@ -9664,10 +9712,49 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9664
9712
  }
9665
9713
  this.gridview.addView(from, size, dropLocation);
9666
9714
  }
9715
+ else if (to.api.location.type === 'floating') {
9716
+ // For moves to floating locations, add as floating group
9717
+ // Get the position/size from the target floating group
9718
+ const targetFloatingGroup = this._floatingGroups.find((x) => x.group === to);
9719
+ if (targetFloatingGroup) {
9720
+ const box = targetFloatingGroup.overlay.toJSON();
9721
+ // Calculate position based on available properties
9722
+ let left, top;
9723
+ if ('left' in box) {
9724
+ left = box.left + 50;
9725
+ }
9726
+ else if ('right' in box) {
9727
+ left = Math.max(0, box.right - box.width - 50);
9728
+ }
9729
+ else {
9730
+ left = 50; // Default fallback
9731
+ }
9732
+ if ('top' in box) {
9733
+ top = box.top + 50;
9734
+ }
9735
+ else if ('bottom' in box) {
9736
+ top = Math.max(0, box.bottom - box.height - 50);
9737
+ }
9738
+ else {
9739
+ top = 50; // Default fallback
9740
+ }
9741
+ this.addFloatingGroup(from, {
9742
+ height: box.height,
9743
+ width: box.width,
9744
+ position: {
9745
+ left,
9746
+ top,
9747
+ },
9748
+ });
9749
+ }
9750
+ }
9667
9751
  }
9668
9752
  from.panels.forEach((panel) => {
9669
9753
  this._onDidMovePanel.fire({ panel, from });
9670
9754
  });
9755
+ if (!options.skipSetActive) {
9756
+ this.doSetGroupAndPanelActive(from);
9757
+ }
9671
9758
  }
9672
9759
  doSetGroupActive(group) {
9673
9760
  super.doSetGroupActive(group);