diff options
Diffstat (limited to 'src/webview/plugin.js')
-rw-r--r-- | src/webview/plugin.js | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/webview/plugin.js b/src/webview/plugin.js index c877132b1..610dffc8e 100644 --- a/src/webview/plugin.js +++ b/src/webview/plugin.js | |||
@@ -1,14 +1,14 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import { ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker'; | ||
2 | import path from 'path'; | 3 | import path from 'path'; |
3 | 4 | ||
5 | import { isDevMode } from '../environment'; | ||
4 | import RecipeWebview from './lib/RecipeWebview'; | 6 | import RecipeWebview from './lib/RecipeWebview'; |
5 | 7 | ||
6 | import Spellchecker from './spellchecker.js'; | 8 | import Spellchecker from './spellchecker.js'; |
7 | import './notifications.js'; | 9 | import './notifications.js'; |
8 | import './ime.js'; | 10 | import './ime.js'; |
9 | 11 | ||
10 | const spellchecker = new Spellchecker(); | ||
11 | |||
12 | ipcRenderer.on('initializeRecipe', (e, data) => { | 12 | ipcRenderer.on('initializeRecipe', (e, data) => { |
13 | const modulePath = path.join(data.recipe.path, 'webview.js'); | 13 | const modulePath = path.join(data.recipe.path, 'webview.js'); |
14 | // Delete module from cache | 14 | // Delete module from cache |
@@ -21,20 +21,27 @@ ipcRenderer.on('initializeRecipe', (e, data) => { | |||
21 | } | 21 | } |
22 | }); | 22 | }); |
23 | 23 | ||
24 | let contextMenuBuilder = new ContextMenuBuilder(null, null, isDevMode); | ||
25 | const spellchecker = new Spellchecker(); | ||
26 | |||
27 | new ContextMenuListener((info) => { // eslint-disable-line | ||
28 | contextMenuBuilder.showPopupMenu(info); | ||
29 | }); | ||
30 | |||
24 | ipcRenderer.on('settings-update', (e, data) => { | 31 | ipcRenderer.on('settings-update', (e, data) => { |
25 | if (data.enableSpellchecking) { | 32 | if (data.enableSpellchecking && !spellchecker.isInitialized) { |
26 | if (!spellchecker.isEnabled) { | 33 | spellchecker.initialize(); |
27 | spellchecker.enable(); | 34 | |
28 | 35 | contextMenuBuilder = new ContextMenuBuilder(spellchecker.handler, null, isDevMode); | |
29 | // TODO: this does not work yet, needs more testing | 36 | |
30 | // if (data.spellcheckingLanguage !== 'auto') { | 37 | new ContextMenuListener((info) => { // eslint-disable-line |
31 | // console.log('set spellchecking language to', data.spellcheckingLanguage); | 38 | contextMenuBuilder.showPopupMenu(info); |
32 | // spellchecker.switchLanguage(data.spellcheckingLanguage); | 39 | }); |
33 | // } | ||
34 | } | ||
35 | } | 40 | } |
36 | }); | 41 | }); |
37 | 42 | ||
43 | // initSpellche | ||
44 | |||
38 | document.addEventListener('DOMContentLoaded', () => { | 45 | document.addEventListener('DOMContentLoaded', () => { |
39 | ipcRenderer.sendToHost('hello'); | 46 | ipcRenderer.sendToHost('hello'); |
40 | }, false); | 47 | }, false); |