From 5c18595d757d7cabf21a54123bf7ed37f1bf3e7f Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Tue, 4 Dec 2018 14:54:38 +0100 Subject: feat(Context Menu): Add "Go Back" and "Go Forward" #1144 --- src/webview/contextMenu.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/webview/contextMenu.js') diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js index ff6d3b21a..ad156128c 100644 --- a/src/webview/contextMenu.js +++ b/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', }); } -- cgit v1.2.3-54-g00ecf