dockview 1.7.5 → 1.7.6

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.7.5
3
+ * @version 1.7.6
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -910,7 +910,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
910
910
  //add sash
911
911
  const sash = document.createElement('div');
912
912
  sash.className = 'sash';
913
- const onStart = (event) => {
913
+ const onPointerStart = (event) => {
914
914
  for (const item of this.viewItems) {
915
915
  item.enabled = false;
916
916
  }
@@ -969,11 +969,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
969
969
  size: snappedViewItem.size,
970
970
  };
971
971
  }
972
- //
973
- const mousemove = (mousemoveEvent) => {
972
+ const onPointerMove = (event) => {
974
973
  const current = this._orientation === exports.Orientation.HORIZONTAL
975
- ? mousemoveEvent.clientX
976
- : mousemoveEvent.clientY;
974
+ ? event.clientX
975
+ : event.clientY;
977
976
  const delta = current - start;
978
977
  this.resize(sashIndex, delta, sizes, undefined, undefined, minDelta, maxDelta, snapBefore, snapAfter);
979
978
  this.distributeEmptySpace();
@@ -987,18 +986,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
987
986
  iframe.style.pointerEvents = 'auto';
988
987
  }
989
988
  this.saveProportions();
990
- document.removeEventListener('mousemove', mousemove);
991
- document.removeEventListener('mouseup', end);
989
+ document.removeEventListener('pointermove', onPointerMove);
990
+ document.removeEventListener('pointerup', end);
991
+ document.removeEventListener('pointercancel', end);
992
992
  this._onDidSashEnd.fire(undefined);
993
993
  };
994
- document.addEventListener('mousemove', mousemove);
995
- document.addEventListener('mouseup', end);
994
+ document.addEventListener('pointermove', onPointerMove);
995
+ document.addEventListener('pointerup', end);
996
+ document.addEventListener('pointercancel', end);
996
997
  };
997
- sash.addEventListener('mousedown', onStart);
998
+ sash.addEventListener('pointerdown', onPointerStart);
998
999
  const sashItem = {
999
1000
  container: sash,
1000
1001
  disposable: () => {
1001
- sash.removeEventListener('mousedown', onStart);
1002
+ sash.removeEventListener('pointerdown', onPointerStart);
1002
1003
  this.sashContainer.removeChild(sash);
1003
1004
  },
1004
1005
  };
@@ -2091,52 +2092,70 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2091
2092
  if (!(parent instanceof BranchNode)) {
2092
2093
  throw new Error('Invalid location');
2093
2094
  }
2094
- const node = parent.children[index];
2095
- if (!(node instanceof LeafNode)) {
2095
+ const nodeToRemove = parent.children[index];
2096
+ if (!(nodeToRemove instanceof LeafNode)) {
2096
2097
  throw new Error('Invalid location');
2097
2098
  }
2098
2099
  parent.removeChild(index, sizing);
2099
- if (parent.children.length === 0) {
2100
- return node.view;
2101
- }
2102
- if (parent.children.length > 1) {
2103
- return node.view;
2104
- }
2100
+ nodeToRemove.dispose();
2101
+ if (parent.children.length !== 1) {
2102
+ return nodeToRemove.view;
2103
+ }
2104
+ // if the parent has only one child and we know the parent is a BranchNode we can make the tree
2105
+ // more efficiently spaced by replacing the parent BranchNode with the child.
2106
+ // if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
2107
+ // is a BranchNode too we should spread it's children into the grandparent.
2108
+ // refer to the remaining child as the sibling
2105
2109
  const sibling = parent.children[0];
2106
2110
  if (pathToParent.length === 0) {
2107
- // parent is root
2111
+ // if the parent is root
2108
2112
  if (sibling instanceof LeafNode) {
2109
- return node.view;
2113
+ // if the sibling is a leaf node no action is required
2114
+ return nodeToRemove.view;
2110
2115
  }
2111
- // we must promote sibling to be the new root
2116
+ // otherwise the sibling is a branch node. since the parent is the root and the root has only one child
2117
+ // which is a branch node we can just set this branch node to be the new root node
2118
+ // for good housekeeping we'll removing the sibling from it's existing tree
2112
2119
  parent.removeChild(0, sizing);
2120
+ // and set that sibling node to be root
2113
2121
  this.root = sibling;
2114
- return node.view;
2122
+ return nodeToRemove.view;
2115
2123
  }
2124
+ // otherwise the parent is apart of a large sub-tree
2116
2125
  const [grandParent, ..._] = [...pathToParent].reverse();
2117
2126
  const [parentIndex, ...__] = [...rest].reverse();
2118
2127
  const isSiblingVisible = parent.isChildVisible(0);
2128
+ // either way we need to remove the sibling from it's existing tree
2119
2129
  parent.removeChild(0, sizing);
2130
+ // note the sizes of all of the grandparents children
2120
2131
  const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2121
- grandParent.removeChild(parentIndex, sizing);
2132
+ // remove the parent from the grandparent since we are moving the sibling to take the parents place
2133
+ // this parent is no longer used and can be disposed of
2134
+ grandParent.removeChild(parentIndex, sizing).dispose();
2122
2135
  if (sibling instanceof BranchNode) {
2136
+ // replace the parent with the siblings children
2123
2137
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
2138
+ // and add those siblings to the grandparent
2124
2139
  for (let i = 0; i < sibling.children.length; i++) {
2125
2140
  const child = sibling.children[i];
2126
2141
  grandParent.addChild(child, child.size, parentIndex + i);
2127
2142
  }
2128
2143
  }
2129
2144
  else {
2145
+ // otherwise create a new leaf node and add that to the grandparent
2130
2146
  const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
2131
2147
  const siblingSizing = isSiblingVisible
2132
2148
  ? sibling.orthogonalSize
2133
2149
  : exports.Sizing.Invisible(sibling.orthogonalSize);
2134
2150
  grandParent.addChild(newSibling, siblingSizing, parentIndex);
2135
2151
  }
2152
+ // the containing node of the sibling is no longer required and can be disposed of
2153
+ sibling.dispose();
2154
+ // resize everything
2136
2155
  for (let i = 0; i < sizes.length; i++) {
2137
2156
  grandParent.resizeChild(i, sizes[i]);
2138
2157
  }
2139
- return node.view;
2158
+ return nodeToRemove.view;
2140
2159
  }
2141
2160
  layout(width, height) {
2142
2161
  const [size, orthogonalSize] = this.root.orientation === exports.Orientation.HORIZONTAL
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.7.5
3
+ * @version 1.7.6
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -943,7 +943,7 @@ class Splitview {
943
943
  //add sash
944
944
  const sash = document.createElement('div');
945
945
  sash.className = 'sash';
946
- const onStart = (event) => {
946
+ const onPointerStart = (event) => {
947
947
  for (const item of this.viewItems) {
948
948
  item.enabled = false;
949
949
  }
@@ -1002,11 +1002,10 @@ class Splitview {
1002
1002
  size: snappedViewItem.size,
1003
1003
  };
1004
1004
  }
1005
- //
1006
- const mousemove = (mousemoveEvent) => {
1005
+ const onPointerMove = (event) => {
1007
1006
  const current = this._orientation === exports.Orientation.HORIZONTAL
1008
- ? mousemoveEvent.clientX
1009
- : mousemoveEvent.clientY;
1007
+ ? event.clientX
1008
+ : event.clientY;
1010
1009
  const delta = current - start;
1011
1010
  this.resize(sashIndex, delta, sizes, undefined, undefined, minDelta, maxDelta, snapBefore, snapAfter);
1012
1011
  this.distributeEmptySpace();
@@ -1020,18 +1019,20 @@ class Splitview {
1020
1019
  iframe.style.pointerEvents = 'auto';
1021
1020
  }
1022
1021
  this.saveProportions();
1023
- document.removeEventListener('mousemove', mousemove);
1024
- document.removeEventListener('mouseup', end);
1022
+ document.removeEventListener('pointermove', onPointerMove);
1023
+ document.removeEventListener('pointerup', end);
1024
+ document.removeEventListener('pointercancel', end);
1025
1025
  this._onDidSashEnd.fire(undefined);
1026
1026
  };
1027
- document.addEventListener('mousemove', mousemove);
1028
- document.addEventListener('mouseup', end);
1027
+ document.addEventListener('pointermove', onPointerMove);
1028
+ document.addEventListener('pointerup', end);
1029
+ document.addEventListener('pointercancel', end);
1029
1030
  };
1030
- sash.addEventListener('mousedown', onStart);
1031
+ sash.addEventListener('pointerdown', onPointerStart);
1031
1032
  const sashItem = {
1032
1033
  container: sash,
1033
1034
  disposable: () => {
1034
- sash.removeEventListener('mousedown', onStart);
1035
+ sash.removeEventListener('pointerdown', onPointerStart);
1035
1036
  this.sashContainer.removeChild(sash);
1036
1037
  },
1037
1038
  };
@@ -2124,52 +2125,70 @@ class Gridview {
2124
2125
  if (!(parent instanceof BranchNode)) {
2125
2126
  throw new Error('Invalid location');
2126
2127
  }
2127
- const node = parent.children[index];
2128
- if (!(node instanceof LeafNode)) {
2128
+ const nodeToRemove = parent.children[index];
2129
+ if (!(nodeToRemove instanceof LeafNode)) {
2129
2130
  throw new Error('Invalid location');
2130
2131
  }
2131
2132
  parent.removeChild(index, sizing);
2132
- if (parent.children.length === 0) {
2133
- return node.view;
2134
- }
2135
- if (parent.children.length > 1) {
2136
- return node.view;
2137
- }
2133
+ nodeToRemove.dispose();
2134
+ if (parent.children.length !== 1) {
2135
+ return nodeToRemove.view;
2136
+ }
2137
+ // if the parent has only one child and we know the parent is a BranchNode we can make the tree
2138
+ // more efficiently spaced by replacing the parent BranchNode with the child.
2139
+ // if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
2140
+ // is a BranchNode too we should spread it's children into the grandparent.
2141
+ // refer to the remaining child as the sibling
2138
2142
  const sibling = parent.children[0];
2139
2143
  if (pathToParent.length === 0) {
2140
- // parent is root
2144
+ // if the parent is root
2141
2145
  if (sibling instanceof LeafNode) {
2142
- return node.view;
2146
+ // if the sibling is a leaf node no action is required
2147
+ return nodeToRemove.view;
2143
2148
  }
2144
- // we must promote sibling to be the new root
2149
+ // otherwise the sibling is a branch node. since the parent is the root and the root has only one child
2150
+ // which is a branch node we can just set this branch node to be the new root node
2151
+ // for good housekeeping we'll removing the sibling from it's existing tree
2145
2152
  parent.removeChild(0, sizing);
2153
+ // and set that sibling node to be root
2146
2154
  this.root = sibling;
2147
- return node.view;
2155
+ return nodeToRemove.view;
2148
2156
  }
2157
+ // otherwise the parent is apart of a large sub-tree
2149
2158
  const [grandParent, ..._] = [...pathToParent].reverse();
2150
2159
  const [parentIndex, ...__] = [...rest].reverse();
2151
2160
  const isSiblingVisible = parent.isChildVisible(0);
2161
+ // either way we need to remove the sibling from it's existing tree
2152
2162
  parent.removeChild(0, sizing);
2163
+ // note the sizes of all of the grandparents children
2153
2164
  const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2154
- grandParent.removeChild(parentIndex, sizing);
2165
+ // remove the parent from the grandparent since we are moving the sibling to take the parents place
2166
+ // this parent is no longer used and can be disposed of
2167
+ grandParent.removeChild(parentIndex, sizing).dispose();
2155
2168
  if (sibling instanceof BranchNode) {
2169
+ // replace the parent with the siblings children
2156
2170
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
2171
+ // and add those siblings to the grandparent
2157
2172
  for (let i = 0; i < sibling.children.length; i++) {
2158
2173
  const child = sibling.children[i];
2159
2174
  grandParent.addChild(child, child.size, parentIndex + i);
2160
2175
  }
2161
2176
  }
2162
2177
  else {
2178
+ // otherwise create a new leaf node and add that to the grandparent
2163
2179
  const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
2164
2180
  const siblingSizing = isSiblingVisible
2165
2181
  ? sibling.orthogonalSize
2166
2182
  : exports.Sizing.Invisible(sibling.orthogonalSize);
2167
2183
  grandParent.addChild(newSibling, siblingSizing, parentIndex);
2168
2184
  }
2185
+ // the containing node of the sibling is no longer required and can be disposed of
2186
+ sibling.dispose();
2187
+ // resize everything
2169
2188
  for (let i = 0; i < sizes.length; i++) {
2170
2189
  grandParent.resizeChild(i, sizes[i]);
2171
2190
  }
2172
- return node.view;
2191
+ return nodeToRemove.view;
2173
2192
  }
2174
2193
  layout(width, height) {
2175
2194
  const [size, orthogonalSize] = this.root.orientation === exports.Orientation.HORIZONTAL
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.7.5
3
+ * @version 1.7.6
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -921,7 +921,7 @@ class Splitview {
921
921
  //add sash
922
922
  const sash = document.createElement('div');
923
923
  sash.className = 'sash';
924
- const onStart = (event) => {
924
+ const onPointerStart = (event) => {
925
925
  for (const item of this.viewItems) {
926
926
  item.enabled = false;
927
927
  }
@@ -980,11 +980,10 @@ class Splitview {
980
980
  size: snappedViewItem.size,
981
981
  };
982
982
  }
983
- //
984
- const mousemove = (mousemoveEvent) => {
983
+ const onPointerMove = (event) => {
985
984
  const current = this._orientation === Orientation.HORIZONTAL
986
- ? mousemoveEvent.clientX
987
- : mousemoveEvent.clientY;
985
+ ? event.clientX
986
+ : event.clientY;
988
987
  const delta = current - start;
989
988
  this.resize(sashIndex, delta, sizes, undefined, undefined, minDelta, maxDelta, snapBefore, snapAfter);
990
989
  this.distributeEmptySpace();
@@ -998,18 +997,20 @@ class Splitview {
998
997
  iframe.style.pointerEvents = 'auto';
999
998
  }
1000
999
  this.saveProportions();
1001
- document.removeEventListener('mousemove', mousemove);
1002
- document.removeEventListener('mouseup', end);
1000
+ document.removeEventListener('pointermove', onPointerMove);
1001
+ document.removeEventListener('pointerup', end);
1002
+ document.removeEventListener('pointercancel', end);
1003
1003
  this._onDidSashEnd.fire(undefined);
1004
1004
  };
1005
- document.addEventListener('mousemove', mousemove);
1006
- document.addEventListener('mouseup', end);
1005
+ document.addEventListener('pointermove', onPointerMove);
1006
+ document.addEventListener('pointerup', end);
1007
+ document.addEventListener('pointercancel', end);
1007
1008
  };
1008
- sash.addEventListener('mousedown', onStart);
1009
+ sash.addEventListener('pointerdown', onPointerStart);
1009
1010
  const sashItem = {
1010
1011
  container: sash,
1011
1012
  disposable: () => {
1012
- sash.removeEventListener('mousedown', onStart);
1013
+ sash.removeEventListener('pointerdown', onPointerStart);
1013
1014
  this.sashContainer.removeChild(sash);
1014
1015
  },
1015
1016
  };
@@ -2102,52 +2103,70 @@ class Gridview {
2102
2103
  if (!(parent instanceof BranchNode)) {
2103
2104
  throw new Error('Invalid location');
2104
2105
  }
2105
- const node = parent.children[index];
2106
- if (!(node instanceof LeafNode)) {
2106
+ const nodeToRemove = parent.children[index];
2107
+ if (!(nodeToRemove instanceof LeafNode)) {
2107
2108
  throw new Error('Invalid location');
2108
2109
  }
2109
2110
  parent.removeChild(index, sizing);
2110
- if (parent.children.length === 0) {
2111
- return node.view;
2112
- }
2113
- if (parent.children.length > 1) {
2114
- return node.view;
2115
- }
2111
+ nodeToRemove.dispose();
2112
+ if (parent.children.length !== 1) {
2113
+ return nodeToRemove.view;
2114
+ }
2115
+ // if the parent has only one child and we know the parent is a BranchNode we can make the tree
2116
+ // more efficiently spaced by replacing the parent BranchNode with the child.
2117
+ // if that child is a LeafNode then we simply replace the BranchNode with the child otherwise if the child
2118
+ // is a BranchNode too we should spread it's children into the grandparent.
2119
+ // refer to the remaining child as the sibling
2116
2120
  const sibling = parent.children[0];
2117
2121
  if (pathToParent.length === 0) {
2118
- // parent is root
2122
+ // if the parent is root
2119
2123
  if (sibling instanceof LeafNode) {
2120
- return node.view;
2124
+ // if the sibling is a leaf node no action is required
2125
+ return nodeToRemove.view;
2121
2126
  }
2122
- // we must promote sibling to be the new root
2127
+ // otherwise the sibling is a branch node. since the parent is the root and the root has only one child
2128
+ // which is a branch node we can just set this branch node to be the new root node
2129
+ // for good housekeeping we'll removing the sibling from it's existing tree
2123
2130
  parent.removeChild(0, sizing);
2131
+ // and set that sibling node to be root
2124
2132
  this.root = sibling;
2125
- return node.view;
2133
+ return nodeToRemove.view;
2126
2134
  }
2135
+ // otherwise the parent is apart of a large sub-tree
2127
2136
  const [grandParent, ..._] = [...pathToParent].reverse();
2128
2137
  const [parentIndex, ...__] = [...rest].reverse();
2129
2138
  const isSiblingVisible = parent.isChildVisible(0);
2139
+ // either way we need to remove the sibling from it's existing tree
2130
2140
  parent.removeChild(0, sizing);
2141
+ // note the sizes of all of the grandparents children
2131
2142
  const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
2132
- grandParent.removeChild(parentIndex, sizing);
2143
+ // remove the parent from the grandparent since we are moving the sibling to take the parents place
2144
+ // this parent is no longer used and can be disposed of
2145
+ grandParent.removeChild(parentIndex, sizing).dispose();
2133
2146
  if (sibling instanceof BranchNode) {
2147
+ // replace the parent with the siblings children
2134
2148
  sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
2149
+ // and add those siblings to the grandparent
2135
2150
  for (let i = 0; i < sibling.children.length; i++) {
2136
2151
  const child = sibling.children[i];
2137
2152
  grandParent.addChild(child, child.size, parentIndex + i);
2138
2153
  }
2139
2154
  }
2140
2155
  else {
2156
+ // otherwise create a new leaf node and add that to the grandparent
2141
2157
  const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
2142
2158
  const siblingSizing = isSiblingVisible
2143
2159
  ? sibling.orthogonalSize
2144
2160
  : Sizing.Invisible(sibling.orthogonalSize);
2145
2161
  grandParent.addChild(newSibling, siblingSizing, parentIndex);
2146
2162
  }
2163
+ // the containing node of the sibling is no longer required and can be disposed of
2164
+ sibling.dispose();
2165
+ // resize everything
2147
2166
  for (let i = 0; i < sizes.length; i++) {
2148
2167
  grandParent.resizeChild(i, sizes[i]);
2149
2168
  }
2150
- return node.view;
2169
+ return nodeToRemove.view;
2151
2170
  }
2152
2171
  layout(width, height) {
2153
2172
  const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL