@lvce-editor/main-area-worker 9.6.0 → 9.8.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 +86 -21
- package/package.json +1 -1
|
@@ -3041,14 +3041,67 @@ const getOptionUriOptions = options => {
|
|
|
3041
3041
|
return options.uri;
|
|
3042
3042
|
};
|
|
3043
3043
|
|
|
3044
|
+
const getEditorInputFromUri = uri => {
|
|
3045
|
+
if (uri.startsWith('diff://?')) {
|
|
3046
|
+
try {
|
|
3047
|
+
const parsed = new URL(uri);
|
|
3048
|
+
const uriLeft = parsed.searchParams.get('left');
|
|
3049
|
+
const uriRight = parsed.searchParams.get('right');
|
|
3050
|
+
if (uriLeft && uriRight) {
|
|
3051
|
+
return {
|
|
3052
|
+
type: 'diff-editor',
|
|
3053
|
+
uriLeft,
|
|
3054
|
+
uriRight
|
|
3055
|
+
};
|
|
3056
|
+
}
|
|
3057
|
+
} catch {
|
|
3058
|
+
// Ignore malformed legacy URIs and fall back to a text editor input.
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
if (uri.startsWith('extension-detail://')) {
|
|
3062
|
+
const extensionIdWithPath = uri.slice('extension-detail://'.length);
|
|
3063
|
+
const extensionId = extensionIdWithPath.split('/')[0];
|
|
3064
|
+
if (extensionId) {
|
|
3065
|
+
return {
|
|
3066
|
+
extensionId,
|
|
3067
|
+
type: 'extension-detail-view'
|
|
3068
|
+
};
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
return {
|
|
3072
|
+
type: 'editor',
|
|
3073
|
+
uri
|
|
3074
|
+
};
|
|
3075
|
+
};
|
|
3076
|
+
const getNormalizedEditorInput = tab => {
|
|
3077
|
+
if (typeof tab?.uri === 'string') {
|
|
3078
|
+
const inferredEditorInput = getEditorInputFromUri(tab.uri);
|
|
3079
|
+
if (inferredEditorInput.type !== 'editor') {
|
|
3080
|
+
return inferredEditorInput;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
return tab?.editorInput;
|
|
3084
|
+
};
|
|
3085
|
+
const normalizeTabEditorInput = tab => {
|
|
3086
|
+
const editorInput = getNormalizedEditorInput(tab);
|
|
3087
|
+
if (!editorInput) {
|
|
3088
|
+
return tab;
|
|
3089
|
+
}
|
|
3090
|
+
return {
|
|
3091
|
+
...tab,
|
|
3092
|
+
editorInput,
|
|
3093
|
+
editorType: getEditorInputEditorType(editorInput)
|
|
3094
|
+
};
|
|
3095
|
+
};
|
|
3096
|
+
const getNormalizedOpenEditorInput = uri => {
|
|
3097
|
+
return getEditorInputFromUri(uri);
|
|
3098
|
+
};
|
|
3099
|
+
|
|
3044
3100
|
const openUri = async (state, options) => {
|
|
3045
3101
|
const uri = getOptionUriOptions(options);
|
|
3046
3102
|
const preview = typeof options === 'string' ? false : options.preview ?? false;
|
|
3047
3103
|
return openInput(state, {
|
|
3048
|
-
editorInput:
|
|
3049
|
-
type: 'editor',
|
|
3050
|
-
uri
|
|
3051
|
-
},
|
|
3104
|
+
editorInput: getNormalizedOpenEditorInput(uri),
|
|
3052
3105
|
focu: typeof options === 'string' ? false : options.focu,
|
|
3053
3106
|
preview
|
|
3054
3107
|
});
|
|
@@ -3769,8 +3822,9 @@ const normalizeRestoredTab = tab => {
|
|
|
3769
3822
|
loadingState: _loadingState,
|
|
3770
3823
|
...rest
|
|
3771
3824
|
} = tab ?? {};
|
|
3825
|
+
const normalizedTab = normalizeTabEditorInput(rest);
|
|
3772
3826
|
return {
|
|
3773
|
-
...
|
|
3827
|
+
...normalizedTab,
|
|
3774
3828
|
editorUid: -1,
|
|
3775
3829
|
isDirty: false,
|
|
3776
3830
|
isPreview: typeof tab?.isPreview === 'boolean' ? tab.isPreview : false
|
|
@@ -3951,6 +4005,17 @@ const loadContent = async (state, savedState) => {
|
|
|
3951
4005
|
};
|
|
3952
4006
|
};
|
|
3953
4007
|
|
|
4008
|
+
const hasTargetGroup = groupId => {
|
|
4009
|
+
return groupId !== undefined && groupId >= 0;
|
|
4010
|
+
};
|
|
4011
|
+
|
|
4012
|
+
const getMenuEntryArgs = groupId => {
|
|
4013
|
+
if (!hasTargetGroup(groupId)) {
|
|
4014
|
+
return undefined;
|
|
4015
|
+
}
|
|
4016
|
+
return [groupId];
|
|
4017
|
+
};
|
|
4018
|
+
|
|
3954
4019
|
const emptyObject = {};
|
|
3955
4020
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
3956
4021
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
@@ -4084,15 +4149,6 @@ const menuEntrySeparator = {
|
|
|
4084
4149
|
label: ''
|
|
4085
4150
|
};
|
|
4086
4151
|
|
|
4087
|
-
const hasTargetGroup = groupId => {
|
|
4088
|
-
return groupId !== undefined && groupId >= 0;
|
|
4089
|
-
};
|
|
4090
|
-
const getArgs = groupId => {
|
|
4091
|
-
if (!hasTargetGroup(groupId)) {
|
|
4092
|
-
return undefined;
|
|
4093
|
-
}
|
|
4094
|
-
return [groupId];
|
|
4095
|
-
};
|
|
4096
4152
|
const getNewWindowMenuEntries = state => {
|
|
4097
4153
|
if (state.platform !== Electron) {
|
|
4098
4154
|
return [];
|
|
@@ -4104,8 +4160,9 @@ const getNewWindowMenuEntries = state => {
|
|
|
4104
4160
|
label: newWindow$1()
|
|
4105
4161
|
}];
|
|
4106
4162
|
};
|
|
4163
|
+
|
|
4107
4164
|
const getMenuEntries$2 = (state, groupId) => {
|
|
4108
|
-
const groupArgs =
|
|
4165
|
+
const groupArgs = getMenuEntryArgs(groupId);
|
|
4109
4166
|
const entries = [{
|
|
4110
4167
|
args: [QuickPick, 'file'],
|
|
4111
4168
|
command: 'Viewlet.openWidget',
|
|
@@ -4931,12 +4988,13 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
|
|
|
4931
4988
|
}, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
|
|
4932
4989
|
};
|
|
4933
4990
|
|
|
4991
|
+
const emptyHeader = {
|
|
4992
|
+
childCount: 1,
|
|
4993
|
+
className: EmptyGroupHeader,
|
|
4994
|
+
type: Div
|
|
4995
|
+
};
|
|
4934
4996
|
const renderEmptyGroupCloseButton = (group, groupIndex) => {
|
|
4935
|
-
return [{
|
|
4936
|
-
childCount: 1,
|
|
4937
|
-
className: EmptyGroupHeader,
|
|
4938
|
-
type: Div
|
|
4939
|
-
}, {
|
|
4997
|
+
return [emptyHeader, {
|
|
4940
4998
|
childCount: 1,
|
|
4941
4999
|
className: EmptyGroupCloseButton,
|
|
4942
5000
|
'data-groupId': String(group.id),
|
|
@@ -5181,6 +5239,9 @@ const renderEventListeners = () => {
|
|
|
5181
5239
|
const saveEditor = async editorUid => {
|
|
5182
5240
|
await invoke('Editor.save', editorUid);
|
|
5183
5241
|
};
|
|
5242
|
+
const getEditorSaveState = async editorUid => {
|
|
5243
|
+
return invoke('Editor.saveState', editorUid);
|
|
5244
|
+
};
|
|
5184
5245
|
|
|
5185
5246
|
const save = async state => {
|
|
5186
5247
|
const activeTabData = getActiveTab(state);
|
|
@@ -5197,6 +5258,10 @@ const save = async state => {
|
|
|
5197
5258
|
if (!tab.isDirty) {
|
|
5198
5259
|
return state;
|
|
5199
5260
|
}
|
|
5261
|
+
const editorState = await getEditorSaveState(tab.editorUid);
|
|
5262
|
+
if (editorState.modified) {
|
|
5263
|
+
return state;
|
|
5264
|
+
}
|
|
5200
5265
|
return updateTab(state, tab.id, {
|
|
5201
5266
|
isDirty: false
|
|
5202
5267
|
});
|
|
@@ -5205,7 +5270,7 @@ const save = async state => {
|
|
|
5205
5270
|
const getFilteredGroups = groups => {
|
|
5206
5271
|
return groups.map(group => ({
|
|
5207
5272
|
...group,
|
|
5208
|
-
tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://'))
|
|
5273
|
+
tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://')).map(normalizeTabEditorInput)
|
|
5209
5274
|
})).filter(group => group.tabs.length > 0);
|
|
5210
5275
|
};
|
|
5211
5276
|
|