blob: 610dffc8ebf3fa089f35ad1784c372a7a8b9315e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import { ipcRenderer } from 'electron';
import { ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker';
import path from 'path';
import { isDevMode } from '../environment';
import RecipeWebview from './lib/RecipeWebview';
import Spellchecker from './spellchecker.js';
import './notifications.js';
import './ime.js';
ipcRenderer.on('initializeRecipe', (e, data) => {
const modulePath = path.join(data.recipe.path, 'webview.js');
// Delete module from cache
delete require.cache[require.resolve(modulePath)];
try {
// eslint-disable-next-line
require(modulePath)(new RecipeWebview(), data);
} catch (err) {
console.error(err);
}
});
let contextMenuBuilder = new ContextMenuBuilder(null, null, isDevMode);
const spellchecker = new Spellchecker();
new ContextMenuListener((info) => { // eslint-disable-line
contextMenuBuilder.showPopupMenu(info);
});
ipcRenderer.on('settings-update', (e, data) => {
if (data.enableSpellchecking && !spellchecker.isInitialized) {
spellchecker.initialize();
contextMenuBuilder = new ContextMenuBuilder(spellchecker.handler, null, isDevMode);
new ContextMenuListener((info) => { // eslint-disable-line
contextMenuBuilder.showPopupMenu(info);
});
}
});
// initSpellche
document.addEventListener('DOMContentLoaded', () => {
ipcRenderer.sendToHost('hello');
}, false);
|