aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/plugin.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-12-11 12:25:49 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-12-11 12:25:49 +0100
commitc5b44c0259387030f9e3d31ae1db8903a95b6b67 (patch)
tree123e726411a33c2f0cea1eb6529d7462636c315e /src/webview/plugin.js
parentMerge pull request #421 from meetfranz/feature/bugfixing (diff)
downloadferdium-app-c5b44c0259387030f9e3d31ae1db8903a95b6b67.tar.gz
ferdium-app-c5b44c0259387030f9e3d31ae1db8903a95b6b67.tar.zst
ferdium-app-c5b44c0259387030f9e3d31ae1db8903a95b6b67.zip
always initialize ContextMenuBuilder but not spellchecker
Diffstat (limited to 'src/webview/plugin.js')
-rw-r--r--src/webview/plugin.js31
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 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer } from 'electron';
2import { ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker';
2import path from 'path'; 3import path from 'path';
3 4
5import { isDevMode } from '../environment';
4import RecipeWebview from './lib/RecipeWebview'; 6import RecipeWebview from './lib/RecipeWebview';
5 7
6import Spellchecker from './spellchecker.js'; 8import Spellchecker from './spellchecker.js';
7import './notifications.js'; 9import './notifications.js';
8import './ime.js'; 10import './ime.js';
9 11
10const spellchecker = new Spellchecker();
11
12ipcRenderer.on('initializeRecipe', (e, data) => { 12ipcRenderer.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
24let contextMenuBuilder = new ContextMenuBuilder(null, null, isDevMode);
25const spellchecker = new Spellchecker();
26
27new ContextMenuListener((info) => { // eslint-disable-line
28 contextMenuBuilder.showPopupMenu(info);
29});
30
24ipcRenderer.on('settings-update', (e, data) => { 31ipcRenderer.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
38document.addEventListener('DOMContentLoaded', () => { 45document.addEventListener('DOMContentLoaded', () => {
39 ipcRenderer.sendToHost('hello'); 46 ipcRenderer.sendToHost('hello');
40}, false); 47}, false);