diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-06-07 15:27:34 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-06-07 15:27:34 +0200 |
commit | 4a06f5e343b6274edbfa5818ba8b26c98f014cf3 (patch) | |
tree | 58ae02a29a63eb04f60409a0763eb2adf4dd7661 /src | |
parent | enable inline meetfranz.com subscriptions (diff) | |
parent | Fix spellchecker integration (diff) | |
download | ferdium-app-4a06f5e343b6274edbfa5818ba8b26c98f014cf3.tar.gz ferdium-app-4a06f5e343b6274edbfa5818ba8b26c98f014cf3.tar.zst ferdium-app-4a06f5e343b6274edbfa5818ba8b26c98f014cf3.zip |
Merge branch 'chore/electron-5.0.1' into release/5.2.0-beta.1
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 4 | ||||
-rw-r--r-- | src/index.js | 1 | ||||
-rw-r--r-- | src/models/Service.js | 4 | ||||
-rw-r--r-- | src/webview/contextMenu.js | 5 | ||||
-rw-r--r-- | src/webview/spellchecker.js | 18 |
5 files changed, 21 insertions, 11 deletions
diff --git a/src/index.html b/src/index.html index 5ce7f6a96..bf15e2d4e 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -17,7 +17,7 @@ | |||
17 | if (isDevMode) { | 17 | if (isDevMode) { |
18 | const debugging = require('debug'); | 18 | const debugging = require('debug'); |
19 | debugging.enable(process.env.DEBUG); | 19 | debugging.enable(process.env.DEBUG); |
20 | 20 | ||
21 | const debug = debugging('Index'); | 21 | const debug = debugging('Index'); |
22 | 22 | ||
23 | document.querySelector('body').classList.add('isDevMode'); | 23 | document.querySelector('body').classList.add('isDevMode'); |
@@ -36,7 +36,7 @@ | |||
36 | window._onLiveReloadFileChanged = (file) => { | 36 | window._onLiveReloadFileChanged = (file) => { |
37 | if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) { | 37 | if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) { |
38 | originalReloadBehaviour(file); | 38 | originalReloadBehaviour(file); |
39 | } else { | 39 | } else { |
40 | if (file.path.includes('/build/webview/')) { | 40 | if (file.path.includes('/build/webview/')) { |
41 | debug('Livereload: Reloading all webvies'); | 41 | debug('Livereload: Reloading all webvies'); |
42 | const webviews = document.querySelectorAll('webview').forEach(webview => webview.reload()); | 42 | const webviews = document.querySelectorAll('webview').forEach(webview => webview.reload()); |
diff --git a/src/index.js b/src/index.js index 3fe996aa7..49cf07618 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -180,6 +180,7 @@ const createWindow = () => { | |||
180 | backgroundColor: !settings.get('darkMode') ? '#3498db' : '#1E1E1E', | 180 | backgroundColor: !settings.get('darkMode') ? '#3498db' : '#1E1E1E', |
181 | webPreferences: { | 181 | webPreferences: { |
182 | nodeIntegration: true, | 182 | nodeIntegration: true, |
183 | webviewTag: true, | ||
183 | }, | 184 | }, |
184 | }); | 185 | }); |
185 | 186 | ||
diff --git a/src/models/Service.js b/src/models/Service.js index 8a2a8d3d8..a118c093e 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -183,7 +183,9 @@ export default class Service { | |||
183 | options, | 183 | options, |
184 | })); | 184 | })); |
185 | 185 | ||
186 | this.webview.addEventListener('did-start-loading', () => { | 186 | this.webview.addEventListener('did-start-loading', (event) => { |
187 | debug('Did start load', this.name, event); | ||
188 | |||
187 | this.hasCrashed = false; | 189 | this.hasCrashed = false; |
188 | this.isLoading = true; | 190 | this.isLoading = true; |
189 | this.isError = false; | 191 | this.isError = false; |
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js index a4a6ab899..967e8e667 100644 --- a/src/webview/contextMenu.js +++ b/src/webview/contextMenu.js | |||
@@ -280,12 +280,13 @@ const buildMenuTpl = (props, suggestions, isSpellcheckEnabled, defaultSpellcheck | |||
280 | }; | 280 | }; |
281 | 281 | ||
282 | export default function contextMenu(spellcheckProvider, isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage) { | 282 | export default function contextMenu(spellcheckProvider, isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage) { |
283 | webContents.on('context-menu', (e, props) => { | 283 | webContents.on('context-menu', async (e, props) => { |
284 | e.preventDefault(); | 284 | e.preventDefault(); |
285 | 285 | ||
286 | let suggestions = []; | 286 | let suggestions = []; |
287 | if (spellcheckProvider && props.misspelledWord) { | 287 | if (spellcheckProvider && props.misspelledWord) { |
288 | suggestions = spellcheckProvider.getSuggestion(props.misspelledWord); | 288 | debug('Mispelled word', props.misspelledWord); |
289 | suggestions = await spellcheckProvider.getSuggestion(props.misspelledWord); | ||
289 | 290 | ||
290 | debug('Suggestions', suggestions); | 291 | debug('Suggestions', suggestions); |
291 | } | 292 | } |
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js index 9158b3b94..64575753f 100644 --- a/src/webview/spellchecker.js +++ b/src/webview/spellchecker.js | |||
@@ -1,6 +1,8 @@ | |||
1 | import { webFrame } from 'electron'; | 1 | import { webFrame } from 'electron'; |
2 | import { SpellCheckerProvider } from 'electron-hunspell'; | 2 | import { attachSpellCheckProvider, SpellCheckerProvider } from 'electron-hunspell'; |
3 | import { ENVIRONMENT } from 'hunspell-asm'; | ||
3 | import path from 'path'; | 4 | import path from 'path'; |
5 | import { readFileSync } from 'fs'; | ||
4 | 6 | ||
5 | import { DICTIONARY_PATH } from '../config'; | 7 | import { DICTIONARY_PATH } from '../config'; |
6 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 8 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
@@ -10,11 +12,12 @@ const debug = require('debug')('Franz:spellchecker'); | |||
10 | let provider; | 12 | let provider; |
11 | let currentDict; | 13 | let currentDict; |
12 | let _isEnabled = false; | 14 | let _isEnabled = false; |
15 | let attached; | ||
13 | 16 | ||
14 | async function loadDictionary(locale) { | 17 | async function loadDictionary(locale) { |
15 | try { | 18 | try { |
16 | const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`); | 19 | const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`); |
17 | await provider.loadDictionary(locale, `${fileLocation}.dic`, `${fileLocation}.aff`); | 20 | await provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`)); |
18 | debug('Loaded dictionary', locale, 'from', fileLocation); | 21 | debug('Loaded dictionary', locale, 'from', fileLocation); |
19 | } catch (err) { | 22 | } catch (err) { |
20 | console.error('Could not load dictionary', err); | 23 | console.error('Could not load dictionary', err); |
@@ -41,7 +44,7 @@ export async function switchDict(locale) { | |||
41 | provider.unloadDictionary(locale); | 44 | provider.unloadDictionary(locale); |
42 | } | 45 | } |
43 | loadDictionary(locale); | 46 | loadDictionary(locale); |
44 | provider.switchDictionary(locale); | 47 | attached.switchLanguage(locale); |
45 | 48 | ||
46 | debug('Switched dictionary to', locale); | 49 | debug('Switched dictionary to', locale); |
47 | 50 | ||
@@ -58,12 +61,15 @@ export default async function initialize(languageCode = 'en-us') { | |||
58 | const locale = languageCode.toLowerCase(); | 61 | const locale = languageCode.toLowerCase(); |
59 | 62 | ||
60 | debug('Init spellchecker'); | 63 | debug('Init spellchecker'); |
61 | await provider.initialize(); | 64 | await provider.initialize({ environment: ENVIRONMENT.NODE }); |
62 | // await loadDictionaries(); | 65 | |
66 | debug('Attaching spellcheck provider'); | ||
67 | attached = await attachSpellCheckProvider(provider); | ||
63 | 68 | ||
64 | debug('Available spellchecker dictionaries', provider.availableDictionaries); | 69 | debug('Available spellchecker dictionaries', provider.availableDictionaries); |
65 | 70 | ||
66 | switchDict(locale); | 71 | attached.switchLanguage(locale); |
72 | console.log('seas oida', attached, provider); | ||
67 | 73 | ||
68 | return provider; | 74 | return provider; |
69 | } catch (err) { | 75 | } catch (err) { |