tauri icon indicating copy to clipboard operation
tauri copied to clipboard

feat: add file association support, closes #3736

Open meowtec opened this issue 3 years ago • 7 comments

Screen Shot 2022-06-21 at 13 08 28 Screen Shot 2022-06-21 at 13 08 51

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:

  1. Add CFBundleDocumentTypes to the plist file, otherwise we CAN NOT choose the app for opening file because the app is disabled in the Open With app list.
  2. 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

meowtec avatar Jun 12 '22 04:06 meowtec

@lucasfernog Would you take a look at this?

meowtec avatar Jun 21 '22 05:06 meowtec

Thanks for the PR @meowtec I'll take a look as soon as we're ready to start merging new features.

lucasfernog avatar Jun 21 '22 11:06 lucasfernog

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 avatar Jun 23 '22 15:06 JonasKruckenberg

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?

meowtec avatar Jun 24 '22 07:06 meowtec

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:

Screen Shot 2022-06-27 at 00 36 12 Screen Shot 2022-06-27 at 00 36 28

This PR should be transformed to draft as i am trying to implement protocol in Windows and Linux.

meowtec avatar Jun 26 '22 16:06 meowtec

@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?

FabianLars avatar Jun 26 '22 17:06 FabianLars

https://github.com/FabianLars/tauri-plugin-deep-link

It looks better to make both file associations and deep-link PRs separated.

meowtec avatar Jun 27 '22 03:06 meowtec

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)

probablykasper avatar Oct 22 '22 07:10 probablykasper

This is now just waiting on tao 0.21 and wry 0.30.

lucasfernog avatar Jul 13 '23 11:07 lucasfernog

I just destroyed my VM testing some NSIS changes :clown_face:

lucasfernog avatar Jul 14 '23 22:07 lucasfernog

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).

lucasfernog avatar Jul 16 '23 21:07 lucasfernog

So.. did this make it in? I'm not seeing it in the tauri docs? Thanks!

tnrich avatar Sep 07 '23 21:09 tnrich

Hi @tnrich , I followed this question up here: https://github.com/tauri-apps/tauri/issues/3736#issuecomment-1711557994

lorenzolewis avatar Sep 08 '23 12:09 lorenzolewis