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 2 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 @@ -52,6 +52,11 @@ declare namespace contextMenu {
*/
readonly copyImageAddress?: string;

/**
@default 'Copy Image'
*/
readonly copyImage?: string;
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved

/**
@default 'Inspect Element'
*/
Expand Down Expand Up @@ -79,6 +84,7 @@ declare namespace contextMenu {
readonly saveImage: (options: ActionOptions) => MenuItem;
readonly saveImageAs: (options: ActionOptions) => MenuItem;
readonly copyImageAddress: (options: ActionOptions) => MenuItem;
readonly copyImage: (options: ActionOptions) => MenuItem;
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
readonly inspect: () => MenuItem;
readonly services: () => MenuItem;
}
Expand Down Expand Up @@ -126,6 +132,13 @@ declare namespace contextMenu {
*/
readonly showCopyImageAddress?: boolean;

/**
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
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 `Save Image As…` menu item when right-clicking on an image.

Expand Down
9 changes: 9 additions & 0 deletions index.js
Expand Up @@ -83,6 +83,14 @@ const create = (win, options) => {
webContents(win).insertText(clipboardContent);
}
}),
copyImage: decorateMenuItem({
id: 'copyImage',
label: 'Copy Image',
visible: props.mediaType === 'image',
click() {
webContents(win).copyImageAt(props.x, props.y);
}
}),
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
saveImage: decorateMenuItem({
id: 'save',
label: 'Save Image',
Expand Down Expand Up @@ -157,6 +165,7 @@ const create = (win, options) => {
defaultActions.separator(),
defaultActions.saveImage(),
options.showSaveImageAs && defaultActions.saveImageAs(),
defaultActions.copyImage(),
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
options.showCopyImageAddress && defaultActions.copyImageAddress(),
defaultActions.separator(),
defaultActions.copyLink(),
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Expand Up @@ -100,6 +100,13 @@ Default: `false`

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

#### showCopyImage
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved

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

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

#### showSaveImageAs

Type: `boolean`<br>
Expand Down Expand Up @@ -188,6 +195,7 @@ Default actions:
- `cut`
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
- `copy`
- `paste`
- `copyImage`
whitecrownclown marked this conversation as resolved.
Show resolved Hide resolved
- `saveImage`
- `saveImageAs`
- `copyImageAddress`
Expand Down