aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/plugin.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview/plugin.js')
-rw-r--r--src/webview/plugin.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/webview/plugin.js b/src/webview/plugin.js
index e2daf09dd..9903ee07a 100644
--- a/src/webview/plugin.js
+++ b/src/webview/plugin.js
@@ -1,13 +1,13 @@
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';
8 10
9const spellchecker = new Spellchecker();
10
11ipcRenderer.on('initializeRecipe', (e, data) => { 11ipcRenderer.on('initializeRecipe', (e, data) => {
12 const modulePath = path.join(data.recipe.path, 'webview.js'); 12 const modulePath = path.join(data.recipe.path, 'webview.js');
13 // Delete module from cache 13 // Delete module from cache
@@ -20,20 +20,22 @@ ipcRenderer.on('initializeRecipe', (e, data) => {
20 } 20 }
21}); 21});
22 22
23const spellchecker = new Spellchecker();
24spellchecker.initialize();
25
26const contextMenuBuilder = new ContextMenuBuilder(spellchecker.handler, null, isDevMode);
27
28new ContextMenuListener((info) => { // eslint-disable-line
29 contextMenuBuilder.showPopupMenu(info);
30});
31
23ipcRenderer.on('settings-update', (e, data) => { 32ipcRenderer.on('settings-update', (e, data) => {
24 if (data.enableSpellchecking) { 33 console.log('settings-update', data);
25 if (!spellchecker.isEnabled) { 34 spellchecker.toggleSpellchecker(data.enableSpellchecking);
26 spellchecker.enable();
27
28 // TODO: this does not work yet, needs more testing
29 // if (data.spellcheckingLanguage !== 'auto') {
30 // console.log('set spellchecking language to', data.spellcheckingLanguage);
31 // spellchecker.switchLanguage(data.spellcheckingLanguage);
32 // }
33 }
34 }
35}); 35});
36 36
37// initSpellche
38
37document.addEventListener('DOMContentLoaded', () => { 39document.addEventListener('DOMContentLoaded', () => {
38 ipcRenderer.sendToHost('hello'); 40 ipcRenderer.sendToHost('hello');
39}, false); 41}, false);