Skip to content

Commit 5c18595

Browse files
committed
feat(Context Menu): Add "Go Back" and "Go Forward"
#1144
1 parent 5d5aa0c commit 5c18595

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/webview/contextMenu.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const buildMenuTpl = (props, suggestions) => {
2727
const hasText = textSelection.length > 0;
2828
const can = type => editFlags[`can${type}`] && hasText;
2929

30+
const canGoBack = webContents.canGoBack();
31+
const canGoForward = webContents.canGoForward();
32+
3033
let menuTpl = [
3134
{
3235
type: 'separator',
@@ -165,6 +168,28 @@ const buildMenuTpl = (props, suggestions) => {
165168
}));
166169
}
167170

171+
if (canGoBack || canGoForward) {
172+
menuTpl.push({
173+
type: 'separator',
174+
}, {
175+
id: 'goBack',
176+
label: 'Go Back',
177+
enabled: canGoBack,
178+
click() {
179+
webContents.goBack();
180+
},
181+
}, {
182+
id: 'goForward',
183+
label: 'Go Forward',
184+
enabled: canGoForward,
185+
click() {
186+
webContents.goForward();
187+
},
188+
}, {
189+
type: 'separator',
190+
});
191+
}
192+
168193
if (isDevMode) {
169194
menuTpl.push({
170195
type: 'separator',
@@ -174,8 +199,6 @@ const buildMenuTpl = (props, suggestions) => {
174199
click() {
175200
webContents.inspectElement(props.x, props.y);
176201
},
177-
}, {
178-
type: 'separator',
179202
});
180203
}
181204

0 commit comments

Comments
 (0)