feat: add file association support, closes #3736
What kind of change does this PR introduce?
- [ ] Bugfix
- [x] Feature
- [ ] Docs
- [ ] New Binding issue #___
- [ ] Code style update
- [ ] Refactor
- [x] Build-related changes
- [ ] Other, please describe:
Does this PR introduce a breaking change?
- [ ] Yes, and the changes were approved in issue #___
- [x] No
Checklist
- [x] When resolving issues, they are referenced in the PR's title (e.g
fix: remove a typo, closes #___, #___) - [ ] A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
- [ ] I have added a convincing reason for adding this feature, if necessary
Other information
ref: #3736
Some apps like a picture viewer or a file editor would need a function that the user can right-click on a file and Open with the app.
In some systems such as windows, this comments (https://github.com/tauri-apps/tauri/issues/918#issuecomment-667667932) may work.
But in macOS, it is required to:
- Add
CFBundleDocumentTypesto the plist file, otherwise we CAN NOT choose the app for opening file because the app is disabled in the Open With app list. - Use NSApplicationDelegate application:openFile to handle the files.
NOTICE: this MR broken because some feature of https://github.com/tauri-apps/tao/pull/422 is required
@lucasfernog Would you take a look at this?
Thanks for the PR @meowtec I'll take a look as soon as we're ready to start merging new features.
We require all commits to be signed across Tauri's repositories. So while we wait for a plan on how we want to handle features going forward, you can use the time to sign your commits.
Follow this guide to s set up commit signing.
We require all commits to be signed across Tauri's repositories. So while we wait for a plan on how we want to handle features going forward, you can use the time to sign your commits.
Follow this guide to s set up commit signing.
@JonasKruckenberg I have signed theme. Is there something incorrect?
Update: This change shoud be compatible with deep-link (https://github.com/tauri-apps/tauri/issues/323), and here is the demo code for macOS: https://github.com/meowtec/tauri/tree/feat/deep-link-mac:
This PR should be transformed to draft as i am trying to implement protocol in Windows and Linux.
@meowtec imo it would be fine to let this PR focus on the file associations, but if you want to do it anyway, i have working implementations for Linux and Windows here: https://github.com/FabianLars/tauri-plugin-deep-link (Just the register and maybe the unregister functions are of interest).
Edit: I planned on splitting that repo into 2 crates, one just for registering the protocols. Would that help you here?
https://github.com/FabianLars/tauri-plugin-deep-link
It looks better to make both file associations and deep-link PRs separated.
Doesn't seem like you can open files with the app in development on macOS. Might be that a .app needs to be built during development (that's what Electron does)
This is now just waiting on tao 0.21 and wry 0.30.
I just destroyed my VM testing some NSIS changes :clown_face:
I've removed the opened event (previously called open-url) because we need a better API to send this information to the webview (the opened event is triggered before the window is created on the first call, and there's no way to get the same information on Windows/Linux - we'd need to expose the CLI args).
So.. did this make it in? I'm not seeing it in the tauri docs? Thanks!
Hi @tnrich , I followed this question up here: https://github.com/tauri-apps/tauri/issues/3736#issuecomment-1711557994