dockview 1.7.4 → 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.
- package/dist/dockview.amd.js +65 -50
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +65 -50
- package/dist/dockview.cjs.js +65 -50
- package/dist/dockview.esm.js +65 -50
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +65 -50
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +65 -50
- package/package.json +3 -3
package/dist/dockview.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.7.
|
|
3
|
+
* @version 1.7.6
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -228,7 +228,7 @@ function addDisposableWindowListener(element, type, listener, options) {
|
|
|
228
228
|
element.addEventListener(type, listener, options);
|
|
229
229
|
return {
|
|
230
230
|
dispose: () => {
|
|
231
|
-
element.removeEventListener(type, listener);
|
|
231
|
+
element.removeEventListener(type, listener, options);
|
|
232
232
|
},
|
|
233
233
|
};
|
|
234
234
|
}
|
|
@@ -236,7 +236,7 @@ function addDisposableListener(element, type, listener, options) {
|
|
|
236
236
|
element.addEventListener(type, listener, options);
|
|
237
237
|
return {
|
|
238
238
|
dispose: () => {
|
|
239
|
-
element.removeEventListener(type, listener);
|
|
239
|
+
element.removeEventListener(type, listener, options);
|
|
240
240
|
},
|
|
241
241
|
};
|
|
242
242
|
}
|
|
@@ -921,7 +921,7 @@ class Splitview {
|
|
|
921
921
|
//add sash
|
|
922
922
|
const sash = document.createElement('div');
|
|
923
923
|
sash.className = 'sash';
|
|
924
|
-
const
|
|
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
|
-
?
|
|
987
|
-
:
|
|
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,20 +997,20 @@ class Splitview {
|
|
|
998
997
|
iframe.style.pointerEvents = 'auto';
|
|
999
998
|
}
|
|
1000
999
|
this.saveProportions();
|
|
1001
|
-
document.removeEventListener('
|
|
1002
|
-
document.removeEventListener('
|
|
1003
|
-
document.removeEventListener('
|
|
1000
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
1001
|
+
document.removeEventListener('pointerup', end);
|
|
1002
|
+
document.removeEventListener('pointercancel', end);
|
|
1004
1003
|
this._onDidSashEnd.fire(undefined);
|
|
1005
1004
|
};
|
|
1006
|
-
document.addEventListener('
|
|
1007
|
-
document.addEventListener('
|
|
1008
|
-
document.addEventListener('
|
|
1005
|
+
document.addEventListener('pointermove', onPointerMove);
|
|
1006
|
+
document.addEventListener('pointerup', end);
|
|
1007
|
+
document.addEventListener('pointercancel', end);
|
|
1009
1008
|
};
|
|
1010
|
-
sash.addEventListener('
|
|
1009
|
+
sash.addEventListener('pointerdown', onPointerStart);
|
|
1011
1010
|
const sashItem = {
|
|
1012
1011
|
container: sash,
|
|
1013
1012
|
disposable: () => {
|
|
1014
|
-
sash.removeEventListener('
|
|
1013
|
+
sash.removeEventListener('pointerdown', onPointerStart);
|
|
1015
1014
|
this.sashContainer.removeChild(sash);
|
|
1016
1015
|
},
|
|
1017
1016
|
};
|
|
@@ -2104,58 +2103,70 @@ class Gridview {
|
|
|
2104
2103
|
if (!(parent instanceof BranchNode)) {
|
|
2105
2104
|
throw new Error('Invalid location');
|
|
2106
2105
|
}
|
|
2107
|
-
const
|
|
2108
|
-
if (!(
|
|
2106
|
+
const nodeToRemove = parent.children[index];
|
|
2107
|
+
if (!(nodeToRemove instanceof LeafNode)) {
|
|
2109
2108
|
throw new Error('Invalid location');
|
|
2110
2109
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
if (parent.children.length === 0) {
|
|
2116
|
-
return view;
|
|
2117
|
-
}
|
|
2118
|
-
if (parent.children.length > 1) {
|
|
2119
|
-
return view;
|
|
2110
|
+
parent.removeChild(index, sizing);
|
|
2111
|
+
nodeToRemove.dispose();
|
|
2112
|
+
if (parent.children.length !== 1) {
|
|
2113
|
+
return nodeToRemove.view;
|
|
2120
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
|
|
2121
2120
|
const sibling = parent.children[0];
|
|
2122
2121
|
if (pathToParent.length === 0) {
|
|
2123
|
-
// parent is root
|
|
2122
|
+
// if the parent is root
|
|
2124
2123
|
if (sibling instanceof LeafNode) {
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2124
|
+
// if the sibling is a leaf node no action is required
|
|
2125
|
+
return nodeToRemove.view;
|
|
2126
|
+
}
|
|
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
|
|
2130
|
+
parent.removeChild(0, sizing);
|
|
2131
|
+
// and set that sibling node to be root
|
|
2130
2132
|
this.root = sibling;
|
|
2131
|
-
return view;
|
|
2133
|
+
return nodeToRemove.view;
|
|
2132
2134
|
}
|
|
2135
|
+
// otherwise the parent is apart of a large sub-tree
|
|
2133
2136
|
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
2134
2137
|
const [parentIndex, ...__] = [...rest].reverse();
|
|
2135
2138
|
const isSiblingVisible = parent.isChildVisible(0);
|
|
2136
|
-
|
|
2137
|
-
|
|
2139
|
+
// either way we need to remove the sibling from it's existing tree
|
|
2140
|
+
parent.removeChild(0, sizing);
|
|
2141
|
+
// note the sizes of all of the grandparents children
|
|
2138
2142
|
const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
|
|
2139
|
-
|
|
2140
|
-
|
|
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();
|
|
2141
2146
|
if (sibling instanceof BranchNode) {
|
|
2147
|
+
// replace the parent with the siblings children
|
|
2142
2148
|
sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
|
|
2149
|
+
// and add those siblings to the grandparent
|
|
2143
2150
|
for (let i = 0; i < sibling.children.length; i++) {
|
|
2144
2151
|
const child = sibling.children[i];
|
|
2145
2152
|
grandParent.addChild(child, child.size, parentIndex + i);
|
|
2146
2153
|
}
|
|
2147
2154
|
}
|
|
2148
2155
|
else {
|
|
2156
|
+
// otherwise create a new leaf node and add that to the grandparent
|
|
2149
2157
|
const newSibling = new LeafNode(sibling.view, orthogonal(sibling.orientation), sibling.size);
|
|
2150
2158
|
const siblingSizing = isSiblingVisible
|
|
2151
2159
|
? sibling.orthogonalSize
|
|
2152
2160
|
: Sizing.Invisible(sibling.orthogonalSize);
|
|
2153
2161
|
grandParent.addChild(newSibling, siblingSizing, parentIndex);
|
|
2154
2162
|
}
|
|
2163
|
+
// the containing node of the sibling is no longer required and can be disposed of
|
|
2164
|
+
sibling.dispose();
|
|
2165
|
+
// resize everything
|
|
2155
2166
|
for (let i = 0; i < sizes.length; i++) {
|
|
2156
2167
|
grandParent.resizeChild(i, sizes[i]);
|
|
2157
2168
|
}
|
|
2158
|
-
return view;
|
|
2169
|
+
return nodeToRemove.view;
|
|
2159
2170
|
}
|
|
2160
2171
|
layout(width, height) {
|
|
2161
2172
|
const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL
|
|
@@ -2868,25 +2879,32 @@ class DragHandler extends CompositeDisposable {
|
|
|
2868
2879
|
constructor(el) {
|
|
2869
2880
|
super();
|
|
2870
2881
|
this.el = el;
|
|
2871
|
-
this.
|
|
2882
|
+
this.dataDisposable = new MutableDisposable();
|
|
2883
|
+
this.pointerEventsDisposable = new MutableDisposable();
|
|
2872
2884
|
this._onDragStart = new Emitter();
|
|
2873
2885
|
this.onDragStart = this._onDragStart.event;
|
|
2874
|
-
this.
|
|
2875
|
-
this.addDisposables(this._onDragStart);
|
|
2886
|
+
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2876
2887
|
this.configure();
|
|
2877
2888
|
}
|
|
2878
2889
|
configure() {
|
|
2879
2890
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2880
|
-
|
|
2891
|
+
const iframes = [
|
|
2881
2892
|
...getElementsByTagName('iframe'),
|
|
2882
2893
|
...getElementsByTagName('webview'),
|
|
2883
2894
|
];
|
|
2884
|
-
|
|
2895
|
+
this.pointerEventsDisposable.value = {
|
|
2896
|
+
dispose: () => {
|
|
2897
|
+
for (const iframe of iframes) {
|
|
2898
|
+
iframe.style.pointerEvents = 'auto';
|
|
2899
|
+
}
|
|
2900
|
+
},
|
|
2901
|
+
};
|
|
2902
|
+
for (const iframe of iframes) {
|
|
2885
2903
|
iframe.style.pointerEvents = 'none';
|
|
2886
2904
|
}
|
|
2887
2905
|
this.el.classList.add('dv-dragged');
|
|
2888
2906
|
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
2889
|
-
this.
|
|
2907
|
+
this.dataDisposable.value = this.getData(event.dataTransfer);
|
|
2890
2908
|
if (event.dataTransfer) {
|
|
2891
2909
|
event.dataTransfer.effectAllowed = 'move';
|
|
2892
2910
|
/**
|
|
@@ -2901,11 +2919,8 @@ class DragHandler extends CompositeDisposable {
|
|
|
2901
2919
|
event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
|
|
2902
2920
|
}
|
|
2903
2921
|
}), addDisposableListener(this.el, 'dragend', () => {
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
}
|
|
2907
|
-
this.iframes = [];
|
|
2908
|
-
this.disposable.dispose();
|
|
2922
|
+
this.pointerEventsDisposable.dispose();
|
|
2923
|
+
this.dataDisposable.dispose();
|
|
2909
2924
|
}));
|
|
2910
2925
|
}
|
|
2911
2926
|
}
|