@lvce-editor/main-area-worker 9.50.1 → 9.51.0
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/mainAreaWorkerMain.js +268 -149
- package/package.json +1 -1
|
@@ -1680,8 +1680,11 @@ const VirtualDomElements = {
|
|
|
1680
1680
|
const Button$1 = 'event.button';
|
|
1681
1681
|
const ClientX = 'event.clientX';
|
|
1682
1682
|
const ClientY = 'event.clientY';
|
|
1683
|
+
const DeltaMode = 'event.deltaMode';
|
|
1684
|
+
const DeltaY = 'event.deltaY';
|
|
1683
1685
|
const DropId = 'event.dropId';
|
|
1684
1686
|
const EventTargetClassName = 'event.target.className';
|
|
1687
|
+
const Key = 'event.key';
|
|
1685
1688
|
const TargetName = 'event.target.name';
|
|
1686
1689
|
|
|
1687
1690
|
const Tab = 13;
|
|
@@ -2825,6 +2828,10 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
2825
2828
|
set$1(uid, state, state);
|
|
2826
2829
|
};
|
|
2827
2830
|
|
|
2831
|
+
const isEqual$3 = (oldState, newState) => {
|
|
2832
|
+
return oldState.layout === newState.layout && oldState.width === newState.width;
|
|
2833
|
+
};
|
|
2834
|
+
|
|
2828
2835
|
const isEqual$2 = (oldState, newState) => {
|
|
2829
2836
|
return false;
|
|
2830
2837
|
};
|
|
@@ -2842,12 +2849,13 @@ const RenderCss = 10;
|
|
|
2842
2849
|
const RenderIncremental = 11;
|
|
2843
2850
|
const RenderPendingViewletUpdate = 12;
|
|
2844
2851
|
const RenderDragData = 13;
|
|
2852
|
+
const RenderActiveTabVisibility = 14;
|
|
2845
2853
|
|
|
2846
2854
|
const isPendingViewletUpdateEqual = (oldState, newState) => {
|
|
2847
2855
|
return newState.pendingViewletUpdate === undefined;
|
|
2848
2856
|
};
|
|
2849
|
-
const modules = [isEqual, isEqual$2, isPendingViewletUpdateEqual, isEqual$1];
|
|
2850
|
-
const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate, RenderDragData];
|
|
2857
|
+
const modules = [isEqual, isEqual$2, isPendingViewletUpdateEqual, isEqual$1, isEqual$3];
|
|
2858
|
+
const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate, RenderDragData, RenderActiveTabVisibility];
|
|
2851
2859
|
|
|
2852
2860
|
const diff = (oldState, newState) => {
|
|
2853
2861
|
const diffResult = [];
|
|
@@ -3203,19 +3211,137 @@ const findTabById = (state, tabId) => {
|
|
|
3203
3211
|
return undefined;
|
|
3204
3212
|
};
|
|
3205
3213
|
|
|
3206
|
-
const
|
|
3214
|
+
const getSegmentSize = segment => {
|
|
3215
|
+
return segment.groups.reduce((total, group) => total + group.size, 0);
|
|
3216
|
+
};
|
|
3217
|
+
const getGroupSegments = (groups, parentDirection) => {
|
|
3218
|
+
const segments = [];
|
|
3219
|
+
let index = 0;
|
|
3220
|
+
while (index < groups.length) {
|
|
3221
|
+
const group = groups[index];
|
|
3222
|
+
if (group.direction !== parentDirection) {
|
|
3223
|
+
const startIndex = index;
|
|
3224
|
+
const nestedGroups = [group];
|
|
3225
|
+
const {
|
|
3226
|
+
segmentId
|
|
3227
|
+
} = group;
|
|
3228
|
+
index++;
|
|
3229
|
+
while (index < groups.length && groups[index].direction === group.direction && groups[index].segmentId === segmentId) {
|
|
3230
|
+
nestedGroups.push(groups[index]);
|
|
3231
|
+
index++;
|
|
3232
|
+
}
|
|
3233
|
+
segments.push({
|
|
3234
|
+
direction: nestedGroups.length === 1 ? undefined : group.direction,
|
|
3235
|
+
groups: nestedGroups,
|
|
3236
|
+
startIndex
|
|
3237
|
+
});
|
|
3238
|
+
continue;
|
|
3239
|
+
}
|
|
3240
|
+
segments.push({
|
|
3241
|
+
direction: undefined,
|
|
3242
|
+
groups: [group],
|
|
3243
|
+
startIndex: index
|
|
3244
|
+
});
|
|
3245
|
+
index++;
|
|
3246
|
+
}
|
|
3247
|
+
return segments;
|
|
3248
|
+
};
|
|
3249
|
+
|
|
3250
|
+
const getChildBounds = (bounds, direction, offset, size) => {
|
|
3251
|
+
if (direction === Horizontal) {
|
|
3252
|
+
return {
|
|
3253
|
+
height: bounds.height,
|
|
3254
|
+
width: bounds.width * size,
|
|
3255
|
+
x: bounds.x + bounds.width * offset,
|
|
3256
|
+
y: bounds.y
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
return {
|
|
3260
|
+
height: bounds.height * size,
|
|
3261
|
+
width: bounds.width,
|
|
3262
|
+
x: bounds.x,
|
|
3263
|
+
y: bounds.y + bounds.height * offset
|
|
3264
|
+
};
|
|
3265
|
+
};
|
|
3266
|
+
const getEditorGroupBoundsFromRoot = (layout, rootBounds) => {
|
|
3207
3267
|
const {
|
|
3268
|
+
direction,
|
|
3269
|
+
groups
|
|
3270
|
+
} = layout;
|
|
3271
|
+
const segments = getGroupSegments(groups, direction);
|
|
3272
|
+
const result = [];
|
|
3273
|
+
let segmentOffset = 0;
|
|
3274
|
+
for (const segment of segments) {
|
|
3275
|
+
const segmentSize = getSegmentSize(segment);
|
|
3276
|
+
const segmentBounds = getChildBounds(rootBounds, direction, segmentOffset / 100, segmentSize / 100);
|
|
3277
|
+
segmentOffset += segmentSize;
|
|
3278
|
+
if (segment.direction === undefined) {
|
|
3279
|
+
result.push({
|
|
3280
|
+
...segmentBounds,
|
|
3281
|
+
group: segment.groups[0]
|
|
3282
|
+
});
|
|
3283
|
+
continue;
|
|
3284
|
+
}
|
|
3285
|
+
let groupOffset = 0;
|
|
3286
|
+
for (const group of segment.groups) {
|
|
3287
|
+
const groupBounds = getChildBounds(segmentBounds, segment.direction, groupOffset / segmentSize, group.size / segmentSize);
|
|
3288
|
+
groupOffset += group.size;
|
|
3289
|
+
result.push({
|
|
3290
|
+
...groupBounds,
|
|
3291
|
+
group
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
return result;
|
|
3296
|
+
};
|
|
3297
|
+
const getEditorGroupBounds = (layout, width, height) => {
|
|
3298
|
+
return getEditorGroupBoundsFromRoot(layout, {
|
|
3208
3299
|
height,
|
|
3300
|
+
width,
|
|
3301
|
+
x: 0,
|
|
3302
|
+
y: 0
|
|
3303
|
+
});
|
|
3304
|
+
};
|
|
3305
|
+
const getEditorGroupContentBounds = (layout, bounds, tabHeight) => {
|
|
3306
|
+
return getEditorGroupBoundsFromRoot(layout, bounds).map(({
|
|
3307
|
+
group,
|
|
3308
|
+
...groupBounds
|
|
3309
|
+
}) => ({
|
|
3310
|
+
...groupBounds,
|
|
3311
|
+
groupId: group.id,
|
|
3312
|
+
height: groupBounds.height - tabHeight,
|
|
3313
|
+
y: groupBounds.y + tabHeight
|
|
3314
|
+
}));
|
|
3315
|
+
};
|
|
3316
|
+
|
|
3317
|
+
const getSelectedTabBounds = (state, groupId = state.layout.activeGroupId) => {
|
|
3318
|
+
const {
|
|
3319
|
+
height,
|
|
3320
|
+
layout,
|
|
3209
3321
|
tabHeight,
|
|
3210
3322
|
width,
|
|
3211
3323
|
x,
|
|
3212
3324
|
y
|
|
3213
3325
|
} = state;
|
|
3214
|
-
|
|
3215
|
-
height
|
|
3326
|
+
const bounds = getEditorGroupContentBounds(layout, {
|
|
3327
|
+
height,
|
|
3216
3328
|
width,
|
|
3217
3329
|
x,
|
|
3218
|
-
y
|
|
3330
|
+
y
|
|
3331
|
+
}, tabHeight).find(item => item.groupId === groupId);
|
|
3332
|
+
if (!bounds) {
|
|
3333
|
+
return {
|
|
3334
|
+
height: height - tabHeight,
|
|
3335
|
+
width,
|
|
3336
|
+
x,
|
|
3337
|
+
y: y + tabHeight
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
return {
|
|
3341
|
+
height: bounds.height,
|
|
3342
|
+
width: bounds.width,
|
|
3343
|
+
x: bounds.x,
|
|
3344
|
+
y: bounds.y
|
|
3219
3345
|
};
|
|
3220
3346
|
};
|
|
3221
3347
|
|
|
@@ -3301,7 +3427,7 @@ const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, ind
|
|
|
3301
3427
|
if (!viewletModuleId) {
|
|
3302
3428
|
return undefined;
|
|
3303
3429
|
}
|
|
3304
|
-
const bounds = getSelectedTabBounds(newState);
|
|
3430
|
+
const bounds = getSelectedTabBounds(newState, newState.layout.groups[groupIndex].id);
|
|
3305
3431
|
let stateWithViewlet = createViewletForTab(newState, tabId);
|
|
3306
3432
|
set$1(uid, state, stateWithViewlet);
|
|
3307
3433
|
if (switchCommands.length > 0) {
|
|
@@ -4131,12 +4257,8 @@ const openInputWithContext = async (context, options) => {
|
|
|
4131
4257
|
await context.updateState(() => unsupportedState);
|
|
4132
4258
|
return;
|
|
4133
4259
|
}
|
|
4134
|
-
const
|
|
4135
|
-
|
|
4136
|
-
width: stateAfterModuleId.width,
|
|
4137
|
-
x: stateAfterModuleId.x,
|
|
4138
|
-
y: stateAfterModuleId.y + stateAfterModuleId.tabHeight
|
|
4139
|
-
};
|
|
4260
|
+
const tabLocation = findTabById(stateAfterModuleId, tabId);
|
|
4261
|
+
const bounds = getSelectedTabBounds(stateAfterModuleId, tabLocation?.groupId);
|
|
4140
4262
|
const stateWithViewlet = createViewletForTab(stateAfterModuleId, tabId, viewletModuleId, bounds);
|
|
4141
4263
|
let intermediateState = stateWithViewlet;
|
|
4142
4264
|
const {
|
|
@@ -4468,42 +4590,6 @@ const retryOpen = async state => {
|
|
|
4468
4590
|
return openUri(state, tab.uri);
|
|
4469
4591
|
};
|
|
4470
4592
|
|
|
4471
|
-
const getSegmentSize = segment => {
|
|
4472
|
-
return segment.groups.reduce((total, group) => total + group.size, 0);
|
|
4473
|
-
};
|
|
4474
|
-
const getGroupSegments = (groups, parentDirection) => {
|
|
4475
|
-
const segments = [];
|
|
4476
|
-
let index = 0;
|
|
4477
|
-
while (index < groups.length) {
|
|
4478
|
-
const group = groups[index];
|
|
4479
|
-
if (group.direction !== parentDirection) {
|
|
4480
|
-
const startIndex = index;
|
|
4481
|
-
const nestedGroups = [group];
|
|
4482
|
-
const {
|
|
4483
|
-
segmentId
|
|
4484
|
-
} = group;
|
|
4485
|
-
index++;
|
|
4486
|
-
while (index < groups.length && groups[index].direction === group.direction && groups[index].segmentId === segmentId) {
|
|
4487
|
-
nestedGroups.push(groups[index]);
|
|
4488
|
-
index++;
|
|
4489
|
-
}
|
|
4490
|
-
segments.push({
|
|
4491
|
-
direction: nestedGroups.length === 1 ? undefined : group.direction,
|
|
4492
|
-
groups: nestedGroups,
|
|
4493
|
-
startIndex
|
|
4494
|
-
});
|
|
4495
|
-
continue;
|
|
4496
|
-
}
|
|
4497
|
-
segments.push({
|
|
4498
|
-
direction: undefined,
|
|
4499
|
-
groups: [group],
|
|
4500
|
-
startIndex: index
|
|
4501
|
-
});
|
|
4502
|
-
index++;
|
|
4503
|
-
}
|
|
4504
|
-
return segments;
|
|
4505
|
-
};
|
|
4506
|
-
|
|
4507
4593
|
const rebalanceGroupSizes = groups => {
|
|
4508
4594
|
const groupCount = groups.length;
|
|
4509
4595
|
if (groupCount === 0) {
|
|
@@ -4822,60 +4908,6 @@ const handleDragLeave = state => {
|
|
|
4822
4908
|
};
|
|
4823
4909
|
};
|
|
4824
4910
|
|
|
4825
|
-
const getChildBounds = (bounds, direction, offset, size) => {
|
|
4826
|
-
if (direction === Horizontal) {
|
|
4827
|
-
return {
|
|
4828
|
-
height: bounds.height,
|
|
4829
|
-
width: bounds.width * size,
|
|
4830
|
-
x: bounds.x + bounds.width * offset,
|
|
4831
|
-
y: bounds.y
|
|
4832
|
-
};
|
|
4833
|
-
}
|
|
4834
|
-
return {
|
|
4835
|
-
height: bounds.height * size,
|
|
4836
|
-
width: bounds.width,
|
|
4837
|
-
x: bounds.x,
|
|
4838
|
-
y: bounds.y + bounds.height * offset
|
|
4839
|
-
};
|
|
4840
|
-
};
|
|
4841
|
-
const getEditorGroupBounds = (layout, width, height) => {
|
|
4842
|
-
const {
|
|
4843
|
-
direction,
|
|
4844
|
-
groups
|
|
4845
|
-
} = layout;
|
|
4846
|
-
const segments = getGroupSegments(groups, direction);
|
|
4847
|
-
const rootBounds = {
|
|
4848
|
-
height,
|
|
4849
|
-
width,
|
|
4850
|
-
x: 0,
|
|
4851
|
-
y: 0
|
|
4852
|
-
};
|
|
4853
|
-
const result = [];
|
|
4854
|
-
let segmentOffset = 0;
|
|
4855
|
-
for (const segment of segments) {
|
|
4856
|
-
const segmentSize = getSegmentSize(segment);
|
|
4857
|
-
const segmentBounds = getChildBounds(rootBounds, direction, segmentOffset / 100, segmentSize / 100);
|
|
4858
|
-
segmentOffset += segmentSize;
|
|
4859
|
-
if (segment.direction === undefined) {
|
|
4860
|
-
result.push({
|
|
4861
|
-
...segmentBounds,
|
|
4862
|
-
group: segment.groups[0]
|
|
4863
|
-
});
|
|
4864
|
-
continue;
|
|
4865
|
-
}
|
|
4866
|
-
let groupOffset = 0;
|
|
4867
|
-
for (const group of segment.groups) {
|
|
4868
|
-
const groupBounds = getChildBounds(segmentBounds, segment.direction, groupOffset / segmentSize, group.size / segmentSize);
|
|
4869
|
-
groupOffset += group.size;
|
|
4870
|
-
result.push({
|
|
4871
|
-
...groupBounds,
|
|
4872
|
-
group
|
|
4873
|
-
});
|
|
4874
|
-
}
|
|
4875
|
-
}
|
|
4876
|
-
return result;
|
|
4877
|
-
};
|
|
4878
|
-
|
|
4879
4911
|
const None = 0;
|
|
4880
4912
|
const Up = 1;
|
|
4881
4913
|
const Down = 2;
|
|
@@ -5361,14 +5393,7 @@ const newFile = async state => {
|
|
|
5361
5393
|
uri: 'untitled:///1'
|
|
5362
5394
|
};
|
|
5363
5395
|
const stateWithNewTab = openTab(newState, targetGroupId, newTab);
|
|
5364
|
-
|
|
5365
|
-
// Calculate bounds: use main area bounds minus tab height
|
|
5366
|
-
const bounds = {
|
|
5367
|
-
height: stateWithNewTab.height - stateWithNewTab.tabHeight,
|
|
5368
|
-
width: stateWithNewTab.width,
|
|
5369
|
-
x: stateWithNewTab.x,
|
|
5370
|
-
y: stateWithNewTab.y + stateWithNewTab.tabHeight
|
|
5371
|
-
};
|
|
5396
|
+
const bounds = getSelectedTabBounds(stateWithNewTab, targetGroupId);
|
|
5372
5397
|
const viewletModuleId = EditorText;
|
|
5373
5398
|
const stateWithViewlet = createViewletForTab(stateWithNewTab, tabId);
|
|
5374
5399
|
let intermediateState = stateWithViewlet;
|
|
@@ -5535,13 +5560,6 @@ const resizeChild = async (editorUid, dimensions) => {
|
|
|
5535
5560
|
}
|
|
5536
5561
|
};
|
|
5537
5562
|
const handleResize = async (state, dimensions) => {
|
|
5538
|
-
const {
|
|
5539
|
-
height,
|
|
5540
|
-
width,
|
|
5541
|
-
x,
|
|
5542
|
-
y
|
|
5543
|
-
} = dimensions;
|
|
5544
|
-
|
|
5545
5563
|
// Resize all editor children to their new bounds
|
|
5546
5564
|
const {
|
|
5547
5565
|
layout,
|
|
@@ -5550,20 +5568,24 @@ const handleResize = async (state, dimensions) => {
|
|
|
5550
5568
|
const {
|
|
5551
5569
|
groups
|
|
5552
5570
|
} = layout;
|
|
5553
|
-
const
|
|
5571
|
+
const groupBounds = getEditorGroupContentBounds(layout, dimensions, tabHeight);
|
|
5554
5572
|
const resizePromises = [];
|
|
5555
|
-
const
|
|
5556
|
-
|
|
5557
|
-
if (
|
|
5573
|
+
for (const group of groups) {
|
|
5574
|
+
const bounds = groupBounds.find(item => item.groupId === group.id);
|
|
5575
|
+
if (!bounds) {
|
|
5558
5576
|
continue;
|
|
5559
5577
|
}
|
|
5560
|
-
const
|
|
5561
|
-
height:
|
|
5562
|
-
width,
|
|
5563
|
-
x,
|
|
5564
|
-
y: y
|
|
5565
|
-
}
|
|
5566
|
-
|
|
5578
|
+
const dimensions = {
|
|
5579
|
+
height: bounds.height,
|
|
5580
|
+
width: bounds.width,
|
|
5581
|
+
x: bounds.x,
|
|
5582
|
+
y: bounds.y
|
|
5583
|
+
};
|
|
5584
|
+
for (const tab of group.tabs) {
|
|
5585
|
+
if (tab.editorUid !== -1) {
|
|
5586
|
+
resizePromises.push(resizeChild(tab.editorUid, dimensions));
|
|
5587
|
+
}
|
|
5588
|
+
}
|
|
5567
5589
|
}
|
|
5568
5590
|
const resizeCommands = await Promise.all(resizePromises);
|
|
5569
5591
|
return resizeCommands.flat();
|
|
@@ -5885,6 +5907,77 @@ const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tab
|
|
|
5885
5907
|
return state;
|
|
5886
5908
|
};
|
|
5887
5909
|
|
|
5910
|
+
const getFocusIndex = (key, index, tabCount) => {
|
|
5911
|
+
switch (key) {
|
|
5912
|
+
case 'ArrowLeft':
|
|
5913
|
+
return (index + tabCount - 1) % tabCount;
|
|
5914
|
+
case 'ArrowRight':
|
|
5915
|
+
return (index + 1) % tabCount;
|
|
5916
|
+
case 'End':
|
|
5917
|
+
return tabCount - 1;
|
|
5918
|
+
case 'Home':
|
|
5919
|
+
return 0;
|
|
5920
|
+
default:
|
|
5921
|
+
return -1;
|
|
5922
|
+
}
|
|
5923
|
+
};
|
|
5924
|
+
const focusTab = async (state, groupIndex, index) => {
|
|
5925
|
+
const selector = `.${MainTab}[data-group-index="${groupIndex}"][data-index="${index}"]`;
|
|
5926
|
+
if (isConnected()) {
|
|
5927
|
+
await invoke('Viewlet.focusSelector', state.uid, selector);
|
|
5928
|
+
} else {
|
|
5929
|
+
await invoke$1('Viewlet.focusSelector', state.uid, selector);
|
|
5930
|
+
}
|
|
5931
|
+
};
|
|
5932
|
+
const handleTabKeyDown = async (state, groupIndexRaw, indexRaw, key) => {
|
|
5933
|
+
if (!groupIndexRaw || !indexRaw) {
|
|
5934
|
+
return state;
|
|
5935
|
+
}
|
|
5936
|
+
const groupIndex = Number.parseInt(groupIndexRaw);
|
|
5937
|
+
const index = Number.parseInt(indexRaw);
|
|
5938
|
+
const group = state.layout.groups[groupIndex];
|
|
5939
|
+
if (!group || index < 0 || index >= group.tabs.length) {
|
|
5940
|
+
return state;
|
|
5941
|
+
}
|
|
5942
|
+
if ([' ', 'Enter', 'Space'].includes(key)) {
|
|
5943
|
+
return selectTab(state, groupIndex, index);
|
|
5944
|
+
}
|
|
5945
|
+
const focusIndex = getFocusIndex(key, index, group.tabs.length);
|
|
5946
|
+
if (focusIndex === -1) {
|
|
5947
|
+
return state;
|
|
5948
|
+
}
|
|
5949
|
+
await focusTab(state, groupIndex, focusIndex);
|
|
5950
|
+
return state;
|
|
5951
|
+
};
|
|
5952
|
+
|
|
5953
|
+
const getPixelDelta = (state, deltaMode, deltaY) => {
|
|
5954
|
+
switch (deltaMode) {
|
|
5955
|
+
case 1:
|
|
5956
|
+
return deltaY * 16;
|
|
5957
|
+
case 2:
|
|
5958
|
+
return deltaY * state.width;
|
|
5959
|
+
default:
|
|
5960
|
+
return deltaY;
|
|
5961
|
+
}
|
|
5962
|
+
};
|
|
5963
|
+
const handleTabsWheel = async (state, groupIndexRaw, deltaMode, deltaY) => {
|
|
5964
|
+
if (!groupIndexRaw || deltaY === 0) {
|
|
5965
|
+
return state;
|
|
5966
|
+
}
|
|
5967
|
+
const groupIndex = Number.parseInt(groupIndexRaw);
|
|
5968
|
+
if (!state.layout.groups[groupIndex]) {
|
|
5969
|
+
return state;
|
|
5970
|
+
}
|
|
5971
|
+
const selector = `.${MainTabs}[data-group-index="${groupIndex}"]`;
|
|
5972
|
+
const pixelDelta = getPixelDelta(state, deltaMode, deltaY);
|
|
5973
|
+
if (isConnected()) {
|
|
5974
|
+
await invoke('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
|
|
5975
|
+
} else {
|
|
5976
|
+
await invoke$1('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
|
|
5977
|
+
}
|
|
5978
|
+
return state;
|
|
5979
|
+
};
|
|
5980
|
+
|
|
5888
5981
|
const handleUriChange = async (state, oldUri, newUri) => {
|
|
5889
5982
|
const {
|
|
5890
5983
|
homeDirUri,
|
|
@@ -6056,7 +6149,10 @@ const tryRestoreLayout = savedState => {
|
|
|
6056
6149
|
return normalizedLayout;
|
|
6057
6150
|
};
|
|
6058
6151
|
|
|
6059
|
-
const createViewlets = async (
|
|
6152
|
+
const createViewlets = async (state, viewletModuleIds) => {
|
|
6153
|
+
const {
|
|
6154
|
+
layout
|
|
6155
|
+
} = state;
|
|
6060
6156
|
const {
|
|
6061
6157
|
groups
|
|
6062
6158
|
} = layout;
|
|
@@ -6067,7 +6163,8 @@ const createViewlets = async (layout, viewletModuleIds, bounds) => {
|
|
|
6067
6163
|
if (activeTab && viewletModuleIds[activeTab.id]) {
|
|
6068
6164
|
const editorUid = activeTab.editorUid === -1 ? create$2() : activeTab.editorUid;
|
|
6069
6165
|
editorUids[activeTab.id] = editorUid;
|
|
6070
|
-
const
|
|
6166
|
+
const bounds = getSelectedTabBounds(state, group.id);
|
|
6167
|
+
const title = await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri || '');
|
|
6071
6168
|
if (title) {
|
|
6072
6169
|
titles[activeTab.id] = title;
|
|
6073
6170
|
}
|
|
@@ -6141,19 +6238,10 @@ const updateTabs = (state, editorUids) => {
|
|
|
6141
6238
|
};
|
|
6142
6239
|
|
|
6143
6240
|
const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
6144
|
-
const {
|
|
6145
|
-
tabHeight
|
|
6146
|
-
} = state;
|
|
6147
6241
|
let newState = {
|
|
6148
6242
|
...state,
|
|
6149
6243
|
layout: restoredLayout
|
|
6150
6244
|
};
|
|
6151
|
-
const bounds = {
|
|
6152
|
-
height: newState.height - tabHeight,
|
|
6153
|
-
width: newState.width,
|
|
6154
|
-
x: newState.x,
|
|
6155
|
-
y: newState.y + tabHeight
|
|
6156
|
-
};
|
|
6157
6245
|
|
|
6158
6246
|
// Get viewlet module IDs for all active tabs
|
|
6159
6247
|
const viewletModuleIds = await getViewletModuleIds(newState.layout);
|
|
@@ -6162,7 +6250,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
|
6162
6250
|
const {
|
|
6163
6251
|
editorUids,
|
|
6164
6252
|
titles
|
|
6165
|
-
} = await createViewlets(newState
|
|
6253
|
+
} = await createViewlets(newState, viewletModuleIds);
|
|
6166
6254
|
|
|
6167
6255
|
// Update tabs with editor UIDs
|
|
6168
6256
|
newState = updateTabs(newState, editorUids);
|
|
@@ -6172,6 +6260,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
|
6172
6260
|
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
6173
6261
|
if (activeTab && viewletModuleIds[activeTab.id]) {
|
|
6174
6262
|
const editorUid = editorUids[activeTab.id];
|
|
6263
|
+
getSelectedTabBounds(newState, group.id);
|
|
6175
6264
|
newState = createViewletForTab(newState, activeTab.id);
|
|
6176
6265
|
newState = handleViewletReady(newState, editorUid, titles[activeTab.id]);
|
|
6177
6266
|
}
|
|
@@ -6695,6 +6784,24 @@ const refresh = state => {
|
|
|
6695
6784
|
};
|
|
6696
6785
|
};
|
|
6697
6786
|
|
|
6787
|
+
const renderActiveTabVisibility = (oldState, newState) => {
|
|
6788
|
+
const {
|
|
6789
|
+
activeGroupId,
|
|
6790
|
+
groups
|
|
6791
|
+
} = newState.layout;
|
|
6792
|
+
const groupIndex = groups.findIndex(group => group.id === activeGroupId);
|
|
6793
|
+
if (groupIndex === -1) {
|
|
6794
|
+
return [];
|
|
6795
|
+
}
|
|
6796
|
+
const group = groups[groupIndex];
|
|
6797
|
+
const tabIndex = group.tabs.findIndex(tab => tab.id === group.activeTabId);
|
|
6798
|
+
if (tabIndex === -1) {
|
|
6799
|
+
return [];
|
|
6800
|
+
}
|
|
6801
|
+
const selector = `.${MainTab}[data-group-index="${groupIndex}"][data-index="${tabIndex}"]`;
|
|
6802
|
+
return ['Viewlet.scrollSelectorIntoView', newState.uid, selector];
|
|
6803
|
+
};
|
|
6804
|
+
|
|
6698
6805
|
const getDragOverlayCss = dragOverlay => {
|
|
6699
6806
|
if (!dragOverlay) {
|
|
6700
6807
|
return [];
|
|
@@ -7168,6 +7275,8 @@ const HandleDrop = 25;
|
|
|
7168
7275
|
const HandleDragStart = 26;
|
|
7169
7276
|
const HandleDragEnd = 27;
|
|
7170
7277
|
const HandleTabMouseUp = 28;
|
|
7278
|
+
const HandleTabKeyDown = 29;
|
|
7279
|
+
const HandleTabsWheel = 30;
|
|
7171
7280
|
|
|
7172
7281
|
const dragOverlayVirtualDom = {
|
|
7173
7282
|
childCount: 0,
|
|
@@ -7396,9 +7505,11 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
7396
7505
|
onDblClick: HandleDoubleClick,
|
|
7397
7506
|
onDragEnd: HandleDragEnd,
|
|
7398
7507
|
onDragStart: HandleDragStart,
|
|
7508
|
+
onKeyDown: HandleTabKeyDown,
|
|
7399
7509
|
onMouseDown: HandleClickTab,
|
|
7400
7510
|
onMouseUp: HandleTabMouseUp,
|
|
7401
7511
|
role: Tab$1,
|
|
7512
|
+
tabIndex: isActive ? 0 : -1,
|
|
7402
7513
|
title: tab.uriTitle || tab.uri || tab.title,
|
|
7403
7514
|
type: Div
|
|
7404
7515
|
}, ...renderTabIcon(tab), tabTitleNode, text(tab.title), ...closeButtonNodes];
|
|
@@ -7408,6 +7519,8 @@ const getTabsVirtualDom = (group, groupIndex, tabsChildCount) => {
|
|
|
7408
7519
|
return [{
|
|
7409
7520
|
childCount: tabsChildCount,
|
|
7410
7521
|
className: MainTabs,
|
|
7522
|
+
'data-groupIndex': groupIndex,
|
|
7523
|
+
onWheel: HandleTabsWheel,
|
|
7411
7524
|
role: TabList,
|
|
7412
7525
|
type: Div
|
|
7413
7526
|
}, ...group.tabs.flatMap((tab, tabIndex) => renderTab(tab, tab.id === group.activeTabId, tabIndex, groupIndex))];
|
|
@@ -7768,6 +7881,8 @@ const renderPendingViewletUpdate = (oldState, newState) => {
|
|
|
7768
7881
|
|
|
7769
7882
|
const getRenderer = diffType => {
|
|
7770
7883
|
switch (diffType) {
|
|
7884
|
+
case RenderActiveTabVisibility:
|
|
7885
|
+
return renderActiveTabVisibility;
|
|
7771
7886
|
case RenderCss:
|
|
7772
7887
|
return renderCss;
|
|
7773
7888
|
case RenderDragData:
|
|
@@ -7820,10 +7935,17 @@ const renderEventListeners = () => {
|
|
|
7820
7935
|
params: ['handleClick', TargetName]
|
|
7821
7936
|
}, {
|
|
7822
7937
|
name: HandleClickClose,
|
|
7823
|
-
params: ['handleClickCloseTab', 'event.
|
|
7938
|
+
params: ['handleClickCloseTab', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index'],
|
|
7939
|
+
stopPropagation: true
|
|
7824
7940
|
}, {
|
|
7825
7941
|
name: HandleClickTab,
|
|
7826
|
-
params: ['handleClickTab', 'event.
|
|
7942
|
+
params: ['handleClickTab', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index', Button$1]
|
|
7943
|
+
}, {
|
|
7944
|
+
name: HandleTabKeyDown,
|
|
7945
|
+
params: ['handleTabKeyDown', 'event.currentTarget.dataset.groupIndex', 'event.currentTarget.dataset.index', Key]
|
|
7946
|
+
}, {
|
|
7947
|
+
name: HandleTabsWheel,
|
|
7948
|
+
params: ['handleTabsWheel', 'event.currentTarget.dataset.groupIndex', DeltaMode, DeltaY]
|
|
7827
7949
|
}, {
|
|
7828
7950
|
name: HandleDoubleClick,
|
|
7829
7951
|
params: ['handleDoubleClick', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
|
|
@@ -7963,12 +8085,7 @@ const reopenEditorWith = async (context, preferredEditorId) => {
|
|
|
7963
8085
|
errorMessage: undefined,
|
|
7964
8086
|
loadingState: undefined
|
|
7965
8087
|
});
|
|
7966
|
-
const bounds =
|
|
7967
|
-
height: resetState.height - resetState.tabHeight,
|
|
7968
|
-
width: resetState.width,
|
|
7969
|
-
x: resetState.x,
|
|
7970
|
-
y: resetState.y + resetState.tabHeight
|
|
7971
|
-
};
|
|
8088
|
+
const bounds = getSelectedTabBounds(resetState, latestTab.groupId);
|
|
7972
8089
|
const stateWithViewlet = createViewletForTab(resetState, initialTab.id);
|
|
7973
8090
|
await context.updateState(() => stateWithViewlet);
|
|
7974
8091
|
const tabWithViewlet = findTabById(stateWithViewlet, initialTab.id);
|
|
@@ -8428,7 +8545,9 @@ const commandMap = {
|
|
|
8428
8545
|
'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
|
|
8429
8546
|
'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
|
|
8430
8547
|
'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
|
|
8548
|
+
'MainArea.handleTabKeyDown': wrapSerialCommand(handleTabKeyDown),
|
|
8431
8549
|
'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
|
|
8550
|
+
'MainArea.handleTabsWheel': wrapSerialCommand(handleTabsWheel),
|
|
8432
8551
|
'MainArea.handleTestWorkerMessagePort': handleTestWorkerMessagePort,
|
|
8433
8552
|
'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
|
|
8434
8553
|
'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
|