diff --git a/index.d.ts b/index.d.ts index 690e169..9bb66d6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -49,6 +49,11 @@ declare namespace contextMenu { @default 'Inspect Element' */ readonly inspect?: string; + + /** + @default 'Services' + */ + readonly services?: string; } interface ActionOptions { @@ -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; @@ -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. diff --git a/index.js b/index.js index 5087a55..6d408e7 100644 --- a/index.js +++ b/index.js @@ -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', @@ -155,6 +161,7 @@ const create = (win, options) => { defaultActions.copyLink(), defaultActions.separator(), options.showInspectElement && defaultActions.inspect(), + options.showServices && defaultActions.services(), defaultActions.separator() ]; diff --git a/readme.md b/readme.md index 20509c8..8123573 100644 --- a/readme.md +++ b/readme.md @@ -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`
+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`
@@ -151,6 +160,7 @@ The following options are ignored when `menu` is used: - `showCopyImageAddress` - `showSaveImageAs` - `showInspectElement` +- `showServices` Default actions: @@ -164,6 +174,7 @@ Default actions: - `copyImageAddress` - `copyLink` - `inspect` +- `services` Example: