@lvce-editor/main-area-worker 8.14.0 → 8.16.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 +209 -22
- package/package.json +1 -1
|
@@ -280,6 +280,44 @@ const closeOtherTabs = (state, groupId) => {
|
|
|
280
280
|
};
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
+
const getNextActiveTabId = (tabs, newTabs, activeTabId) => {
|
|
284
|
+
if (activeTabId === undefined) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
if (newTabs.some(tab => tab.id === activeTabId)) {
|
|
288
|
+
return activeTabId;
|
|
289
|
+
}
|
|
290
|
+
const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
|
|
291
|
+
if (activeTabIndex === -1 || newTabs.length === 0) {
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
return newTabs[Math.min(activeTabIndex, newTabs.length - 1)].id;
|
|
295
|
+
};
|
|
296
|
+
const closeSavedInGroup = group => {
|
|
297
|
+
const {
|
|
298
|
+
activeTabId,
|
|
299
|
+
tabs
|
|
300
|
+
} = group;
|
|
301
|
+
const newTabs = tabs.filter(tab => tab.isDirty);
|
|
302
|
+
if (newTabs.length === tabs.length) {
|
|
303
|
+
return group;
|
|
304
|
+
}
|
|
305
|
+
const newActiveTabId = getNextActiveTabId(tabs, newTabs, activeTabId);
|
|
306
|
+
return {
|
|
307
|
+
...group,
|
|
308
|
+
activeTabId: newActiveTabId,
|
|
309
|
+
isEmpty: newTabs.length === 0,
|
|
310
|
+
tabs: newTabs
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
const closeSaved$1 = state => {
|
|
314
|
+
const {
|
|
315
|
+
groups
|
|
316
|
+
} = state.layout;
|
|
317
|
+
const newGroups = groups.map(closeSavedInGroup);
|
|
318
|
+
return withGroups(state, newGroups);
|
|
319
|
+
};
|
|
320
|
+
|
|
283
321
|
const getGroupById = (state, groupId) => {
|
|
284
322
|
return state.layout.groups.find(group => group.id === groupId);
|
|
285
323
|
};
|
|
@@ -2359,7 +2397,7 @@ const handleClickTogglePreview = async state => {
|
|
|
2359
2397
|
|
|
2360
2398
|
const CloseGroup = 'close-group';
|
|
2361
2399
|
const RetryOpen = 'retry-open';
|
|
2362
|
-
const SplitRight = 'split-right';
|
|
2400
|
+
const SplitRight$1 = 'split-right';
|
|
2363
2401
|
const TogglePreview$1 = 'toggle-preview';
|
|
2364
2402
|
|
|
2365
2403
|
const getBasename$1 = uri => {
|
|
@@ -2382,7 +2420,7 @@ const getLabel = uri => {
|
|
|
2382
2420
|
return getBasename$1(uri);
|
|
2383
2421
|
};
|
|
2384
2422
|
|
|
2385
|
-
const createEmptyGroup = (state, uri, requestId) => {
|
|
2423
|
+
const createEmptyGroup = (state, uri, requestId, preview = false) => {
|
|
2386
2424
|
const {
|
|
2387
2425
|
layout
|
|
2388
2426
|
} = state;
|
|
@@ -2400,7 +2438,7 @@ const createEmptyGroup = (state, uri, requestId) => {
|
|
|
2400
2438
|
icon: '',
|
|
2401
2439
|
id: tabId,
|
|
2402
2440
|
isDirty: false,
|
|
2403
|
-
isPreview:
|
|
2441
|
+
isPreview: preview,
|
|
2404
2442
|
language: '',
|
|
2405
2443
|
loadingState: 'loading',
|
|
2406
2444
|
title,
|
|
@@ -2460,7 +2498,7 @@ const openTab = (state, groupId, tab) => {
|
|
|
2460
2498
|
};
|
|
2461
2499
|
};
|
|
2462
2500
|
|
|
2463
|
-
const ensureActiveGroup = (state, uri) => {
|
|
2501
|
+
const ensureActiveGroup = (state, uri, preview = false) => {
|
|
2464
2502
|
// Find the active group (by activeGroupId or focused flag)
|
|
2465
2503
|
const {
|
|
2466
2504
|
layout
|
|
@@ -2472,11 +2510,49 @@ const ensureActiveGroup = (state, uri) => {
|
|
|
2472
2510
|
const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
|
|
2473
2511
|
|
|
2474
2512
|
// Generate a request ID for content loading
|
|
2475
|
-
getNextRequestId();
|
|
2513
|
+
const requestId = getNextRequestId();
|
|
2476
2514
|
|
|
2477
2515
|
// If no active group exists, create one
|
|
2478
2516
|
let newState;
|
|
2479
2517
|
if (activeGroup) {
|
|
2518
|
+
const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
2519
|
+
if (activeTab?.isPreview) {
|
|
2520
|
+
const title = getLabel(uri);
|
|
2521
|
+
const updatedGroups = groups.map(group => {
|
|
2522
|
+
if (group.id !== activeGroup.id) {
|
|
2523
|
+
return group;
|
|
2524
|
+
}
|
|
2525
|
+
const updatedTabs = group.tabs.map(tab => {
|
|
2526
|
+
if (tab.id !== activeTab.id) {
|
|
2527
|
+
return tab;
|
|
2528
|
+
}
|
|
2529
|
+
return {
|
|
2530
|
+
...tab,
|
|
2531
|
+
errorMessage: '',
|
|
2532
|
+
icon: '',
|
|
2533
|
+
isDirty: false,
|
|
2534
|
+
isPreview: preview,
|
|
2535
|
+
language: '',
|
|
2536
|
+
loadingState: 'loading',
|
|
2537
|
+
title,
|
|
2538
|
+
uri
|
|
2539
|
+
};
|
|
2540
|
+
});
|
|
2541
|
+
return {
|
|
2542
|
+
...group,
|
|
2543
|
+
tabs: updatedTabs
|
|
2544
|
+
};
|
|
2545
|
+
});
|
|
2546
|
+
return {
|
|
2547
|
+
...state,
|
|
2548
|
+
layout: {
|
|
2549
|
+
...layout,
|
|
2550
|
+
activeGroupId: activeGroup.id,
|
|
2551
|
+
groups: updatedGroups
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2480
2556
|
// Create a new tab with the URI in the active group
|
|
2481
2557
|
const title = getLabel(uri);
|
|
2482
2558
|
const tabId = create$1();
|
|
@@ -2488,7 +2564,7 @@ const ensureActiveGroup = (state, uri) => {
|
|
|
2488
2564
|
icon: '',
|
|
2489
2565
|
id: tabId,
|
|
2490
2566
|
isDirty: false,
|
|
2491
|
-
isPreview:
|
|
2567
|
+
isPreview: preview,
|
|
2492
2568
|
language: '',
|
|
2493
2569
|
loadingState: 'loading',
|
|
2494
2570
|
title,
|
|
@@ -2496,7 +2572,7 @@ const ensureActiveGroup = (state, uri) => {
|
|
|
2496
2572
|
};
|
|
2497
2573
|
newState = openTab(state, activeGroup.id, newTab);
|
|
2498
2574
|
} else {
|
|
2499
|
-
newState = createEmptyGroup(state, uri);
|
|
2575
|
+
newState = createEmptyGroup(state, uri, requestId, preview);
|
|
2500
2576
|
}
|
|
2501
2577
|
return newState;
|
|
2502
2578
|
};
|
|
@@ -2698,6 +2774,7 @@ const openUri = async (state, options) => {
|
|
|
2698
2774
|
uid
|
|
2699
2775
|
} = state;
|
|
2700
2776
|
const uri = getOptionUriOptions(options);
|
|
2777
|
+
const preview = typeof options === 'string' ? false : options.preview ?? false;
|
|
2701
2778
|
|
|
2702
2779
|
// Check if a tab with this URI already exists in the passed-in state
|
|
2703
2780
|
const existingTab = findTabByUri(state, uri);
|
|
@@ -2745,7 +2822,7 @@ const openUri = async (state, options) => {
|
|
|
2745
2822
|
tabId = existingTab.tab.id;
|
|
2746
2823
|
} else {
|
|
2747
2824
|
// Add tab to state BEFORE any async calls to prevent race conditions
|
|
2748
|
-
stateWithTab = ensureActiveGroup(currentState, uri);
|
|
2825
|
+
stateWithTab = ensureActiveGroup(currentState, uri, preview);
|
|
2749
2826
|
tabId = getActiveTabId(stateWithTab);
|
|
2750
2827
|
}
|
|
2751
2828
|
|
|
@@ -2968,7 +3045,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
|
|
|
2968
3045
|
return state;
|
|
2969
3046
|
case RetryOpen:
|
|
2970
3047
|
return retryOpen(state);
|
|
2971
|
-
case SplitRight:
|
|
3048
|
+
case SplitRight$1:
|
|
2972
3049
|
return splitEditorGroup$1(state, activeGroup.id, Right);
|
|
2973
3050
|
case TogglePreview$1:
|
|
2974
3051
|
return handleClickTogglePreview(state);
|
|
@@ -3047,6 +3124,7 @@ const IconButton = 'IconButton';
|
|
|
3047
3124
|
const MainTab = 'MainTab';
|
|
3048
3125
|
const MainTabs = 'MainTabs';
|
|
3049
3126
|
const MainTabModified = 'MainTabModified';
|
|
3127
|
+
const MainTabPreview = 'MainTabPreview';
|
|
3050
3128
|
const MainTabSelected = 'MainTabSelected';
|
|
3051
3129
|
|
|
3052
3130
|
const newFile = async state => {
|
|
@@ -3725,14 +3803,28 @@ const Close = 'Close';
|
|
|
3725
3803
|
const CloseEditorGroup = 'Close Editor Group';
|
|
3726
3804
|
const CloseAll = 'Close All';
|
|
3727
3805
|
const CloseOthers = 'Close Others';
|
|
3806
|
+
const CloseSaved = 'Close Saved';
|
|
3728
3807
|
const CloseToTheRight = 'Close To The Right';
|
|
3729
3808
|
const CopyPath = 'Copy Path';
|
|
3730
3809
|
const CopyRelativePath = 'Copy Relative Path';
|
|
3731
3810
|
const FindFileReferences = 'Find File References';
|
|
3732
|
-
const
|
|
3811
|
+
const ReopenEditorWith = 'Reopen Editor With...';
|
|
3812
|
+
const Share = 'Share';
|
|
3813
|
+
const AddFileToChat = 'Add File to Chat';
|
|
3814
|
+
const OpenContainingFolder = 'Open Containing Folder';
|
|
3815
|
+
const RevealInExplorerView = 'Reveal in Explorer View';
|
|
3816
|
+
const KeepOpen = 'Keep Open';
|
|
3817
|
+
const Pin = 'Pin';
|
|
3818
|
+
const SplitAndMove = 'Split & Move';
|
|
3819
|
+
const MoveIntoNewWindow = 'Move into New Window';
|
|
3820
|
+
const CopyIntoNewWindow = 'Copy into New Window';
|
|
3733
3821
|
const SplitEditorGroup = 'Split Editor Group';
|
|
3822
|
+
const SplitRight = 'Split Right';
|
|
3734
3823
|
const TogglePreview = 'Toggle Preview';
|
|
3735
3824
|
|
|
3825
|
+
const splitRight$1 = () => {
|
|
3826
|
+
return i18nString(SplitRight);
|
|
3827
|
+
};
|
|
3736
3828
|
const splitEditorGroup = () => {
|
|
3737
3829
|
return i18nString(SplitEditorGroup);
|
|
3738
3830
|
};
|
|
@@ -3748,8 +3840,8 @@ const closeOthers = () => {
|
|
|
3748
3840
|
const closeAll = () => {
|
|
3749
3841
|
return i18nString(CloseAll);
|
|
3750
3842
|
};
|
|
3751
|
-
const
|
|
3752
|
-
return i18nString(
|
|
3843
|
+
const closeSaved = () => {
|
|
3844
|
+
return i18nString(CloseSaved);
|
|
3753
3845
|
};
|
|
3754
3846
|
const closeToTheRight = () => {
|
|
3755
3847
|
return i18nString(CloseToTheRight);
|
|
@@ -3763,6 +3855,36 @@ const copyPath = () => {
|
|
|
3763
3855
|
const copyRelativePath = () => {
|
|
3764
3856
|
return i18nString(CopyRelativePath);
|
|
3765
3857
|
};
|
|
3858
|
+
const reopenEditorWith = () => {
|
|
3859
|
+
return i18nString(ReopenEditorWith);
|
|
3860
|
+
};
|
|
3861
|
+
const share = () => {
|
|
3862
|
+
return i18nString(Share);
|
|
3863
|
+
};
|
|
3864
|
+
const addFileToChat = () => {
|
|
3865
|
+
return i18nString(AddFileToChat);
|
|
3866
|
+
};
|
|
3867
|
+
const openContainingFolder = () => {
|
|
3868
|
+
return i18nString(OpenContainingFolder);
|
|
3869
|
+
};
|
|
3870
|
+
const revealInExplorerView = () => {
|
|
3871
|
+
return i18nString(RevealInExplorerView);
|
|
3872
|
+
};
|
|
3873
|
+
const keepOpen = () => {
|
|
3874
|
+
return i18nString(KeepOpen);
|
|
3875
|
+
};
|
|
3876
|
+
const pin = () => {
|
|
3877
|
+
return i18nString(Pin);
|
|
3878
|
+
};
|
|
3879
|
+
const splitAndMove = () => {
|
|
3880
|
+
return i18nString(SplitAndMove);
|
|
3881
|
+
};
|
|
3882
|
+
const moveIntoNewWindow = () => {
|
|
3883
|
+
return i18nString(MoveIntoNewWindow);
|
|
3884
|
+
};
|
|
3885
|
+
const copyIntoNewWindow = () => {
|
|
3886
|
+
return i18nString(CopyIntoNewWindow);
|
|
3887
|
+
};
|
|
3766
3888
|
const togglePreview = () => {
|
|
3767
3889
|
return i18nString(TogglePreview);
|
|
3768
3890
|
};
|
|
@@ -3812,18 +3934,17 @@ const getMenuEntries$1 = state => {
|
|
|
3812
3934
|
flags: None,
|
|
3813
3935
|
id: 'tabCloseToTheRight',
|
|
3814
3936
|
label: closeToTheRight()
|
|
3937
|
+
}, {
|
|
3938
|
+
command: 'Main.closeSaved',
|
|
3939
|
+
flags: None,
|
|
3940
|
+
id: 'tabCloseSaved',
|
|
3941
|
+
label: closeSaved()
|
|
3815
3942
|
}, {
|
|
3816
3943
|
command: 'Main.closeAll',
|
|
3817
3944
|
flags: None,
|
|
3818
3945
|
id: 'tabCloseAll',
|
|
3819
3946
|
label: closeAll()
|
|
3820
3947
|
}, menuEntrySeparator, {
|
|
3821
|
-
args: [path],
|
|
3822
|
-
command: 'Explorer.revealItem',
|
|
3823
|
-
flags: None,
|
|
3824
|
-
id: 'revealInExplorer',
|
|
3825
|
-
label: revealInExplorer()
|
|
3826
|
-
}, {
|
|
3827
3948
|
args: [path],
|
|
3828
3949
|
command: 'Main.copyPath',
|
|
3829
3950
|
flags: None,
|
|
@@ -3835,6 +3956,62 @@ const getMenuEntries$1 = state => {
|
|
|
3835
3956
|
flags: None,
|
|
3836
3957
|
id: 'copyRelativePath',
|
|
3837
3958
|
label: copyRelativePath()
|
|
3959
|
+
}, menuEntrySeparator, {
|
|
3960
|
+
command: '',
|
|
3961
|
+
flags: None,
|
|
3962
|
+
id: 'reopenEditorWith',
|
|
3963
|
+
label: reopenEditorWith()
|
|
3964
|
+
}, menuEntrySeparator, {
|
|
3965
|
+
command: '',
|
|
3966
|
+
flags: None,
|
|
3967
|
+
id: 'share',
|
|
3968
|
+
label: share()
|
|
3969
|
+
}, menuEntrySeparator, {
|
|
3970
|
+
command: '',
|
|
3971
|
+
flags: None,
|
|
3972
|
+
id: 'addFileToChat',
|
|
3973
|
+
label: addFileToChat()
|
|
3974
|
+
}, menuEntrySeparator, {
|
|
3975
|
+
command: '',
|
|
3976
|
+
flags: None,
|
|
3977
|
+
id: 'openContainingFolder',
|
|
3978
|
+
label: openContainingFolder()
|
|
3979
|
+
}, {
|
|
3980
|
+
args: [path],
|
|
3981
|
+
command: 'Explorer.revealItem',
|
|
3982
|
+
flags: None,
|
|
3983
|
+
id: 'revealInExplorerView',
|
|
3984
|
+
label: revealInExplorerView()
|
|
3985
|
+
}, menuEntrySeparator, {
|
|
3986
|
+
command: '',
|
|
3987
|
+
flags: None,
|
|
3988
|
+
id: 'keepOpen',
|
|
3989
|
+
label: keepOpen()
|
|
3990
|
+
}, {
|
|
3991
|
+
command: '',
|
|
3992
|
+
flags: None,
|
|
3993
|
+
id: 'pin',
|
|
3994
|
+
label: pin()
|
|
3995
|
+
}, menuEntrySeparator, {
|
|
3996
|
+
command: 'Main.splitRight',
|
|
3997
|
+
flags: None,
|
|
3998
|
+
id: 'splitRight',
|
|
3999
|
+
label: splitRight$1()
|
|
4000
|
+
}, {
|
|
4001
|
+
command: '',
|
|
4002
|
+
flags: None,
|
|
4003
|
+
id: 'splitAndMove',
|
|
4004
|
+
label: splitAndMove()
|
|
4005
|
+
}, {
|
|
4006
|
+
command: '',
|
|
4007
|
+
flags: None,
|
|
4008
|
+
id: 'moveIntoNewWindow',
|
|
4009
|
+
label: moveIntoNewWindow()
|
|
4010
|
+
}, {
|
|
4011
|
+
command: '',
|
|
4012
|
+
flags: None,
|
|
4013
|
+
id: 'copyIntoNewWindow',
|
|
4014
|
+
label: copyIntoNewWindow()
|
|
3838
4015
|
}, menuEntrySeparator, {
|
|
3839
4016
|
args: [/* id */'References', /* focus */true, path],
|
|
3840
4017
|
command: 'SideBar.show',
|
|
@@ -4320,6 +4497,9 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
4320
4497
|
if (tab.isDirty) {
|
|
4321
4498
|
className += ' ' + MainTabModified;
|
|
4322
4499
|
}
|
|
4500
|
+
if (tab.isPreview) {
|
|
4501
|
+
className += ' ' + MainTabPreview;
|
|
4502
|
+
}
|
|
4323
4503
|
return [{
|
|
4324
4504
|
'aria-selected': isActive,
|
|
4325
4505
|
childCount: 3,
|
|
@@ -4388,9 +4568,9 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
|
|
|
4388
4568
|
buttons.push({
|
|
4389
4569
|
childCount: 1,
|
|
4390
4570
|
className: EditorGroupActionButton + ' ' + SplitEditorGroupButton,
|
|
4391
|
-
'data-action': SplitRight,
|
|
4571
|
+
'data-action': SplitRight$1,
|
|
4392
4572
|
'data-groupId': String(group.id),
|
|
4393
|
-
name: SplitRight,
|
|
4573
|
+
name: SplitRight$1,
|
|
4394
4574
|
onClick: HandleClickAction,
|
|
4395
4575
|
title: splitEditorGroup(),
|
|
4396
4576
|
type: Button$2
|
|
@@ -4474,14 +4654,19 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
|
|
|
4474
4654
|
const getSashClassName = direction => {
|
|
4475
4655
|
return direction === 'horizontal' ? 'Sash SashVertical' : 'Sash SashHorizontal';
|
|
4476
4656
|
};
|
|
4657
|
+
|
|
4477
4658
|
const renderSash = (direction, sashId, style) => {
|
|
4478
4659
|
return [{
|
|
4479
|
-
childCount:
|
|
4660
|
+
childCount: 1,
|
|
4480
4661
|
className: getSashClassName(direction),
|
|
4481
4662
|
'data-sashId': sashId,
|
|
4482
4663
|
onPointerDown: HandleSashPointerDown,
|
|
4483
4664
|
style,
|
|
4484
4665
|
type: Div
|
|
4666
|
+
}, {
|
|
4667
|
+
childCount: 0,
|
|
4668
|
+
className: 'SashBorder',
|
|
4669
|
+
type: Div
|
|
4485
4670
|
}];
|
|
4486
4671
|
};
|
|
4487
4672
|
|
|
@@ -4519,7 +4704,8 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
|
|
|
4519
4704
|
children.push(...renderSash(direction, sashId, style));
|
|
4520
4705
|
childCount++;
|
|
4521
4706
|
}
|
|
4522
|
-
|
|
4707
|
+
const editorGroupDom = renderEditorGroup(groups[i], i, splitButtonEnabled, sizeProperty);
|
|
4708
|
+
children.push(...editorGroupDom);
|
|
4523
4709
|
childCount++;
|
|
4524
4710
|
}
|
|
4525
4711
|
return [{
|
|
@@ -4751,6 +4937,7 @@ const commandMap = {
|
|
|
4751
4937
|
'MainArea.closeAllEditors': wrapCommand(closeAll$1),
|
|
4752
4938
|
'MainArea.closeFocusedTab': wrapCommand(closeFocusedTab),
|
|
4753
4939
|
'MainArea.closeOthers': wrapCommand(closeOtherTabs),
|
|
4940
|
+
'MainArea.closeSaved': wrapCommand(closeSaved$1),
|
|
4754
4941
|
'MainArea.closeTabsRight': wrapCommand(closeTabsRight),
|
|
4755
4942
|
'MainArea.copyPath': wrapCommand(copyPath$1),
|
|
4756
4943
|
'MainArea.copyRelativePath': wrapCommand(copyRelativePath$1),
|