diff options
author | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-05-15 18:34:25 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-15 15:04:25 +0200 |
commit | 8ef5380b941a8f1483ee5d30e61a5086e669b12e (patch) | |
tree | 8e4db26f558722622738c17c21f97187cdb23ea0 /src/webview/contextMenuBuilder.js | |
parent | Minor refactoring to have consistent command-line invocations. (diff) | |
download | ferdium-app-8ef5380b941a8f1483ee5d30e61a5086e669b12e.tar.gz ferdium-app-8ef5380b941a8f1483ee5d30e61a5086e669b12e.tar.zst ferdium-app-8ef5380b941a8f1483ee5d30e61a5086e669b12e.zip |
Adding DuckDuckGo as an alternative search engine (#1414)
* Adding DuckDuckGo as an alternative search engine.
* Fixing review comments.
* Fixing review comments.
Diffstat (limited to 'src/webview/contextMenuBuilder.js')
-rw-r--r-- | src/webview/contextMenuBuilder.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/webview/contextMenuBuilder.js b/src/webview/contextMenuBuilder.js index b5095915c..49c4550a9 100644 --- a/src/webview/contextMenuBuilder.js +++ b/src/webview/contextMenuBuilder.js | |||
@@ -8,6 +8,8 @@ | |||
8 | */ | 8 | */ |
9 | import { isMac } from '../environment'; | 9 | import { isMac } from '../environment'; |
10 | 10 | ||
11 | import { SEARCH_ENGINE_NAMES, SEARCH_ENGINE_URLS } from '../config'; | ||
12 | |||
11 | const { | 13 | const { |
12 | clipboard, nativeImage, remote, shell, | 14 | clipboard, nativeImage, remote, shell, |
13 | } = require('electron'); | 15 | } = require('electron'); |
@@ -27,7 +29,7 @@ const contextMenuStringTable = { | |||
27 | cut: () => 'Cut', | 29 | cut: () => 'Cut', |
28 | copy: () => 'Copy', | 30 | copy: () => 'Copy', |
29 | paste: () => 'Paste', | 31 | paste: () => 'Paste', |
30 | searchGoogle: () => 'Search with Google', | 32 | searchWith: ({ searchEngine }) => `Search with ${searchEngine}`, |
31 | openLinkUrl: () => 'Open Link', | 33 | openLinkUrl: () => 'Open Link', |
32 | openLinkInFerdiUrl: () => 'Open Link in Ferdi', | 34 | openLinkInFerdiUrl: () => 'Open Link in Ferdi', |
33 | openInBrowser: () => 'Open in Browser', | 35 | openInBrowser: () => 'Open in Browser', |
@@ -286,10 +288,9 @@ module.exports = class ContextMenuBuilder { | |||
286 | } | 288 | } |
287 | 289 | ||
288 | const search = new MenuItem({ | 290 | const search = new MenuItem({ |
289 | label: this.stringTable.searchGoogle(), | 291 | label: this.stringTable.searchWith({ searchEngine: SEARCH_ENGINE_NAMES[menuInfo.searchEngine] }), |
290 | click: () => { | 292 | click: () => { |
291 | const url = `https://www.google.com/search?q=${encodeURIComponent(menuInfo.selectionText)}`; | 293 | const url = SEARCH_ENGINE_URLS[menuInfo.searchEngine]({ searchTerm: encodeURIComponent(menuInfo.selectionText) }); |
292 | |||
293 | shell.openExternal(url); | 294 | shell.openExternal(url); |
294 | }, | 295 | }, |
295 | }); | 296 | }); |