@lvce-editor/main-area-worker 9.67.10 → 9.68.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 +34 -3
- package/package.json +1 -1
|
@@ -2310,11 +2310,23 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
|
|
|
2310
2310
|
return newState;
|
|
2311
2311
|
};
|
|
2312
2312
|
|
|
2313
|
+
const legacyRenderers = new WeakSet();
|
|
2313
2314
|
const saveEditor = async (editorUid, skipFormatting = false) => {
|
|
2314
|
-
|
|
2315
|
-
|
|
2315
|
+
const args = skipFormatting ? [editorUid, true] : [editorUid];
|
|
2316
|
+
const rpc = get$2(RendererWorker);
|
|
2317
|
+
if (legacyRenderers.has(rpc)) {
|
|
2318
|
+
return invoke$2('Editor.save', ...args);
|
|
2319
|
+
}
|
|
2320
|
+
try {
|
|
2321
|
+
return await invoke$2('Viewlet.save', ...args);
|
|
2322
|
+
} catch (error) {
|
|
2323
|
+
// Older renderers support only text editors. Never retry an actual save failure.
|
|
2324
|
+
if (!(error instanceof Error) || !['Command not found Viewlet.save', 'Command "Viewlet.save" not found (renderer worker)'].includes(error.message)) {
|
|
2325
|
+
throw error;
|
|
2326
|
+
}
|
|
2327
|
+
legacyRenderers.add(rpc);
|
|
2328
|
+
return invoke$2('Editor.save', ...args);
|
|
2316
2329
|
}
|
|
2317
|
-
return invoke$2('Editor.save', editorUid);
|
|
2318
2330
|
};
|
|
2319
2331
|
|
|
2320
2332
|
const promptLegacy = async (message, discardPrompt) => {
|
|
@@ -8850,6 +8862,23 @@ const save = async state => {
|
|
|
8850
8862
|
const saveWithoutFormatting = async state => {
|
|
8851
8863
|
return saveInternal(state, true);
|
|
8852
8864
|
};
|
|
8865
|
+
const saveAll = async context => {
|
|
8866
|
+
const initialState = context.getState();
|
|
8867
|
+
const tabs = initialState.layout.groups.flatMap(group => group.tabs).filter(tab => tab.isDirty && tab.loadingState !== 'loading');
|
|
8868
|
+
for (const tab of tabs) {
|
|
8869
|
+
const current = context.getState().layout.groups.flatMap(group => group.tabs).find(item => item.id === tab.id);
|
|
8870
|
+
if (!current?.isDirty || current.editorUid !== tab.editorUid) {
|
|
8871
|
+
continue;
|
|
8872
|
+
}
|
|
8873
|
+
const result = await saveEditorAndHandleSettingsChange(current, initialState.applicationId);
|
|
8874
|
+
if (result?.modified) {
|
|
8875
|
+
continue;
|
|
8876
|
+
}
|
|
8877
|
+
await context.updateState(state => updateTab(state, tab.id, {
|
|
8878
|
+
isDirty: false
|
|
8879
|
+
}));
|
|
8880
|
+
}
|
|
8881
|
+
};
|
|
8853
8882
|
|
|
8854
8883
|
const getSavedTab = tab => {
|
|
8855
8884
|
const normalizedTab = normalizeTabEditorInput(tab);
|
|
@@ -9206,6 +9235,7 @@ const commandMap = {
|
|
|
9206
9235
|
'Main.openUris': wrapSerialAsyncCommand(openUrisWithContext),
|
|
9207
9236
|
'Main.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
|
|
9208
9237
|
'Main.save': wrapSerialCommand(save),
|
|
9238
|
+
'Main.saveAll': wrapAsyncCommand(saveAll),
|
|
9209
9239
|
'Main.saveState': wrapGetter(saveState),
|
|
9210
9240
|
'Main.splitRight': splitRightAndResize,
|
|
9211
9241
|
'MainArea.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
|
|
@@ -9287,6 +9317,7 @@ const commandMap = {
|
|
|
9287
9317
|
'MainArea.resize': resize,
|
|
9288
9318
|
'MainArea.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
|
|
9289
9319
|
'MainArea.save': wrapSerialCommand(save),
|
|
9320
|
+
'MainArea.saveAll': wrapAsyncCommand(saveAll),
|
|
9290
9321
|
'MainArea.saveState': wrapGetter(saveState),
|
|
9291
9322
|
'MainArea.saveWithoutFormatting': wrapSerialCommand(saveWithoutFormatting),
|
|
9292
9323
|
'MainArea.selectTab': wrapSerialCommand(selectTab),
|