dockview 1.7.3 → 1.7.5
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 +281 -194
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +281 -194
- package/dist/dockview.cjs.js +281 -194
- package/dist/dockview.esm.js +281 -194
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +281 -194
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +281 -194
- package/package.json +3 -3
package/dist/dockview.noStyle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.7.
|
|
3
|
+
* @version 1.7.5
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -115,9 +115,49 @@
|
|
|
115
115
|
};
|
|
116
116
|
};
|
|
117
117
|
})(exports.DockviewEvent || (exports.DockviewEvent = {}));
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
class LeakageMonitor {
|
|
119
|
+
constructor() {
|
|
120
|
+
this.events = new Map();
|
|
121
|
+
}
|
|
122
|
+
get size() {
|
|
123
|
+
return this.events.size;
|
|
124
|
+
}
|
|
125
|
+
add(event, stacktrace) {
|
|
126
|
+
this.events.set(event, stacktrace);
|
|
127
|
+
}
|
|
128
|
+
delete(event) {
|
|
129
|
+
this.events.delete(event);
|
|
130
|
+
}
|
|
131
|
+
clear() {
|
|
132
|
+
this.events.clear();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class Stacktrace {
|
|
136
|
+
static create() {
|
|
137
|
+
var _a;
|
|
138
|
+
return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
|
|
139
|
+
}
|
|
140
|
+
constructor(value) {
|
|
141
|
+
this.value = value;
|
|
142
|
+
}
|
|
143
|
+
print() {
|
|
144
|
+
console.warn(this.value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
class Listener {
|
|
148
|
+
constructor(callback, stacktrace) {
|
|
149
|
+
this.callback = callback;
|
|
150
|
+
this.stacktrace = stacktrace;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
|
|
120
154
|
class Emitter {
|
|
155
|
+
static setLeakageMonitorEnabled(isEnabled) {
|
|
156
|
+
if (isEnabled !== Emitter.ENABLE_TRACKING) {
|
|
157
|
+
Emitter.MEMORY_LEAK_WATCHER.clear();
|
|
158
|
+
}
|
|
159
|
+
Emitter.ENABLE_TRACKING = isEnabled;
|
|
160
|
+
}
|
|
121
161
|
constructor(options) {
|
|
122
162
|
this.options = options;
|
|
123
163
|
this._listeners = [];
|
|
@@ -125,11 +165,12 @@
|
|
|
125
165
|
}
|
|
126
166
|
get event() {
|
|
127
167
|
if (!this._event) {
|
|
128
|
-
this._event = (
|
|
168
|
+
this._event = (callback) => {
|
|
129
169
|
var _a;
|
|
130
170
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
|
|
131
|
-
|
|
171
|
+
callback(this._last);
|
|
132
172
|
}
|
|
173
|
+
const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
|
|
133
174
|
this._listeners.push(listener);
|
|
134
175
|
return {
|
|
135
176
|
dispose: () => {
|
|
@@ -137,28 +178,50 @@
|
|
|
137
178
|
if (index > -1) {
|
|
138
179
|
this._listeners.splice(index, 1);
|
|
139
180
|
}
|
|
181
|
+
else if (Emitter.ENABLE_TRACKING) ;
|
|
140
182
|
},
|
|
141
183
|
};
|
|
142
184
|
};
|
|
185
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
186
|
+
Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
|
|
187
|
+
}
|
|
143
188
|
}
|
|
144
189
|
return this._event;
|
|
145
190
|
}
|
|
146
191
|
fire(e) {
|
|
147
192
|
this._last = e;
|
|
148
193
|
for (const listener of this._listeners) {
|
|
149
|
-
listener(e);
|
|
194
|
+
listener.callback(e);
|
|
150
195
|
}
|
|
151
196
|
}
|
|
152
197
|
dispose() {
|
|
153
|
-
this.
|
|
154
|
-
|
|
198
|
+
if (!this._disposed) {
|
|
199
|
+
this._disposed = true;
|
|
200
|
+
if (this._listeners.length > 0) {
|
|
201
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
202
|
+
queueMicrotask(() => {
|
|
203
|
+
var _a;
|
|
204
|
+
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
|
|
205
|
+
for (const listener of this._listeners) {
|
|
206
|
+
console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
this._listeners = [];
|
|
211
|
+
}
|
|
212
|
+
if (Emitter.ENABLE_TRACKING && this._event) {
|
|
213
|
+
Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
155
216
|
}
|
|
156
217
|
}
|
|
218
|
+
Emitter.ENABLE_TRACKING = false;
|
|
219
|
+
Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
|
|
157
220
|
function addDisposableWindowListener(element, type, listener, options) {
|
|
158
221
|
element.addEventListener(type, listener, options);
|
|
159
222
|
return {
|
|
160
223
|
dispose: () => {
|
|
161
|
-
element.removeEventListener(type, listener);
|
|
224
|
+
element.removeEventListener(type, listener, options);
|
|
162
225
|
},
|
|
163
226
|
};
|
|
164
227
|
}
|
|
@@ -166,7 +229,7 @@
|
|
|
166
229
|
element.addEventListener(type, listener, options);
|
|
167
230
|
return {
|
|
168
231
|
dispose: () => {
|
|
169
|
-
element.removeEventListener(type, listener);
|
|
232
|
+
element.removeEventListener(type, listener, options);
|
|
170
233
|
},
|
|
171
234
|
};
|
|
172
235
|
}
|
|
@@ -206,13 +269,13 @@
|
|
|
206
269
|
}
|
|
207
270
|
constructor(...args) {
|
|
208
271
|
this._isDisposed = false;
|
|
209
|
-
this.
|
|
272
|
+
this._disposables = args;
|
|
210
273
|
}
|
|
211
274
|
addDisposables(...args) {
|
|
212
|
-
args.forEach((arg) => this.
|
|
275
|
+
args.forEach((arg) => this._disposables.push(arg));
|
|
213
276
|
}
|
|
214
277
|
dispose() {
|
|
215
|
-
this.
|
|
278
|
+
this._disposables.forEach((arg) => arg.dispose());
|
|
216
279
|
this._isDisposed = true;
|
|
217
280
|
}
|
|
218
281
|
}
|
|
@@ -302,6 +365,7 @@
|
|
|
302
365
|
this.onDidFocus = this._onDidFocus.event;
|
|
303
366
|
this._onDidBlur = new Emitter();
|
|
304
367
|
this.onDidBlur = this._onDidBlur.event;
|
|
368
|
+
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
305
369
|
let hasFocus = isAncestor(document.activeElement, element);
|
|
306
370
|
let loosingFocus = false;
|
|
307
371
|
const onFocus = () => {
|
|
@@ -346,11 +410,6 @@
|
|
|
346
410
|
refreshState() {
|
|
347
411
|
this._refreshStateHandler();
|
|
348
412
|
}
|
|
349
|
-
dispose() {
|
|
350
|
-
super.dispose();
|
|
351
|
-
this._onDidBlur.dispose();
|
|
352
|
-
this._onDidFocus.dispose();
|
|
353
|
-
}
|
|
354
413
|
}
|
|
355
414
|
|
|
356
415
|
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
@@ -579,7 +638,7 @@
|
|
|
579
638
|
this._orthogonalSize = value;
|
|
580
639
|
}
|
|
581
640
|
get length() {
|
|
582
|
-
return this.
|
|
641
|
+
return this.viewItems.length;
|
|
583
642
|
}
|
|
584
643
|
get proportions() {
|
|
585
644
|
return this._proportions ? [...this._proportions] : undefined;
|
|
@@ -598,12 +657,12 @@
|
|
|
598
657
|
: 'vertical');
|
|
599
658
|
}
|
|
600
659
|
get minimumSize() {
|
|
601
|
-
return this.
|
|
660
|
+
return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
|
|
602
661
|
}
|
|
603
662
|
get maximumSize() {
|
|
604
663
|
return this.length === 0
|
|
605
664
|
? Number.POSITIVE_INFINITY
|
|
606
|
-
: this.
|
|
665
|
+
: this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
|
|
607
666
|
}
|
|
608
667
|
get startSnappingEnabled() {
|
|
609
668
|
return this._startSnappingEnabled;
|
|
@@ -627,7 +686,7 @@
|
|
|
627
686
|
}
|
|
628
687
|
constructor(container, options) {
|
|
629
688
|
this.container = container;
|
|
630
|
-
this.
|
|
689
|
+
this.viewItems = [];
|
|
631
690
|
this.sashes = [];
|
|
632
691
|
this._size = 0;
|
|
633
692
|
this._orthogonalSize = 0;
|
|
@@ -641,12 +700,12 @@
|
|
|
641
700
|
this.onDidAddView = this._onDidAddView.event;
|
|
642
701
|
this._onDidRemoveView = new Emitter();
|
|
643
702
|
this.onDidRemoveView = this._onDidRemoveView.event;
|
|
644
|
-
this.resize = (index, delta, sizes = this.
|
|
645
|
-
if (index < 0 || index > this.
|
|
703
|
+
this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
|
|
704
|
+
if (index < 0 || index > this.viewItems.length) {
|
|
646
705
|
return 0;
|
|
647
706
|
}
|
|
648
707
|
const upIndexes = range(index, -1);
|
|
649
|
-
const downIndexes = range(index + 1, this.
|
|
708
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
650
709
|
//
|
|
651
710
|
if (highPriorityIndexes) {
|
|
652
711
|
for (const i of highPriorityIndexes) {
|
|
@@ -661,34 +720,34 @@
|
|
|
661
720
|
}
|
|
662
721
|
}
|
|
663
722
|
//
|
|
664
|
-
const upItems = upIndexes.map((i) => this.
|
|
723
|
+
const upItems = upIndexes.map((i) => this.viewItems[i]);
|
|
665
724
|
const upSizes = upIndexes.map((i) => sizes[i]);
|
|
666
725
|
//
|
|
667
|
-
const downItems = downIndexes.map((i) => this.
|
|
726
|
+
const downItems = downIndexes.map((i) => this.viewItems[i]);
|
|
668
727
|
const downSizes = downIndexes.map((i) => sizes[i]);
|
|
669
728
|
//
|
|
670
|
-
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
671
|
-
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
729
|
+
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
|
|
730
|
+
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
|
|
672
731
|
//
|
|
673
732
|
const maxDeltaDown = downIndexes.length === 0
|
|
674
733
|
? Number.POSITIVE_INFINITY
|
|
675
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
734
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
|
|
676
735
|
const minDeltaDown = downIndexes.length === 0
|
|
677
736
|
? Number.NEGATIVE_INFINITY
|
|
678
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
737
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
|
|
679
738
|
//
|
|
680
739
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
681
740
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
682
741
|
//
|
|
683
742
|
let snapped = false;
|
|
684
743
|
if (snapBefore) {
|
|
685
|
-
const snapView = this.
|
|
744
|
+
const snapView = this.viewItems[snapBefore.index];
|
|
686
745
|
const visible = delta >= snapBefore.limitDelta;
|
|
687
746
|
snapped = visible !== snapView.visible;
|
|
688
747
|
snapView.setVisible(visible, snapBefore.size);
|
|
689
748
|
}
|
|
690
749
|
if (!snapped && snapAfter) {
|
|
691
|
-
const snapView = this.
|
|
750
|
+
const snapView = this.viewItems[snapAfter.index];
|
|
692
751
|
const visible = delta < snapAfter.limitDelta;
|
|
693
752
|
snapped = visible !== snapView.visible;
|
|
694
753
|
snapView.setVisible(visible, snapAfter.size);
|
|
@@ -750,7 +809,7 @@
|
|
|
750
809
|
);
|
|
751
810
|
});
|
|
752
811
|
// Initialize content size and proportions for first layout
|
|
753
|
-
this.contentSize = this.
|
|
812
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
754
813
|
this.saveProportions();
|
|
755
814
|
}
|
|
756
815
|
}
|
|
@@ -767,18 +826,18 @@
|
|
|
767
826
|
}
|
|
768
827
|
}
|
|
769
828
|
isViewVisible(index) {
|
|
770
|
-
if (index < 0 || index >= this.
|
|
829
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
771
830
|
throw new Error('Index out of bounds');
|
|
772
831
|
}
|
|
773
|
-
const viewItem = this.
|
|
832
|
+
const viewItem = this.viewItems[index];
|
|
774
833
|
return viewItem.visible;
|
|
775
834
|
}
|
|
776
835
|
setViewVisible(index, visible) {
|
|
777
|
-
if (index < 0 || index >= this.
|
|
836
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
778
837
|
throw new Error('Index out of bounds');
|
|
779
838
|
}
|
|
780
839
|
toggleClass(this.container, 'visible', visible);
|
|
781
|
-
const viewItem = this.
|
|
840
|
+
const viewItem = this.viewItems[index];
|
|
782
841
|
toggleClass(this.container, 'visible', visible);
|
|
783
842
|
viewItem.setVisible(visible, viewItem.size);
|
|
784
843
|
this.distributeEmptySpace(index);
|
|
@@ -786,33 +845,33 @@
|
|
|
786
845
|
this.saveProportions();
|
|
787
846
|
}
|
|
788
847
|
getViewSize(index) {
|
|
789
|
-
if (index < 0 || index >= this.
|
|
848
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
790
849
|
return -1;
|
|
791
850
|
}
|
|
792
|
-
return this.
|
|
851
|
+
return this.viewItems[index].size;
|
|
793
852
|
}
|
|
794
853
|
resizeView(index, size) {
|
|
795
|
-
if (index < 0 || index >= this.
|
|
854
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
796
855
|
return;
|
|
797
856
|
}
|
|
798
|
-
const indexes = range(this.
|
|
857
|
+
const indexes = range(this.viewItems.length).filter((i) => i !== index);
|
|
799
858
|
const lowPriorityIndexes = [
|
|
800
|
-
...indexes.filter((i) => this.
|
|
859
|
+
...indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low),
|
|
801
860
|
index,
|
|
802
861
|
];
|
|
803
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
804
|
-
const item = this.
|
|
862
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
863
|
+
const item = this.viewItems[index];
|
|
805
864
|
size = Math.round(size);
|
|
806
865
|
size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
|
|
807
866
|
item.size = size;
|
|
808
867
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
809
868
|
}
|
|
810
869
|
getViews() {
|
|
811
|
-
return this.
|
|
870
|
+
return this.viewItems.map((x) => x.view);
|
|
812
871
|
}
|
|
813
872
|
onDidChange(item, size) {
|
|
814
|
-
const index = this.
|
|
815
|
-
if (index < 0 || index >= this.
|
|
873
|
+
const index = this.viewItems.indexOf(item);
|
|
874
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
816
875
|
return;
|
|
817
876
|
}
|
|
818
877
|
size = typeof size === 'number' ? size : item.size;
|
|
@@ -820,7 +879,7 @@
|
|
|
820
879
|
item.size = size;
|
|
821
880
|
this.relayout([index]);
|
|
822
881
|
}
|
|
823
|
-
addView(view, size = { type: 'distribute' }, index = this.
|
|
882
|
+
addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
|
|
824
883
|
const container = document.createElement('div');
|
|
825
884
|
container.className = 'view';
|
|
826
885
|
container.appendChild(view.element);
|
|
@@ -838,24 +897,25 @@
|
|
|
838
897
|
viewSize = view.minimumSize;
|
|
839
898
|
}
|
|
840
899
|
const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
900
|
+
const viewItem = new ViewItem(container, view, viewSize, {
|
|
901
|
+
dispose: () => {
|
|
902
|
+
disposable.dispose();
|
|
903
|
+
this.viewContainer.removeChild(container);
|
|
904
|
+
},
|
|
905
|
+
});
|
|
906
|
+
if (index === this.viewItems.length) {
|
|
847
907
|
this.viewContainer.appendChild(container);
|
|
848
908
|
}
|
|
849
909
|
else {
|
|
850
910
|
this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
|
|
851
911
|
}
|
|
852
|
-
this.
|
|
853
|
-
if (this.
|
|
912
|
+
this.viewItems.splice(index, 0, viewItem);
|
|
913
|
+
if (this.viewItems.length > 1) {
|
|
854
914
|
//add sash
|
|
855
915
|
const sash = document.createElement('div');
|
|
856
916
|
sash.className = 'sash';
|
|
857
917
|
const onStart = (event) => {
|
|
858
|
-
for (const item of this.
|
|
918
|
+
for (const item of this.viewItems) {
|
|
859
919
|
item.enabled = false;
|
|
860
920
|
}
|
|
861
921
|
const iframes = [
|
|
@@ -870,27 +930,29 @@
|
|
|
870
930
|
: event.clientY;
|
|
871
931
|
const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
|
|
872
932
|
//
|
|
873
|
-
const sizes = this.
|
|
933
|
+
const sizes = this.viewItems.map((x) => x.size);
|
|
874
934
|
//
|
|
875
935
|
let snapBefore;
|
|
876
936
|
let snapAfter;
|
|
877
937
|
const upIndexes = range(sashIndex, -1);
|
|
878
|
-
const downIndexes = range(sashIndex + 1, this.
|
|
879
|
-
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
880
|
-
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
938
|
+
const downIndexes = range(sashIndex + 1, this.viewItems.length);
|
|
939
|
+
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
|
|
940
|
+
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
|
|
881
941
|
const maxDeltaDown = downIndexes.length === 0
|
|
882
942
|
? Number.POSITIVE_INFINITY
|
|
883
|
-
: downIndexes.reduce((r, i) => r +
|
|
943
|
+
: downIndexes.reduce((r, i) => r +
|
|
944
|
+
(sizes[i] - this.viewItems[i].minimumSize), 0);
|
|
884
945
|
const minDeltaDown = downIndexes.length === 0
|
|
885
946
|
? Number.NEGATIVE_INFINITY
|
|
886
947
|
: downIndexes.reduce((r, i) => r +
|
|
887
|
-
(sizes[i] -
|
|
948
|
+
(sizes[i] -
|
|
949
|
+
this.viewItems[i].viewMaximumSize), 0);
|
|
888
950
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
889
951
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
890
952
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
891
953
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
892
954
|
if (typeof snapBeforeIndex === 'number') {
|
|
893
|
-
const snappedViewItem = this.
|
|
955
|
+
const snappedViewItem = this.viewItems[snapBeforeIndex];
|
|
894
956
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
895
957
|
snapBefore = {
|
|
896
958
|
index: snapBeforeIndex,
|
|
@@ -901,7 +963,7 @@
|
|
|
901
963
|
};
|
|
902
964
|
}
|
|
903
965
|
if (typeof snapAfterIndex === 'number') {
|
|
904
|
-
const snappedViewItem = this.
|
|
966
|
+
const snappedViewItem = this.viewItems[snapAfterIndex];
|
|
905
967
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
906
968
|
snapAfter = {
|
|
907
969
|
index: snapAfterIndex,
|
|
@@ -922,7 +984,7 @@
|
|
|
922
984
|
this.layoutViews();
|
|
923
985
|
};
|
|
924
986
|
const end = () => {
|
|
925
|
-
for (const item of this.
|
|
987
|
+
for (const item of this.viewItems) {
|
|
926
988
|
item.enabled = true;
|
|
927
989
|
}
|
|
928
990
|
for (const iframe of iframes) {
|
|
@@ -931,12 +993,10 @@
|
|
|
931
993
|
this.saveProportions();
|
|
932
994
|
document.removeEventListener('mousemove', mousemove);
|
|
933
995
|
document.removeEventListener('mouseup', end);
|
|
934
|
-
document.removeEventListener('mouseend', end);
|
|
935
996
|
this._onDidSashEnd.fire(undefined);
|
|
936
997
|
};
|
|
937
998
|
document.addEventListener('mousemove', mousemove);
|
|
938
999
|
document.addEventListener('mouseup', end);
|
|
939
|
-
document.addEventListener('mouseend', end);
|
|
940
1000
|
};
|
|
941
1001
|
sash.addEventListener('mousedown', onStart);
|
|
942
1002
|
const sashItem = {
|
|
@@ -962,7 +1022,7 @@
|
|
|
962
1022
|
distributeViewSizes() {
|
|
963
1023
|
const flexibleViewItems = [];
|
|
964
1024
|
let flexibleSize = 0;
|
|
965
|
-
for (const item of this.
|
|
1025
|
+
for (const item of this.viewItems) {
|
|
966
1026
|
if (item.maximumSize - item.minimumSize > 0) {
|
|
967
1027
|
flexibleViewItems.push(item);
|
|
968
1028
|
flexibleSize += item.size;
|
|
@@ -972,17 +1032,17 @@
|
|
|
972
1032
|
for (const item of flexibleViewItems) {
|
|
973
1033
|
item.size = clamp(size, item.minimumSize, item.maximumSize);
|
|
974
1034
|
}
|
|
975
|
-
const indexes = range(this.
|
|
976
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
977
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1035
|
+
const indexes = range(this.viewItems.length);
|
|
1036
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1037
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
978
1038
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
979
1039
|
}
|
|
980
1040
|
removeView(index, sizing, skipLayout = false) {
|
|
981
1041
|
// Remove view
|
|
982
|
-
const viewItem = this.
|
|
1042
|
+
const viewItem = this.viewItems.splice(index, 1)[0];
|
|
983
1043
|
viewItem.dispose();
|
|
984
1044
|
// Remove sash
|
|
985
|
-
if (this.
|
|
1045
|
+
if (this.viewItems.length >= 1) {
|
|
986
1046
|
const sashIndex = Math.max(index - 1, 0);
|
|
987
1047
|
const sashItem = this.sashes.splice(sashIndex, 1)[0];
|
|
988
1048
|
sashItem.disposable();
|
|
@@ -997,10 +1057,10 @@
|
|
|
997
1057
|
return viewItem.view;
|
|
998
1058
|
}
|
|
999
1059
|
getViewCachedVisibleSize(index) {
|
|
1000
|
-
if (index < 0 || index >= this.
|
|
1060
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
1001
1061
|
throw new Error('Index out of bounds');
|
|
1002
1062
|
}
|
|
1003
|
-
const viewItem = this.
|
|
1063
|
+
const viewItem = this.viewItems[index];
|
|
1004
1064
|
return viewItem.cachedVisibleSize;
|
|
1005
1065
|
}
|
|
1006
1066
|
moveView(from, to) {
|
|
@@ -1016,14 +1076,14 @@
|
|
|
1016
1076
|
this.size = size;
|
|
1017
1077
|
this.orthogonalSize = orthogonalSize;
|
|
1018
1078
|
if (!this.proportions) {
|
|
1019
|
-
const indexes = range(this.
|
|
1020
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1021
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1022
|
-
this.resize(this.
|
|
1079
|
+
const indexes = range(this.viewItems.length);
|
|
1080
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1081
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1082
|
+
this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1023
1083
|
}
|
|
1024
1084
|
else {
|
|
1025
|
-
for (let i = 0; i < this.
|
|
1026
|
-
const item = this.
|
|
1085
|
+
for (let i = 0; i < this.viewItems.length; i++) {
|
|
1086
|
+
const item = this.viewItems[i];
|
|
1027
1087
|
item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
|
|
1028
1088
|
}
|
|
1029
1089
|
}
|
|
@@ -1031,18 +1091,18 @@
|
|
|
1031
1091
|
this.layoutViews();
|
|
1032
1092
|
}
|
|
1033
1093
|
relayout(lowPriorityIndexes, highPriorityIndexes) {
|
|
1034
|
-
const contentSize = this.
|
|
1035
|
-
this.resize(this.
|
|
1094
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1095
|
+
this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1036
1096
|
this.distributeEmptySpace();
|
|
1037
1097
|
this.layoutViews();
|
|
1038
1098
|
this.saveProportions();
|
|
1039
1099
|
}
|
|
1040
1100
|
distributeEmptySpace(lowPriorityIndex) {
|
|
1041
|
-
const contentSize = this.
|
|
1101
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1042
1102
|
let emptyDelta = this.size - contentSize;
|
|
1043
|
-
const indexes = range(this.
|
|
1044
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1045
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1103
|
+
const indexes = range(this.viewItems.length - 1, -1);
|
|
1104
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.Low);
|
|
1105
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === exports.LayoutPriority.High);
|
|
1046
1106
|
for (const index of highPriorityIndexes) {
|
|
1047
1107
|
pushToStart(indexes, index);
|
|
1048
1108
|
}
|
|
@@ -1053,7 +1113,7 @@
|
|
|
1053
1113
|
pushToEnd(indexes, lowPriorityIndex);
|
|
1054
1114
|
}
|
|
1055
1115
|
for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
|
|
1056
|
-
const item = this.
|
|
1116
|
+
const item = this.viewItems[indexes[i]];
|
|
1057
1117
|
const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
|
|
1058
1118
|
const viewDelta = size - item.size;
|
|
1059
1119
|
emptyDelta -= viewDelta;
|
|
@@ -1062,16 +1122,16 @@
|
|
|
1062
1122
|
}
|
|
1063
1123
|
saveProportions() {
|
|
1064
1124
|
if (this.proportionalLayout && this.contentSize > 0) {
|
|
1065
|
-
this._proportions = this.
|
|
1125
|
+
this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
|
|
1066
1126
|
}
|
|
1067
1127
|
}
|
|
1068
1128
|
layoutViews() {
|
|
1069
|
-
this.contentSize = this.
|
|
1129
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1070
1130
|
let sum = 0;
|
|
1071
1131
|
const x = [];
|
|
1072
1132
|
this.updateSashEnablement();
|
|
1073
|
-
for (let i = 0; i < this.
|
|
1074
|
-
sum += this.
|
|
1133
|
+
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
|
1134
|
+
sum += this.viewItems[i].size;
|
|
1075
1135
|
x.push(sum);
|
|
1076
1136
|
const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
|
|
1077
1137
|
if (this._orientation === exports.Orientation.HORIZONTAL) {
|
|
@@ -1083,7 +1143,7 @@
|
|
|
1083
1143
|
this.sashes[i].container.style.top = `${offset}px`;
|
|
1084
1144
|
}
|
|
1085
1145
|
}
|
|
1086
|
-
this.
|
|
1146
|
+
this.viewItems.forEach((view, i) => {
|
|
1087
1147
|
if (this._orientation === exports.Orientation.HORIZONTAL) {
|
|
1088
1148
|
view.container.style.width = `${view.size}px`;
|
|
1089
1149
|
view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
|
|
@@ -1102,7 +1162,7 @@
|
|
|
1102
1162
|
findFirstSnapIndex(indexes) {
|
|
1103
1163
|
// visible views first
|
|
1104
1164
|
for (const index of indexes) {
|
|
1105
|
-
const viewItem = this.
|
|
1165
|
+
const viewItem = this.viewItems[index];
|
|
1106
1166
|
if (!viewItem.visible) {
|
|
1107
1167
|
continue;
|
|
1108
1168
|
}
|
|
@@ -1112,7 +1172,7 @@
|
|
|
1112
1172
|
}
|
|
1113
1173
|
// then, hidden views
|
|
1114
1174
|
for (const index of indexes) {
|
|
1115
|
-
const viewItem = this.
|
|
1175
|
+
const viewItem = this.viewItems[index];
|
|
1116
1176
|
if (viewItem.visible &&
|
|
1117
1177
|
viewItem.maximumSize - viewItem.minimumSize > 0) {
|
|
1118
1178
|
return undefined;
|
|
@@ -1125,10 +1185,10 @@
|
|
|
1125
1185
|
}
|
|
1126
1186
|
updateSashEnablement() {
|
|
1127
1187
|
let previous = false;
|
|
1128
|
-
const collapsesDown = this.
|
|
1188
|
+
const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
|
|
1129
1189
|
previous = false;
|
|
1130
|
-
const expandsDown = this.
|
|
1131
|
-
const reverseViews = [...this.
|
|
1190
|
+
const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
|
|
1191
|
+
const reverseViews = [...this.viewItems].reverse();
|
|
1132
1192
|
previous = false;
|
|
1133
1193
|
const collapsesUp = reverseViews
|
|
1134
1194
|
.map((i) => (previous = i.size - i.minimumSize > 0 || previous))
|
|
@@ -1140,19 +1200,19 @@
|
|
|
1140
1200
|
let position = 0;
|
|
1141
1201
|
for (let index = 0; index < this.sashes.length; index++) {
|
|
1142
1202
|
const sash = this.sashes[index];
|
|
1143
|
-
const viewItem = this.
|
|
1203
|
+
const viewItem = this.viewItems[index];
|
|
1144
1204
|
position += viewItem.size;
|
|
1145
1205
|
const min = !(collapsesDown[index] && expandsUp[index + 1]);
|
|
1146
1206
|
const max = !(expandsDown[index] && collapsesUp[index + 1]);
|
|
1147
1207
|
if (min && max) {
|
|
1148
1208
|
const upIndexes = range(index, -1);
|
|
1149
|
-
const downIndexes = range(index + 1, this.
|
|
1209
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
1150
1210
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
1151
1211
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
1152
1212
|
const snappedBefore = typeof snapBeforeIndex === 'number' &&
|
|
1153
|
-
!this.
|
|
1213
|
+
!this.viewItems[snapBeforeIndex].visible;
|
|
1154
1214
|
const snappedAfter = typeof snapAfterIndex === 'number' &&
|
|
1155
|
-
!this.
|
|
1215
|
+
!this.viewItems[snapAfterIndex].visible;
|
|
1156
1216
|
if (snappedBefore &&
|
|
1157
1217
|
collapsesUp[index] &&
|
|
1158
1218
|
(position > 0 || this.startSnappingEnabled)) {
|
|
@@ -1212,6 +1272,9 @@
|
|
|
1212
1272
|
break;
|
|
1213
1273
|
}
|
|
1214
1274
|
}
|
|
1275
|
+
for (const viewItem of this.viewItems) {
|
|
1276
|
+
viewItem.dispose();
|
|
1277
|
+
}
|
|
1215
1278
|
this.element.remove();
|
|
1216
1279
|
}
|
|
1217
1280
|
}
|
|
@@ -1646,7 +1709,7 @@
|
|
|
1646
1709
|
throw new Error('Invalid index');
|
|
1647
1710
|
}
|
|
1648
1711
|
this.splitview.removeView(index, sizing);
|
|
1649
|
-
this._removeChild(index);
|
|
1712
|
+
return this._removeChild(index);
|
|
1650
1713
|
}
|
|
1651
1714
|
_addChild(node, index) {
|
|
1652
1715
|
this.children.splice(index, 0, node);
|
|
@@ -1668,10 +1731,10 @@
|
|
|
1668
1731
|
});
|
|
1669
1732
|
}
|
|
1670
1733
|
dispose() {
|
|
1671
|
-
super.dispose();
|
|
1672
1734
|
this._childrenDisposable.dispose();
|
|
1673
|
-
this.children.forEach((child) => child.dispose());
|
|
1674
1735
|
this.splitview.dispose();
|
|
1736
|
+
this.children.forEach((child) => child.dispose());
|
|
1737
|
+
super.dispose();
|
|
1675
1738
|
}
|
|
1676
1739
|
}
|
|
1677
1740
|
|
|
@@ -1901,7 +1964,8 @@
|
|
|
1901
1964
|
if (oldRoot.children.length === 1) {
|
|
1902
1965
|
// can remove one level of redundant branching if there is only a single child
|
|
1903
1966
|
const childReference = oldRoot.children[0];
|
|
1904
|
-
oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1967
|
+
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1968
|
+
child.dispose();
|
|
1905
1969
|
oldRoot.dispose();
|
|
1906
1970
|
this._root.addChild(
|
|
1907
1971
|
/**
|
|
@@ -2008,7 +2072,8 @@
|
|
|
2008
2072
|
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
2009
2073
|
newSiblingSize = exports.Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
2010
2074
|
}
|
|
2011
|
-
grandParent.removeChild(parentIndex);
|
|
2075
|
+
const child = grandParent.removeChild(parentIndex);
|
|
2076
|
+
child.dispose();
|
|
2012
2077
|
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
2013
2078
|
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
2014
2079
|
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
@@ -2570,6 +2635,7 @@
|
|
|
2570
2635
|
}
|
|
2571
2636
|
dispose() {
|
|
2572
2637
|
this.removeDropTarget();
|
|
2638
|
+
super.dispose();
|
|
2573
2639
|
}
|
|
2574
2640
|
toggleClasses(quadrant, width, height) {
|
|
2575
2641
|
var _a, _b, _c, _d;
|
|
@@ -2747,8 +2813,8 @@
|
|
|
2747
2813
|
if (this.panel.view) {
|
|
2748
2814
|
const _onDidFocus = this.panel.view.content.onDidFocus;
|
|
2749
2815
|
const _onDidBlur = this.panel.view.content.onDidBlur;
|
|
2750
|
-
const
|
|
2751
|
-
disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
|
|
2816
|
+
const focusTracker = trackFocus(this._element);
|
|
2817
|
+
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
2752
2818
|
if (_onDidFocus) {
|
|
2753
2819
|
disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
|
|
2754
2820
|
}
|
|
@@ -2787,24 +2853,32 @@
|
|
|
2787
2853
|
constructor(el) {
|
|
2788
2854
|
super();
|
|
2789
2855
|
this.el = el;
|
|
2790
|
-
this.
|
|
2856
|
+
this.dataDisposable = new MutableDisposable();
|
|
2857
|
+
this.pointerEventsDisposable = new MutableDisposable();
|
|
2791
2858
|
this._onDragStart = new Emitter();
|
|
2792
2859
|
this.onDragStart = this._onDragStart.event;
|
|
2793
|
-
this.
|
|
2860
|
+
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2794
2861
|
this.configure();
|
|
2795
2862
|
}
|
|
2796
2863
|
configure() {
|
|
2797
2864
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2798
|
-
|
|
2865
|
+
const iframes = [
|
|
2799
2866
|
...getElementsByTagName('iframe'),
|
|
2800
2867
|
...getElementsByTagName('webview'),
|
|
2801
2868
|
];
|
|
2802
|
-
|
|
2869
|
+
this.pointerEventsDisposable.value = {
|
|
2870
|
+
dispose: () => {
|
|
2871
|
+
for (const iframe of iframes) {
|
|
2872
|
+
iframe.style.pointerEvents = 'auto';
|
|
2873
|
+
}
|
|
2874
|
+
},
|
|
2875
|
+
};
|
|
2876
|
+
for (const iframe of iframes) {
|
|
2803
2877
|
iframe.style.pointerEvents = 'none';
|
|
2804
2878
|
}
|
|
2805
2879
|
this.el.classList.add('dv-dragged');
|
|
2806
2880
|
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
2807
|
-
this.
|
|
2881
|
+
this.dataDisposable.value = this.getData(event.dataTransfer);
|
|
2808
2882
|
if (event.dataTransfer) {
|
|
2809
2883
|
event.dataTransfer.effectAllowed = 'move';
|
|
2810
2884
|
/**
|
|
@@ -2819,11 +2893,8 @@
|
|
|
2819
2893
|
event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
|
|
2820
2894
|
}
|
|
2821
2895
|
}), addDisposableListener(this.el, 'dragend', () => {
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
}
|
|
2825
|
-
this.iframes = [];
|
|
2826
|
-
this.disposable.dispose();
|
|
2896
|
+
this.pointerEventsDisposable.dispose();
|
|
2897
|
+
this.dataDisposable.dispose();
|
|
2827
2898
|
}));
|
|
2828
2899
|
}
|
|
2829
2900
|
}
|
|
@@ -2841,13 +2912,12 @@
|
|
|
2841
2912
|
this.onChanged = this._onChanged.event;
|
|
2842
2913
|
this._onDropped = new Emitter();
|
|
2843
2914
|
this.onDrop = this._onDropped.event;
|
|
2844
|
-
this.addDisposables(this._onChanged, this._onDropped);
|
|
2845
2915
|
this._element = document.createElement('div');
|
|
2846
2916
|
this._element.className = 'tab';
|
|
2847
2917
|
this._element.tabIndex = 0;
|
|
2848
2918
|
this._element.draggable = true;
|
|
2849
2919
|
toggleClass(this.element, 'inactive-tab', true);
|
|
2850
|
-
this.addDisposables(new (class Handler extends DragHandler {
|
|
2920
|
+
this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
|
|
2851
2921
|
constructor() {
|
|
2852
2922
|
super(...arguments);
|
|
2853
2923
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
@@ -2860,9 +2930,6 @@
|
|
|
2860
2930
|
},
|
|
2861
2931
|
};
|
|
2862
2932
|
}
|
|
2863
|
-
dispose() {
|
|
2864
|
-
//
|
|
2865
|
-
}
|
|
2866
2933
|
})(this._element));
|
|
2867
2934
|
this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
|
|
2868
2935
|
if (event.defaultPrevented) {
|
|
@@ -2897,7 +2964,7 @@
|
|
|
2897
2964
|
});
|
|
2898
2965
|
this.addDisposables(this.droptarget.onDrop((event) => {
|
|
2899
2966
|
this._onDropped.fire(event);
|
|
2900
|
-
}));
|
|
2967
|
+
}), this.droptarget);
|
|
2901
2968
|
}
|
|
2902
2969
|
setActive(isActive) {
|
|
2903
2970
|
toggleClass(this.element, 'active-tab', isActive);
|
|
@@ -2912,7 +2979,6 @@
|
|
|
2912
2979
|
}
|
|
2913
2980
|
dispose() {
|
|
2914
2981
|
super.dispose();
|
|
2915
|
-
this.droptarget.dispose();
|
|
2916
2982
|
}
|
|
2917
2983
|
}
|
|
2918
2984
|
|
|
@@ -2958,9 +3024,6 @@
|
|
|
2958
3024
|
},
|
|
2959
3025
|
};
|
|
2960
3026
|
}
|
|
2961
|
-
dispose() {
|
|
2962
|
-
//
|
|
2963
|
-
}
|
|
2964
3027
|
}
|
|
2965
3028
|
|
|
2966
3029
|
class VoidContainer extends CompositeDisposable {
|
|
@@ -3116,6 +3179,7 @@
|
|
|
3116
3179
|
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
3117
3180
|
const { value, disposable } = tabToRemove;
|
|
3118
3181
|
disposable.dispose();
|
|
3182
|
+
value.dispose();
|
|
3119
3183
|
value.element.remove();
|
|
3120
3184
|
}
|
|
3121
3185
|
setActivePanel(panel) {
|
|
@@ -3159,9 +3223,10 @@
|
|
|
3159
3223
|
}
|
|
3160
3224
|
dispose() {
|
|
3161
3225
|
super.dispose();
|
|
3162
|
-
this.tabs
|
|
3163
|
-
|
|
3164
|
-
|
|
3226
|
+
for (const { value, disposable } of this.tabs) {
|
|
3227
|
+
disposable.dispose();
|
|
3228
|
+
value.dispose();
|
|
3229
|
+
}
|
|
3165
3230
|
this.tabs = [];
|
|
3166
3231
|
}
|
|
3167
3232
|
}
|
|
@@ -3259,7 +3324,7 @@
|
|
|
3259
3324
|
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
3260
3325
|
this.header.hidden = !!options.hideHeader;
|
|
3261
3326
|
this.locked = !!options.locked;
|
|
3262
|
-
this.addDisposables(this.
|
|
3327
|
+
this.addDisposables(this.tabsContainer.onDrop((event) => {
|
|
3263
3328
|
this.handleDropEvent(event.event, 'center', event.index);
|
|
3264
3329
|
}), this.contentContainer.onDidFocus(() => {
|
|
3265
3330
|
this.accessor.doSetGroupActive(this.groupPanel, true);
|
|
@@ -3267,7 +3332,7 @@
|
|
|
3267
3332
|
// noop
|
|
3268
3333
|
}), this.dropTarget.onDrop((event) => {
|
|
3269
3334
|
this.handleDropEvent(event.nativeEvent, event.position);
|
|
3270
|
-
}));
|
|
3335
|
+
}), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
|
|
3271
3336
|
}
|
|
3272
3337
|
initialize() {
|
|
3273
3338
|
var _a, _b;
|
|
@@ -3701,8 +3766,7 @@
|
|
|
3701
3766
|
this.layout(0, 0, true); // set some elements height/widths
|
|
3702
3767
|
this.addDisposables(this.gridview.onDidChange(() => {
|
|
3703
3768
|
this._bufferOnDidLayoutChange.fire();
|
|
3704
|
-
}))
|
|
3705
|
-
this.addDisposables(exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3769
|
+
}), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3706
3770
|
this._bufferOnDidLayoutChange.fire();
|
|
3707
3771
|
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
3708
3772
|
this._onDidLayoutChange.fire();
|
|
@@ -3805,7 +3869,6 @@
|
|
|
3805
3869
|
this.gridview.layout(width, height);
|
|
3806
3870
|
}
|
|
3807
3871
|
dispose() {
|
|
3808
|
-
super.dispose();
|
|
3809
3872
|
this._onDidActiveGroupChange.dispose();
|
|
3810
3873
|
this._onDidAddGroup.dispose();
|
|
3811
3874
|
this._onDidRemoveGroup.dispose();
|
|
@@ -3814,6 +3877,7 @@
|
|
|
3814
3877
|
group.dispose();
|
|
3815
3878
|
}
|
|
3816
3879
|
this.gridview.dispose();
|
|
3880
|
+
super.dispose();
|
|
3817
3881
|
}
|
|
3818
3882
|
}
|
|
3819
3883
|
|
|
@@ -3877,7 +3941,7 @@
|
|
|
3877
3941
|
//
|
|
3878
3942
|
this._onUpdateParameters = new Emitter();
|
|
3879
3943
|
this.onUpdateParameters = this._onUpdateParameters.event;
|
|
3880
|
-
this.addDisposables(this.
|
|
3944
|
+
this.addDisposables(this.onDidFocusChange((event) => {
|
|
3881
3945
|
this._isFocused = event.isFocused;
|
|
3882
3946
|
}), this.onDidActiveChange((event) => {
|
|
3883
3947
|
this._isActive = event.isActive;
|
|
@@ -3886,14 +3950,12 @@
|
|
|
3886
3950
|
}), this.onDidDimensionsChange((event) => {
|
|
3887
3951
|
this._width = event.width;
|
|
3888
3952
|
this._height = event.height;
|
|
3889
|
-
}));
|
|
3953
|
+
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
|
|
3890
3954
|
}
|
|
3891
3955
|
initialize(panel) {
|
|
3892
3956
|
this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
|
|
3893
3957
|
panel.update({
|
|
3894
|
-
params:
|
|
3895
|
-
params: parameters,
|
|
3896
|
-
},
|
|
3958
|
+
params: parameters,
|
|
3897
3959
|
});
|
|
3898
3960
|
});
|
|
3899
3961
|
}
|
|
@@ -3988,12 +4050,12 @@
|
|
|
3988
4050
|
this._element.style.height = '100%';
|
|
3989
4051
|
this._element.style.width = '100%';
|
|
3990
4052
|
this._element.style.overflow = 'hidden';
|
|
3991
|
-
const
|
|
3992
|
-
this.addDisposables(this.api, onDidFocus(() => {
|
|
4053
|
+
const focusTracker = trackFocus(this._element);
|
|
4054
|
+
this.addDisposables(this.api, focusTracker.onDidFocus(() => {
|
|
3993
4055
|
this.api._onDidChangeFocus.fire({ isFocused: true });
|
|
3994
|
-
}), onDidBlur(() => {
|
|
4056
|
+
}), focusTracker.onDidBlur(() => {
|
|
3995
4057
|
this.api._onDidChangeFocus.fire({ isFocused: false });
|
|
3996
|
-
}));
|
|
4058
|
+
}), focusTracker);
|
|
3997
4059
|
}
|
|
3998
4060
|
focus() {
|
|
3999
4061
|
this.api._onFocusEvent.fire();
|
|
@@ -4014,7 +4076,18 @@
|
|
|
4014
4076
|
}
|
|
4015
4077
|
update(event) {
|
|
4016
4078
|
var _a, _b;
|
|
4079
|
+
// merge the new parameters with the existing parameters
|
|
4017
4080
|
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) });
|
|
4081
|
+
/**
|
|
4082
|
+
* delete new keys that have a value of undefined,
|
|
4083
|
+
* allow values of null
|
|
4084
|
+
*/
|
|
4085
|
+
for (const key of Object.keys(event.params)) {
|
|
4086
|
+
if (event.params[key] === undefined) {
|
|
4087
|
+
delete this._params.params[key];
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
// update the view with the updated props
|
|
4018
4091
|
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
|
|
4019
4092
|
}
|
|
4020
4093
|
toJSON() {
|
|
@@ -4028,9 +4101,9 @@
|
|
|
4028
4101
|
}
|
|
4029
4102
|
dispose() {
|
|
4030
4103
|
var _a;
|
|
4031
|
-
super.dispose();
|
|
4032
4104
|
this.api.dispose();
|
|
4033
4105
|
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4106
|
+
super.dispose();
|
|
4034
4107
|
}
|
|
4035
4108
|
}
|
|
4036
4109
|
|
|
@@ -4409,7 +4482,7 @@
|
|
|
4409
4482
|
this._maximumHeight = options.maximumHeight;
|
|
4410
4483
|
}
|
|
4411
4484
|
this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
|
|
4412
|
-
this.addDisposables(this.
|
|
4485
|
+
this.addDisposables(this.api.onVisibilityChange((event) => {
|
|
4413
4486
|
const { isVisible } = event;
|
|
4414
4487
|
const { accessor } = this._params;
|
|
4415
4488
|
accessor.setVisible(this, isVisible);
|
|
@@ -4438,7 +4511,7 @@
|
|
|
4438
4511
|
height: event.height,
|
|
4439
4512
|
width: event.width,
|
|
4440
4513
|
});
|
|
4441
|
-
}));
|
|
4514
|
+
}), this._onDidChange);
|
|
4442
4515
|
}
|
|
4443
4516
|
setVisible(isVisible) {
|
|
4444
4517
|
this.api._onDidVisibilityChange.fire({ isVisible });
|
|
@@ -4595,7 +4668,7 @@
|
|
|
4595
4668
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4596
4669
|
}
|
|
4597
4670
|
setTitle(title) {
|
|
4598
|
-
this.panel.
|
|
4671
|
+
this.panel.setTitle(title);
|
|
4599
4672
|
}
|
|
4600
4673
|
close() {
|
|
4601
4674
|
this.group.model.closePanel(this.panel);
|
|
@@ -4660,12 +4733,18 @@
|
|
|
4660
4733
|
}
|
|
4661
4734
|
}
|
|
4662
4735
|
update(event) {
|
|
4663
|
-
|
|
4664
|
-
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4736
|
+
// merge the new parameters with the existing parameters
|
|
4737
|
+
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
|
|
4738
|
+
/**
|
|
4739
|
+
* delete new keys that have a value of undefined,
|
|
4740
|
+
* allow values of null
|
|
4741
|
+
*/
|
|
4742
|
+
for (const key of Object.keys(event.params)) {
|
|
4743
|
+
if (event.params[key] === undefined) {
|
|
4744
|
+
delete this._params[key];
|
|
4745
|
+
}
|
|
4668
4746
|
}
|
|
4747
|
+
// update the view with the updated props
|
|
4669
4748
|
this.view.update({
|
|
4670
4749
|
params: {
|
|
4671
4750
|
params: this._params,
|
|
@@ -5041,7 +5120,7 @@
|
|
|
5041
5120
|
size: { type: 'pixels', value: 20 },
|
|
5042
5121
|
},
|
|
5043
5122
|
});
|
|
5044
|
-
this.addDisposables(dropTarget
|
|
5123
|
+
this.addDisposables(dropTarget.onDrop((event) => {
|
|
5045
5124
|
const data = getPanelData();
|
|
5046
5125
|
if (data) {
|
|
5047
5126
|
this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
|
|
@@ -5049,7 +5128,7 @@
|
|
|
5049
5128
|
else {
|
|
5050
5129
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
5051
5130
|
}
|
|
5052
|
-
}));
|
|
5131
|
+
}), dropTarget);
|
|
5053
5132
|
this._api = new DockviewApi(this);
|
|
5054
5133
|
this.updateWatermark();
|
|
5055
5134
|
}
|
|
@@ -5373,31 +5452,33 @@
|
|
|
5373
5452
|
}
|
|
5374
5453
|
super.doRemoveGroup(group, { skipActive });
|
|
5375
5454
|
}
|
|
5376
|
-
moveGroupOrPanel(
|
|
5455
|
+
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5377
5456
|
var _a;
|
|
5378
|
-
const sourceGroup =
|
|
5379
|
-
? (_a = this._groups.get(
|
|
5457
|
+
const sourceGroup = sourceGroupId
|
|
5458
|
+
? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
5380
5459
|
: undefined;
|
|
5381
|
-
if (
|
|
5460
|
+
if (sourceItemId === undefined) {
|
|
5382
5461
|
if (sourceGroup) {
|
|
5383
|
-
this.moveGroup(sourceGroup,
|
|
5462
|
+
this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
|
|
5384
5463
|
}
|
|
5385
5464
|
return;
|
|
5386
5465
|
}
|
|
5387
|
-
if (!
|
|
5388
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5389
|
-
this.panels.find((panel) => panel.id ===
|
|
5466
|
+
if (!destinationTarget || destinationTarget === 'center') {
|
|
5467
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5468
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5390
5469
|
if (!groupItem) {
|
|
5391
|
-
throw new Error(`No panel with id ${
|
|
5470
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5392
5471
|
}
|
|
5393
5472
|
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
5394
5473
|
this.doRemoveGroup(sourceGroup);
|
|
5395
5474
|
}
|
|
5396
|
-
|
|
5475
|
+
destinationGroup.model.openPanel(groupItem, {
|
|
5476
|
+
index: destinationIndex,
|
|
5477
|
+
});
|
|
5397
5478
|
}
|
|
5398
5479
|
else {
|
|
5399
|
-
const referenceLocation = getGridLocation(
|
|
5400
|
-
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5480
|
+
const referenceLocation = getGridLocation(destinationGroup.element);
|
|
5481
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5401
5482
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5402
5483
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5403
5484
|
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
@@ -5415,18 +5496,18 @@
|
|
|
5415
5496
|
skipDispose: true,
|
|
5416
5497
|
});
|
|
5417
5498
|
// after deleting the group we need to re-evaulate the ref location
|
|
5418
|
-
const updatedReferenceLocation = getGridLocation(
|
|
5419
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation,
|
|
5499
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5500
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5420
5501
|
this.doAddGroup(targetGroup, location);
|
|
5421
5502
|
}
|
|
5422
5503
|
}
|
|
5423
5504
|
else {
|
|
5424
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5425
|
-
this.panels.find((panel) => panel.id ===
|
|
5505
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5506
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5426
5507
|
if (!groupItem) {
|
|
5427
|
-
throw new Error(`No panel with id ${
|
|
5508
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5428
5509
|
}
|
|
5429
|
-
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5510
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5430
5511
|
const group = this.createGroupAtLocation(dropLocation);
|
|
5431
5512
|
group.model.openPanel(groupItem);
|
|
5432
5513
|
}
|
|
@@ -5520,11 +5601,11 @@
|
|
|
5520
5601
|
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
5521
5602
|
}
|
|
5522
5603
|
dispose() {
|
|
5523
|
-
super.dispose();
|
|
5524
5604
|
this._onDidActivePanelChange.dispose();
|
|
5525
5605
|
this._onDidAddPanel.dispose();
|
|
5526
5606
|
this._onDidRemovePanel.dispose();
|
|
5527
5607
|
this._onDidLayoutFromJSON.dispose();
|
|
5608
|
+
super.dispose();
|
|
5528
5609
|
}
|
|
5529
5610
|
}
|
|
5530
5611
|
|
|
@@ -5782,7 +5863,7 @@
|
|
|
5782
5863
|
}
|
|
5783
5864
|
set splitview(value) {
|
|
5784
5865
|
this._splitview = value;
|
|
5785
|
-
this.
|
|
5866
|
+
this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
|
|
5786
5867
|
this._onDidLayoutChange.fire(undefined);
|
|
5787
5868
|
}), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
|
|
5788
5869
|
}
|
|
@@ -5804,7 +5885,7 @@
|
|
|
5804
5885
|
}
|
|
5805
5886
|
constructor(options) {
|
|
5806
5887
|
super(options.parentElement);
|
|
5807
|
-
this.
|
|
5888
|
+
this._splitviewChangeDisposable = new MutableDisposable();
|
|
5808
5889
|
this._panels = new Map();
|
|
5809
5890
|
this._onDidLayoutfromJSON = new Emitter();
|
|
5810
5891
|
this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
|
|
@@ -5822,7 +5903,7 @@
|
|
|
5822
5903
|
options.frameworkComponents = {};
|
|
5823
5904
|
}
|
|
5824
5905
|
this.splitview = new Splitview(this.element, options);
|
|
5825
|
-
this.addDisposables(this.
|
|
5906
|
+
this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
|
|
5826
5907
|
}
|
|
5827
5908
|
updateOptions(options) {
|
|
5828
5909
|
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
@@ -5860,15 +5941,15 @@
|
|
|
5860
5941
|
}
|
|
5861
5942
|
}
|
|
5862
5943
|
removePanel(panel, sizing) {
|
|
5863
|
-
const
|
|
5864
|
-
if (!
|
|
5944
|
+
const item = this._panels.get(panel.id);
|
|
5945
|
+
if (!item) {
|
|
5865
5946
|
throw new Error(`unknown splitview panel ${panel.id}`);
|
|
5866
5947
|
}
|
|
5867
|
-
|
|
5868
|
-
disposable.value.dispose();
|
|
5948
|
+
item.dispose();
|
|
5869
5949
|
this._panels.delete(panel.id);
|
|
5870
5950
|
const index = this.panels.findIndex((_) => _ === panel);
|
|
5871
|
-
this.splitview.removeView(index, sizing);
|
|
5951
|
+
const removedView = this.splitview.removeView(index, sizing);
|
|
5952
|
+
removedView.dispose();
|
|
5872
5953
|
const panels = this.panels;
|
|
5873
5954
|
if (panels.length > 0) {
|
|
5874
5955
|
this.setActive(panels[panels.length - 1]);
|
|
@@ -5915,7 +5996,7 @@
|
|
|
5915
5996
|
}
|
|
5916
5997
|
this.setActive(view, true);
|
|
5917
5998
|
});
|
|
5918
|
-
this._panels.set(view.id,
|
|
5999
|
+
this._panels.set(view.id, disposable);
|
|
5919
6000
|
}
|
|
5920
6001
|
toJSON() {
|
|
5921
6002
|
var _a;
|
|
@@ -5988,20 +6069,26 @@
|
|
|
5988
6069
|
this._onDidLayoutfromJSON.fire();
|
|
5989
6070
|
}
|
|
5990
6071
|
clear() {
|
|
5991
|
-
for (const
|
|
5992
|
-
|
|
5993
|
-
value.value.dispose();
|
|
6072
|
+
for (const disposable of this._panels.values()) {
|
|
6073
|
+
disposable.dispose();
|
|
5994
6074
|
}
|
|
5995
6075
|
this._panels.clear();
|
|
5996
|
-
this.splitview.
|
|
6076
|
+
while (this.splitview.length > 0) {
|
|
6077
|
+
const view = this.splitview.removeView(0, exports.Sizing.Distribute, true);
|
|
6078
|
+
view.dispose();
|
|
6079
|
+
}
|
|
5997
6080
|
}
|
|
5998
6081
|
dispose() {
|
|
5999
|
-
for (const
|
|
6000
|
-
|
|
6001
|
-
value.value.dispose();
|
|
6082
|
+
for (const disposable of this._panels.values()) {
|
|
6083
|
+
disposable.dispose();
|
|
6002
6084
|
}
|
|
6003
6085
|
this._panels.clear();
|
|
6086
|
+
const views = this.splitview.getViews();
|
|
6087
|
+
this._splitviewChangeDisposable.dispose();
|
|
6004
6088
|
this.splitview.dispose();
|
|
6089
|
+
for (const view of views) {
|
|
6090
|
+
view.dispose();
|
|
6091
|
+
}
|
|
6005
6092
|
super.dispose();
|
|
6006
6093
|
}
|
|
6007
6094
|
}
|