Home / GitHub Page

Services menu item on macOS

I’ve run some tests and added the Services menu item on macOS, since Electron supports roles.

It’s basically nothing more than:

{
    role: 'services',
    platforms: ['darwin']
}

However, it seems that this is not entirely working as expected. Items are missing. In TextEdit or Sublime Text, the Services menu looks like this when I select a text:

In the Electron app (Joplin), it looks like this when I select text in th editor:

Here is the really strange part. When I select text in the preview pane, it looks like this:

If anyone has an idea how to fix this or make it work properly, please let me know.

What does the services item do normally? what should we see in the list if it works?

The menu shows you the services configured in System Preferences -> Keyboard -> Shotcuts -> Services. In my case it was supposed to show the same services as in the first image (in Sublime Text).
e.g. OpenPGP: Sign Selection - if you select text and pick that one, your text will be signed and replaced with an inline gpg signed text.

So for some reason the Joplin editor, the react natice framework, or whatever, does not tell the services component that we are in fact in an editable area and that text is selected.

I see. Could it be because Ace Editor is not an actual text area? I forgot how they render but I believe it’s a div so maybe not detected by your service.

Does it work if you select text for example in the title text input (which is a proper HTML input element)?

I thought about that as well, or at least I thought it might have to do with the editor. react-native or electron only has to convey to the macOS services component that we are in fact in an area where text can be altered.

I’ve just tried and yes, it works! So there must be some sort of a workaround for the editor.

I hoped that someone in this forum came across this issue before…

Has anyone an idea how to make this work for the editor as well?