-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add the ability to open files from the UI #486
feat: add the ability to open files from the UI #486
Conversation
Signed-off-by: tylerslaton <[email protected]>
99beafc
to
bc31a17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh Cool, I wonder if this will help fix #280
We'd have to do some stuff with our Markdown renderer to know to treat those links in a custom way but yeah its doable. |
window.alert( | ||
'Coming soon, we promise! This will open your file.' | ||
// This submits a request to the electron main process to open the file | ||
(window as any).electronAPI.openFile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you globally update the window object to add TypeScript support?
ideally add a file @/types/window.d.ts
with these contents:
declare global {
interface Window {
electronApi: <ElectronApiType>; // You may have to type this yourself
}
}
export {} // this is required to allow the types to be globally accessible throughout the application
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
942aebc
942aebc
to
a13ef15
Compare
For those coming back to the PR, the latest change is that I added typing for the electron API in the window object. |
Signed-off-by: tylerslaton <[email protected]>
a13ef15
to
83c8f48
Compare
This uses Electron's IPC code to open system files through the UI. It is done through a listeners on in the
main.js
of electron and an emitter in the next js app. Once the emitted event is received with a file it is opened with the system default.https://www.electronjs.org/docs/latest/tutorial/ipc for more info.
#322