diff options
author | 2018-11-30 14:32:45 +0100 | |
---|---|---|
committer | 2018-11-30 14:32:45 +0100 | |
commit | 3d87c0e45cead95ddb6c11fc6540b82e375bdcf5 (patch) | |
tree | c91f425a39cb585242d6df5b4070de4a2141b3b4 /src/webview/plugin.js | |
parent | Merge branch 'update/monetization' into develop (diff) | |
download | ferdium-app-3d87c0e45cead95ddb6c11fc6540b82e375bdcf5.tar.gz ferdium-app-3d87c0e45cead95ddb6c11fc6540b82e375bdcf5.tar.zst ferdium-app-3d87c0e45cead95ddb6c11fc6540b82e375bdcf5.zip |
feat(App): Improved spell checker & context menu
Diffstat (limited to 'src/webview/plugin.js')
-rw-r--r-- | src/webview/plugin.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/webview/plugin.js b/src/webview/plugin.js index 427ec75ad..72530733d 100644 --- a/src/webview/plugin.js +++ b/src/webview/plugin.js | |||
@@ -1,12 +1,11 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import { ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker'; | ||
3 | import path from 'path'; | 2 | import path from 'path'; |
4 | 3 | ||
5 | import { isDevMode } from '../environment'; | ||
6 | import RecipeWebview from './lib/RecipeWebview'; | 4 | import RecipeWebview from './lib/RecipeWebview'; |
7 | 5 | ||
8 | import Spellchecker from './spellchecker'; | 6 | import spellchecker, { switchDict, disable as disableSpellchecker } from './spellchecker'; |
9 | import { injectDarkModeStyle, isDarkModeStyleInjected, removeDarkModeStyle } from './darkmode'; | 7 | import { injectDarkModeStyle, isDarkModeStyleInjected, removeDarkModeStyle } from './darkmode'; |
8 | import contextMenu from './contextMenu'; | ||
10 | import './notifications'; | 9 | import './notifications'; |
11 | 10 | ||
12 | const debug = require('debug')('Franz:Plugin'); | 11 | const debug = require('debug')('Franz:Plugin'); |
@@ -34,19 +33,21 @@ ipcRenderer.on('initializeRecipe', (e, data) => { | |||
34 | } | 33 | } |
35 | }); | 34 | }); |
36 | 35 | ||
37 | const spellchecker = new Spellchecker(); | 36 | // Needs to run asap to intialize dictionaries |
38 | spellchecker.initialize(); | 37 | (async () => { |
38 | const spellcheckingProvider = await spellchecker(); | ||
39 | contextMenu(spellcheckingProvider); | ||
40 | })(); | ||
39 | 41 | ||
40 | const contextMenuBuilder = new ContextMenuBuilder(spellchecker.handler, null, isDevMode); | 42 | ipcRenderer.on('settings-update', async (e, data) => { |
41 | |||
42 | new ContextMenuListener((info) => { // eslint-disable-line | ||
43 | contextMenuBuilder.showPopupMenu(info); | ||
44 | }); | ||
45 | |||
46 | ipcRenderer.on('settings-update', (e, data) => { | ||
47 | debug('Settings update received', data); | 43 | debug('Settings update received', data); |
48 | 44 | ||
49 | spellchecker.toggleSpellchecker(data.enableSpellchecking); | 45 | if (data.enableSpellchecking) { |
46 | switchDict(data.spellcheckerLanguage); | ||
47 | } else { | ||
48 | disableSpellchecker(); | ||
49 | } | ||
50 | |||
50 | window.franzSettings = data; | 51 | window.franzSettings = data; |
51 | }); | 52 | }); |
52 | 53 | ||
@@ -64,7 +65,7 @@ ipcRenderer.on('service-settings-update', (e, data) => { | |||
64 | } | 65 | } |
65 | }); | 66 | }); |
66 | 67 | ||
67 | // Needed for current implementation of electrons 'login' event | 68 | // Needed for current implementation of electrons 'login' event 🤦 |
68 | ipcRenderer.on('get-service-id', (event) => { | 69 | ipcRenderer.on('get-service-id', (event) => { |
69 | debug('Asking for service id', event); | 70 | debug('Asking for service id', event); |
70 | 71 | ||