diff options
author | vantezzen <hello@vantezzen.io> | 2020-03-02 10:05:58 +0100 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2020-03-02 10:05:58 +0100 |
commit | 581663761d44d91bf00a96956823b92d354d2bf1 (patch) | |
tree | 5cf1a189445d1d83aa83418b134d0201beb0354c /src/webview/contextMenu.js | |
parent | Add "Open Link in Ferdi" to context menu (diff) | |
download | ferdium-app-581663761d44d91bf00a96956823b92d354d2bf1.tar.gz ferdium-app-581663761d44d91bf00a96956823b92d354d2bf1.tar.zst ferdium-app-581663761d44d91bf00a96956823b92d354d2bf1.zip |
Run linter
Diffstat (limited to 'src/webview/contextMenu.js')
-rw-r--r-- | src/webview/contextMenu.js | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js index e77ff2326..eeb825ece 100644 --- a/src/webview/contextMenu.js +++ b/src/webview/contextMenu.js | |||
@@ -1,34 +1,36 @@ | |||
1 | import { remote } from "electron"; | 1 | import { remote } from 'electron'; |
2 | import { ContextMenuBuilder, ContextMenuListener } from "electron-spellchecker"; | 2 | import { ContextMenuBuilder, ContextMenuListener } from 'electron-spellchecker'; |
3 | 3 | ||
4 | const webContents = remote.getCurrentWebContents(); | 4 | const webContents = remote.getCurrentWebContents(); |
5 | 5 | ||
6 | export default async function setupContextMenu(handler) { | 6 | export default async function setupContextMenu(handler) { |
7 | const processMenu = (menu, menuInfo) => { | 7 | const addCustomMenuItems = (menu, menuInfo) => { |
8 | // Add "Paste as plain text" item when right-clicking editable content | ||
8 | if ( | 9 | if ( |
9 | menuInfo.editFlags.canPaste && | 10 | menuInfo.editFlags.canPaste |
10 | !menuInfo.linkText && | 11 | && !menuInfo.linkText |
11 | !menuInfo.hasImageContents | 12 | && !menuInfo.hasImageContents |
12 | ) { | 13 | ) { |
13 | menu.insert( | 14 | menu.insert( |
14 | 3, | 15 | 3, |
15 | new remote.MenuItem({ | 16 | new remote.MenuItem({ |
16 | label: "Paste as plain text", | 17 | label: 'Paste as plain text', |
17 | accelerator: "CommandOrControl+Shift+V", | 18 | accelerator: 'CommandOrControl+Shift+V', |
18 | click: () => webContents.pasteAndMatchStyle() | 19 | click: () => webContents.pasteAndMatchStyle(), |
19 | }) | 20 | }), |
20 | ); | 21 | ); |
21 | } | 22 | } |
22 | 23 | ||
24 | // Add "Open Link in Ferdi" item for links | ||
23 | if (menuInfo.linkURL) { | 25 | if (menuInfo.linkURL) { |
24 | menu.insert( | 26 | menu.insert( |
25 | 2, | 27 | 2, |
26 | new remote.MenuItem({ | 28 | new remote.MenuItem({ |
27 | label: "Open Link in Ferdi", | 29 | label: 'Open Link in Ferdi', |
28 | click: () => { | 30 | click: () => { |
29 | window.location.href = menuInfo.linkURL; | 31 | window.location.href = menuInfo.linkURL; |
30 | } | 32 | }, |
31 | }) | 33 | }), |
32 | ); | 34 | ); |
33 | } | 35 | } |
34 | 36 | ||
@@ -39,10 +41,10 @@ export default async function setupContextMenu(handler) { | |||
39 | handler, | 41 | handler, |
40 | null, | 42 | null, |
41 | true, | 43 | true, |
42 | processMenu | 44 | addCustomMenuItems, |
43 | ); | 45 | ); |
44 | // eslint-disable-next-line no-new | 46 | // eslint-disable-next-line no-new |
45 | new ContextMenuListener(info => { | 47 | new ContextMenuListener((info) => { |
46 | contextMenuBuilder.showPopupMenu(info); | 48 | contextMenuBuilder.showPopupMenu(info); |
47 | }); | 49 | }); |
48 | } | 50 | } |