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.esm.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
|
*/
|
|
@@ -122,9 +122,49 @@ var Event;
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
})(Event || (Event = {}));
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
class LeakageMonitor {
|
|
126
|
+
constructor() {
|
|
127
|
+
this.events = new Map();
|
|
128
|
+
}
|
|
129
|
+
get size() {
|
|
130
|
+
return this.events.size;
|
|
131
|
+
}
|
|
132
|
+
add(event, stacktrace) {
|
|
133
|
+
this.events.set(event, stacktrace);
|
|
134
|
+
}
|
|
135
|
+
delete(event) {
|
|
136
|
+
this.events.delete(event);
|
|
137
|
+
}
|
|
138
|
+
clear() {
|
|
139
|
+
this.events.clear();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class Stacktrace {
|
|
143
|
+
static create() {
|
|
144
|
+
var _a;
|
|
145
|
+
return new Stacktrace((_a = new Error().stack) !== null && _a !== void 0 ? _a : '');
|
|
146
|
+
}
|
|
147
|
+
constructor(value) {
|
|
148
|
+
this.value = value;
|
|
149
|
+
}
|
|
150
|
+
print() {
|
|
151
|
+
console.warn(this.value);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
class Listener {
|
|
155
|
+
constructor(callback, stacktrace) {
|
|
156
|
+
this.callback = callback;
|
|
157
|
+
this.stacktrace = stacktrace;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// relatively simple event emitter taken from https://github.com/microsoft/vscode/blob/master/src/vs/base/common/event.ts
|
|
127
161
|
class Emitter {
|
|
162
|
+
static setLeakageMonitorEnabled(isEnabled) {
|
|
163
|
+
if (isEnabled !== Emitter.ENABLE_TRACKING) {
|
|
164
|
+
Emitter.MEMORY_LEAK_WATCHER.clear();
|
|
165
|
+
}
|
|
166
|
+
Emitter.ENABLE_TRACKING = isEnabled;
|
|
167
|
+
}
|
|
128
168
|
constructor(options) {
|
|
129
169
|
this.options = options;
|
|
130
170
|
this._listeners = [];
|
|
@@ -132,11 +172,12 @@ class Emitter {
|
|
|
132
172
|
}
|
|
133
173
|
get event() {
|
|
134
174
|
if (!this._event) {
|
|
135
|
-
this._event = (
|
|
175
|
+
this._event = (callback) => {
|
|
136
176
|
var _a;
|
|
137
177
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.replay) && this._last !== undefined) {
|
|
138
|
-
|
|
178
|
+
callback(this._last);
|
|
139
179
|
}
|
|
180
|
+
const listener = new Listener(callback, Emitter.ENABLE_TRACKING ? Stacktrace.create() : undefined);
|
|
140
181
|
this._listeners.push(listener);
|
|
141
182
|
return {
|
|
142
183
|
dispose: () => {
|
|
@@ -144,28 +185,50 @@ class Emitter {
|
|
|
144
185
|
if (index > -1) {
|
|
145
186
|
this._listeners.splice(index, 1);
|
|
146
187
|
}
|
|
188
|
+
else if (Emitter.ENABLE_TRACKING) ;
|
|
147
189
|
},
|
|
148
190
|
};
|
|
149
191
|
};
|
|
192
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
193
|
+
Emitter.MEMORY_LEAK_WATCHER.add(this._event, Stacktrace.create());
|
|
194
|
+
}
|
|
150
195
|
}
|
|
151
196
|
return this._event;
|
|
152
197
|
}
|
|
153
198
|
fire(e) {
|
|
154
199
|
this._last = e;
|
|
155
200
|
for (const listener of this._listeners) {
|
|
156
|
-
listener(e);
|
|
201
|
+
listener.callback(e);
|
|
157
202
|
}
|
|
158
203
|
}
|
|
159
204
|
dispose() {
|
|
160
|
-
this.
|
|
161
|
-
|
|
205
|
+
if (!this._disposed) {
|
|
206
|
+
this._disposed = true;
|
|
207
|
+
if (this._listeners.length > 0) {
|
|
208
|
+
if (Emitter.ENABLE_TRACKING) {
|
|
209
|
+
queueMicrotask(() => {
|
|
210
|
+
var _a;
|
|
211
|
+
// don't check until stack of execution is completed to allow for out-of-order disposals within the same execution block
|
|
212
|
+
for (const listener of this._listeners) {
|
|
213
|
+
console.warn((_a = listener.stacktrace) === null || _a === void 0 ? void 0 : _a.print());
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
this._listeners = [];
|
|
218
|
+
}
|
|
219
|
+
if (Emitter.ENABLE_TRACKING && this._event) {
|
|
220
|
+
Emitter.MEMORY_LEAK_WATCHER.delete(this._event);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
162
223
|
}
|
|
163
224
|
}
|
|
225
|
+
Emitter.ENABLE_TRACKING = false;
|
|
226
|
+
Emitter.MEMORY_LEAK_WATCHER = new LeakageMonitor();
|
|
164
227
|
function addDisposableWindowListener(element, type, listener, options) {
|
|
165
228
|
element.addEventListener(type, listener, options);
|
|
166
229
|
return {
|
|
167
230
|
dispose: () => {
|
|
168
|
-
element.removeEventListener(type, listener);
|
|
231
|
+
element.removeEventListener(type, listener, options);
|
|
169
232
|
},
|
|
170
233
|
};
|
|
171
234
|
}
|
|
@@ -173,7 +236,7 @@ function addDisposableListener(element, type, listener, options) {
|
|
|
173
236
|
element.addEventListener(type, listener, options);
|
|
174
237
|
return {
|
|
175
238
|
dispose: () => {
|
|
176
|
-
element.removeEventListener(type, listener);
|
|
239
|
+
element.removeEventListener(type, listener, options);
|
|
177
240
|
},
|
|
178
241
|
};
|
|
179
242
|
}
|
|
@@ -213,13 +276,13 @@ class CompositeDisposable {
|
|
|
213
276
|
}
|
|
214
277
|
constructor(...args) {
|
|
215
278
|
this._isDisposed = false;
|
|
216
|
-
this.
|
|
279
|
+
this._disposables = args;
|
|
217
280
|
}
|
|
218
281
|
addDisposables(...args) {
|
|
219
|
-
args.forEach((arg) => this.
|
|
282
|
+
args.forEach((arg) => this._disposables.push(arg));
|
|
220
283
|
}
|
|
221
284
|
dispose() {
|
|
222
|
-
this.
|
|
285
|
+
this._disposables.forEach((arg) => arg.dispose());
|
|
223
286
|
this._isDisposed = true;
|
|
224
287
|
}
|
|
225
288
|
}
|
|
@@ -309,6 +372,7 @@ class FocusTracker extends CompositeDisposable {
|
|
|
309
372
|
this.onDidFocus = this._onDidFocus.event;
|
|
310
373
|
this._onDidBlur = new Emitter();
|
|
311
374
|
this.onDidBlur = this._onDidBlur.event;
|
|
375
|
+
this.addDisposables(this._onDidFocus, this._onDidBlur);
|
|
312
376
|
let hasFocus = isAncestor(document.activeElement, element);
|
|
313
377
|
let loosingFocus = false;
|
|
314
378
|
const onFocus = () => {
|
|
@@ -353,11 +417,6 @@ class FocusTracker extends CompositeDisposable {
|
|
|
353
417
|
refreshState() {
|
|
354
418
|
this._refreshStateHandler();
|
|
355
419
|
}
|
|
356
|
-
dispose() {
|
|
357
|
-
super.dispose();
|
|
358
|
-
this._onDidBlur.dispose();
|
|
359
|
-
this._onDidFocus.dispose();
|
|
360
|
-
}
|
|
361
420
|
}
|
|
362
421
|
|
|
363
422
|
function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
|
|
@@ -586,7 +645,7 @@ class Splitview {
|
|
|
586
645
|
this._orthogonalSize = value;
|
|
587
646
|
}
|
|
588
647
|
get length() {
|
|
589
|
-
return this.
|
|
648
|
+
return this.viewItems.length;
|
|
590
649
|
}
|
|
591
650
|
get proportions() {
|
|
592
651
|
return this._proportions ? [...this._proportions] : undefined;
|
|
@@ -605,12 +664,12 @@ class Splitview {
|
|
|
605
664
|
: 'vertical');
|
|
606
665
|
}
|
|
607
666
|
get minimumSize() {
|
|
608
|
-
return this.
|
|
667
|
+
return this.viewItems.reduce((r, item) => r + item.minimumSize, 0);
|
|
609
668
|
}
|
|
610
669
|
get maximumSize() {
|
|
611
670
|
return this.length === 0
|
|
612
671
|
? Number.POSITIVE_INFINITY
|
|
613
|
-
: this.
|
|
672
|
+
: this.viewItems.reduce((r, item) => r + item.maximumSize, 0);
|
|
614
673
|
}
|
|
615
674
|
get startSnappingEnabled() {
|
|
616
675
|
return this._startSnappingEnabled;
|
|
@@ -634,7 +693,7 @@ class Splitview {
|
|
|
634
693
|
}
|
|
635
694
|
constructor(container, options) {
|
|
636
695
|
this.container = container;
|
|
637
|
-
this.
|
|
696
|
+
this.viewItems = [];
|
|
638
697
|
this.sashes = [];
|
|
639
698
|
this._size = 0;
|
|
640
699
|
this._orthogonalSize = 0;
|
|
@@ -648,12 +707,12 @@ class Splitview {
|
|
|
648
707
|
this.onDidAddView = this._onDidAddView.event;
|
|
649
708
|
this._onDidRemoveView = new Emitter();
|
|
650
709
|
this.onDidRemoveView = this._onDidRemoveView.event;
|
|
651
|
-
this.resize = (index, delta, sizes = this.
|
|
652
|
-
if (index < 0 || index > this.
|
|
710
|
+
this.resize = (index, delta, sizes = this.viewItems.map((x) => x.size), lowPriorityIndexes, highPriorityIndexes, overloadMinDelta = Number.NEGATIVE_INFINITY, overloadMaxDelta = Number.POSITIVE_INFINITY, snapBefore, snapAfter) => {
|
|
711
|
+
if (index < 0 || index > this.viewItems.length) {
|
|
653
712
|
return 0;
|
|
654
713
|
}
|
|
655
714
|
const upIndexes = range(index, -1);
|
|
656
|
-
const downIndexes = range(index + 1, this.
|
|
715
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
657
716
|
//
|
|
658
717
|
if (highPriorityIndexes) {
|
|
659
718
|
for (const i of highPriorityIndexes) {
|
|
@@ -668,34 +727,34 @@ class Splitview {
|
|
|
668
727
|
}
|
|
669
728
|
}
|
|
670
729
|
//
|
|
671
|
-
const upItems = upIndexes.map((i) => this.
|
|
730
|
+
const upItems = upIndexes.map((i) => this.viewItems[i]);
|
|
672
731
|
const upSizes = upIndexes.map((i) => sizes[i]);
|
|
673
732
|
//
|
|
674
|
-
const downItems = downIndexes.map((i) => this.
|
|
733
|
+
const downItems = downIndexes.map((i) => this.viewItems[i]);
|
|
675
734
|
const downSizes = downIndexes.map((i) => sizes[i]);
|
|
676
735
|
//
|
|
677
|
-
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
678
|
-
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.
|
|
736
|
+
const minDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].minimumSize - sizes[i], 0);
|
|
737
|
+
const maxDeltaUp = upIndexes.reduce((_, i) => _ + this.viewItems[i].maximumSize - sizes[i], 0);
|
|
679
738
|
//
|
|
680
739
|
const maxDeltaDown = downIndexes.length === 0
|
|
681
740
|
? Number.POSITIVE_INFINITY
|
|
682
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
741
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].minimumSize, 0);
|
|
683
742
|
const minDeltaDown = downIndexes.length === 0
|
|
684
743
|
? Number.NEGATIVE_INFINITY
|
|
685
|
-
: downIndexes.reduce((_, i) => _ + sizes[i] - this.
|
|
744
|
+
: downIndexes.reduce((_, i) => _ + sizes[i] - this.viewItems[i].maximumSize, 0);
|
|
686
745
|
//
|
|
687
746
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
688
747
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
689
748
|
//
|
|
690
749
|
let snapped = false;
|
|
691
750
|
if (snapBefore) {
|
|
692
|
-
const snapView = this.
|
|
751
|
+
const snapView = this.viewItems[snapBefore.index];
|
|
693
752
|
const visible = delta >= snapBefore.limitDelta;
|
|
694
753
|
snapped = visible !== snapView.visible;
|
|
695
754
|
snapView.setVisible(visible, snapBefore.size);
|
|
696
755
|
}
|
|
697
756
|
if (!snapped && snapAfter) {
|
|
698
|
-
const snapView = this.
|
|
757
|
+
const snapView = this.viewItems[snapAfter.index];
|
|
699
758
|
const visible = delta < snapAfter.limitDelta;
|
|
700
759
|
snapped = visible !== snapView.visible;
|
|
701
760
|
snapView.setVisible(visible, snapAfter.size);
|
|
@@ -757,7 +816,7 @@ class Splitview {
|
|
|
757
816
|
);
|
|
758
817
|
});
|
|
759
818
|
// Initialize content size and proportions for first layout
|
|
760
|
-
this.contentSize = this.
|
|
819
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
761
820
|
this.saveProportions();
|
|
762
821
|
}
|
|
763
822
|
}
|
|
@@ -774,18 +833,18 @@ class Splitview {
|
|
|
774
833
|
}
|
|
775
834
|
}
|
|
776
835
|
isViewVisible(index) {
|
|
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
|
-
const viewItem = this.
|
|
839
|
+
const viewItem = this.viewItems[index];
|
|
781
840
|
return viewItem.visible;
|
|
782
841
|
}
|
|
783
842
|
setViewVisible(index, visible) {
|
|
784
|
-
if (index < 0 || index >= this.
|
|
843
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
785
844
|
throw new Error('Index out of bounds');
|
|
786
845
|
}
|
|
787
846
|
toggleClass(this.container, 'visible', visible);
|
|
788
|
-
const viewItem = this.
|
|
847
|
+
const viewItem = this.viewItems[index];
|
|
789
848
|
toggleClass(this.container, 'visible', visible);
|
|
790
849
|
viewItem.setVisible(visible, viewItem.size);
|
|
791
850
|
this.distributeEmptySpace(index);
|
|
@@ -793,33 +852,33 @@ class Splitview {
|
|
|
793
852
|
this.saveProportions();
|
|
794
853
|
}
|
|
795
854
|
getViewSize(index) {
|
|
796
|
-
if (index < 0 || index >= this.
|
|
855
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
797
856
|
return -1;
|
|
798
857
|
}
|
|
799
|
-
return this.
|
|
858
|
+
return this.viewItems[index].size;
|
|
800
859
|
}
|
|
801
860
|
resizeView(index, size) {
|
|
802
|
-
if (index < 0 || index >= this.
|
|
861
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
803
862
|
return;
|
|
804
863
|
}
|
|
805
|
-
const indexes = range(this.
|
|
864
|
+
const indexes = range(this.viewItems.length).filter((i) => i !== index);
|
|
806
865
|
const lowPriorityIndexes = [
|
|
807
|
-
...indexes.filter((i) => this.
|
|
866
|
+
...indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low),
|
|
808
867
|
index,
|
|
809
868
|
];
|
|
810
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
811
|
-
const item = this.
|
|
869
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
870
|
+
const item = this.viewItems[index];
|
|
812
871
|
size = Math.round(size);
|
|
813
872
|
size = clamp(size, item.minimumSize, Math.min(item.maximumSize, this._size));
|
|
814
873
|
item.size = size;
|
|
815
874
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
816
875
|
}
|
|
817
876
|
getViews() {
|
|
818
|
-
return this.
|
|
877
|
+
return this.viewItems.map((x) => x.view);
|
|
819
878
|
}
|
|
820
879
|
onDidChange(item, size) {
|
|
821
|
-
const index = this.
|
|
822
|
-
if (index < 0 || index >= this.
|
|
880
|
+
const index = this.viewItems.indexOf(item);
|
|
881
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
823
882
|
return;
|
|
824
883
|
}
|
|
825
884
|
size = typeof size === 'number' ? size : item.size;
|
|
@@ -827,7 +886,7 @@ class Splitview {
|
|
|
827
886
|
item.size = size;
|
|
828
887
|
this.relayout([index]);
|
|
829
888
|
}
|
|
830
|
-
addView(view, size = { type: 'distribute' }, index = this.
|
|
889
|
+
addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
|
|
831
890
|
const container = document.createElement('div');
|
|
832
891
|
container.className = 'view';
|
|
833
892
|
container.appendChild(view.element);
|
|
@@ -845,24 +904,25 @@ class Splitview {
|
|
|
845
904
|
viewSize = view.minimumSize;
|
|
846
905
|
}
|
|
847
906
|
const disposable = view.onDidChange((newSize) => this.onDidChange(viewItem, newSize.size));
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
907
|
+
const viewItem = new ViewItem(container, view, viewSize, {
|
|
908
|
+
dispose: () => {
|
|
909
|
+
disposable.dispose();
|
|
910
|
+
this.viewContainer.removeChild(container);
|
|
911
|
+
},
|
|
912
|
+
});
|
|
913
|
+
if (index === this.viewItems.length) {
|
|
854
914
|
this.viewContainer.appendChild(container);
|
|
855
915
|
}
|
|
856
916
|
else {
|
|
857
917
|
this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
|
|
858
918
|
}
|
|
859
|
-
this.
|
|
860
|
-
if (this.
|
|
919
|
+
this.viewItems.splice(index, 0, viewItem);
|
|
920
|
+
if (this.viewItems.length > 1) {
|
|
861
921
|
//add sash
|
|
862
922
|
const sash = document.createElement('div');
|
|
863
923
|
sash.className = 'sash';
|
|
864
924
|
const onStart = (event) => {
|
|
865
|
-
for (const item of this.
|
|
925
|
+
for (const item of this.viewItems) {
|
|
866
926
|
item.enabled = false;
|
|
867
927
|
}
|
|
868
928
|
const iframes = [
|
|
@@ -877,27 +937,29 @@ class Splitview {
|
|
|
877
937
|
: event.clientY;
|
|
878
938
|
const sashIndex = firstIndex(this.sashes, (s) => s.container === sash);
|
|
879
939
|
//
|
|
880
|
-
const sizes = this.
|
|
940
|
+
const sizes = this.viewItems.map((x) => x.size);
|
|
881
941
|
//
|
|
882
942
|
let snapBefore;
|
|
883
943
|
let snapAfter;
|
|
884
944
|
const upIndexes = range(sashIndex, -1);
|
|
885
|
-
const downIndexes = range(sashIndex + 1, this.
|
|
886
|
-
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
887
|
-
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.
|
|
945
|
+
const downIndexes = range(sashIndex + 1, this.viewItems.length);
|
|
946
|
+
const minDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].minimumSize - sizes[i]), 0);
|
|
947
|
+
const maxDeltaUp = upIndexes.reduce((r, i) => r + (this.viewItems[i].viewMaximumSize - sizes[i]), 0);
|
|
888
948
|
const maxDeltaDown = downIndexes.length === 0
|
|
889
949
|
? Number.POSITIVE_INFINITY
|
|
890
|
-
: downIndexes.reduce((r, i) => r +
|
|
950
|
+
: downIndexes.reduce((r, i) => r +
|
|
951
|
+
(sizes[i] - this.viewItems[i].minimumSize), 0);
|
|
891
952
|
const minDeltaDown = downIndexes.length === 0
|
|
892
953
|
? Number.NEGATIVE_INFINITY
|
|
893
954
|
: downIndexes.reduce((r, i) => r +
|
|
894
|
-
(sizes[i] -
|
|
955
|
+
(sizes[i] -
|
|
956
|
+
this.viewItems[i].viewMaximumSize), 0);
|
|
895
957
|
const minDelta = Math.max(minDeltaUp, minDeltaDown);
|
|
896
958
|
const maxDelta = Math.min(maxDeltaDown, maxDeltaUp);
|
|
897
959
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
898
960
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
899
961
|
if (typeof snapBeforeIndex === 'number') {
|
|
900
|
-
const snappedViewItem = this.
|
|
962
|
+
const snappedViewItem = this.viewItems[snapBeforeIndex];
|
|
901
963
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
902
964
|
snapBefore = {
|
|
903
965
|
index: snapBeforeIndex,
|
|
@@ -908,7 +970,7 @@ class Splitview {
|
|
|
908
970
|
};
|
|
909
971
|
}
|
|
910
972
|
if (typeof snapAfterIndex === 'number') {
|
|
911
|
-
const snappedViewItem = this.
|
|
973
|
+
const snappedViewItem = this.viewItems[snapAfterIndex];
|
|
912
974
|
const halfSize = Math.floor(snappedViewItem.viewMinimumSize / 2);
|
|
913
975
|
snapAfter = {
|
|
914
976
|
index: snapAfterIndex,
|
|
@@ -929,7 +991,7 @@ class Splitview {
|
|
|
929
991
|
this.layoutViews();
|
|
930
992
|
};
|
|
931
993
|
const end = () => {
|
|
932
|
-
for (const item of this.
|
|
994
|
+
for (const item of this.viewItems) {
|
|
933
995
|
item.enabled = true;
|
|
934
996
|
}
|
|
935
997
|
for (const iframe of iframes) {
|
|
@@ -938,12 +1000,10 @@ class Splitview {
|
|
|
938
1000
|
this.saveProportions();
|
|
939
1001
|
document.removeEventListener('mousemove', mousemove);
|
|
940
1002
|
document.removeEventListener('mouseup', end);
|
|
941
|
-
document.removeEventListener('mouseend', end);
|
|
942
1003
|
this._onDidSashEnd.fire(undefined);
|
|
943
1004
|
};
|
|
944
1005
|
document.addEventListener('mousemove', mousemove);
|
|
945
1006
|
document.addEventListener('mouseup', end);
|
|
946
|
-
document.addEventListener('mouseend', end);
|
|
947
1007
|
};
|
|
948
1008
|
sash.addEventListener('mousedown', onStart);
|
|
949
1009
|
const sashItem = {
|
|
@@ -969,7 +1029,7 @@ class Splitview {
|
|
|
969
1029
|
distributeViewSizes() {
|
|
970
1030
|
const flexibleViewItems = [];
|
|
971
1031
|
let flexibleSize = 0;
|
|
972
|
-
for (const item of this.
|
|
1032
|
+
for (const item of this.viewItems) {
|
|
973
1033
|
if (item.maximumSize - item.minimumSize > 0) {
|
|
974
1034
|
flexibleViewItems.push(item);
|
|
975
1035
|
flexibleSize += item.size;
|
|
@@ -979,17 +1039,17 @@ class Splitview {
|
|
|
979
1039
|
for (const item of flexibleViewItems) {
|
|
980
1040
|
item.size = clamp(size, item.minimumSize, item.maximumSize);
|
|
981
1041
|
}
|
|
982
|
-
const indexes = range(this.
|
|
983
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
984
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1042
|
+
const indexes = range(this.viewItems.length);
|
|
1043
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low);
|
|
1044
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
985
1045
|
this.relayout(lowPriorityIndexes, highPriorityIndexes);
|
|
986
1046
|
}
|
|
987
1047
|
removeView(index, sizing, skipLayout = false) {
|
|
988
1048
|
// Remove view
|
|
989
|
-
const viewItem = this.
|
|
1049
|
+
const viewItem = this.viewItems.splice(index, 1)[0];
|
|
990
1050
|
viewItem.dispose();
|
|
991
1051
|
// Remove sash
|
|
992
|
-
if (this.
|
|
1052
|
+
if (this.viewItems.length >= 1) {
|
|
993
1053
|
const sashIndex = Math.max(index - 1, 0);
|
|
994
1054
|
const sashItem = this.sashes.splice(sashIndex, 1)[0];
|
|
995
1055
|
sashItem.disposable();
|
|
@@ -1004,10 +1064,10 @@ class Splitview {
|
|
|
1004
1064
|
return viewItem.view;
|
|
1005
1065
|
}
|
|
1006
1066
|
getViewCachedVisibleSize(index) {
|
|
1007
|
-
if (index < 0 || index >= this.
|
|
1067
|
+
if (index < 0 || index >= this.viewItems.length) {
|
|
1008
1068
|
throw new Error('Index out of bounds');
|
|
1009
1069
|
}
|
|
1010
|
-
const viewItem = this.
|
|
1070
|
+
const viewItem = this.viewItems[index];
|
|
1011
1071
|
return viewItem.cachedVisibleSize;
|
|
1012
1072
|
}
|
|
1013
1073
|
moveView(from, to) {
|
|
@@ -1023,14 +1083,14 @@ class Splitview {
|
|
|
1023
1083
|
this.size = size;
|
|
1024
1084
|
this.orthogonalSize = orthogonalSize;
|
|
1025
1085
|
if (!this.proportions) {
|
|
1026
|
-
const indexes = range(this.
|
|
1027
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1028
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1029
|
-
this.resize(this.
|
|
1086
|
+
const indexes = range(this.viewItems.length);
|
|
1087
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low);
|
|
1088
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
1089
|
+
this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1030
1090
|
}
|
|
1031
1091
|
else {
|
|
1032
|
-
for (let i = 0; i < this.
|
|
1033
|
-
const item = this.
|
|
1092
|
+
for (let i = 0; i < this.viewItems.length; i++) {
|
|
1093
|
+
const item = this.viewItems[i];
|
|
1034
1094
|
item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
|
|
1035
1095
|
}
|
|
1036
1096
|
}
|
|
@@ -1038,18 +1098,18 @@ class Splitview {
|
|
|
1038
1098
|
this.layoutViews();
|
|
1039
1099
|
}
|
|
1040
1100
|
relayout(lowPriorityIndexes, highPriorityIndexes) {
|
|
1041
|
-
const contentSize = this.
|
|
1042
|
-
this.resize(this.
|
|
1101
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1102
|
+
this.resize(this.viewItems.length - 1, this._size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
|
|
1043
1103
|
this.distributeEmptySpace();
|
|
1044
1104
|
this.layoutViews();
|
|
1045
1105
|
this.saveProportions();
|
|
1046
1106
|
}
|
|
1047
1107
|
distributeEmptySpace(lowPriorityIndex) {
|
|
1048
|
-
const contentSize = this.
|
|
1108
|
+
const contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1049
1109
|
let emptyDelta = this.size - contentSize;
|
|
1050
|
-
const indexes = range(this.
|
|
1051
|
-
const lowPriorityIndexes = indexes.filter((i) => this.
|
|
1052
|
-
const highPriorityIndexes = indexes.filter((i) => this.
|
|
1110
|
+
const indexes = range(this.viewItems.length - 1, -1);
|
|
1111
|
+
const lowPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low);
|
|
1112
|
+
const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
|
|
1053
1113
|
for (const index of highPriorityIndexes) {
|
|
1054
1114
|
pushToStart(indexes, index);
|
|
1055
1115
|
}
|
|
@@ -1060,7 +1120,7 @@ class Splitview {
|
|
|
1060
1120
|
pushToEnd(indexes, lowPriorityIndex);
|
|
1061
1121
|
}
|
|
1062
1122
|
for (let i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
|
|
1063
|
-
const item = this.
|
|
1123
|
+
const item = this.viewItems[indexes[i]];
|
|
1064
1124
|
const size = clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
|
|
1065
1125
|
const viewDelta = size - item.size;
|
|
1066
1126
|
emptyDelta -= viewDelta;
|
|
@@ -1069,16 +1129,16 @@ class Splitview {
|
|
|
1069
1129
|
}
|
|
1070
1130
|
saveProportions() {
|
|
1071
1131
|
if (this.proportionalLayout && this.contentSize > 0) {
|
|
1072
|
-
this._proportions = this.
|
|
1132
|
+
this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
|
|
1073
1133
|
}
|
|
1074
1134
|
}
|
|
1075
1135
|
layoutViews() {
|
|
1076
|
-
this.contentSize = this.
|
|
1136
|
+
this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
|
|
1077
1137
|
let sum = 0;
|
|
1078
1138
|
const x = [];
|
|
1079
1139
|
this.updateSashEnablement();
|
|
1080
|
-
for (let i = 0; i < this.
|
|
1081
|
-
sum += this.
|
|
1140
|
+
for (let i = 0; i < this.viewItems.length - 1; i++) {
|
|
1141
|
+
sum += this.viewItems[i].size;
|
|
1082
1142
|
x.push(sum);
|
|
1083
1143
|
const offset = Math.min(Math.max(0, sum - 2), this.size - 4);
|
|
1084
1144
|
if (this._orientation === Orientation.HORIZONTAL) {
|
|
@@ -1090,7 +1150,7 @@ class Splitview {
|
|
|
1090
1150
|
this.sashes[i].container.style.top = `${offset}px`;
|
|
1091
1151
|
}
|
|
1092
1152
|
}
|
|
1093
|
-
this.
|
|
1153
|
+
this.viewItems.forEach((view, i) => {
|
|
1094
1154
|
if (this._orientation === Orientation.HORIZONTAL) {
|
|
1095
1155
|
view.container.style.width = `${view.size}px`;
|
|
1096
1156
|
view.container.style.left = i == 0 ? '0px' : `${x[i - 1]}px`;
|
|
@@ -1109,7 +1169,7 @@ class Splitview {
|
|
|
1109
1169
|
findFirstSnapIndex(indexes) {
|
|
1110
1170
|
// visible views first
|
|
1111
1171
|
for (const index of indexes) {
|
|
1112
|
-
const viewItem = this.
|
|
1172
|
+
const viewItem = this.viewItems[index];
|
|
1113
1173
|
if (!viewItem.visible) {
|
|
1114
1174
|
continue;
|
|
1115
1175
|
}
|
|
@@ -1119,7 +1179,7 @@ class Splitview {
|
|
|
1119
1179
|
}
|
|
1120
1180
|
// then, hidden views
|
|
1121
1181
|
for (const index of indexes) {
|
|
1122
|
-
const viewItem = this.
|
|
1182
|
+
const viewItem = this.viewItems[index];
|
|
1123
1183
|
if (viewItem.visible &&
|
|
1124
1184
|
viewItem.maximumSize - viewItem.minimumSize > 0) {
|
|
1125
1185
|
return undefined;
|
|
@@ -1132,10 +1192,10 @@ class Splitview {
|
|
|
1132
1192
|
}
|
|
1133
1193
|
updateSashEnablement() {
|
|
1134
1194
|
let previous = false;
|
|
1135
|
-
const collapsesDown = this.
|
|
1195
|
+
const collapsesDown = this.viewItems.map((i) => (previous = i.size - i.minimumSize > 0 || previous));
|
|
1136
1196
|
previous = false;
|
|
1137
|
-
const expandsDown = this.
|
|
1138
|
-
const reverseViews = [...this.
|
|
1197
|
+
const expandsDown = this.viewItems.map((i) => (previous = i.maximumSize - i.size > 0 || previous));
|
|
1198
|
+
const reverseViews = [...this.viewItems].reverse();
|
|
1139
1199
|
previous = false;
|
|
1140
1200
|
const collapsesUp = reverseViews
|
|
1141
1201
|
.map((i) => (previous = i.size - i.minimumSize > 0 || previous))
|
|
@@ -1147,19 +1207,19 @@ class Splitview {
|
|
|
1147
1207
|
let position = 0;
|
|
1148
1208
|
for (let index = 0; index < this.sashes.length; index++) {
|
|
1149
1209
|
const sash = this.sashes[index];
|
|
1150
|
-
const viewItem = this.
|
|
1210
|
+
const viewItem = this.viewItems[index];
|
|
1151
1211
|
position += viewItem.size;
|
|
1152
1212
|
const min = !(collapsesDown[index] && expandsUp[index + 1]);
|
|
1153
1213
|
const max = !(expandsDown[index] && collapsesUp[index + 1]);
|
|
1154
1214
|
if (min && max) {
|
|
1155
1215
|
const upIndexes = range(index, -1);
|
|
1156
|
-
const downIndexes = range(index + 1, this.
|
|
1216
|
+
const downIndexes = range(index + 1, this.viewItems.length);
|
|
1157
1217
|
const snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
|
|
1158
1218
|
const snapAfterIndex = this.findFirstSnapIndex(downIndexes);
|
|
1159
1219
|
const snappedBefore = typeof snapBeforeIndex === 'number' &&
|
|
1160
|
-
!this.
|
|
1220
|
+
!this.viewItems[snapBeforeIndex].visible;
|
|
1161
1221
|
const snappedAfter = typeof snapAfterIndex === 'number' &&
|
|
1162
|
-
!this.
|
|
1222
|
+
!this.viewItems[snapAfterIndex].visible;
|
|
1163
1223
|
if (snappedBefore &&
|
|
1164
1224
|
collapsesUp[index] &&
|
|
1165
1225
|
(position > 0 || this.startSnappingEnabled)) {
|
|
@@ -1219,6 +1279,9 @@ class Splitview {
|
|
|
1219
1279
|
break;
|
|
1220
1280
|
}
|
|
1221
1281
|
}
|
|
1282
|
+
for (const viewItem of this.viewItems) {
|
|
1283
|
+
viewItem.dispose();
|
|
1284
|
+
}
|
|
1222
1285
|
this.element.remove();
|
|
1223
1286
|
}
|
|
1224
1287
|
}
|
|
@@ -1653,7 +1716,7 @@ class BranchNode extends CompositeDisposable {
|
|
|
1653
1716
|
throw new Error('Invalid index');
|
|
1654
1717
|
}
|
|
1655
1718
|
this.splitview.removeView(index, sizing);
|
|
1656
|
-
this._removeChild(index);
|
|
1719
|
+
return this._removeChild(index);
|
|
1657
1720
|
}
|
|
1658
1721
|
_addChild(node, index) {
|
|
1659
1722
|
this.children.splice(index, 0, node);
|
|
@@ -1675,10 +1738,10 @@ class BranchNode extends CompositeDisposable {
|
|
|
1675
1738
|
});
|
|
1676
1739
|
}
|
|
1677
1740
|
dispose() {
|
|
1678
|
-
super.dispose();
|
|
1679
1741
|
this._childrenDisposable.dispose();
|
|
1680
|
-
this.children.forEach((child) => child.dispose());
|
|
1681
1742
|
this.splitview.dispose();
|
|
1743
|
+
this.children.forEach((child) => child.dispose());
|
|
1744
|
+
super.dispose();
|
|
1682
1745
|
}
|
|
1683
1746
|
}
|
|
1684
1747
|
|
|
@@ -1908,7 +1971,8 @@ class Gridview {
|
|
|
1908
1971
|
if (oldRoot.children.length === 1) {
|
|
1909
1972
|
// can remove one level of redundant branching if there is only a single child
|
|
1910
1973
|
const childReference = oldRoot.children[0];
|
|
1911
|
-
oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1974
|
+
const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
|
|
1975
|
+
child.dispose();
|
|
1912
1976
|
oldRoot.dispose();
|
|
1913
1977
|
this._root.addChild(
|
|
1914
1978
|
/**
|
|
@@ -2015,7 +2079,8 @@ class Gridview {
|
|
|
2015
2079
|
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
2016
2080
|
newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
2017
2081
|
}
|
|
2018
|
-
grandParent.removeChild(parentIndex);
|
|
2082
|
+
const child = grandParent.removeChild(parentIndex);
|
|
2083
|
+
child.dispose();
|
|
2019
2084
|
const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
|
|
2020
2085
|
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
2021
2086
|
const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
|
|
@@ -2577,6 +2642,7 @@ class Droptarget extends CompositeDisposable {
|
|
|
2577
2642
|
}
|
|
2578
2643
|
dispose() {
|
|
2579
2644
|
this.removeDropTarget();
|
|
2645
|
+
super.dispose();
|
|
2580
2646
|
}
|
|
2581
2647
|
toggleClasses(quadrant, width, height) {
|
|
2582
2648
|
var _a, _b, _c, _d;
|
|
@@ -2754,8 +2820,8 @@ class ContentContainer extends CompositeDisposable {
|
|
|
2754
2820
|
if (this.panel.view) {
|
|
2755
2821
|
const _onDidFocus = this.panel.view.content.onDidFocus;
|
|
2756
2822
|
const _onDidBlur = this.panel.view.content.onDidBlur;
|
|
2757
|
-
const
|
|
2758
|
-
disposable.addDisposables(onDidFocus(() => this._onDidFocus.fire()), onDidBlur(() => this._onDidBlur.fire()));
|
|
2823
|
+
const focusTracker = trackFocus(this._element);
|
|
2824
|
+
disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
|
2759
2825
|
if (_onDidFocus) {
|
|
2760
2826
|
disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
|
|
2761
2827
|
}
|
|
@@ -2794,24 +2860,32 @@ class DragHandler extends CompositeDisposable {
|
|
|
2794
2860
|
constructor(el) {
|
|
2795
2861
|
super();
|
|
2796
2862
|
this.el = el;
|
|
2797
|
-
this.
|
|
2863
|
+
this.dataDisposable = new MutableDisposable();
|
|
2864
|
+
this.pointerEventsDisposable = new MutableDisposable();
|
|
2798
2865
|
this._onDragStart = new Emitter();
|
|
2799
2866
|
this.onDragStart = this._onDragStart.event;
|
|
2800
|
-
this.
|
|
2867
|
+
this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
|
|
2801
2868
|
this.configure();
|
|
2802
2869
|
}
|
|
2803
2870
|
configure() {
|
|
2804
2871
|
this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
|
|
2805
|
-
|
|
2872
|
+
const iframes = [
|
|
2806
2873
|
...getElementsByTagName('iframe'),
|
|
2807
2874
|
...getElementsByTagName('webview'),
|
|
2808
2875
|
];
|
|
2809
|
-
|
|
2876
|
+
this.pointerEventsDisposable.value = {
|
|
2877
|
+
dispose: () => {
|
|
2878
|
+
for (const iframe of iframes) {
|
|
2879
|
+
iframe.style.pointerEvents = 'auto';
|
|
2880
|
+
}
|
|
2881
|
+
},
|
|
2882
|
+
};
|
|
2883
|
+
for (const iframe of iframes) {
|
|
2810
2884
|
iframe.style.pointerEvents = 'none';
|
|
2811
2885
|
}
|
|
2812
2886
|
this.el.classList.add('dv-dragged');
|
|
2813
2887
|
setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
|
|
2814
|
-
this.
|
|
2888
|
+
this.dataDisposable.value = this.getData(event.dataTransfer);
|
|
2815
2889
|
if (event.dataTransfer) {
|
|
2816
2890
|
event.dataTransfer.effectAllowed = 'move';
|
|
2817
2891
|
/**
|
|
@@ -2826,11 +2900,8 @@ class DragHandler extends CompositeDisposable {
|
|
|
2826
2900
|
event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
|
|
2827
2901
|
}
|
|
2828
2902
|
}), addDisposableListener(this.el, 'dragend', () => {
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
}
|
|
2832
|
-
this.iframes = [];
|
|
2833
|
-
this.disposable.dispose();
|
|
2903
|
+
this.pointerEventsDisposable.dispose();
|
|
2904
|
+
this.dataDisposable.dispose();
|
|
2834
2905
|
}));
|
|
2835
2906
|
}
|
|
2836
2907
|
}
|
|
@@ -2848,13 +2919,12 @@ class Tab extends CompositeDisposable {
|
|
|
2848
2919
|
this.onChanged = this._onChanged.event;
|
|
2849
2920
|
this._onDropped = new Emitter();
|
|
2850
2921
|
this.onDrop = this._onDropped.event;
|
|
2851
|
-
this.addDisposables(this._onChanged, this._onDropped);
|
|
2852
2922
|
this._element = document.createElement('div');
|
|
2853
2923
|
this._element.className = 'tab';
|
|
2854
2924
|
this._element.tabIndex = 0;
|
|
2855
2925
|
this._element.draggable = true;
|
|
2856
2926
|
toggleClass(this.element, 'inactive-tab', true);
|
|
2857
|
-
this.addDisposables(new (class Handler extends DragHandler {
|
|
2927
|
+
this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
|
|
2858
2928
|
constructor() {
|
|
2859
2929
|
super(...arguments);
|
|
2860
2930
|
this.panelTransfer = LocalSelectionTransfer.getInstance();
|
|
@@ -2867,9 +2937,6 @@ class Tab extends CompositeDisposable {
|
|
|
2867
2937
|
},
|
|
2868
2938
|
};
|
|
2869
2939
|
}
|
|
2870
|
-
dispose() {
|
|
2871
|
-
//
|
|
2872
|
-
}
|
|
2873
2940
|
})(this._element));
|
|
2874
2941
|
this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
|
|
2875
2942
|
if (event.defaultPrevented) {
|
|
@@ -2904,7 +2971,7 @@ class Tab extends CompositeDisposable {
|
|
|
2904
2971
|
});
|
|
2905
2972
|
this.addDisposables(this.droptarget.onDrop((event) => {
|
|
2906
2973
|
this._onDropped.fire(event);
|
|
2907
|
-
}));
|
|
2974
|
+
}), this.droptarget);
|
|
2908
2975
|
}
|
|
2909
2976
|
setActive(isActive) {
|
|
2910
2977
|
toggleClass(this.element, 'active-tab', isActive);
|
|
@@ -2919,7 +2986,6 @@ class Tab extends CompositeDisposable {
|
|
|
2919
2986
|
}
|
|
2920
2987
|
dispose() {
|
|
2921
2988
|
super.dispose();
|
|
2922
|
-
this.droptarget.dispose();
|
|
2923
2989
|
}
|
|
2924
2990
|
}
|
|
2925
2991
|
|
|
@@ -2965,9 +3031,6 @@ class GroupDragHandler extends DragHandler {
|
|
|
2965
3031
|
},
|
|
2966
3032
|
};
|
|
2967
3033
|
}
|
|
2968
|
-
dispose() {
|
|
2969
|
-
//
|
|
2970
|
-
}
|
|
2971
3034
|
}
|
|
2972
3035
|
|
|
2973
3036
|
class VoidContainer extends CompositeDisposable {
|
|
@@ -3123,6 +3186,7 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3123
3186
|
const tabToRemove = this.tabs.splice(index, 1)[0];
|
|
3124
3187
|
const { value, disposable } = tabToRemove;
|
|
3125
3188
|
disposable.dispose();
|
|
3189
|
+
value.dispose();
|
|
3126
3190
|
value.element.remove();
|
|
3127
3191
|
}
|
|
3128
3192
|
setActivePanel(panel) {
|
|
@@ -3166,9 +3230,10 @@ class TabsContainer extends CompositeDisposable {
|
|
|
3166
3230
|
}
|
|
3167
3231
|
dispose() {
|
|
3168
3232
|
super.dispose();
|
|
3169
|
-
this.tabs
|
|
3170
|
-
|
|
3171
|
-
|
|
3233
|
+
for (const { value, disposable } of this.tabs) {
|
|
3234
|
+
disposable.dispose();
|
|
3235
|
+
value.dispose();
|
|
3236
|
+
}
|
|
3172
3237
|
this.tabs = [];
|
|
3173
3238
|
}
|
|
3174
3239
|
}
|
|
@@ -3266,7 +3331,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3266
3331
|
container.append(this.tabsContainer.element, this.contentContainer.element);
|
|
3267
3332
|
this.header.hidden = !!options.hideHeader;
|
|
3268
3333
|
this.locked = !!options.locked;
|
|
3269
|
-
this.addDisposables(this.
|
|
3334
|
+
this.addDisposables(this.tabsContainer.onDrop((event) => {
|
|
3270
3335
|
this.handleDropEvent(event.event, 'center', event.index);
|
|
3271
3336
|
}), this.contentContainer.onDidFocus(() => {
|
|
3272
3337
|
this.accessor.doSetGroupActive(this.groupPanel, true);
|
|
@@ -3274,7 +3339,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
|
|
|
3274
3339
|
// noop
|
|
3275
3340
|
}), this.dropTarget.onDrop((event) => {
|
|
3276
3341
|
this.handleDropEvent(event.nativeEvent, event.position);
|
|
3277
|
-
}));
|
|
3342
|
+
}), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
|
|
3278
3343
|
}
|
|
3279
3344
|
initialize() {
|
|
3280
3345
|
var _a, _b;
|
|
@@ -3708,8 +3773,7 @@ class BaseGrid extends Resizable {
|
|
|
3708
3773
|
this.layout(0, 0, true); // set some elements height/widths
|
|
3709
3774
|
this.addDisposables(this.gridview.onDidChange(() => {
|
|
3710
3775
|
this._bufferOnDidLayoutChange.fire();
|
|
3711
|
-
}))
|
|
3712
|
-
this.addDisposables(Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3776
|
+
}), Event.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
|
|
3713
3777
|
this._bufferOnDidLayoutChange.fire();
|
|
3714
3778
|
}), this._bufferOnDidLayoutChange.onEvent(() => {
|
|
3715
3779
|
this._onDidLayoutChange.fire();
|
|
@@ -3812,7 +3876,6 @@ class BaseGrid extends Resizable {
|
|
|
3812
3876
|
this.gridview.layout(width, height);
|
|
3813
3877
|
}
|
|
3814
3878
|
dispose() {
|
|
3815
|
-
super.dispose();
|
|
3816
3879
|
this._onDidActiveGroupChange.dispose();
|
|
3817
3880
|
this._onDidAddGroup.dispose();
|
|
3818
3881
|
this._onDidRemoveGroup.dispose();
|
|
@@ -3821,6 +3884,7 @@ class BaseGrid extends Resizable {
|
|
|
3821
3884
|
group.dispose();
|
|
3822
3885
|
}
|
|
3823
3886
|
this.gridview.dispose();
|
|
3887
|
+
super.dispose();
|
|
3824
3888
|
}
|
|
3825
3889
|
}
|
|
3826
3890
|
|
|
@@ -3884,7 +3948,7 @@ class PanelApiImpl extends CompositeDisposable {
|
|
|
3884
3948
|
//
|
|
3885
3949
|
this._onUpdateParameters = new Emitter();
|
|
3886
3950
|
this.onUpdateParameters = this._onUpdateParameters.event;
|
|
3887
|
-
this.addDisposables(this.
|
|
3951
|
+
this.addDisposables(this.onDidFocusChange((event) => {
|
|
3888
3952
|
this._isFocused = event.isFocused;
|
|
3889
3953
|
}), this.onDidActiveChange((event) => {
|
|
3890
3954
|
this._isActive = event.isActive;
|
|
@@ -3893,14 +3957,12 @@ class PanelApiImpl extends CompositeDisposable {
|
|
|
3893
3957
|
}), this.onDidDimensionsChange((event) => {
|
|
3894
3958
|
this._width = event.width;
|
|
3895
3959
|
this._height = event.height;
|
|
3896
|
-
}));
|
|
3960
|
+
}), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
|
|
3897
3961
|
}
|
|
3898
3962
|
initialize(panel) {
|
|
3899
3963
|
this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
|
|
3900
3964
|
panel.update({
|
|
3901
|
-
params:
|
|
3902
|
-
params: parameters,
|
|
3903
|
-
},
|
|
3965
|
+
params: parameters,
|
|
3904
3966
|
});
|
|
3905
3967
|
});
|
|
3906
3968
|
}
|
|
@@ -3995,12 +4057,12 @@ class BasePanelView extends CompositeDisposable {
|
|
|
3995
4057
|
this._element.style.height = '100%';
|
|
3996
4058
|
this._element.style.width = '100%';
|
|
3997
4059
|
this._element.style.overflow = 'hidden';
|
|
3998
|
-
const
|
|
3999
|
-
this.addDisposables(this.api, onDidFocus(() => {
|
|
4060
|
+
const focusTracker = trackFocus(this._element);
|
|
4061
|
+
this.addDisposables(this.api, focusTracker.onDidFocus(() => {
|
|
4000
4062
|
this.api._onDidChangeFocus.fire({ isFocused: true });
|
|
4001
|
-
}), onDidBlur(() => {
|
|
4063
|
+
}), focusTracker.onDidBlur(() => {
|
|
4002
4064
|
this.api._onDidChangeFocus.fire({ isFocused: false });
|
|
4003
|
-
}));
|
|
4065
|
+
}), focusTracker);
|
|
4004
4066
|
}
|
|
4005
4067
|
focus() {
|
|
4006
4068
|
this.api._onFocusEvent.fire();
|
|
@@ -4021,7 +4083,18 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4021
4083
|
}
|
|
4022
4084
|
update(event) {
|
|
4023
4085
|
var _a, _b;
|
|
4086
|
+
// merge the new parameters with the existing parameters
|
|
4024
4087
|
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) });
|
|
4088
|
+
/**
|
|
4089
|
+
* delete new keys that have a value of undefined,
|
|
4090
|
+
* allow values of null
|
|
4091
|
+
*/
|
|
4092
|
+
for (const key of Object.keys(event.params)) {
|
|
4093
|
+
if (event.params[key] === undefined) {
|
|
4094
|
+
delete this._params.params[key];
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
// update the view with the updated props
|
|
4025
4098
|
(_b = this.part) === null || _b === void 0 ? void 0 : _b.update({ params: this._params.params });
|
|
4026
4099
|
}
|
|
4027
4100
|
toJSON() {
|
|
@@ -4035,9 +4108,9 @@ class BasePanelView extends CompositeDisposable {
|
|
|
4035
4108
|
}
|
|
4036
4109
|
dispose() {
|
|
4037
4110
|
var _a;
|
|
4038
|
-
super.dispose();
|
|
4039
4111
|
this.api.dispose();
|
|
4040
4112
|
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
4113
|
+
super.dispose();
|
|
4041
4114
|
}
|
|
4042
4115
|
}
|
|
4043
4116
|
|
|
@@ -4416,7 +4489,7 @@ class GridviewPanel extends BasePanelView {
|
|
|
4416
4489
|
this._maximumHeight = options.maximumHeight;
|
|
4417
4490
|
}
|
|
4418
4491
|
this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
|
|
4419
|
-
this.addDisposables(this.
|
|
4492
|
+
this.addDisposables(this.api.onVisibilityChange((event) => {
|
|
4420
4493
|
const { isVisible } = event;
|
|
4421
4494
|
const { accessor } = this._params;
|
|
4422
4495
|
accessor.setVisible(this, isVisible);
|
|
@@ -4445,7 +4518,7 @@ class GridviewPanel extends BasePanelView {
|
|
|
4445
4518
|
height: event.height,
|
|
4446
4519
|
width: event.width,
|
|
4447
4520
|
});
|
|
4448
|
-
}));
|
|
4521
|
+
}), this._onDidChange);
|
|
4449
4522
|
}
|
|
4450
4523
|
setVisible(isVisible) {
|
|
4451
4524
|
this.api._onDidVisibilityChange.fire({ isVisible });
|
|
@@ -4602,7 +4675,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
|
|
|
4602
4675
|
this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
|
|
4603
4676
|
}
|
|
4604
4677
|
setTitle(title) {
|
|
4605
|
-
this.panel.
|
|
4678
|
+
this.panel.setTitle(title);
|
|
4606
4679
|
}
|
|
4607
4680
|
close() {
|
|
4608
4681
|
this.group.model.closePanel(this.panel);
|
|
@@ -4667,12 +4740,18 @@ class DockviewPanel extends CompositeDisposable {
|
|
|
4667
4740
|
}
|
|
4668
4741
|
}
|
|
4669
4742
|
update(event) {
|
|
4670
|
-
|
|
4671
|
-
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4743
|
+
// merge the new parameters with the existing parameters
|
|
4744
|
+
this._params = Object.assign(Object.assign({}, (this._params || {})), event.params);
|
|
4745
|
+
/**
|
|
4746
|
+
* delete new keys that have a value of undefined,
|
|
4747
|
+
* allow values of null
|
|
4748
|
+
*/
|
|
4749
|
+
for (const key of Object.keys(event.params)) {
|
|
4750
|
+
if (event.params[key] === undefined) {
|
|
4751
|
+
delete this._params[key];
|
|
4752
|
+
}
|
|
4675
4753
|
}
|
|
4754
|
+
// update the view with the updated props
|
|
4676
4755
|
this.view.update({
|
|
4677
4756
|
params: {
|
|
4678
4757
|
params: this._params,
|
|
@@ -5048,7 +5127,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5048
5127
|
size: { type: 'pixels', value: 20 },
|
|
5049
5128
|
},
|
|
5050
5129
|
});
|
|
5051
|
-
this.addDisposables(dropTarget
|
|
5130
|
+
this.addDisposables(dropTarget.onDrop((event) => {
|
|
5052
5131
|
const data = getPanelData();
|
|
5053
5132
|
if (data) {
|
|
5054
5133
|
this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, data.panelId || undefined, 'center');
|
|
@@ -5056,7 +5135,7 @@ class DockviewComponent extends BaseGrid {
|
|
|
5056
5135
|
else {
|
|
5057
5136
|
this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
|
|
5058
5137
|
}
|
|
5059
|
-
}));
|
|
5138
|
+
}), dropTarget);
|
|
5060
5139
|
this._api = new DockviewApi(this);
|
|
5061
5140
|
this.updateWatermark();
|
|
5062
5141
|
}
|
|
@@ -5380,31 +5459,33 @@ class DockviewComponent extends BaseGrid {
|
|
|
5380
5459
|
}
|
|
5381
5460
|
super.doRemoveGroup(group, { skipActive });
|
|
5382
5461
|
}
|
|
5383
|
-
moveGroupOrPanel(
|
|
5462
|
+
moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
|
|
5384
5463
|
var _a;
|
|
5385
|
-
const sourceGroup =
|
|
5386
|
-
? (_a = this._groups.get(
|
|
5464
|
+
const sourceGroup = sourceGroupId
|
|
5465
|
+
? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
|
|
5387
5466
|
: undefined;
|
|
5388
|
-
if (
|
|
5467
|
+
if (sourceItemId === undefined) {
|
|
5389
5468
|
if (sourceGroup) {
|
|
5390
|
-
this.moveGroup(sourceGroup,
|
|
5469
|
+
this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
|
|
5391
5470
|
}
|
|
5392
5471
|
return;
|
|
5393
5472
|
}
|
|
5394
|
-
if (!
|
|
5395
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5396
|
-
this.panels.find((panel) => panel.id ===
|
|
5473
|
+
if (!destinationTarget || destinationTarget === 'center') {
|
|
5474
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5475
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5397
5476
|
if (!groupItem) {
|
|
5398
|
-
throw new Error(`No panel with id ${
|
|
5477
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5399
5478
|
}
|
|
5400
5479
|
if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
|
|
5401
5480
|
this.doRemoveGroup(sourceGroup);
|
|
5402
5481
|
}
|
|
5403
|
-
|
|
5482
|
+
destinationGroup.model.openPanel(groupItem, {
|
|
5483
|
+
index: destinationIndex,
|
|
5484
|
+
});
|
|
5404
5485
|
}
|
|
5405
5486
|
else {
|
|
5406
|
-
const referenceLocation = getGridLocation(
|
|
5407
|
-
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5487
|
+
const referenceLocation = getGridLocation(destinationGroup.element);
|
|
5488
|
+
const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5408
5489
|
if (sourceGroup && sourceGroup.size < 2) {
|
|
5409
5490
|
const [targetParentLocation, to] = tail(targetLocation);
|
|
5410
5491
|
const sourceLocation = getGridLocation(sourceGroup.element);
|
|
@@ -5422,18 +5503,18 @@ class DockviewComponent extends BaseGrid {
|
|
|
5422
5503
|
skipDispose: true,
|
|
5423
5504
|
});
|
|
5424
5505
|
// after deleting the group we need to re-evaulate the ref location
|
|
5425
|
-
const updatedReferenceLocation = getGridLocation(
|
|
5426
|
-
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation,
|
|
5506
|
+
const updatedReferenceLocation = getGridLocation(destinationGroup.element);
|
|
5507
|
+
const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
|
|
5427
5508
|
this.doAddGroup(targetGroup, location);
|
|
5428
5509
|
}
|
|
5429
5510
|
}
|
|
5430
5511
|
else {
|
|
5431
|
-
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(
|
|
5432
|
-
this.panels.find((panel) => panel.id ===
|
|
5512
|
+
const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
|
|
5513
|
+
this.panels.find((panel) => panel.id === sourceItemId);
|
|
5433
5514
|
if (!groupItem) {
|
|
5434
|
-
throw new Error(`No panel with id ${
|
|
5515
|
+
throw new Error(`No panel with id ${sourceItemId}`);
|
|
5435
5516
|
}
|
|
5436
|
-
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation,
|
|
5517
|
+
const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
|
|
5437
5518
|
const group = this.createGroupAtLocation(dropLocation);
|
|
5438
5519
|
group.model.openPanel(groupItem);
|
|
5439
5520
|
}
|
|
@@ -5527,11 +5608,11 @@ class DockviewComponent extends BaseGrid {
|
|
|
5527
5608
|
return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
|
|
5528
5609
|
}
|
|
5529
5610
|
dispose() {
|
|
5530
|
-
super.dispose();
|
|
5531
5611
|
this._onDidActivePanelChange.dispose();
|
|
5532
5612
|
this._onDidAddPanel.dispose();
|
|
5533
5613
|
this._onDidRemovePanel.dispose();
|
|
5534
5614
|
this._onDidLayoutFromJSON.dispose();
|
|
5615
|
+
super.dispose();
|
|
5535
5616
|
}
|
|
5536
5617
|
}
|
|
5537
5618
|
|
|
@@ -5789,7 +5870,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5789
5870
|
}
|
|
5790
5871
|
set splitview(value) {
|
|
5791
5872
|
this._splitview = value;
|
|
5792
|
-
this.
|
|
5873
|
+
this._splitviewChangeDisposable.value = new CompositeDisposable(this._splitview.onDidSashEnd(() => {
|
|
5793
5874
|
this._onDidLayoutChange.fire(undefined);
|
|
5794
5875
|
}), this._splitview.onDidAddView((e) => this._onDidAddView.fire(e)), this._splitview.onDidRemoveView((e) => this._onDidRemoveView.fire(e)));
|
|
5795
5876
|
}
|
|
@@ -5811,7 +5892,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5811
5892
|
}
|
|
5812
5893
|
constructor(options) {
|
|
5813
5894
|
super(options.parentElement);
|
|
5814
|
-
this.
|
|
5895
|
+
this._splitviewChangeDisposable = new MutableDisposable();
|
|
5815
5896
|
this._panels = new Map();
|
|
5816
5897
|
this._onDidLayoutfromJSON = new Emitter();
|
|
5817
5898
|
this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
|
|
@@ -5829,7 +5910,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5829
5910
|
options.frameworkComponents = {};
|
|
5830
5911
|
}
|
|
5831
5912
|
this.splitview = new Splitview(this.element, options);
|
|
5832
|
-
this.addDisposables(this.
|
|
5913
|
+
this.addDisposables(this._onDidAddView, this._onDidLayoutfromJSON, this._onDidRemoveView, this._onDidLayoutChange);
|
|
5833
5914
|
}
|
|
5834
5915
|
updateOptions(options) {
|
|
5835
5916
|
const hasOrientationChanged = typeof options.orientation === 'string' &&
|
|
@@ -5867,15 +5948,15 @@ class SplitviewComponent extends Resizable {
|
|
|
5867
5948
|
}
|
|
5868
5949
|
}
|
|
5869
5950
|
removePanel(panel, sizing) {
|
|
5870
|
-
const
|
|
5871
|
-
if (!
|
|
5951
|
+
const item = this._panels.get(panel.id);
|
|
5952
|
+
if (!item) {
|
|
5872
5953
|
throw new Error(`unknown splitview panel ${panel.id}`);
|
|
5873
5954
|
}
|
|
5874
|
-
|
|
5875
|
-
disposable.value.dispose();
|
|
5955
|
+
item.dispose();
|
|
5876
5956
|
this._panels.delete(panel.id);
|
|
5877
5957
|
const index = this.panels.findIndex((_) => _ === panel);
|
|
5878
|
-
this.splitview.removeView(index, sizing);
|
|
5958
|
+
const removedView = this.splitview.removeView(index, sizing);
|
|
5959
|
+
removedView.dispose();
|
|
5879
5960
|
const panels = this.panels;
|
|
5880
5961
|
if (panels.length > 0) {
|
|
5881
5962
|
this.setActive(panels[panels.length - 1]);
|
|
@@ -5922,7 +6003,7 @@ class SplitviewComponent extends Resizable {
|
|
|
5922
6003
|
}
|
|
5923
6004
|
this.setActive(view, true);
|
|
5924
6005
|
});
|
|
5925
|
-
this._panels.set(view.id,
|
|
6006
|
+
this._panels.set(view.id, disposable);
|
|
5926
6007
|
}
|
|
5927
6008
|
toJSON() {
|
|
5928
6009
|
var _a;
|
|
@@ -5995,20 +6076,26 @@ class SplitviewComponent extends Resizable {
|
|
|
5995
6076
|
this._onDidLayoutfromJSON.fire();
|
|
5996
6077
|
}
|
|
5997
6078
|
clear() {
|
|
5998
|
-
for (const
|
|
5999
|
-
|
|
6000
|
-
value.value.dispose();
|
|
6079
|
+
for (const disposable of this._panels.values()) {
|
|
6080
|
+
disposable.dispose();
|
|
6001
6081
|
}
|
|
6002
6082
|
this._panels.clear();
|
|
6003
|
-
this.splitview.
|
|
6083
|
+
while (this.splitview.length > 0) {
|
|
6084
|
+
const view = this.splitview.removeView(0, Sizing.Distribute, true);
|
|
6085
|
+
view.dispose();
|
|
6086
|
+
}
|
|
6004
6087
|
}
|
|
6005
6088
|
dispose() {
|
|
6006
|
-
for (const
|
|
6007
|
-
|
|
6008
|
-
value.value.dispose();
|
|
6089
|
+
for (const disposable of this._panels.values()) {
|
|
6090
|
+
disposable.dispose();
|
|
6009
6091
|
}
|
|
6010
6092
|
this._panels.clear();
|
|
6093
|
+
const views = this.splitview.getViews();
|
|
6094
|
+
this._splitviewChangeDisposable.dispose();
|
|
6011
6095
|
this.splitview.dispose();
|
|
6096
|
+
for (const view of views) {
|
|
6097
|
+
view.dispose();
|
|
6098
|
+
}
|
|
6012
6099
|
super.dispose();
|
|
6013
6100
|
}
|
|
6014
6101
|
}
|