diff options
author | 2020-03-02 03:00:11 +0100 | |
---|---|---|
committer | 2020-03-02 03:00:11 +0100 | |
commit | 9582acc6eb946ef49659e03a2166d52163e8aeab (patch) | |
tree | c1bcf2a68c300fcd85c6d1c3e8e90b9e3ca5392d | |
parent | Remove conflicting context menu (diff) | |
download | ferdium-app-9582acc6eb946ef49659e03a2166d52163e8aeab.tar.gz ferdium-app-9582acc6eb946ef49659e03a2166d52163e8aeab.tar.zst ferdium-app-9582acc6eb946ef49659e03a2166d52163e8aeab.zip |
Keep separation of concern between context menu / spellchecker
-rw-r--r-- | src/webview/contextMenu.js | 9 | ||||
-rw-r--r-- | src/webview/spellchecker.js | 12 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js new file mode 100644 index 000000000..f02dd1a01 --- /dev/null +++ b/src/webview/contextMenu.js | |||
@@ -0,0 +1,9 @@ | |||
1 | import { ContextMenuBuilder, ContextMenuListener } from "electron-spellchecker"; | ||
2 | |||
3 | export default async function setupContextMenu(handler) { | ||
4 | let contextMenuBuilder = new ContextMenuBuilder(handler); | ||
5 | // eslint-disable-next-line no-new | ||
6 | new ContextMenuListener(info => { | ||
7 | contextMenuBuilder.showPopupMenu(info); | ||
8 | }); | ||
9 | } | ||
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js index 8a1c8782b..a33a506b2 100644 --- a/src/webview/spellchecker.js +++ b/src/webview/spellchecker.js | |||
@@ -1,13 +1,12 @@ | |||
1 | import { webFrame } from 'electron'; | 1 | import { webFrame } from 'electron'; |
2 | import { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker'; | 2 | import { SpellCheckHandler } from 'electron-spellchecker'; |
3 | |||
4 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 3 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
4 | import setupContextMenu from './contextMenu'; | ||
5 | 5 | ||
6 | const debug = require('debug')('Franz:spellchecker'); | 6 | const debug = require('debug')('Franz:spellchecker'); |
7 | 7 | ||
8 | let handler; | 8 | let handler; |
9 | let currentDict; | 9 | let currentDict; |
10 | let contextMenuBuilder; | ||
11 | let _isEnabled = false; | 10 | let _isEnabled = false; |
12 | 11 | ||
13 | export async function switchDict(locale) { | 12 | export async function switchDict(locale) { |
@@ -46,12 +45,7 @@ export default async function initialize(languageCode = 'en-us') { | |||
46 | debug('Init spellchecker'); | 45 | debug('Init spellchecker'); |
47 | 46 | ||
48 | switchDict(locale); | 47 | switchDict(locale); |
49 | 48 | setupContextMenu(handler); | |
50 | contextMenuBuilder = new ContextMenuBuilder(handler); | ||
51 | // eslint-disable-next-line no-new | ||
52 | new ContextMenuListener((info) => { | ||
53 | contextMenuBuilder.showPopupMenu(info); | ||
54 | }); | ||
55 | 49 | ||
56 | return handler; | 50 | return handler; |
57 | } catch (err) { | 51 | } catch (err) { |