@lvce-editor/main-area-worker 9.40.0 → 9.42.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 +299 -197
- package/package.json +1 -1
|
@@ -2951,6 +2951,7 @@ const getNextRequestId = () => {
|
|
|
2951
2951
|
|
|
2952
2952
|
const getEditorInputEditorType = editorInput => {
|
|
2953
2953
|
switch (editorInput.type) {
|
|
2954
|
+
case 'binary':
|
|
2954
2955
|
case 'diff-editor':
|
|
2955
2956
|
case 'extension-detail-view':
|
|
2956
2957
|
case 'image':
|
|
@@ -2966,6 +2967,8 @@ const getEditorInputEditorType = editorInput => {
|
|
|
2966
2967
|
|
|
2967
2968
|
const getEditorInputUri = editorInput => {
|
|
2968
2969
|
switch (editorInput.type) {
|
|
2970
|
+
case 'binary':
|
|
2971
|
+
return editorInput.uri;
|
|
2969
2972
|
case 'diff-editor':
|
|
2970
2973
|
return `diff://?left=${encodeURIComponent(editorInput.uriLeft)}&right=${encodeURIComponent(editorInput.uriRight)}`;
|
|
2971
2974
|
case 'editor':
|
|
@@ -2984,6 +2987,7 @@ const getEditorInputUri = editorInput => {
|
|
|
2984
2987
|
|
|
2985
2988
|
const imageExtensions = new Set(['.avif', '.bmp', '.gif', '.ico', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff', '.webp']);
|
|
2986
2989
|
const videoExtensions = new Set(['.avi', '.m4v', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.ogv', '.webm']);
|
|
2990
|
+
const binaryFileSuffixes = ['.7z', '.apk', '.br', '.bz2', '.deb', '.gz', '.jar', '.pdf', '.rar', '.rpm', '.tar', '.tar.br', '.tar.bz2', '.tar.gz', '.tar.xz', '.tar.zst', '.tbr', '.tgz', '.war', '.xz', '.zip', '.zst'];
|
|
2987
2991
|
const getPathEndIndex = pathName => {
|
|
2988
2992
|
const queryIndex = pathName.indexOf('?');
|
|
2989
2993
|
const hashIndex = pathName.indexOf('#');
|
|
@@ -3016,6 +3020,12 @@ const getLowerCaseExtension = uri => {
|
|
|
3016
3020
|
}
|
|
3017
3021
|
return cleanPath.slice(lastDotIndex).toLowerCase();
|
|
3018
3022
|
};
|
|
3023
|
+
const hasBinaryFileSuffix = uri => {
|
|
3024
|
+
const pathName = getPathName(uri);
|
|
3025
|
+
const endIndex = getPathEndIndex(pathName);
|
|
3026
|
+
const cleanPath = pathName.slice(0, endIndex).toLowerCase();
|
|
3027
|
+
return binaryFileSuffixes.some(suffix => cleanPath.endsWith(suffix));
|
|
3028
|
+
};
|
|
3019
3029
|
const getEditorInputFromUri = uri => {
|
|
3020
3030
|
if (uri.startsWith('diff://?')) {
|
|
3021
3031
|
try {
|
|
@@ -3066,6 +3076,12 @@ const getEditorInputFromUri = uri => {
|
|
|
3066
3076
|
uri
|
|
3067
3077
|
};
|
|
3068
3078
|
}
|
|
3079
|
+
if (hasBinaryFileSuffix(uri)) {
|
|
3080
|
+
return {
|
|
3081
|
+
type: 'binary',
|
|
3082
|
+
uri
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3069
3085
|
return {
|
|
3070
3086
|
type: 'editor',
|
|
3071
3087
|
uri
|
|
@@ -3106,6 +3122,10 @@ const normalizeTabEditorInput = tab => {
|
|
|
3106
3122
|
...tab,
|
|
3107
3123
|
editorInput,
|
|
3108
3124
|
editorType: getEditorInputEditorType(editorInput),
|
|
3125
|
+
...(editorInput.type === 'binary' && {
|
|
3126
|
+
editorUid: -1,
|
|
3127
|
+
loadingState: 'binary'
|
|
3128
|
+
}),
|
|
3109
3129
|
uri
|
|
3110
3130
|
};
|
|
3111
3131
|
};
|
|
@@ -3240,6 +3260,8 @@ const QuickPick = 'QuickPick';
|
|
|
3240
3260
|
|
|
3241
3261
|
const getViewletModuleIdForEditorInput = async editorInput => {
|
|
3242
3262
|
switch (editorInput.type) {
|
|
3263
|
+
case 'binary':
|
|
3264
|
+
return undefined;
|
|
3243
3265
|
case 'diff-editor':
|
|
3244
3266
|
return DiffEditor;
|
|
3245
3267
|
case 'editor':
|
|
@@ -3467,19 +3489,12 @@ const handleClickTogglePreview = async state => {
|
|
|
3467
3489
|
};
|
|
3468
3490
|
|
|
3469
3491
|
const CloseGroup = 'close-group';
|
|
3492
|
+
const OpenInTextEditor$1 = 'open-in-text-editor';
|
|
3470
3493
|
const RetryOpen = 'retry-open';
|
|
3471
3494
|
const RestoreClosedTab = 'restore-closed-tab';
|
|
3472
3495
|
const SplitRight$1 = 'split-right';
|
|
3473
3496
|
const TogglePreview$1 = 'toggle-preview';
|
|
3474
3497
|
|
|
3475
|
-
const parseRawGroupId = rawGroupId => {
|
|
3476
|
-
if (!rawGroupId) {
|
|
3477
|
-
return undefined;
|
|
3478
|
-
}
|
|
3479
|
-
const groupId = Number(rawGroupId);
|
|
3480
|
-
return Number.isNaN(groupId) ? undefined : groupId;
|
|
3481
|
-
};
|
|
3482
|
-
|
|
3483
3498
|
const findTabByUri = (state, uri) => {
|
|
3484
3499
|
const {
|
|
3485
3500
|
layout
|
|
@@ -3499,192 +3514,6 @@ const findTabByUri = (state, uri) => {
|
|
|
3499
3514
|
return undefined;
|
|
3500
3515
|
};
|
|
3501
3516
|
|
|
3502
|
-
const focusGroup = (groups, groupId, activeTabId) => {
|
|
3503
|
-
return groups.map(group => {
|
|
3504
|
-
if (group.id === groupId) {
|
|
3505
|
-
return {
|
|
3506
|
-
...group,
|
|
3507
|
-
activeTabId,
|
|
3508
|
-
focused: true
|
|
3509
|
-
};
|
|
3510
|
-
}
|
|
3511
|
-
return {
|
|
3512
|
-
...group,
|
|
3513
|
-
focused: false
|
|
3514
|
-
};
|
|
3515
|
-
});
|
|
3516
|
-
};
|
|
3517
|
-
const clampIndex = (value, min, max) => {
|
|
3518
|
-
return Math.min(Math.max(value, min), max);
|
|
3519
|
-
};
|
|
3520
|
-
const getRestoredTab = tab => {
|
|
3521
|
-
return {
|
|
3522
|
-
...tab,
|
|
3523
|
-
editorUid: -1,
|
|
3524
|
-
errorMessage: '',
|
|
3525
|
-
loadingState: undefined
|
|
3526
|
-
};
|
|
3527
|
-
};
|
|
3528
|
-
const getStateWithoutLastClosedTab = state => {
|
|
3529
|
-
const {
|
|
3530
|
-
closedTabs
|
|
3531
|
-
} = state;
|
|
3532
|
-
return {
|
|
3533
|
-
...state,
|
|
3534
|
-
closedTabs: closedTabs.slice(0, -1)
|
|
3535
|
-
};
|
|
3536
|
-
};
|
|
3537
|
-
const restoreExistingUri = (state, entry) => {
|
|
3538
|
-
const {
|
|
3539
|
-
layout
|
|
3540
|
-
} = state;
|
|
3541
|
-
const {
|
|
3542
|
-
groups: layoutGroups
|
|
3543
|
-
} = layout;
|
|
3544
|
-
if (!entry.tab.uri) {
|
|
3545
|
-
return undefined;
|
|
3546
|
-
}
|
|
3547
|
-
const existing = findTabByUri(state, entry.tab.uri);
|
|
3548
|
-
if (!existing) {
|
|
3549
|
-
return undefined;
|
|
3550
|
-
}
|
|
3551
|
-
const groupIndex = layoutGroups.findIndex(group => group.id === existing.groupId);
|
|
3552
|
-
if (groupIndex === -1) {
|
|
3553
|
-
return undefined;
|
|
3554
|
-
}
|
|
3555
|
-
const tabIndex = layoutGroups[groupIndex].tabs.findIndex(tab => tab.id === existing.tab.id);
|
|
3556
|
-
if (tabIndex === -1) {
|
|
3557
|
-
return undefined;
|
|
3558
|
-
}
|
|
3559
|
-
const newStateWithoutClosedTab = getStateWithoutLastClosedTab(state);
|
|
3560
|
-
const groups = focusGroup(newStateWithoutClosedTab.layout.groups, existing.groupId, existing.tab.id);
|
|
3561
|
-
return {
|
|
3562
|
-
groupIndex,
|
|
3563
|
-
newState: {
|
|
3564
|
-
...newStateWithoutClosedTab,
|
|
3565
|
-
layout: {
|
|
3566
|
-
...newStateWithoutClosedTab.layout,
|
|
3567
|
-
activeGroupId: existing.groupId,
|
|
3568
|
-
groups
|
|
3569
|
-
}
|
|
3570
|
-
},
|
|
3571
|
-
tabIndex
|
|
3572
|
-
};
|
|
3573
|
-
};
|
|
3574
|
-
const restoreIntoExistingGroup = (state, entry) => {
|
|
3575
|
-
const {
|
|
3576
|
-
layout
|
|
3577
|
-
} = state;
|
|
3578
|
-
const {
|
|
3579
|
-
groups
|
|
3580
|
-
} = layout;
|
|
3581
|
-
const groupIndex = groups.findIndex(group => group.id === entry.group.id);
|
|
3582
|
-
if (groupIndex === -1) {
|
|
3583
|
-
return undefined;
|
|
3584
|
-
}
|
|
3585
|
-
const restoredTab = getRestoredTab(entry.tab);
|
|
3586
|
-
const group = groups[groupIndex];
|
|
3587
|
-
const tabIndex = clampIndex(entry.tabIndex, 0, group.tabs.length);
|
|
3588
|
-
const tabs = [...group.tabs];
|
|
3589
|
-
tabs.splice(tabIndex, 0, restoredTab);
|
|
3590
|
-
const newStateWithoutClosedTab = getStateWithoutLastClosedTab(state);
|
|
3591
|
-
const updatedGroups = groups.map((currentGroup, index) => {
|
|
3592
|
-
if (index === groupIndex) {
|
|
3593
|
-
return {
|
|
3594
|
-
...currentGroup,
|
|
3595
|
-
activeTabId: restoredTab.id,
|
|
3596
|
-
focused: true,
|
|
3597
|
-
isEmpty: false,
|
|
3598
|
-
tabs
|
|
3599
|
-
};
|
|
3600
|
-
}
|
|
3601
|
-
return {
|
|
3602
|
-
...currentGroup,
|
|
3603
|
-
focused: false
|
|
3604
|
-
};
|
|
3605
|
-
});
|
|
3606
|
-
return {
|
|
3607
|
-
groupIndex,
|
|
3608
|
-
newState: {
|
|
3609
|
-
...newStateWithoutClosedTab,
|
|
3610
|
-
layout: {
|
|
3611
|
-
...newStateWithoutClosedTab.layout,
|
|
3612
|
-
activeGroupId: group.id,
|
|
3613
|
-
groups: updatedGroups
|
|
3614
|
-
}
|
|
3615
|
-
},
|
|
3616
|
-
tabIndex
|
|
3617
|
-
};
|
|
3618
|
-
};
|
|
3619
|
-
const createRestoredGroup = entry => {
|
|
3620
|
-
return {
|
|
3621
|
-
...entry.group,
|
|
3622
|
-
activeTabId: entry.tab.id,
|
|
3623
|
-
focused: true,
|
|
3624
|
-
isEmpty: false,
|
|
3625
|
-
tabs: [getRestoredTab(entry.tab)]
|
|
3626
|
-
};
|
|
3627
|
-
};
|
|
3628
|
-
const restoreIntoRecreatedGroup = (state, entry) => {
|
|
3629
|
-
const newStateWithoutClosedTab = getStateWithoutLastClosedTab(state);
|
|
3630
|
-
const restoredGroup = createRestoredGroup(entry);
|
|
3631
|
-
const {
|
|
3632
|
-
groups
|
|
3633
|
-
} = newStateWithoutClosedTab.layout;
|
|
3634
|
-
if (groups.length === 0) {
|
|
3635
|
-
return {
|
|
3636
|
-
groupIndex: 0,
|
|
3637
|
-
newState: {
|
|
3638
|
-
...newStateWithoutClosedTab,
|
|
3639
|
-
layout: {
|
|
3640
|
-
...newStateWithoutClosedTab.layout,
|
|
3641
|
-
activeGroupId: restoredGroup.id,
|
|
3642
|
-
groups: [restoredGroup]
|
|
3643
|
-
}
|
|
3644
|
-
},
|
|
3645
|
-
tabIndex: 0
|
|
3646
|
-
};
|
|
3647
|
-
}
|
|
3648
|
-
const groupIndex = clampIndex(entry.groupIndex, 0, groups.length);
|
|
3649
|
-
const unfocusedGroups = groups.map(group => ({
|
|
3650
|
-
...group,
|
|
3651
|
-
focused: false
|
|
3652
|
-
}));
|
|
3653
|
-
const insertedGroups = [...unfocusedGroups.slice(0, groupIndex), restoredGroup, ...unfocusedGroups.slice(groupIndex)];
|
|
3654
|
-
return {
|
|
3655
|
-
groupIndex,
|
|
3656
|
-
newState: {
|
|
3657
|
-
...newStateWithoutClosedTab,
|
|
3658
|
-
layout: {
|
|
3659
|
-
...newStateWithoutClosedTab.layout,
|
|
3660
|
-
activeGroupId: restoredGroup.id,
|
|
3661
|
-
groups: redistributeSizesWithRounding(insertedGroups)
|
|
3662
|
-
}
|
|
3663
|
-
},
|
|
3664
|
-
tabIndex: 0
|
|
3665
|
-
};
|
|
3666
|
-
};
|
|
3667
|
-
const restoreClosedTabState = state => {
|
|
3668
|
-
const {
|
|
3669
|
-
closedTabs
|
|
3670
|
-
} = state;
|
|
3671
|
-
const entry = closedTabs.at(-1);
|
|
3672
|
-
if (!entry) {
|
|
3673
|
-
return undefined;
|
|
3674
|
-
}
|
|
3675
|
-
return restoreExistingUri(state, entry) || restoreIntoExistingGroup(state, entry) || restoreIntoRecreatedGroup(state, entry);
|
|
3676
|
-
};
|
|
3677
|
-
|
|
3678
|
-
const restoreClosedTab = async state => {
|
|
3679
|
-
const restored = restoreClosedTabState(state);
|
|
3680
|
-
if (!restored) {
|
|
3681
|
-
return state;
|
|
3682
|
-
}
|
|
3683
|
-
const newState = await selectTab(restored.newState, restored.groupIndex, restored.tabIndex);
|
|
3684
|
-
set(state.uid, state, newState);
|
|
3685
|
-
return newState;
|
|
3686
|
-
};
|
|
3687
|
-
|
|
3688
3517
|
const focusEditorGroup = (state, groupId) => {
|
|
3689
3518
|
const {
|
|
3690
3519
|
layout
|
|
@@ -3800,6 +3629,8 @@ const getLabel = uri => {
|
|
|
3800
3629
|
|
|
3801
3630
|
const getEditorInputTitle = editorInput => {
|
|
3802
3631
|
switch (editorInput.type) {
|
|
3632
|
+
case 'binary':
|
|
3633
|
+
return getLabel(editorInput.uri);
|
|
3803
3634
|
case 'diff-editor':
|
|
3804
3635
|
{
|
|
3805
3636
|
const leftTitle = getLabel(editorInput.uriLeft);
|
|
@@ -4033,6 +3864,7 @@ const getStateWithTab = (currentState, editorInput, existingTab, shouldRetryExis
|
|
|
4033
3864
|
return {
|
|
4034
3865
|
stateWithTab: updateTab(focusedState, existingTab.tab.id, {
|
|
4035
3866
|
editorInput,
|
|
3867
|
+
editorType,
|
|
4036
3868
|
errorMessage: '',
|
|
4037
3869
|
loadingState: 'loading',
|
|
4038
3870
|
title,
|
|
@@ -4254,6 +4086,12 @@ const getActivePreviewEditorUid = state => {
|
|
|
4254
4086
|
const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
4255
4087
|
return activeTab?.isPreview ? activeTab.editorUid : -1;
|
|
4256
4088
|
};
|
|
4089
|
+
const shouldRetryExistingTab = (existingTab, editorInput) => {
|
|
4090
|
+
if (!existingTab) {
|
|
4091
|
+
return false;
|
|
4092
|
+
}
|
|
4093
|
+
return existingTab.tab.loadingState === 'error' || editorInput.type === 'editor' && editorInput.forceText === true && existingTab.tab.editorInput?.type === 'binary';
|
|
4094
|
+
};
|
|
4257
4095
|
const openInputWithContext = async (context, options) => {
|
|
4258
4096
|
const state = context.getState();
|
|
4259
4097
|
object(state);
|
|
@@ -4267,8 +4105,8 @@ const openInputWithContext = async (context, options) => {
|
|
|
4267
4105
|
const editorType = getEditorInputEditorType(editorInput);
|
|
4268
4106
|
const currentState = state;
|
|
4269
4107
|
const existingTab = options.reuseExisting === false ? undefined : findTabByUri(currentState, uri);
|
|
4270
|
-
const
|
|
4271
|
-
if (existingTab && !
|
|
4108
|
+
const shouldRetry = shouldRetryExistingTab(existingTab, editorInput);
|
|
4109
|
+
if (existingTab && !shouldRetry) {
|
|
4272
4110
|
const switchedState = getExistingTabState(currentState, existingTab, preview);
|
|
4273
4111
|
await context.updateState(() => switchedState);
|
|
4274
4112
|
return;
|
|
@@ -4278,7 +4116,7 @@ const openInputWithContext = async (context, options) => {
|
|
|
4278
4116
|
const {
|
|
4279
4117
|
stateWithTab,
|
|
4280
4118
|
tabId
|
|
4281
|
-
} = getStateWithTab(currentState, editorInput, existingTab,
|
|
4119
|
+
} = getStateWithTab(currentState, editorInput, existingTab, shouldRetry, uri, preview, title, editorType);
|
|
4282
4120
|
await context.updateState(() => stateWithTab);
|
|
4283
4121
|
if (replacedEditorUid !== -1) {
|
|
4284
4122
|
await disposeEditors([replacedEditorUid]);
|
|
@@ -4292,6 +4130,15 @@ const openInputWithContext = async (context, options) => {
|
|
|
4292
4130
|
await context.updateState(() => errorState);
|
|
4293
4131
|
return;
|
|
4294
4132
|
}
|
|
4133
|
+
if (editorInput.type === 'binary') {
|
|
4134
|
+
const latestState = context.getState();
|
|
4135
|
+
const binaryState = updateTab(latestState, tabId, {
|
|
4136
|
+
editorUid: -1,
|
|
4137
|
+
loadingState: 'binary'
|
|
4138
|
+
});
|
|
4139
|
+
await context.updateState(() => binaryState);
|
|
4140
|
+
return;
|
|
4141
|
+
}
|
|
4295
4142
|
try {
|
|
4296
4143
|
const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput);
|
|
4297
4144
|
const stateAfterModuleId = context.getState();
|
|
@@ -4369,6 +4216,220 @@ const openInput = async (state, options) => {
|
|
|
4369
4216
|
return context.getState();
|
|
4370
4217
|
};
|
|
4371
4218
|
|
|
4219
|
+
const openBinaryAsText = async state => {
|
|
4220
|
+
const activeTabData = getActiveTab(state);
|
|
4221
|
+
const editorInput = activeTabData?.tab.editorInput;
|
|
4222
|
+
if (!activeTabData || editorInput?.type !== 'binary') {
|
|
4223
|
+
return state;
|
|
4224
|
+
}
|
|
4225
|
+
const {
|
|
4226
|
+
tab
|
|
4227
|
+
} = activeTabData;
|
|
4228
|
+
return openInput(state, {
|
|
4229
|
+
editorInput: {
|
|
4230
|
+
forceText: true,
|
|
4231
|
+
type: 'editor',
|
|
4232
|
+
uri: editorInput.uri
|
|
4233
|
+
},
|
|
4234
|
+
focus: false,
|
|
4235
|
+
preview: tab.isPreview
|
|
4236
|
+
});
|
|
4237
|
+
};
|
|
4238
|
+
|
|
4239
|
+
const parseRawGroupId = rawGroupId => {
|
|
4240
|
+
if (!rawGroupId) {
|
|
4241
|
+
return undefined;
|
|
4242
|
+
}
|
|
4243
|
+
const groupId = Number(rawGroupId);
|
|
4244
|
+
return Number.isNaN(groupId) ? undefined : groupId;
|
|
4245
|
+
};
|
|
4246
|
+
|
|
4247
|
+
const focusGroup = (groups, groupId, activeTabId) => {
|
|
4248
|
+
return groups.map(group => {
|
|
4249
|
+
if (group.id === groupId) {
|
|
4250
|
+
return {
|
|
4251
|
+
...group,
|
|
4252
|
+
activeTabId,
|
|
4253
|
+
focused: true
|
|
4254
|
+
};
|
|
4255
|
+
}
|
|
4256
|
+
return {
|
|
4257
|
+
...group,
|
|
4258
|
+
focused: false
|
|
4259
|
+
};
|
|
4260
|
+
});
|
|
4261
|
+
};
|
|
4262
|
+
const clampIndex = (value, min, max) => {
|
|
4263
|
+
return Math.min(Math.max(value, min), max);
|
|
4264
|
+
};
|
|
4265
|
+
const getRestoredTab = tab => {
|
|
4266
|
+
return {
|
|
4267
|
+
...tab,
|
|
4268
|
+
editorUid: -1,
|
|
4269
|
+
errorMessage: '',
|
|
4270
|
+
loadingState: undefined
|
|
4271
|
+
};
|
|
4272
|
+
};
|
|
4273
|
+
const getStateWithoutLastClosedTab = state => {
|
|
4274
|
+
const {
|
|
4275
|
+
closedTabs
|
|
4276
|
+
} = state;
|
|
4277
|
+
return {
|
|
4278
|
+
...state,
|
|
4279
|
+
closedTabs: closedTabs.slice(0, -1)
|
|
4280
|
+
};
|
|
4281
|
+
};
|
|
4282
|
+
const restoreExistingUri = (state, entry) => {
|
|
4283
|
+
const {
|
|
4284
|
+
layout
|
|
4285
|
+
} = state;
|
|
4286
|
+
const {
|
|
4287
|
+
groups: layoutGroups
|
|
4288
|
+
} = layout;
|
|
4289
|
+
if (!entry.tab.uri) {
|
|
4290
|
+
return undefined;
|
|
4291
|
+
}
|
|
4292
|
+
const existing = findTabByUri(state, entry.tab.uri);
|
|
4293
|
+
if (!existing) {
|
|
4294
|
+
return undefined;
|
|
4295
|
+
}
|
|
4296
|
+
const groupIndex = layoutGroups.findIndex(group => group.id === existing.groupId);
|
|
4297
|
+
if (groupIndex === -1) {
|
|
4298
|
+
return undefined;
|
|
4299
|
+
}
|
|
4300
|
+
const tabIndex = layoutGroups[groupIndex].tabs.findIndex(tab => tab.id === existing.tab.id);
|
|
4301
|
+
if (tabIndex === -1) {
|
|
4302
|
+
return undefined;
|
|
4303
|
+
}
|
|
4304
|
+
const newStateWithoutClosedTab = getStateWithoutLastClosedTab(state);
|
|
4305
|
+
const groups = focusGroup(newStateWithoutClosedTab.layout.groups, existing.groupId, existing.tab.id);
|
|
4306
|
+
return {
|
|
4307
|
+
groupIndex,
|
|
4308
|
+
newState: {
|
|
4309
|
+
...newStateWithoutClosedTab,
|
|
4310
|
+
layout: {
|
|
4311
|
+
...newStateWithoutClosedTab.layout,
|
|
4312
|
+
activeGroupId: existing.groupId,
|
|
4313
|
+
groups
|
|
4314
|
+
}
|
|
4315
|
+
},
|
|
4316
|
+
tabIndex
|
|
4317
|
+
};
|
|
4318
|
+
};
|
|
4319
|
+
const restoreIntoExistingGroup = (state, entry) => {
|
|
4320
|
+
const {
|
|
4321
|
+
layout
|
|
4322
|
+
} = state;
|
|
4323
|
+
const {
|
|
4324
|
+
groups
|
|
4325
|
+
} = layout;
|
|
4326
|
+
const groupIndex = groups.findIndex(group => group.id === entry.group.id);
|
|
4327
|
+
if (groupIndex === -1) {
|
|
4328
|
+
return undefined;
|
|
4329
|
+
}
|
|
4330
|
+
const restoredTab = getRestoredTab(entry.tab);
|
|
4331
|
+
const group = groups[groupIndex];
|
|
4332
|
+
const tabIndex = clampIndex(entry.tabIndex, 0, group.tabs.length);
|
|
4333
|
+
const tabs = [...group.tabs];
|
|
4334
|
+
tabs.splice(tabIndex, 0, restoredTab);
|
|
4335
|
+
const newStateWithoutClosedTab = getStateWithoutLastClosedTab(state);
|
|
4336
|
+
const updatedGroups = groups.map((currentGroup, index) => {
|
|
4337
|
+
if (index === groupIndex) {
|
|
4338
|
+
return {
|
|
4339
|
+
...currentGroup,
|
|
4340
|
+
activeTabId: restoredTab.id,
|
|
4341
|
+
focused: true,
|
|
4342
|
+
isEmpty: false,
|
|
4343
|
+
tabs
|
|
4344
|
+
};
|
|
4345
|
+
}
|
|
4346
|
+
return {
|
|
4347
|
+
...currentGroup,
|
|
4348
|
+
focused: false
|
|
4349
|
+
};
|
|
4350
|
+
});
|
|
4351
|
+
return {
|
|
4352
|
+
groupIndex,
|
|
4353
|
+
newState: {
|
|
4354
|
+
...newStateWithoutClosedTab,
|
|
4355
|
+
layout: {
|
|
4356
|
+
...newStateWithoutClosedTab.layout,
|
|
4357
|
+
activeGroupId: group.id,
|
|
4358
|
+
groups: updatedGroups
|
|
4359
|
+
}
|
|
4360
|
+
},
|
|
4361
|
+
tabIndex
|
|
4362
|
+
};
|
|
4363
|
+
};
|
|
4364
|
+
const createRestoredGroup = entry => {
|
|
4365
|
+
return {
|
|
4366
|
+
...entry.group,
|
|
4367
|
+
activeTabId: entry.tab.id,
|
|
4368
|
+
focused: true,
|
|
4369
|
+
isEmpty: false,
|
|
4370
|
+
tabs: [getRestoredTab(entry.tab)]
|
|
4371
|
+
};
|
|
4372
|
+
};
|
|
4373
|
+
const restoreIntoRecreatedGroup = (state, entry) => {
|
|
4374
|
+
const newStateWithoutClosedTab = getStateWithoutLastClosedTab(state);
|
|
4375
|
+
const restoredGroup = createRestoredGroup(entry);
|
|
4376
|
+
const {
|
|
4377
|
+
groups
|
|
4378
|
+
} = newStateWithoutClosedTab.layout;
|
|
4379
|
+
if (groups.length === 0) {
|
|
4380
|
+
return {
|
|
4381
|
+
groupIndex: 0,
|
|
4382
|
+
newState: {
|
|
4383
|
+
...newStateWithoutClosedTab,
|
|
4384
|
+
layout: {
|
|
4385
|
+
...newStateWithoutClosedTab.layout,
|
|
4386
|
+
activeGroupId: restoredGroup.id,
|
|
4387
|
+
groups: [restoredGroup]
|
|
4388
|
+
}
|
|
4389
|
+
},
|
|
4390
|
+
tabIndex: 0
|
|
4391
|
+
};
|
|
4392
|
+
}
|
|
4393
|
+
const groupIndex = clampIndex(entry.groupIndex, 0, groups.length);
|
|
4394
|
+
const unfocusedGroups = groups.map(group => ({
|
|
4395
|
+
...group,
|
|
4396
|
+
focused: false
|
|
4397
|
+
}));
|
|
4398
|
+
const insertedGroups = [...unfocusedGroups.slice(0, groupIndex), restoredGroup, ...unfocusedGroups.slice(groupIndex)];
|
|
4399
|
+
return {
|
|
4400
|
+
groupIndex,
|
|
4401
|
+
newState: {
|
|
4402
|
+
...newStateWithoutClosedTab,
|
|
4403
|
+
layout: {
|
|
4404
|
+
...newStateWithoutClosedTab.layout,
|
|
4405
|
+
activeGroupId: restoredGroup.id,
|
|
4406
|
+
groups: redistributeSizesWithRounding(insertedGroups)
|
|
4407
|
+
}
|
|
4408
|
+
},
|
|
4409
|
+
tabIndex: 0
|
|
4410
|
+
};
|
|
4411
|
+
};
|
|
4412
|
+
const restoreClosedTabState = state => {
|
|
4413
|
+
const {
|
|
4414
|
+
closedTabs
|
|
4415
|
+
} = state;
|
|
4416
|
+
const entry = closedTabs.at(-1);
|
|
4417
|
+
if (!entry) {
|
|
4418
|
+
return undefined;
|
|
4419
|
+
}
|
|
4420
|
+
return restoreExistingUri(state, entry) || restoreIntoExistingGroup(state, entry) || restoreIntoRecreatedGroup(state, entry);
|
|
4421
|
+
};
|
|
4422
|
+
|
|
4423
|
+
const restoreClosedTab = async state => {
|
|
4424
|
+
const restored = restoreClosedTabState(state);
|
|
4425
|
+
if (!restored) {
|
|
4426
|
+
return state;
|
|
4427
|
+
}
|
|
4428
|
+
const newState = await selectTab(restored.newState, restored.groupIndex, restored.tabIndex);
|
|
4429
|
+
set(state.uid, state, newState);
|
|
4430
|
+
return newState;
|
|
4431
|
+
};
|
|
4432
|
+
|
|
4372
4433
|
const getOptionUriOptions = options => {
|
|
4373
4434
|
if (typeof options === 'string') {
|
|
4374
4435
|
return options;
|
|
@@ -4660,6 +4721,8 @@ const handleClickAction = async (state, action, rawGroupId) => {
|
|
|
4660
4721
|
}
|
|
4661
4722
|
return closeEditorGroup$1(state, groupId);
|
|
4662
4723
|
}
|
|
4724
|
+
case OpenInTextEditor$1:
|
|
4725
|
+
return openBinaryAsText(state);
|
|
4663
4726
|
case RetryOpen:
|
|
4664
4727
|
return retryOpen(state);
|
|
4665
4728
|
case SplitRight$1:
|
|
@@ -5144,6 +5207,8 @@ const TextEditorLoading = 'TextEditor TextEditor--loading';
|
|
|
5144
5207
|
const EditorContentLoading = 'EditorContent EditorContent--loading';
|
|
5145
5208
|
const TextEditorError = 'TextEditor TextEditorError';
|
|
5146
5209
|
const EditorContentError = 'EditorContent EditorContentError';
|
|
5210
|
+
const TextEditorBinary = 'TextEditor TextEditorError TextEditorBinary';
|
|
5211
|
+
const EditorContentBinary = 'EditorContent EditorContentError EditorContentBinary';
|
|
5147
5212
|
const DragOverlay = 'DragOverlay';
|
|
5148
5213
|
const Main = 'Main';
|
|
5149
5214
|
const EDITOR_GROUPS_CONTAINER = 'editor-groups-container';
|
|
@@ -6184,6 +6249,8 @@ const CopyIntoNewWindow = 'Copy into New Window';
|
|
|
6184
6249
|
const NewTextFile = 'New Text File';
|
|
6185
6250
|
const NewWindow = 'New Window';
|
|
6186
6251
|
const OpenFile = 'Open File';
|
|
6252
|
+
const OpenInTextEditor = 'Open in Text Editor';
|
|
6253
|
+
const BinaryFileNotDisplayed = 'The file is not displayed in the text editor because its contents are binary.';
|
|
6187
6254
|
const SplitDown = 'Split Down';
|
|
6188
6255
|
const SplitEditorGroup = 'Split Editor Group';
|
|
6189
6256
|
const SplitLeft = 'Split Left';
|
|
@@ -6195,6 +6262,12 @@ const Retry = 'Retry';
|
|
|
6195
6262
|
const openFile = () => {
|
|
6196
6263
|
return i18nString(OpenFile);
|
|
6197
6264
|
};
|
|
6265
|
+
const openInTextEditor = () => {
|
|
6266
|
+
return i18nString(OpenInTextEditor);
|
|
6267
|
+
};
|
|
6268
|
+
const binaryFileNotDisplayed = () => {
|
|
6269
|
+
return i18nString(BinaryFileNotDisplayed);
|
|
6270
|
+
};
|
|
6198
6271
|
const splitUp = () => {
|
|
6199
6272
|
return i18nString(SplitUp);
|
|
6200
6273
|
};
|
|
@@ -7007,6 +7080,32 @@ const getDragOverlayVirtualDom = () => {
|
|
|
7007
7080
|
return dragOverlayVirtualDom;
|
|
7008
7081
|
};
|
|
7009
7082
|
|
|
7083
|
+
const textEditorBinaryNode = {
|
|
7084
|
+
childCount: 1,
|
|
7085
|
+
className: TextEditorBinary,
|
|
7086
|
+
type: Div
|
|
7087
|
+
};
|
|
7088
|
+
const editorContentBinaryNode = {
|
|
7089
|
+
childCount: 2,
|
|
7090
|
+
className: EditorContentBinary,
|
|
7091
|
+
type: Div
|
|
7092
|
+
};
|
|
7093
|
+
const paragraphNode$1 = {
|
|
7094
|
+
childCount: 1,
|
|
7095
|
+
type: P
|
|
7096
|
+
};
|
|
7097
|
+
const openInTextEditorButtonNode = {
|
|
7098
|
+
childCount: 1,
|
|
7099
|
+
className: mergeClassNames(Button, ButtonSecondary),
|
|
7100
|
+
'data-action': OpenInTextEditor$1,
|
|
7101
|
+
name: OpenInTextEditor$1,
|
|
7102
|
+
onClick: HandleClickAction,
|
|
7103
|
+
type: Button$2
|
|
7104
|
+
};
|
|
7105
|
+
const renderBinary = () => {
|
|
7106
|
+
return [textEditorBinaryNode, editorContentBinaryNode, paragraphNode$1, text(binaryFileNotDisplayed()), openInTextEditorButtonNode, text(openInTextEditor())];
|
|
7107
|
+
};
|
|
7108
|
+
|
|
7010
7109
|
const textEditorNode = {
|
|
7011
7110
|
childCount: 1,
|
|
7012
7111
|
className: TextEditor,
|
|
@@ -7080,6 +7179,9 @@ const renderEditor = tab => {
|
|
|
7080
7179
|
if (tab.loadingState === 'loading') {
|
|
7081
7180
|
return renderLoading();
|
|
7082
7181
|
}
|
|
7182
|
+
if (tab.loadingState === 'binary') {
|
|
7183
|
+
return renderBinary();
|
|
7184
|
+
}
|
|
7083
7185
|
|
|
7084
7186
|
// Viewlet is ready - render a reference node
|
|
7085
7187
|
// Frontend will append the pre-created component at this position using the uid
|