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 Copy Image option #79

Merged
merged 4 commits into from
Aug 30, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ declare namespace contextMenu {
*/
readonly copyLink?: string;

/**
@default 'Copy Image'
*/
readonly copyImage?: string;

/**
@default 'Copy Image Address'
*/
Expand Down Expand Up @@ -78,6 +83,7 @@ declare namespace contextMenu {
readonly paste: (options: ActionOptions) => MenuItem;
readonly saveImage: (options: ActionOptions) => MenuItem;
readonly saveImageAs: (options: ActionOptions) => MenuItem;
readonly copyImage: (options: ActionOptions) => MenuItem;
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
readonly copyImageAddress: (options: ActionOptions) => MenuItem;
readonly inspect: () => MenuItem;
readonly services: () => MenuItem;
Expand Down Expand Up @@ -119,6 +125,13 @@ declare namespace contextMenu {
*/
readonly showLookUpSelection?: boolean;

/**
Show the `Copy Image` menu item when right-clicking on an image.

@default true
*/
readonly showCopyImage?: boolean;

/**
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
Show the `Copy Image Address` menu item when right-clicking on an image.

Expand Down Expand Up @@ -194,11 +207,12 @@ declare namespace contextMenu {

The following options are ignored when `menu` is used:

- `showCopyImage`
- `showCopyImageAddress`
- `showSaveImageAs`
- `showInspectElement`

@default [defaultActions.cut(), defaultActions.copy(), defaultActions.paste(), defaultActions.separator(), defaultActions.saveImage(), defaultActions.saveImageAs(), defaultActions.copyImageAddress(), defaultActions.separator(), defaultActions.copyLink(), defaultActions.separator(), defaultActions.inspect()]
@default [defaultActions.cut(), defaultActions.copy(), defaultActions.paste(), defaultActions.separator(), defaultActions.saveImage(), defaultActions.saveImageAs(), defaultActions.copyImage(), defaultActions.copyImageAddress(), defaultActions.separator(), defaultActions.copyLink(), defaultActions.separator(), defaultActions.inspect()]
*/
readonly menu?: (
defaultActions: Actions,
Expand Down
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ const create = (win, options) => {
});
}
}),
copyImage: decorateMenuItem({
id: 'copyImage',
label: 'Copy Image',
visible: props.mediaType === 'image',
click() {
webContents(win).copyImageAt(props.x, props.y);
}
}),
copyImageAddress: decorateMenuItem({
id: 'copyImageAddress',
label: 'Copy Image Address',
Expand Down Expand Up @@ -157,6 +165,7 @@ const create = (win, options) => {
defaultActions.separator(),
defaultActions.saveImage(),
options.showSaveImageAs && defaultActions.saveImageAs(),
options.showCopyImage !== false && defaultActions.copyImage(),
options.showCopyImageAddress && defaultActions.copyImageAddress(),
defaultActions.separator(),
defaultActions.copyLink(),
Expand Down
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ Default: `true`

Show the `Look Up {selection}` menu item when right-clicking text on macOS.

#### showCopyImage

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

Show the `Copy Image` menu item when right-clicking on an image.

#### showCopyImageAddress

Type: `boolean`<br>
Expand Down Expand Up @@ -176,6 +183,7 @@ Even though you include an action, it will still only be shown/enabled when appr
The following options are ignored when `menu` is used:

- `showLookUpSelection`
- `showCopyImage`
- `showCopyImageAddress`
- `showSaveImageAs`
- `showInspectElement`
Expand All @@ -190,6 +198,7 @@ Default actions:
- `paste`
- `saveImage`
- `saveImageAs`
- `copyImage`
- `copyImageAddress`
- `copyLink`
- `inspect`
Expand Down