electron: Add API to trigger share menu on macOS
- Electron version: 1.2.5
- Operating system: macOS 10.11
So I can let users share content from my app.
I’m thinking an API that lets you popup a share menu from wherever you like and specify the content:
(Notes.app)
And a share MenuItem role that you can just add to your menu:
(Desktop)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 32
- Comments: 22 (5 by maintainers)
@cawa-93 this has been mentioned previously. Doesn’t look like we can expect Chrome to implement that on Desktop. Looks like browser developers are just keeping it on mobile.
However, MacOS already has native share menu functionality that any app can tap into. All the Electron app would need to do is to tap into the native MacOS API for triggering a share menu and interacting with it.
API: https://developer.apple.com/design/human-interface-guidelines/macos/extensions/share-extensions/
Leaving a +1. Been a few years. Highly valued feature in Mac land
Looks like Chrome is considering adding this:
https://bugs.chromium.org/p/chromium/issues/detail?id=465302 https://codereview.chromium.org/1105143005
@ericpardee @felixrieseberg if Slack does this, can it please be open source? This feature could single-handedly make Electron apps more appealing to users and developers. Easy sharing of data and documents might not be sexy rocket science, but it is so key to the end user, and severely lacking in Electron-based apps.
@dukewan actually, i was just looking at Chrome’s impl for this to see how feasible it would be for us. I can’t make any promises but i’ve added it to my backlog and can try to get to it within the next month.
The share submenu and the share extension are two different things. The share extension requires dealing with native macOS APIs and unfortunately there’s no easy way to implement this in an Electron app.
Looking at this stackoverflow question, it looks like there’s a “hacky” way to implement this. I wish there was a better way or at least a clear guide explaining how to do this…
@felixrieseberg Slack needs this 👍
As an end user of an app using Electron, it is frustrating that we don’t have a solution to this problem (which is a shame, as there are some great electron based app out there that would work so much better if they could share data more easily)
Worth mentioning is that there is an experimental Web Share API standard which has been implemented in Chrome for Android.
The progress for implementing this in Chromium can be followed here: https://bugs.chromium.org/p/chromium/issues/list?q=component:Blink>WebShare
Seems Chromium 64.0.3265 supports share menu in the File menu. But it causes like 80ms delay in rendering the thread. I tested in 64.0.3282.186 and the share menu is not there, instead, “Email page location” replaced it. So maybe they removed it in the latest build. Electron 2.0.0-beta 1 is only upgrading Chromium version to 61, a long way to go.
Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=465302
@ramaprasanna I filed that Chromium suggestion linked above; looks like it will finally be implemented in Chrome 60 which should release within a few weeks. After that I believe the Electron team can make it available to us.