Skip to content

Commit

Permalink
feat(Context Menu): Add "Go Back" and "Go Forward"
Browse files Browse the repository at this point in the history
#1144
  • Loading branch information
adlk committed Dec 4, 2018
1 parent 5d5aa0c commit 5c18595
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/webview/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -174,8 +199,6 @@ const buildMenuTpl = (props, suggestions) => {
click() {
webContents.inspectElement(props.x, props.y);
},
}, {
type: 'separator',
});
}

Expand Down

0 comments on commit 5c18595

Please sign in to comment.