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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions index.d.ts
Expand Up @@ -49,6 +49,11 @@ declare namespace contextMenu {
@default 'Inspect Element'
*/
readonly inspect?: string;

/**
@default 'Services'
*/
readonly services?: string;
}

interface ActionOptions {
Expand All @@ -61,6 +66,7 @@ declare namespace contextMenu {
interface Actions {
readonly separator: () => MenuItem;
readonly inspect: () => MenuItem;
readonly services: () => MenuItem;
readonly cut: (options: ActionOptions) => MenuItem;
readonly copy: (options: ActionOptions) => MenuItem;
readonly paste: (options: ActionOptions) => MenuItem;
Expand Down Expand Up @@ -116,6 +122,13 @@ declare namespace contextMenu {
*/
readonly showInspectElement?: boolean;

/**
Show the system `Services` submenu on macOS.

@default false
*/
readonly showServices?: boolean;

/**
Show the `Look Up [selection]` menu item when right-clicking text on macOS.

Expand Down
7 changes: 7 additions & 0 deletions index.js
Expand Up @@ -83,6 +83,12 @@ const create = (win, options) => {
}
}
}),
services: () => ({
id: 'services',
label: 'Services',
role: 'services',
visible: process.platform === 'darwin' && (props.isEditable || hasText)
}),
separator: () => ({type: 'separator'}),
saveImage: decorateMenuItem({
id: 'save',
Expand Down Expand Up @@ -155,6 +161,7 @@ const create = (win, options) => {
defaultActions.copyLink(),
defaultActions.separator(),
options.showInspectElement && defaultActions.inspect(),
options.showServices && defaultActions.services(),
defaultActions.separator()
];

Expand Down
11 changes: 11 additions & 0 deletions readme.md
Expand Up @@ -93,6 +93,15 @@ Default: [Only in development](https://github.com/sindresorhus/electron-is-dev)

Force enable or disable the `Inspect Element` menu item.

#### showServices

Type: `boolean`<br>
Default: `false`

Show the system `Services` submenu when right-clicking text on macOS.

Note: Due to [a bug in the Electron implementation](https://github.com/electron/electron/issues/18476), this menu is not identical to the "Services" submenu in the context menus of native apps. Instead, it looks the same as the "Services" menu in the main App Menu. For this reason, it is currently disabled by default.

#### showLookUpSelection

Type: `boolean`<br>
Expand Down Expand Up @@ -150,6 +159,7 @@ The following options are ignored when `menu` is used:
- `showCopyImageAddress`
- `showSaveImageAs`
- `showInspectElement`
- `showServices`

Default actions:

Expand All @@ -162,6 +172,7 @@ Default actions:
- `copyImageAddress`
- `copyLink`
- `inspect`
- `services`

Example:

Expand Down