Skip to content

Commit e791576

Browse files
committed
Add selectSaveFilePath to the desktop API
1 parent 234a40b commit e791576

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,13 @@ ipcMain.handle('select-file-path', ipcHandler(async () => {
631631
else return result.filePaths[0];
632632
}));
633633

634+
ipcMain.handle('select-save-file-path', ipcHandler(async () => {
635+
const result = await dialog.showSaveDialog({});
636+
637+
if (!result || result.canceled) return undefined;
638+
else return result.filePath;
639+
}));
640+
634641
// Enable the default context menu
635642
registerContextMenu({
636643
showSaveImageAs: true,

src/preload.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ contextBridge.exposeInMainWorld('desktopApi', {
3939
ipcRenderer.invoke('select-application'),
4040
selectFilePath: () =>
4141
ipcRenderer.invoke('select-file-path'),
42+
selectSaveFilePath: () =>
43+
ipcRenderer.invoke('select-save-file-path'),
4244

4345
openContextMenu: (options: ContextMenuDefinition) =>
4446
ipcRenderer.invoke('open-context-menu', options),

0 commit comments

Comments
 (0)