@lvce-editor/main-area-worker 9.30.0 → 9.30.1

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.
@@ -1786,6 +1786,10 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1786
1786
  const command = 'HandleMessagePort.handleMessagePort2';
1787
1787
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1788
1788
  };
1789
+ const confirm = async (message, options) => {
1790
+ const result = await invoke('ConfirmPrompt.prompt', message, options);
1791
+ return result;
1792
+ };
1789
1793
  const writeClipBoardText = async text => {
1790
1794
  await invoke('ClipBoard.writeText', /* text */text);
1791
1795
  };
@@ -2254,18 +2258,42 @@ const saveEditor = async editorUid => {
2254
2258
  return invoke('Editor.save', editorUid);
2255
2259
  };
2256
2260
 
2261
+ const promptSave = async title => {
2262
+ const shouldSave = await confirm(`Do you want to save the changes you made to ${title}?`, {
2263
+ cancelMessage: 'More Options',
2264
+ confirmMessage: 'Save',
2265
+ title: 'Save Changes'
2266
+ });
2267
+ if (shouldSave) {
2268
+ return 'save';
2269
+ }
2270
+ const shouldDiscard = await confirm(`Discard the changes you made to ${title}?`, {
2271
+ cancelMessage: 'Cancel',
2272
+ confirmMessage: "Don't Save",
2273
+ title: 'Save Changes'
2274
+ });
2275
+ return shouldDiscard ? 'discard' : 'cancel';
2276
+ };
2257
2277
  const closeTabAndSave = async (state, groupId, tabId) => {
2258
2278
  const tab = findTabInState(state, groupId, tabId);
2259
2279
  if (!tab) {
2260
2280
  return state;
2261
2281
  }
2262
2282
  if (tab.editorUid !== -1 && tab.isDirty) {
2263
- const editorState = await saveEditor(tab.editorUid);
2264
- if (editorState?.modified !== false) {
2283
+ const savePromptResult = await promptSave(tab.title);
2284
+ if (savePromptResult === 'cancel') {
2265
2285
  return state;
2266
2286
  }
2267
- if (tab.uri) {
2268
- await handleModifiedStatusChange$1(tab.uri, false);
2287
+ if (savePromptResult === 'save') {
2288
+ const editorState = await saveEditor(tab.editorUid);
2289
+ if (editorState?.modified !== false) {
2290
+ return state;
2291
+ }
2292
+ if (tab.uri) {
2293
+ await handleModifiedStatusChange$1(tab.uri, false);
2294
+ }
2295
+ } else if (savePromptResult !== 'discard') {
2296
+ return state;
2269
2297
  }
2270
2298
  }
2271
2299
  if (tab.uri?.startsWith('simple-browser://')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.30.0",
3
+ "version": "9.30.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",