Permalink
Browse files

feat(Context Menu): Add "Go Back" and "Go Forward"

  • Loading branch information...
adlk committed Dec 4, 2018
1 parent 5d5aa0c commit 5c18595d757d7cabf21a54123bf7ed37f1bf3e7f
Showing with 25 additions and 2 deletions.
  1. +25 −2 src/webview/contextMenu.js
@@ -27,6 +27,9 @@ const buildMenuTpl = (props, suggestions) => {
const hasText = textSelection.length > 0;
const can = type => editFlags[`can${type}`] && hasText;
const canGoBack = webContents.canGoBack();
const canGoForward = webContents.canGoForward();
let menuTpl = [
{
type: 'separator',
@@ -165,6 +168,28 @@ const buildMenuTpl = (props, suggestions) => {
}));
}
if (canGoBack || canGoForward) {
menuTpl.push({
type: 'separator',
}, {
id: 'goBack',
label: 'Go Back',
enabled: canGoBack,
click() {
webContents.goBack();
},
}, {
id: 'goForward',
label: 'Go Forward',
enabled: canGoForward,
click() {
webContents.goForward();
},
}, {
type: 'separator',
});
}
if (isDevMode) {
menuTpl.push({
type: 'separator',
@@ -174,8 +199,6 @@ const buildMenuTpl = (props, suggestions) => {
click() {
webContents.inspectElement(props.x, props.y);
},
}, {
type: 'separator',
});
}

0 comments on commit 5c18595

Please sign in to comment.