dockview 1.7.2 → 1.7.4
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 +284 -196
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +284 -196
- package/dist/dockview.cjs.js +284 -196
- package/dist/dockview.esm.js +284 -196
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +284 -196
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +284 -196
- package/package.json +4 -5
package/dist/dockview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.7.
|
|
3
|
+
* @version 1.7.4
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -145,9 +145,49 @@
|
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
147
|
})(exports.DockviewEvent || (exports.DockviewEvent = {}));
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
class LeakageMonitor {
|
|
149
|
+
constructor() {
|
|
150
|
+
this.events = new Map();
|
|
151
|
+
}
|
|
152
|
+
get size() {
|
|
153
|
+
return this.events.size;
|
|
154
|
+
}
|
|
155
|
+
add(event, stacktrace) {
|
|
156
|
+
this.events.set(event, stacktrace);
|
|
157
|
+
}
|
|
158
|
+
delete(event) {
|
|
159
|
+
this.events.delete(event);
|
|
160
|
+
}
|
|
161
|
+
clear() {
|
|
162
|
+
this.events.clear();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
class Stacktrace {
|
|
166
|
+
static create() {
|
|
167
|
+
var _a;
|
|
168
|
+
return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
|
|
169
|
+
}
|
|
170
|
+
constructor(value) {
|
|
171
|
+
this.value = value;
|
|
172
|
+
}
|
|
173
|
+
print() {
|
|
174
|
+
console.warn(this.value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
class Listener {
|
|
178
|
+
constructor(callback, stacktrace) {
|
|
179
|
+
this.callback = callback;
|
|
180
|
+
this.stacktrace = stacktrace;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
|
|
150
184
|
class Emitter {
|
|
185
|
+
static setLeakageMonitorEnabled(isEnabled) {
|
|
186
|
+
if (isEnabled !== Emitter.ENABLE_TRACKING) {
|
|
187
|
+
Emitter.MEMORY_LEAK_WATCHER.clear();
|
|
188
|
+
}
|
|
189
|
+
Emitter.ENABLE_TRACKING = isEnabled;
|
|
190
|
+
}
|
|
151
191
|
constructor(options) {
|
|
152
192
|
this.options = options;
|
|
153
193
|
this._listeners = [];
|
|
@@ -155,11 +195,12 @@
|
|
|
155
195
|
}
|
|
156
196
|
get event() {
|
|
157
197
|
if (!this._event) {
|
|
158
|
-
this._event = (
|
|
198
|
+
this._event = (callback) => {
|
|
159
199
|
var _a;
|
|
160
200
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
|
|
161
|
-
|
|
201
|
+
callback(this._last);
|
|
162
202
|
}
|
|
203
|
+
const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
|
|
163
204
|
this._listeners.push(listener);
|
|
164
205
|
return {
|
|
165
206
|
dispose: () => {
|
|
@@ -167,23 +208,45 @@
|
|
|
167
208
|
if (index > -1) {
|
|
168
209
|
this._listeners.splice(index, 1);
|
|
169
210
|
}
|
|
211
|
+
else if (Emitter.ENABLE_TRACKING) ;
|
|
170
212
|
},
|
|
171
213
|
};
|
|
172
214
|
};
|
|
215
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
216
|
+
Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
|
|
217
|
+
}
|
|
173
218
|
}
|
|
174
219
|
return this._event;
|
|
175
220
|
}
|
|
176
221
|
fire(e) {
|
|
177
222
|
this._last = e;
|
|
178
223
|
for (const listener of this._listeners) {
|
|
179
|
-
listener(e);
|
|
224
|
+
listener.callback(e);
|
|
180
225
|
}
|
|
181
226
|
}
|
|
182
227
|
dispose() {
|
|
183
|
-
this.
|
|
184
|
-
|
|
228
|
+
if (!this._disposed) {
|
|
229
|
+
this._disposed = true;
|
|
230
|
+
if (this._listeners.length > 0) {
|
|
231
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
232
|
+
queueMicrotask(() => {
|
|
233
|
+
var _a;
|
|
234
|
+
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
|
|
235
|
+
for (const listener of this._listeners) {
|
|
236
|
+
console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
this._listeners = [];
|
|
241
|
+
}
|
|
242
|
+
if (Emitter.ENABLE_TRACKING && this._event) {
|
|
243
|
+
Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
185
246
|
}
|
|
186
247
|
}
|
|
248
|
+
Emitter.ENABLE_TRACKING = false;
|
|
249
|
+
Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
|
|
187
250
|
function addDisposableWindowListener(element, type, listener, options) {
|
|
188
251
|
element.addEventListener(type, listener, options);
|
|
189
252
|
return {
|
|
@@ -236,13 +299,13 @@
|
|
|
236
299
|
}
|
|
237
300
|
constructor(...args) {
|
|
238
301
|
this._isDisposed = false;
|
|
239
|
-
this.
|
|
302
|
+
this._disposables = args;
|
|
240
303
|
}
|
|
241
304
|
addDisposables(...args) {
|
|
242
|
-
args.forEach((arg) => this.
|
|
305
|
+
args.forEach((arg) => this._disposables.push(arg));
|
|
243
306
|
}
|
|
244
307
|
dispose() {
|
|
245
|
-
this.
|
|
308
|
+
this._disposables.forEach((arg) => arg.dispose());
|
|
246
309
|
this._isDisposed = true;
|
|
247
310
|
}
|
|
248
311
|
}
|
|
@@ -332,6 +395,7 @@
|
|
|
332
395
|
this.onDidFocus = this._onDidFocus.event;
|
|
333
396
|
this._onDidBlur = new Emitter();
|
|
334
397
|
this.onDidBlur = this._onDidBlur.event;
|
|
398
|
+
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
335
399
|
let hasFocus = isAncestor(document.activeElement, element);
|
|
336
400
|
let loosingFocus = false;
|
|
337
401
|
const onFocus = () => {
|
|
@@ -376,11 +440,6 @@
|
|
|
376
440
|
refreshState() {
|
|
377
441
|
this._refreshStateHandler();
|
|
378
442
|
}
|
|
379
|
-
dispose() {
|
|
380
|
-
super.dispose();
|
|
381
|
-
this._onDidBlur.dispose();
|
|
382
|
-
this._onDidFocus.dispose();
|
|
383
|
-
}
|
|
384
443
|
}
|
|
385
444
|
|
|
386
445
|
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
@@ -609,7 +668,7 @@
|
|
|
609
668
|
this._orthogonalSize = value;
|
|
610
669
|
}
|
|
611
670
|
get length() {
|
|
612
|
-
return this.
|
|
671
|
+
return this.viewItems.length;
|
|
613
672
|
}
|
|
614
673
|
get proportions() {
|
|
615
674
|
return this._proportions ? [...this._proportions] : undefined;
|
|
@@ -628,12 +687,12 @@
|
|
|
628
687
|
: 'vertical');
|
|
629
688
|
}
|
|
630
689
|
get minimumSize() {
|
|
631
|
-
return this.
|
|
690
|
+
return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
|
|
632
691
|
}
|
|
633
692
|
get maximumSize() {
|
|
634
693
|
return this.length === 0
|
|
635
694
|
? Number.POSITIVE_INFINITY
|
|
636
|
-
: this.
|
|
695
|
+
: this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
|
|
637
696
|
}
|
|
638
697
|
get startSnappingEnabled() {
|
|
639
698
|
return this._startSnappingEnabled;
|
|
@@ -657,7 +716,7 @@
|
|
|
657
716
|
}
|
|
658
717
|
constructor(container, options) {
|
|
659
718
|
this.container = container;
|
|
660
|
-
this.
|
|
719
|
+
this.viewItems = [];
|
|
661
720
|
this.sashes = [];
|
|
662
721
|
this._size = 0;
|
|
663
722
|
this._orthogonalSize = 0;
|
|
@@ -671,12 +730,12 @@
|
|
|
671
730
|
this.onDidAddView = this._onDidAddView.event;
|
|
672
731
|
this._onDidRemoveView = new Emitter();
|
|
673
732
|
this.onDidRemoveView = this._onDidRemoveView.event;
|
|
674
|
-
this.resize = (index, delta, sizes = this.
|
|
675
|
-
if (index < 0 || index > this.
|
|
733
|
+
this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
|
|
734
|
+
if (index < 0 || index > this.viewItems.length) {
|
|
676
735
|
return 0;
|
|
677
736
|
}
|
|
678
737
|
const upIndexes = range(index, -1);
|
|
679
|
-
const downIndexes = range(index + 1, this.
|
|
738
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
680
739
|
//
|
|
681
740
|
if (highPriorityIndexes) {
|
|
682
741
|
for (const i of highPriorityIndexes) {
|
|
@@ -691,34 +750,34 @@
|
|
|
691
750
|
}
|
|
692
751
|
}
|
|
693
752
|
//
|
|
694
|
-
const upItems = upIndexes.map((i) => this.
|
|
753
|
+
const upItems = upIndexes.map((i) => this.viewItems[i]);
|
|
695
754
|
const upSizes = upIndexes.map((i) => sizes[i]);
|
|
696
755
|
//
|
|
697
|
-
const downItems = downIndexes.map((i) => this.
|
|
756
|
+
const downItems = downIndexes.map((i) => this.viewItems[i]);
|
|
698
757
|
const downSizes = downIndexes.map((i) => sizes[i]);
|
|
699
758
|
//
|
|
700
|
-
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
701
|
-
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
759
|
+
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
|
|
760
|
+
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
|
|
702
761
|
//
|
|
703
762
|
const maxDeltaDown = downIndexes.length === 0
|
|
704
763
|
? Number.POSITIVE_INFINITY
|
|
705
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
764
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
|
|
706
765
|
const minDeltaDown = downIndexes.length === 0
|
|
707
766
|
? Number.NEGATIVE_INFINITY
|
|
708
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
767
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
|
|
709
768
|
//
|
|
710
769
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
711
770
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
712
771
|
//
|
|
713
772
|
let snapped = false;
|
|
714
773
|
if (snapBefore) {
|
|
715
|
-
const snapView = this.
|
|
774
|
+
const snapView = this.viewItems[snapBefore.index];
|
|
716
775
|
const visible = delta >= snapBefore.limitDelta;
|
|
717
776
|
snapped = visible !== snapView.visible;
|
|
718
777
|
snapView.setVisible(visible, snapBefore.size);
|
|
719
778
|
}
|
|
720
779
|
if (!snapped && snapAfter) {
|
|
721
|
-
const snapView = this.
|
|
780
|
+
const snapView = this.viewItems[snapAfter.index];
|
|
722
781
|
const visible = delta < snapAfter.limitDelta;
|
|
723
782
|
snapped = visible !== snapView.visible;
|
|
724
783
|
snapView.setVisible(visible, snapAfter.size);
|
|
@@ -780,7 +839,7 @@
|
|
|
780
839
|
);
|
|
781
840
|
});
|
|
782
841
|
// Initialize content size and proportions for first layout
|
|
783
|
-
this.contentSize = this.
|
|
842
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
784
843
|
this.saveProportions();
|
|
785
844
|
}
|
|
786
845
|
}
|
|
@@ -797,18 +856,18 @@
|
|
|
797
856
|
}
|
|
798
857
|
}
|
|
799
858
|
isViewVisible(index) {
|
|
800
|
-
if (index < 0 || index >= this.
|
|
859
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
801
860
|
throw new Error('Index out of bounds');
|
|
802
861
|
}
|
|
803
|
-
const viewItem = this.
|
|
862
|
+
const viewItem = this.viewItems[index];
|
|
804
863
|
return viewItem.visible;
|
|
805
864
|
}
|
|
806
865
|
setViewVisible(index, visible) {
|
|
807
|
-
if (index < 0 || index >= this.
|
|
866
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
808
867
|
throw new Error('Index out of bounds');
|
|
809
868
|
}
|
|
810
869
|
toggleClass(this.container, 'visible', visible);
|
|
811
|
-
const viewItem = this.
|
|
870
|
+
const viewItem = this.viewItems[index];
|
|
812
871
|
toggleClass(this.container, 'visible', visible);
|
|
813
872
|
viewItem.setVisible(visible, viewItem.size);
|
|
814
873
|
this.distributeEmptySpace(index);
|
|
@@ -816,33 +875,33 @@
|
|
|
816
875
|
this.saveProportions();
|
|
817
876
|
}
|
|
818
877
|
getViewSize(index) {
|
|
819
|
-
if (index < 0 || index >= this.
|
|
878
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
820
879
|
return -1;
|
|
821
880
|
}
|
|
822
|
-
return this.
|
|
881
|
+
return this.viewItems[index].size;
|
|
823
882
|
}
|
|
824
883
|
resizeView(index, size) {
|
|
825
|
-
if (index < 0 || index >= this.
|
|
884
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
826
885
|
return;
|
|
827
886
|
}
|
|
828
|
-
const indexes = range(this.
|
|
887
|
+
const indexes = range(this.viewItems.length).filter((i) => i !== index);
|
|
829
888
|
const lowPriorityIndexes = [
|
|
830
|
-
...indexes.filter((i) => this.
|
|
889
|
+
...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
|
|
831
890
|
index,
|
|
832
891
|
];
|
|
833
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
834
|
-
const item = this.
|
|
892
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
893
|
+
const item = this.viewItems[index];
|
|
835
894
|
size = Math.round(size);
|
|
836
895
|
size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
|
|
837
896
|
item.size = size;
|
|
838
897
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
839
898
|
}
|
|
840
899
|
getViews() {
|
|
841
|
-
return this.
|
|
900
|
+
return this.viewItems.map((x) => x.view);
|
|
842
901
|
}
|
|
843
902
|
onDidChange(item, size) {
|
|
844
|
-
const index = this.
|
|
845
|
-
if (index < 0 || index >= this.
|
|
903
|
+
const index = this.viewItems.indexOf(item);
|
|
904
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
846
905
|
return;
|
|
847
906
|
}
|
|
848
907
|
size = typeof size === 'number' ? size : item.size;
|
|
@@ -850,7 +909,7 @@
|
|
|
850
909
|
item.size = size;
|
|
851
910
|
this.relayout([index]);
|
|
852
911
|
}
|
|
853
|
-
addView(view, size = { type: 'distribute' }, index = this.
|
|
912
|
+
addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
|
|
854
913
|
const container = document.createElement('div');
|
|
855
914
|
container.className = 'view';
|
|
856
915
|
container.appendChild(view.element);
|
|
@@ -868,24 +927,25 @@
|
|
|
868
927
|
viewSize = view.minimumSize;
|
|
869
928
|
}
|
|
870
929
|
const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
930
|
+
const viewItem = new ViewItem(container, view, viewSize, {
|
|
931
|
+
dispose: () => {
|
|
932
|
+
disposable.dispose();
|
|
933
|
+
this.viewContainer.removeChild(container);
|
|
934
|
+
},
|
|
935
|
+
});
|
|
936
|
+
if (index === this.viewItems.length) {
|
|
877
937
|
this.viewContainer.appendChild(container);
|
|
878
938
|
}
|
|
879
939
|
else {
|
|
880
940
|
this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
|
|
881
941
|
}
|
|
882
|
-
this.
|
|
883
|
-
if (this.
|
|
942
|
+
this.viewItems.splice(index, 0, viewItem);
|
|
943
|
+
if (this.viewItems.length > 1) {
|
|
884
944
|
//add sash
|
|
885
945
|
const sash = document.createElement('div');
|
|
886
946
|
sash.className = 'sash';
|
|
887
947
|
const onStart = (event) => {
|
|
888
|
-
for (const item of this.
|
|
948
|
+
for (const item of this.viewItems) {
|
|
889
949
|
item.enabled = false;
|
|
890
950
|
}
|
|
891
951
|
const iframes = [
|
|
@@ -900,27 +960,29 @@
|
|
|
900
960
|
: event.clientY;
|
|
901
961
|
const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
|
|
902
962
|
//
|
|
903
|
-
const sizes = this.
|
|
963
|
+
const sizes = this.viewItems.map((x) => x.size);
|
|
904
964
|
//
|
|
905
965
|
let snapBefore;
|
|
906
966
|
let snapAfter;
|
|
907
967
|
const upIndexes = range(sashIndex, -1);
|
|
908
|
-
const downIndexes = range(sashIndex + 1, this.
|
|
909
|
-
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
910
|
-
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
968
|
+
const downIndexes = range(sashIndex + 1, this.viewItems.length);
|
|
969
|
+
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
|
|
970
|
+
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
|
|
911
971
|
const maxDeltaDown = downIndexes.length === 0
|
|
912
972
|
? Number.POSITIVE_INFINITY
|
|
913
|
-
: downIndexes.reduce((r, i) => r +
|
|
973
|
+
: downIndexes.reduce((r, i) => r +
|
|
974
|
+
(sizes[i] - this.viewItems[i].minimumSize), 0);
|
|
914
975
|
const minDeltaDown = downIndexes.length === 0
|
|
915
976
|
? Number.NEGATIVE_INFINITY
|
|
916
977
|
: downIndexes.reduce((r, i) => r +
|
|
917
|
-
(sizes[i] -
|
|
978
|
+
(sizes[i] -
|
|
979
|
+
this.viewItems[i].viewMaximumSize), 0);
|
|
918
980
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
919
981
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
920
982
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
921
983
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
922
984
|
if (typeof snapBeforeIndex === 'number') {
|
|
923
|
-
const snappedViewItem = this.
|
|
985
|
+
const snappedViewItem = this.viewItems[snapBeforeIndex];
|
|
924
986
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
925
987
|
snapBefore = {
|
|
926
988
|
index: snapBeforeIndex,
|
|
@@ -931,7 +993,7 @@
|
|
|
931
993
|
};
|
|
932
994
|
}
|
|
933
995
|
if (typeof snapAfterIndex === 'number') {
|
|
934
|
-
const snappedViewItem = this.
|
|
996
|
+
const snappedViewItem = this.viewItems[snapAfterIndex];
|
|
935
997
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
936
998
|
snapAfter = {
|
|
937
999
|
index: snapAfterIndex,
|
|
@@ -952,7 +1014,7 @@
|
|
|
952
1014
|
this.layoutViews();
|
|
953
1015
|
};
|
|
954
1016
|
const end = () => {
|
|
955
|
-
for (const item of this.
|
|
1017
|
+
for (const item of this.viewItems) {
|
|
956
1018
|
item.enabled = true;
|
|
957
1019
|
}
|
|
958
1020
|
for (const iframe of iframes) {
|
|
@@ -992,7 +1054,7 @@
|
|
|
992
1054
|
distributeViewSizes() {
|
|
993
1055
|
const flexibleViewItems = [];
|
|
994
1056
|
let flexibleSize = 0;
|
|
995
|
-
for (const item of this.
|
|
1057
|
+
for (const item of this.viewItems) {
|
|
996
1058
|
if (item.maximumSize - item.minimumSize > 0) {
|
|
997
1059
|
flexibleViewItems.push(item);
|
|
998
1060
|
flexibleSize += item.size;
|
|
@@ -1002,17 +1064,17 @@
|
|
|
1002
1064
|
for (const item of flexibleViewItems) {
|
|
1003
1065
|
item.size = clamp(size, item.minimumSize, item.maximumSize);
|
|
1004
1066
|
}
|
|
1005
|
-
const indexes = range(this.
|
|
1006
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1007
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1067
|
+
const indexes = range(this.viewItems.length);
|
|
1068
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1069
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1008
1070
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
1009
1071
|
}
|
|
1010
1072
|
removeView(index, sizing, skipLayout = false) {
|
|
1011
1073
|
// Remove view
|
|
1012
|
-
const viewItem = this.
|
|
1074
|
+
const viewItem = this.viewItems.splice(index, 1)[0];
|
|
1013
1075
|
viewItem.dispose();
|
|
1014
1076
|
// Remove sash
|
|
1015
|
-
if (this.
|
|
1077
|
+
if (this.viewItems.length >= 1) {
|
|
1016
1078
|
const sashIndex = Math.max(index - 1, 0);
|
|
1017
1079
|
const sashItem = this.sashes.splice(sashIndex, 1)[0];
|
|
1018
1080
|
sashItem.disposable();
|
|
@@ -1027,10 +1089,10 @@
|
|
|
1027
1089
|
return viewItem.view;
|
|
1028
1090
|
}
|
|
1029
1091
|
getViewCachedVisibleSize(index) {
|
|
1030
|
-
if (index < 0 || index >= this.
|
|
1092
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
1031
1093
|
throw new Error('Index out of bounds');
|
|
1032
1094
|
}
|
|
1033
|
-
const viewItem = this.
|
|
1095
|
+
const viewItem = this.viewItems[index];
|
|
1034
1096
|
return viewItem.cachedVisibleSize;
|
|
1035
1097
|
}
|
|
1036
1098
|
moveView(from, to) {
|
|
@@ -1046,14 +1108,14 @@
|
|
|
1046
1108
|
this.size = size;
|
|
1047
1109
|
this.orthogonalSize = orthogonalSize;
|
|
1048
1110
|
if (!this.proportions) {
|
|
1049
|
-
const indexes = range(this.
|
|
1050
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1051
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1052
|
-
this.resize(this.
|
|
1111
|
+
const indexes = range(this.viewItems.length);
|
|
1112
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1113
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1114
|
+
this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1053
1115
|
}
|
|
1054
1116
|
else {
|
|
1055
|
-
for (let i = 0; i < this.
|
|
1056
|
-
const item = this.
|
|
1117
|
+
for (let i = 0; i < this.viewItems.length; i++) {
|
|
1118
|
+
const item = this.viewItems[i];
|
|
1057
1119
|
item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
|
|
1058
1120
|
}
|
|
1059
1121
|
}
|
|
@@ -1061,18 +1123,18 @@
|
|
|
1061
1123
|
this.layoutViews();
|
|
1062
1124
|
}
|
|
1063
1125
|
relayout(lowPriorityIndexes, highPriorityIndexes) {
|
|
1064
|
-
const contentSize = this.
|
|
1065
|
-
this.resize(this.
|
|
1126
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1127
|
+
this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1066
1128
|
this.distributeEmptySpace();
|
|
1067
1129
|
this.layoutViews();
|
|
1068
1130
|
this.saveProportions();
|
|
1069
1131
|
}
|
|
1070
1132
|
distributeEmptySpace(lowPriorityIndex) {
|
|
1071
|
-
const contentSize = this.
|
|
1133
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1072
1134
|
let emptyDelta = this.size - contentSize;
|
|
1073
|
-
const indexes = range(this.
|
|
1074
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1075
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1135
|
+
const indexes = range(this.viewItems.length - 1, -1);
|
|
1136
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1137
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1076
1138
|
for (const index of highPriorityIndexes) {
|
|
1077
1139
|
pushToStart(indexes, index);
|
|
1078
1140
|
}
|
|
@@ -1083,7 +1145,7 @@
|
|
|
1083
1145
|
pushToEnd(indexes, lowPriorityIndex);
|
|
1084
1146
|
}
|
|
1085
1147
|
for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
|
|
1086
|
-
const item = this.
|
|
1148
|
+
const item = this.viewItems[indexes[i]];
|
|
1087
1149
|
const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
|
|
1088
1150
|
const viewDelta = size - item.size;
|
|
1089
1151
|
emptyDelta -= viewDelta;
|
|
@@ -1092,16 +1154,16 @@
|
|
|
1092
1154
|
}
|
|
1093
1155
|
saveProportions() {
|
|
1094
1156
|
if (this.proportionalLayout && this.contentSize > 0) {
|
|
1095
|
-
this._proportions = this.
|
|
1157
|
+
this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
|
|
1096
1158
|
}
|
|
1097
1159
|
}
|
|
1098
1160
|
layoutViews() {
|
|
1099
|
-
this.contentSize = this.
|
|
1161
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1100
1162
|
let sum = 0;
|
|
1101
1163
|
const x = [];
|
|
1102
1164
|
this.updateSashEnablement();
|
|
1103
|
-
for (let i = 0; i < this.
|
|
1104
|
-
sum += this.
|
|
1165
|
+
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
|
1166
|
+
sum += this.viewItems[i].size;
|
|
1105
1167
|
x.push(sum);
|
|
1106
1168
|
const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
|
|
1107
1169
|
if (this._orientation === exports.Orientation.HORIZONTAL) {
|
|
@@ -1113,7 +1175,7 @@
|
|
|
1113
1175
|
this.sashes[i].container.style.top = `${offset}px`;
|
|
1114
1176
|
}
|
|
1115
1177
|
}
|
|
1116
|
-
this.
|
|
1178
|
+
this.viewItems.forEach((view, i) => {
|
|
1117
1179
|
if (this._orientation === exports.Orientation.HORIZONTAL) {
|
|
1118
1180
|
view.container.style.width = `${view.size}px`;
|
|
1119
1181
|
view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
|
|
@@ -1132,7 +1194,7 @@
|
|
|
1132
1194
|
findFirstSnapIndex(indexes) {
|
|
1133
1195
|
// visible views first
|
|
1134
1196
|
for (const index of indexes) {
|
|
1135
|
-
const viewItem = this.
|
|
1197
|
+
const viewItem = this.viewItems[index];
|
|
1136
1198
|
if (!viewItem.visible) {
|
|
1137
1199
|
continue;
|
|
1138
1200
|
}
|
|
@@ -1142,7 +1204,7 @@
|
|
|
1142
1204
|
}
|
|
1143
1205
|
// then, hidden views
|
|
1144
1206
|
for (const index of indexes) {
|
|
1145
|
-
const viewItem = this.
|
|
1207
|
+
const viewItem = this.viewItems[index];
|
|
1146
1208
|
if (viewItem.visible &&
|
|
1147
1209
|
viewItem.maximumSize - viewItem.minimumSize > 0) {
|
|
1148
1210
|
return undefined;
|
|
@@ -1155,10 +1217,10 @@
|
|
|
1155
1217
|
}
|
|
1156
1218
|
updateSashEnablement() {
|
|
1157
1219
|
let previous = false;
|
|
1158
|
-
const collapsesDown = this.
|
|
1220
|
+
const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
|
|
1159
1221
|
previous = false;
|
|
1160
|
-
const expandsDown = this.
|
|
1161
|
-
const reverseViews = [...this.
|
|
1222
|
+
const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
|
|
1223
|
+
const reverseViews = [...this.viewItems].reverse();
|
|
1162
1224
|
previous = false;
|
|
1163
1225
|
const collapsesUp = reverseViews
|
|
1164
1226
|
.map((i) => (previous = i.size - i.minimumSize > 0 || previous))
|
|
@@ -1170,19 +1232,19 @@
|
|
|
1170
1232
|
let position = 0;
|
|
1171
1233
|
for (let index = 0; index < this.sashes.length; index++) {
|
|
1172
1234
|
const sash = this.sashes[index];
|
|
1173
|
-
const viewItem = this.
|
|
1235
|
+
const viewItem = this.viewItems[index];
|
|
1174
1236
|
position += viewItem.size;
|
|
1175
1237
|
const min = !(collapsesDown[index] && expandsUp[index + 1]);
|
|
1176
1238
|
const max = !(expandsDown[index] && collapsesUp[index + 1]);
|
|
1177
1239
|
if (min && max) {
|
|
1178
1240
|
const upIndexes = range(index, -1);
|
|
1179
|
-
const downIndexes = range(index + 1, this.
|
|
1241
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
1180
1242
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
1181
1243
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
1182
1244
|
const snappedBefore = typeof snapBeforeIndex === 'number' &&
|
|
1183
|
-
!this.
|
|
1245
|
+
!this.viewItems[snapBeforeIndex].visible;
|
|
1184
1246
|
const snappedAfter = typeof snapAfterIndex === 'number' &&
|
|
1185
|
-
!this.
|
|
1247
|
+
!this.viewItems[snapAfterIndex].visible;
|
|
1186
1248
|
if (snappedBefore &&
|
|
1187
1249
|
collapsesUp[index] &&
|
|
1188
1250
|
(position > 0 || this.startSnappingEnabled)) {
|
|
@@ -1242,6 +1304,9 @@
|
|
|
1242
1304
|
break;
|
|
1243
1305
|
}
|
|
1244
1306
|
}
|
|
1307
|
+
for (const viewItem of this.viewItems) {
|
|
1308
|
+
viewItem.dispose();
|
|
1309
|
+
}
|
|
1245
1310
|
this.element.remove();
|
|
1246
1311
|
}
|
|
1247
1312
|
}
|
|
@@ -1676,7 +1741,7 @@
|
|
|
1676
1741
|
throw new Error('Invalid index');
|
|
1677
1742
|
}
|
|
1678
1743
|
this.splitview.removeView(index, sizing);
|
|
1679
|
-
this._removeChild(index);
|
|
1744
|
+
return this._removeChild(index);
|
|
1680
1745
|
}
|
|
1681
1746
|
_addChild(node, index) {
|
|
1682
1747
|
this.children.splice(index, 0, node);
|
|
@@ -1698,10 +1763,10 @@
|
|
|
1698
1763
|
});
|
|
1699
1764
|
}
|
|
1700
1765
|
dispose() {
|
|
1701
|
-
super.dispose();
|
|
1702
1766
|
this._childrenDisposable.dispose();
|
|
1703
|
-
this.children.forEach((child) => child.dispose());
|
|
1704
1767
|
this.splitview.dispose();
|
|
1768
|
+
this.children.forEach((child) => child.dispose());
|
|
1769
|
+
super.dispose();
|
|
1705
1770
|
}
|
|
1706
1771
|
}
|
|
1707
1772
|
|
|
@@ -1931,7 +1996,8 @@
|
|
|
1931
1996
|
if (oldRoot.children.length === 1) {
|
|
1932
1997
|
// can remove one level of redundant branching if there is only a single child
|
|
1933
1998
|
const childReference = oldRoot.children[0];
|
|
1934
|
-
oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1999
|
+
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
2000
|
+
child.dispose();
|
|
1935
2001
|
oldRoot.dispose();
|
|
1936
2002
|
this._root.addChild(
|
|
1937
2003
|
/**
|
|
@@ -2038,7 +2104,8 @@
|
|
|
2038
2104
|
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
2039
2105
|
newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
2040
2106
|
}
|
|
2041
|
-
grandParent.removeChild(parentIndex);
|
|
2107
|
+
const child = grandParent.removeChild(parentIndex);
|
|
2108
|
+
child.dispose();
|
|
2042
2109
|
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
2043
2110
|
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
2044
2111
|
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
@@ -2064,30 +2131,36 @@
|
|
|
2064
2131
|
if (!(node instanceof LeafNode)) {
|
|
2065
2132
|
throw new Error('Invalid location');
|
|
2066
2133
|
}
|
|
2067
|
-
|
|
2134
|
+
const view = node.view;
|
|
2135
|
+
node.dispose(); // dispose of node
|
|
2136
|
+
const child = parent.removeChild(index, sizing);
|
|
2137
|
+
child.dispose();
|
|
2068
2138
|
if (parent.children.length === 0) {
|
|
2069
|
-
return
|
|
2139
|
+
return view;
|
|
2070
2140
|
}
|
|
2071
2141
|
if (parent.children.length > 1) {
|
|
2072
|
-
return
|
|
2142
|
+
return view;
|
|
2073
2143
|
}
|
|
2074
2144
|
const sibling = parent.children[0];
|
|
2075
2145
|
if (pathToParent.length === 0) {
|
|
2076
2146
|
// parent is root
|
|
2077
2147
|
if (sibling instanceof LeafNode) {
|
|
2078
|
-
return
|
|
2148
|
+
return view;
|
|
2079
2149
|
}
|
|
2080
2150
|
// we must promote sibling to be the new root
|
|
2081
|
-
parent.removeChild(0, sizing);
|
|
2151
|
+
const child = parent.removeChild(0, sizing);
|
|
2152
|
+
child.dispose();
|
|
2082
2153
|
this.root = sibling;
|
|
2083
|
-
return
|
|
2154
|
+
return view;
|
|
2084
2155
|
}
|
|
2085
2156
|
const [grandParent, ..._] = [...pathToParent].reverse();
|
|
2086
2157
|
const [parentIndex, ...__] = [...rest].reverse();
|
|
2087
2158
|
const isSiblingVisible = parent.isChildVisible(0);
|
|
2088
|
-
parent.removeChild(0, sizing);
|
|
2159
|
+
const childNode = parent.removeChild(0, sizing);
|
|
2160
|
+
childNode.dispose();
|
|
2089
2161
|
const sizes = grandParent.children.map((_size, i) => grandParent.getChildSize(i));
|
|
2090
|
-
grandParent.removeChild(parentIndex, sizing);
|
|
2162
|
+
const parentNode = grandParent.removeChild(parentIndex, sizing);
|
|
2163
|
+
parentNode.dispose();
|
|
2091
2164
|
if (sibling instanceof BranchNode) {
|
|
2092
2165
|
sizes.splice(parentIndex, 1, ...sibling.children.map((c) => c.size));
|
|
2093
2166
|
for (let i = 0; i < sibling.children.length; i++) {
|
|
@@ -2105,7 +2178,7 @@
|
|
|
2105
2178
|
for (let i = 0; i < sizes.length; i++) {
|
|
2106
2179
|
grandParent.resizeChild(i, sizes[i]);
|
|
2107
2180
|
}
|
|
2108
|
-
return
|
|
2181
|
+
return view;
|
|
2109
2182
|
}
|
|
2110
2183
|
layout(width, height) {
|
|
2111
2184
|
const [size, orthogonalSize] = this.root.orientation === exports.Orientation.HORIZONTAL
|
|
@@ -2600,6 +2673,7 @@
|
|
|
2600
2673
|
}
|
|
2601
2674
|
dispose() {
|
|
2602
2675
|
this.removeDropTarget();
|
|
2676
|
+
super.dispose();
|
|
2603
2677
|
}
|
|
2604
2678
|
toggleClasses(quadrant, width, height) {
|
|
2605
2679
|
var _a, _b, _c, _d;
|
|
@@ -2777,8 +2851,8 @@
|
|
|
2777
2851
|
if (this.panel.view) {
|
|
2778
2852
|
const _onDidFocus = this.panel.view.content.onDidFocus;
|
|
2779
2853
|
const _onDidBlur = this.panel.view.content.onDidBlur;
|
|
2780
|
-
const
|
|
2781
|
-
disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
|
|
2854
|
+
const focusTracker = trackFocus(this._element);
|
|
2855
|
+
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
2782
2856
|
if (_onDidFocus) {
|
|
2783
2857
|
disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
|
|
2784
2858
|
}
|
|
@@ -2821,6 +2895,7 @@
|
|
|
2821
2895
|
this._onDragStart = new Emitter();
|
|
2822
2896
|
this.onDragStart = this._onDragStart.event;
|
|
2823
2897
|
this.iframes = [];
|
|
2898
|
+
this.addDisposables(this._onDragStart);
|
|
2824
2899
|
this.configure();
|
|
2825
2900
|
}
|
|
2826
2901
|
configure() {
|
|
@@ -2871,13 +2946,12 @@
|
|
|
2871
2946
|
this.onChanged = this._onChanged.event;
|
|
2872
2947
|
this._onDropped = new Emitter();
|
|
2873
2948
|
this.onDrop = this._onDropped.event;
|
|
2874
|
-
this.addDisposables(this._onChanged, this._onDropped);
|
|
2875
2949
|
this._element = document.createElement('div');
|
|
2876
2950
|
this._element.className = 'tab';
|
|
2877
2951
|
this._element.tabIndex = 0;
|
|
2878
2952
|
this._element.draggable = true;
|
|
2879
2953
|
toggleClass(this.element, 'inactive-tab', true);
|
|
2880
|
-
this.addDisposables(new (class Handler extends DragHandler {
|
|
2954
|
+
this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
|
|
2881
2955
|
constructor() {
|
|
2882
2956
|
super(...arguments);
|
|
2883
2957
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
@@ -2890,9 +2964,6 @@
|
|
|
2890
2964
|
},
|
|
2891
2965
|
};
|
|
2892
2966
|
}
|
|
2893
|
-
dispose() {
|
|
2894
|
-
//
|
|
2895
|
-
}
|
|
2896
2967
|
})(this._element));
|
|
2897
2968
|
this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
|
|
2898
2969
|
if (event.defaultPrevented) {
|
|
@@ -2927,7 +2998,7 @@
|
|
|
2927
2998
|
});
|
|
2928
2999
|
this.addDisposables(this.droptarget.onDrop((event) => {
|
|
2929
3000
|
this._onDropped.fire(event);
|
|
2930
|
-
}));
|
|
3001
|
+
}), this.droptarget);
|
|
2931
3002
|
}
|
|
2932
3003
|
setActive(isActive) {
|
|
2933
3004
|
toggleClass(this.element, 'active-tab', isActive);
|
|
@@ -2942,7 +3013,6 @@
|
|
|
2942
3013
|
}
|
|
2943
3014
|
dispose() {
|
|
2944
3015
|
super.dispose();
|
|
2945
|
-
this.droptarget.dispose();
|
|
2946
3016
|
}
|
|
2947
3017
|
}
|
|
2948
3018
|
|
|
@@ -2988,9 +3058,6 @@
|
|
|
2988
3058
|
},
|
|
2989
3059
|
};
|
|
2990
3060
|
}
|
|
2991
|
-
dispose() {
|
|
2992
|
-
//
|
|
2993
|
-
}
|
|
2994
3061
|
}
|
|
2995
3062
|
|
|
2996
3063
|
class VoidContainer extends CompositeDisposable {
|
|
@@ -3146,6 +3213,7 @@
|
|
|
3146
3213
|
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
3147
3214
|
const { value, disposable } = tabToRemove;
|
|
3148
3215
|
disposable.dispose();
|
|
3216
|
+
value.dispose();
|
|
3149
3217
|
value.element.remove();
|
|
3150
3218
|
}
|
|
3151
3219
|
setActivePanel(panel) {
|
|
@@ -3189,9 +3257,10 @@
|
|
|
3189
3257
|
}
|
|
3190
3258
|
dispose() {
|
|
3191
3259
|
super.dispose();
|
|
3192
|
-
this.tabs
|
|
3193
|
-
|
|
3194
|
-
|
|
3260
|
+
for (const { value, disposable } of this.tabs) {
|
|
3261
|
+
disposable.dispose();
|
|
3262
|
+
value.dispose();
|
|
3263
|
+
}
|
|
3195
3264
|
this.tabs = [];
|
|
3196
3265
|
}
|
|
3197
3266
|
}
|
|
@@ -3289,7 +3358,7 @@
|
|
|
3289
3358
|
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
3290
3359
|
this.header.hidden = !!options.hideHeader;
|
|
3291
3360
|
this.locked = !!options.locked;
|
|
3292
|
-
this.addDisposables(this.
|
|
3361
|
+
this.addDisposables(this.tabsContainer.onDrop((event) => {
|
|
3293
3362
|
this.handleDropEvent(event.event, 'center', event.index);
|
|
3294
3363
|
}), this.contentContainer.onDidFocus(() => {
|
|
3295
3364
|
this.accessor.doSetGroupActive(this.groupPanel, true);
|
|
@@ -3297,7 +3366,7 @@
|
|
|
3297
3366
|
// noop
|
|
3298
3367
|
}), this.dropTarget.onDrop((event) => {
|
|
3299
3368
|
this.handleDropEvent(event.nativeEvent, event.position);
|
|
3300
|
-
}));
|
|
3369
|
+
}), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
|
|
3301
3370
|
}
|
|
3302
3371
|
initialize() {
|
|
3303
3372
|
var _a, _b;
|
|
@@ -3731,8 +3800,7 @@
|
|
|
3731
3800
|
this.layout(0, 0, true); // set some elements height/widths
|
|
3732
3801
|
this.addDisposables(this.gridview.onDidChange(() => {
|
|
3733
3802
|
this._bufferOnDidLayoutChange.fire();
|
|
3734
|
-
}))
|
|
3735
|
-
this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3803
|
+
}), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3736
3804
|
this._bufferOnDidLayoutChange.fire();
|
|
3737
3805
|
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
3738
3806
|
this._onDidLayoutChange.fire();
|
|
@@ -3835,7 +3903,6 @@
|
|
|
3835
3903
|
this.gridview.layout(width, height);
|
|
3836
3904
|
}
|
|
3837
3905
|
dispose() {
|
|
3838
|
-
super.dispose();
|
|
3839
3906
|
this._onDidActiveGroupChange.dispose();
|
|
3840
3907
|
this._onDidAddGroup.dispose();
|
|
3841
3908
|
this._onDidRemoveGroup.dispose();
|
|
@@ -3844,6 +3911,7 @@
|
|
|
3844
3911
|
group.dispose();
|
|
3845
3912
|
}
|
|
3846
3913
|
this.gridview.dispose();
|
|
3914
|
+
super.dispose();
|
|
3847
3915
|
}
|
|
3848
3916
|
}
|
|
3849
3917
|
|
|
@@ -3907,7 +3975,7 @@
|
|
|
3907
3975
|
//
|
|
3908
3976
|
this._onUpdateParameters = new Emitter();
|
|
3909
3977
|
this.onUpdateParameters = this._onUpdateParameters.event;
|
|
3910
|
-
this.addDisposables(this.
|
|
3978
|
+
this.addDisposables(this.onDidFocusChange((event) => {
|
|
3911
3979
|
this._isFocused = event.isFocused;
|
|
3912
3980
|
}), this.onDidActiveChange((event) => {
|
|
3913
3981
|
this._isActive = event.isActive;
|
|
@@ -3916,14 +3984,12 @@
|
|
|
3916
3984
|
}), this.onDidDimensionsChange((event) => {
|
|
3917
3985
|
this._width = event.width;
|
|
3918
3986
|
this._height = event.height;
|
|
3919
|
-
}));
|
|
3987
|
+
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
|
|
3920
3988
|
}
|
|
3921
3989
|
initialize(panel) {
|
|
3922
3990
|
this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
|
|
3923
3991
|
panel.update({
|
|
3924
|
-
params:
|
|
3925
|
-
params: parameters,
|
|
3926
|
-
},
|
|
3992
|
+
params: parameters,
|
|
3927
3993
|
});
|
|
3928
3994
|
});
|
|
3929
3995
|
}
|
|
@@ -4018,12 +4084,12 @@
|
|
|
4018
4084
|
this._element.style.height = '100%';
|
|
4019
4085
|
this._element.style.width = '100%';
|
|
4020
4086
|
this._element.style.overflow = 'hidden';
|
|
4021
|
-
const
|
|
4022
|
-
this.addDisposables(this.api, onDidFocus(() => {
|
|
4087
|
+
const focusTracker = trackFocus(this._element);
|
|
4088
|
+
this.addDisposables(this.api, focusTracker.onDidFocus(() => {
|
|
4023
4089
|
this.api._onDidChangeFocus.fire({ isFocused: true });
|
|
4024
|
-
}), onDidBlur(() => {
|
|
4090
|
+
}), focusTracker.onDidBlur(() => {
|
|
4025
4091
|
this.api._onDidChangeFocus.fire({ isFocused: false });
|
|
4026
|
-
}));
|
|
4092
|
+
}), focusTracker);
|
|
4027
4093
|
}
|
|
4028
4094
|
focus() {
|
|
4029
4095
|
this.api._onFocusEvent.fire();
|
|
@@ -4044,7 +4110,18 @@
|
|
|
4044
4110
|
}
|
|
4045
4111
|
update(event) {
|
|
4046
4112
|
var _a, _b;
|
|
4113
|
+
// merge the new parameters with the existing parameters
|
|
4047
4114
|
this._params = Object.assign(Object.assign({}, this._params), { params: Object.assign(Object.assign({}, (_a = this._params) === null || _a === void 0 ? void 0 : _a.params), event.params) });
|
|
4115
|
+
/**
|
|
4116
|
+
* delete new keys that have a value of undefined,
|
|
4117
|
+
* allow values of null
|
|
4118
|
+
*/
|
|
4119
|
+
for (const key of Object.keys(event.params)) {
|
|
4120
|
+
if (event.params[key] === undefined) {
|
|
4121
|
+
delete this._params.params[key];
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
// update the view with the updated props
|
|
4048
4125
|
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
|
|
4049
4126
|
}
|
|
4050
4127
|
toJSON() {
|
|
@@ -4058,9 +4135,9 @@
|
|
|
4058
4135
|
}
|
|
4059
4136
|
dispose() {
|
|
4060
4137
|
var _a;
|
|
4061
|
-
super.dispose();
|
|
4062
4138
|
this.api.dispose();
|
|
4063
4139
|
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4140
|
+
super.dispose();
|
|
4064
4141
|
}
|
|
4065
4142
|
}
|
|
4066
4143
|
|
|
@@ -4439,7 +4516,7 @@
|
|
|
4439
4516
|
this._maximumHeight = options.maximumHeight;
|
|
4440
4517
|
}
|
|
4441
4518
|
this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
|
|
4442
|
-
this.addDisposables(this.
|
|
4519
|
+
this.addDisposables(this.api.onVisibilityChange((event) => {
|
|
4443
4520
|
const { isVisible } = event;
|
|
4444
4521
|
const { accessor } = this._params;
|
|
4445
4522
|
accessor.setVisible(this, isVisible);
|
|
@@ -4468,7 +4545,7 @@
|
|
|
4468
4545
|
height: event.height,
|
|
4469
4546
|
width: event.width,
|
|
4470
4547
|
});
|
|
4471
|
-
}));
|
|
4548
|
+
}), this._onDidChange);
|
|
4472
4549
|
}
|
|
4473
4550
|
setVisible(isVisible) {
|
|
4474
4551
|
this.api._onDidVisibilityChange.fire({ isVisible });
|
|
@@ -4625,7 +4702,7 @@
|
|
|
4625
4702
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4626
4703
|
}
|
|
4627
4704
|
setTitle(title) {
|
|
4628
|
-
this.panel.
|
|
4705
|
+
this.panel.setTitle(title);
|
|
4629
4706
|
}
|
|
4630
4707
|
close() {
|
|
4631
4708
|
this.group.model.closePanel(this.panel);
|
|
@@ -4647,7 +4724,6 @@
|
|
|
4647
4724
|
this.id = id;
|
|
4648
4725
|
this.containerApi = containerApi;
|
|
4649
4726
|
this.view = view;
|
|
4650
|
-
this._title = '';
|
|
4651
4727
|
this._group = group;
|
|
4652
4728
|
this.api = new DockviewPanelApiImpl(this, this._group);
|
|
4653
4729
|
this.addDisposables(this.api.onActiveChange(() => {
|
|
@@ -4660,8 +4736,8 @@
|
|
|
4660
4736
|
}
|
|
4661
4737
|
init(params) {
|
|
4662
4738
|
this._params = params.params;
|
|
4663
|
-
this.setTitle(params.title);
|
|
4664
4739
|
this.view.init(Object.assign(Object.assign({}, params), { api: this.api, containerApi: this.containerApi }));
|
|
4740
|
+
this.setTitle(params.title);
|
|
4665
4741
|
}
|
|
4666
4742
|
focus() {
|
|
4667
4743
|
this.api._onFocusEvent.fire();
|
|
@@ -4678,11 +4754,10 @@
|
|
|
4678
4754
|
};
|
|
4679
4755
|
}
|
|
4680
4756
|
setTitle(title) {
|
|
4681
|
-
|
|
4682
|
-
const didTitleChange = title !== ((_a = this._params) === null || _a === void 0 ? void 0 : _a.title);
|
|
4757
|
+
const didTitleChange = title !== this.title;
|
|
4683
4758
|
if (didTitleChange) {
|
|
4684
4759
|
this._title = title;
|
|
4685
|
-
|
|
4760
|
+
this.view.update({
|
|
4686
4761
|
params: {
|
|
4687
4762
|
params: this._params,
|
|
4688
4763
|
title: this.title,
|
|
@@ -4692,14 +4767,19 @@
|
|
|
4692
4767
|
}
|
|
4693
4768
|
}
|
|
4694
4769
|
update(event) {
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4770
|
+
// merge the new parameters with the existing parameters
|
|
4771
|
+
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
|
|
4772
|
+
/**
|
|
4773
|
+
* delete new keys that have a value of undefined,
|
|
4774
|
+
* allow values of null
|
|
4775
|
+
*/
|
|
4776
|
+
for (const key of Object.keys(event.params)) {
|
|
4777
|
+
if (event.params[key] === undefined) {
|
|
4778
|
+
delete this._params[key];
|
|
4779
|
+
}
|
|
4701
4780
|
}
|
|
4702
|
-
|
|
4781
|
+
// update the view with the updated props
|
|
4782
|
+
this.view.update({
|
|
4703
4783
|
params: {
|
|
4704
4784
|
params: this._params,
|
|
4705
4785
|
title: this.title,
|
|
@@ -5074,7 +5154,7 @@
|
|
|
5074
5154
|
size: { type: 'pixels', value: 20 },
|
|
5075
5155
|
},
|
|
5076
5156
|
});
|
|
5077
|
-
this.addDisposables(dropTarget
|
|
5157
|
+
this.addDisposables(dropTarget.onDrop((event) => {
|
|
5078
5158
|
const data = getPanelData();
|
|
5079
5159
|
if (data) {
|
|
5080
5160
|
this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
|
|
@@ -5082,7 +5162,7 @@
|
|
|
5082
5162
|
else {
|
|
5083
5163
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
5084
5164
|
}
|
|
5085
|
-
}));
|
|
5165
|
+
}), dropTarget);
|
|
5086
5166
|
this._api = new DockviewApi(this);
|
|
5087
5167
|
this.updateWatermark();
|
|
5088
5168
|
}
|
|
@@ -5406,31 +5486,33 @@
|
|
|
5406
5486
|
}
|
|
5407
5487
|
super.doRemoveGroup(group, { skipActive });
|
|
5408
5488
|
}
|
|
5409
|
-
moveGroupOrPanel(
|
|
5489
|
+
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5410
5490
|
var _a;
|
|
5411
|
-
const sourceGroup =
|
|
5412
|
-
? (_a = this._groups.get(
|
|
5491
|
+
const sourceGroup = sourceGroupId
|
|
5492
|
+
? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
5413
5493
|
: undefined;
|
|
5414
|
-
if (
|
|
5494
|
+
if (sourceItemId === undefined) {
|
|
5415
5495
|
if (sourceGroup) {
|
|
5416
|
-
this.moveGroup(sourceGroup,
|
|
5496
|
+
this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
|
|
5417
5497
|
}
|
|
5418
5498
|
return;
|
|
5419
5499
|
}
|
|
5420
|
-
if (!
|
|
5421
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5422
|
-
this.panels.find((panel) => panel.id ===
|
|
5500
|
+
if (!destinationTarget || destinationTarget === 'center') {
|
|
5501
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5502
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5423
5503
|
if (!groupItem) {
|
|
5424
|
-
throw new Error(`No panel with id ${
|
|
5504
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5425
5505
|
}
|
|
5426
5506
|
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
5427
5507
|
this.doRemoveGroup(sourceGroup);
|
|
5428
5508
|
}
|
|
5429
|
-
|
|
5509
|
+
destinationGroup.model.openPanel(groupItem, {
|
|
5510
|
+
index: destinationIndex,
|
|
5511
|
+
});
|
|
5430
5512
|
}
|
|
5431
5513
|
else {
|
|
5432
|
-
const referenceLocation = getGridLocation(
|
|
5433
|
-
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5514
|
+
const referenceLocation = getGridLocation(destinationGroup.element);
|
|
5515
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5434
5516
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5435
5517
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5436
5518
|
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
@@ -5448,18 +5530,18 @@
|
|
|
5448
5530
|
skipDispose: true,
|
|
5449
5531
|
});
|
|
5450
5532
|
// after deleting the group we need to re-evaulate the ref location
|
|
5451
|
-
const updatedReferenceLocation = getGridLocation(
|
|
5452
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation,
|
|
5533
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5534
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5453
5535
|
this.doAddGroup(targetGroup, location);
|
|
5454
5536
|
}
|
|
5455
5537
|
}
|
|
5456
5538
|
else {
|
|
5457
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5458
|
-
this.panels.find((panel) => panel.id ===
|
|
5539
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5540
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5459
5541
|
if (!groupItem) {
|
|
5460
|
-
throw new Error(`No panel with id ${
|
|
5542
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5461
5543
|
}
|
|
5462
|
-
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5544
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5463
5545
|
const group = this.createGroupAtLocation(dropLocation);
|
|
5464
5546
|
group.model.openPanel(groupItem);
|
|
5465
5547
|
}
|
|
@@ -5553,11 +5635,11 @@
|
|
|
5553
5635
|
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
5554
5636
|
}
|
|
5555
5637
|
dispose() {
|
|
5556
|
-
super.dispose();
|
|
5557
5638
|
this._onDidActivePanelChange.dispose();
|
|
5558
5639
|
this._onDidAddPanel.dispose();
|
|
5559
5640
|
this._onDidRemovePanel.dispose();
|
|
5560
5641
|
this._onDidLayoutFromJSON.dispose();
|
|
5642
|
+
super.dispose();
|
|
5561
5643
|
}
|
|
5562
5644
|
}
|
|
5563
5645
|
|
|
@@ -5815,7 +5897,7 @@
|
|
|
5815
5897
|
}
|
|
5816
5898
|
set splitview(value) {
|
|
5817
5899
|
this._splitview = value;
|
|
5818
|
-
this.
|
|
5900
|
+
this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
|
|
5819
5901
|
this._onDidLayoutChange.fire(undefined);
|
|
5820
5902
|
}), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
|
|
5821
5903
|
}
|
|
@@ -5837,7 +5919,7 @@
|
|
|
5837
5919
|
}
|
|
5838
5920
|
constructor(options) {
|
|
5839
5921
|
super(options.parentElement);
|
|
5840
|
-
this.
|
|
5922
|
+
this._splitviewChangeDisposable = new MutableDisposable();
|
|
5841
5923
|
this._panels = new Map();
|
|
5842
5924
|
this._onDidLayoutfromJSON = new Emitter();
|
|
5843
5925
|
this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
|
|
@@ -5855,7 +5937,7 @@
|
|
|
5855
5937
|
options.frameworkComponents = {};
|
|
5856
5938
|
}
|
|
5857
5939
|
this.splitview = new Splitview(this.element, options);
|
|
5858
|
-
this.addDisposables(this.
|
|
5940
|
+
this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
|
|
5859
5941
|
}
|
|
5860
5942
|
updateOptions(options) {
|
|
5861
5943
|
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
@@ -5893,15 +5975,15 @@
|
|
|
5893
5975
|
}
|
|
5894
5976
|
}
|
|
5895
5977
|
removePanel(panel, sizing) {
|
|
5896
|
-
const
|
|
5897
|
-
if (!
|
|
5978
|
+
const item = this._panels.get(panel.id);
|
|
5979
|
+
if (!item) {
|
|
5898
5980
|
throw new Error(`unknown splitview panel ${panel.id}`);
|
|
5899
5981
|
}
|
|
5900
|
-
|
|
5901
|
-
disposable.value.dispose();
|
|
5982
|
+
item.dispose();
|
|
5902
5983
|
this._panels.delete(panel.id);
|
|
5903
5984
|
const index = this.panels.findIndex((_) => _ === panel);
|
|
5904
|
-
this.splitview.removeView(index, sizing);
|
|
5985
|
+
const removedView = this.splitview.removeView(index, sizing);
|
|
5986
|
+
removedView.dispose();
|
|
5905
5987
|
const panels = this.panels;
|
|
5906
5988
|
if (panels.length > 0) {
|
|
5907
5989
|
this.setActive(panels[panels.length - 1]);
|
|
@@ -5948,7 +6030,7 @@
|
|
|
5948
6030
|
}
|
|
5949
6031
|
this.setActive(view, true);
|
|
5950
6032
|
});
|
|
5951
|
-
this._panels.set(view.id,
|
|
6033
|
+
this._panels.set(view.id, disposable);
|
|
5952
6034
|
}
|
|
5953
6035
|
toJSON() {
|
|
5954
6036
|
var _a;
|
|
@@ -6021,20 +6103,26 @@
|
|
|
6021
6103
|
this._onDidLayoutfromJSON.fire();
|
|
6022
6104
|
}
|
|
6023
6105
|
clear() {
|
|
6024
|
-
for (const
|
|
6025
|
-
|
|
6026
|
-
value.value.dispose();
|
|
6106
|
+
for (const disposable of this._panels.values()) {
|
|
6107
|
+
disposable.dispose();
|
|
6027
6108
|
}
|
|
6028
6109
|
this._panels.clear();
|
|
6029
|
-
this.splitview.
|
|
6110
|
+
while (this.splitview.length > 0) {
|
|
6111
|
+
const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
|
|
6112
|
+
view.dispose();
|
|
6113
|
+
}
|
|
6030
6114
|
}
|
|
6031
6115
|
dispose() {
|
|
6032
|
-
for (const
|
|
6033
|
-
|
|
6034
|
-
value.value.dispose();
|
|
6116
|
+
for (const disposable of this._panels.values()) {
|
|
6117
|
+
disposable.dispose();
|
|
6035
6118
|
}
|
|
6036
6119
|
this._panels.clear();
|
|
6120
|
+
const views = this.splitview.getViews();
|
|
6121
|
+
this._splitviewChangeDisposable.dispose();
|
|
6037
6122
|
this.splitview.dispose();
|
|
6123
|
+
for (const view of views) {
|
|
6124
|
+
view.dispose();
|
|
6125
|
+
}
|
|
6038
6126
|
super.dispose();
|
|
6039
6127
|
}
|
|
6040
6128
|
}
|