Skip to content

Commit e21611a

Browse files
committed
Add select-file-path API to prepare us for Electron v32
1 parent 249f749 commit e21611a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,15 @@ ipcMain.handle('select-application', ipcHandler(async () => {
626626
else return result.filePaths[0];
627627
}));
628628

629+
ipcMain.handle('select-file-path', ipcHandler(async () => {
630+
const result = await dialog.showOpenDialog({
631+
properties: ['openFile']
632+
});
633+
634+
if (!result || result.canceled) return undefined;
635+
else return result.filePaths[0];
636+
}));
637+
629638
// Enable the default context menu
630639
registerContextMenu({
631640
showSaveImageAs: true,

src/preload.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ contextBridge.exposeInMainWorld('desktopApi', {
2727

2828
selectApplication: () =>
2929
ipcRenderer.invoke('select-application'),
30+
selectFilePath: () =>
31+
ipcRenderer.invoke('select-file-path'),
32+
3033
openContextMenu: (options: ContextMenuDefinition) =>
3134
ipcRenderer.invoke('open-context-menu', options),
3235

0 commit comments

Comments
 (0)