Skip to content
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

Add Services submenu on macOS #73

Merged
merged 4 commits into from Jun 3, 2019
Merged

Add Services submenu on macOS #73

merged 4 commits into from Jun 3, 2019

Conversation

caesar
Copy link
Contributor

@caesar caesar commented May 26, 2019

Adds support for the system “Services” menu on macOS.

Enabled by default; can be disabled using showServices: false.

Only enabled for text; this seems to be standard across most Mac apps.


Note that the menu is not identical to that shown by native apps in the context menu – in fact it is the same as the “Services” submenu in the application menu in the main menubar.

This is because of Electron's implementation of the { role: services } menu API, and should probably be filed as a bug with Electron core (Chromium has support).

Screenshot:

Screenshot 2019-05-26 at 21 16 28


Closes #72

@sindresorhus
Copy link
Owner

Can you open an Electron issue about what you mentioned above?

@caesar
Copy link
Contributor Author

caesar commented May 28, 2019

Absolutely – I'd been intending to do so, but hadn't got around to it yet.

@caesar
Copy link
Contributor Author

caesar commented May 28, 2019

Electron bug: electron/electron#18476

index.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

sindresorhus commented May 29, 2019

Only enabled for text; this seems to be standard across most Mac apps.

What apps? I tried Chrome, Safar, TextEdit, Notes, and none of them have a "Services" menu item when right-clicking text. Instead, they all have a "Share" menu (electron/electron#6330).

@caesar
Copy link
Contributor Author

caesar commented May 29, 2019

I tried Chrome, Safar, TextEdit, Notes, and none of them have a "Services" menu item when right-clicking text. Instead, they all have a "Share" menu (electron/electron#6330).

Interesting! All of the above have both a "Share" menu and a "Services" menu for me (the screenshot in #72 is from Safari). I'm on macOS 10.14.5. I wonder what the difference is in our configs?

That said, I haven't been able to find the Cocoa method for use in a context menu for the Services menu, whereas the one for the Share menu is easy to find (NSSharingServicePicker).
So it looks like the "correct" behaviour for this menu isn't likely to be implemented in Electron the short term (see discussion at electron/electron#6330).

Maybe a "Share" menu is a more useful addition anyway! Obviously dependent on electron/electron#6330.

@caesar
Copy link
Contributor Author

caesar commented May 29, 2019

Further oddity: Preview has "Services" and not "Share" for me. What does it have for you?
Chrome too, now I check it again. Safari, TextEdit, and Notes have both.

@sindresorhus
Copy link
Owner

Turns out I didn't have any applicable Services enabled. I see it in Safari and Chrome now.

Can you fix the merge conflict?

index.d.ts Outdated
@@ -60,6 +60,7 @@ declare namespace contextMenu {

interface Actions {
readonly separator: () => MenuItem;
readonly services: () => MenuItem;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ordered after inspect, like in the menu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done – I hadn't realised that was the intended ordering here.

Bearing that in mind, I seem to have put the entries for lookUpSelection in the wrong place too; shall I submit a PR to fix that?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall I submit a PR to fix that?

👍 And also the labels thing in the same PR.

index.js Outdated Show resolved Hide resolved
@caesar
Copy link
Contributor Author

caesar commented May 30, 2019

Turns out I didn't have any applicable Services enabled. I see it in Safari and Chrome now.

Aha, cool!

Can you fix the merge conflict?

Happy to do so. Are you going to commit this anyway then, or not unless the Electron implementation is fixed?

If we implement it in its current state, maybe (I'm not sure) it should default to off, since it's not identical to the native implementation? What do you think?

@sindresorhus
Copy link
Owner

Are you going to commit this anyway then

Yes

If we implement it in its current state, maybe (I'm not sure) it should default to off, since it's not identical to the native implementation? What do you think?

Sure, let's keep it off for now.

readme.md Outdated Show resolved Hide resolved
@caesar
Copy link
Contributor Author

caesar commented May 30, 2019

Rebased onto current master to fix the merge conflicts, and I think I've addressed all the other issues discussed.

@caesar
Copy link
Contributor Author

caesar commented May 31, 2019

Turns out that although Electron (not macOS) sets the default label, we can override it ourselves.
So I've just done that, and added it to Labels like all the rest, no caveats necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for macOS Services submenu
2 participants