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 c877132b1..cf38169d3 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,22 @@ ipcRenderer.on('initializeRecipe', (e, data) => {
21 } 21 }
22}); 22});
23 23
24const spellchecker = new Spellchecker();
25spellchecker.initialize();
26
27const contextMenuBuilder = new ContextMenuBuilder(spellchecker.handler, null, isDevMode);
28
29new ContextMenuListener((info) => { // eslint-disable-line
30 contextMenuBuilder.showPopupMenu(info);
31});
32
24ipcRenderer.on('settings-update', (e, data) => { 33ipcRenderer.on('settings-update', (e, data) => {
25 if (data.enableSpellchecking) { 34 console.log('settings-update', data);
26 if (!spellchecker.isEnabled) { 35 spellchecker.toggleSpellchecker(data.enableSpellchecking);
27 spellchecker.enable();
28
29 // TODO: this does not work yet, needs more testing
30 // if (data.spellcheckingLanguage !== 'auto') {
31 // console.log('set spellchecking language to', data.spellcheckingLanguage);
32 // spellchecker.switchLanguage(data.spellcheckingLanguage);
33 // }
34 }
35 }
36}); 36});
37 37
38// initSpellche
39
38document.addEventListener('DOMContentLoaded', () => { 40document.addEventListener('DOMContentLoaded', () => {
39 ipcRenderer.sendToHost('hello'); 41 ipcRenderer.sendToHost('hello');
40}, false); 42}, false);