Skip to content

Commit

Permalink
fix(Windows): Fix copy & paste in service context menus
Browse files Browse the repository at this point in the history
Closes #1316
  • Loading branch information
adlk committed Mar 8, 2019
1 parent c62a6a6 commit e66fcaa
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/webview/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const buildMenuTpl = (props, suggestions, isSpellcheckEnabled, defaultSpellcheck
const canGoBack = webContents.canGoBack();
const canGoForward = webContents.canGoForward();

// @adlk: we can't use roles here due to a bug with electron where electron.remote.webContents.getFocusedWebContents() returns the first webview in DOM instead of the focused one
// Github issue creation is pending
let menuTpl = [
{
type: 'separator',
Expand All @@ -48,19 +50,32 @@ const buildMenuTpl = (props, suggestions, isSpellcheckEnabled, defaultSpellcheck
type: 'separator',
}, {
id: 'cut',
role: can('Cut') ? 'cut' : '',
label: 'Cut',
click() {
if (can('Cut')) {
webContents.cut();
}
},
enabled: can('Cut'),
visible: hasText && props.isEditable,
}, {
id: 'copy',
label: 'Copy',
role: can('Copy') ? 'copy' : '',
click() {
if (can('Copy')) {
webContents.copy();
}
},
enabled: can('Copy'),
visible: props.isEditable || hasText,
}, {
id: 'paste',
label: 'Paste',
role: editFlags.canPaste ? 'paste' : '',
click() {
if (editFlags.canPaste) {
webContents.paste();
}
},
enabled: editFlags.canPaste,
visible: props.isEditable,
}, {
Expand Down

0 comments on commit e66fcaa

Please sign in to comment.