aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-06-25 13:00:16 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-06-25 13:00:16 +0200
commitc1e592e6f530eadf730a77e4fa551f4eb0dbf337 (patch)
tree4bf073bd1306fd1e1a62be59fe8ecb661ae91590
parentUpdate CHANGELOG.md (diff)
downloadferdium-app-c1e592e6f530eadf730a77e4fa551f4eb0dbf337.tar.gz
ferdium-app-c1e592e6f530eadf730a77e4fa551f4eb0dbf337.tar.zst
ferdium-app-c1e592e6f530eadf730a77e4fa551f4eb0dbf337.zip
Revert: fix spellchecker
-rw-r--r--package-lock.json50
-rw-r--r--package.json2
-rw-r--r--src/webview/contextMenu.js5
-rw-r--r--src/webview/spellchecker.js17
4 files changed, 25 insertions, 49 deletions
diff --git a/package-lock.json b/package-lock.json
index 53b46196a..b4d86c5e1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7043,12 +7043,14 @@
7043 } 7043 }
7044 }, 7044 },
7045 "electron-hunspell": { 7045 "electron-hunspell": {
7046 "version": "1.0.0-beta.7", 7046 "version": "0.1.1",
7047 "resolved": "https://registry.npmjs.org/electron-hunspell/-/electron-hunspell-1.0.0-beta.7.tgz", 7047 "resolved": "https://registry.npmjs.org/electron-hunspell/-/electron-hunspell-0.1.1.tgz",
7048 "integrity": "sha512-BByCXqU8sZbuzyoxKcBYjycp8ORiqjeYZd2OT8RNjVW+XGPmZkHewXUu4tUa1IXW6ij6IqojV5kr+xhYKLN1DA==", 7048 "integrity": "sha512-B3nOQqHexIX+8bz72FZkNk+iFBrdqS9DpV2SaH+t7T9SLbONBVBRLJ2Jj2ytXFUzvw81q7vz2dfxPCddh/E3ww==",
7049 "requires": { 7049 "requires": {
7050 "hunspell-asm": "^2.0.0", 7050 "hunspell-asm": "1.0.2",
7051 "tslib": "1.9.3" 7051 "lodash": "^4.17.11",
7052 "tslib": "1.9.3",
7053 "unixify": "1.0.0"
7052 } 7054 }
7053 }, 7055 },
7054 "electron-is-dev": { 7056 "electron-is-dev": {
@@ -11379,34 +11381,14 @@
11379 } 11381 }
11380 }, 11382 },
11381 "hunspell-asm": { 11383 "hunspell-asm": {
11382 "version": "2.0.0", 11384 "version": "1.0.2",
11383 "resolved": "https://registry.npmjs.org/hunspell-asm/-/hunspell-asm-2.0.0.tgz", 11385 "resolved": "https://registry.npmjs.org/hunspell-asm/-/hunspell-asm-1.0.2.tgz",
11384 "integrity": "sha512-FMIUBpy+bRREFAvC63RcYEK9U6+FdlEojGSVsvMTpuZ2CekYyUBwEfG4+ExIQOQyEN0U6f1MoVgrFqvgPNSA2g==", 11386 "integrity": "sha512-UTLBvc0yZiIcHl9qrgxnFTZbX3zF4CprzEY+u+N0iXlUKZnUJRIgvgppTdgiQTsucm5b0aN/rHsgXz2q/0kBRA==",
11385 "requires": { 11387 "requires": {
11386 "emscripten-wasm-loader": "^2.2.3", 11388 "emscripten-wasm-loader": "^1.0.0",
11387 "nanoid": "^2.0.1", 11389 "nanoid": "^1.0.2",
11388 "tslib": "^1.9.3", 11390 "tslib": "^1.9.0",
11389 "unixify": "^1.0.0" 11391 "unixify": "^1.0.0"
11390 },
11391 "dependencies": {
11392 "emscripten-wasm-loader": {
11393 "version": "2.2.3",
11394 "resolved": "https://registry.npmjs.org/emscripten-wasm-loader/-/emscripten-wasm-loader-2.2.3.tgz",
11395 "integrity": "sha512-//gI0afvtVnY7smttrPOW/BM+pTJLmdIcXAQV3fgRdQ0o6wm2vdSI0kjLYVOeo/rbtRsGgVuMLu6fT+O//EfaA==",
11396 "requires": {
11397 "getroot": "^1.0.0",
11398 "nanoid": "^1.3.4",
11399 "tslib": "^1.9.3",
11400 "unixify": "^1.0.0"
11401 },
11402 "dependencies": {
11403 "nanoid": {
11404 "version": "1.3.4",
11405 "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.3.4.tgz",
11406 "integrity": "sha512-4ug4BsuHxiVHoRUe1ud6rUFT3WUMmjXt1W0quL0CviZQANdan7D8kqN5/maw53hmAApY/jfzMRkC57BNNs60ZQ=="
11407 }
11408 }
11409 }
11410 } 11392 }
11411 }, 11393 },
11412 "husky": { 11394 "husky": {
@@ -14385,9 +14367,9 @@
14385 "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==" 14367 "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw=="
14386 }, 14368 },
14387 "nanoid": { 14369 "nanoid": {
14388 "version": "2.0.3", 14370 "version": "1.3.4",
14389 "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.0.3.tgz", 14371 "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.3.4.tgz",
14390 "integrity": "sha512-NbaoqdhIYmY6FXDRB4eYtDVC9Z9eCbn8TyaiC16LNKtpPv/aqa0tOPD8y6gNE4yUNnaZ7LLhYtXOev/6+cBtfw==" 14372 "integrity": "sha512-4ug4BsuHxiVHoRUe1ud6rUFT3WUMmjXt1W0quL0CviZQANdan7D8kqN5/maw53hmAApY/jfzMRkC57BNNs60ZQ=="
14391 }, 14373 },
14392 "nanomatch": { 14374 "nanomatch": {
14393 "version": "1.2.13", 14375 "version": "1.2.13",
diff --git a/package.json b/package.json
index e982c7542..517dd1c6f 100644
--- a/package.json
+++ b/package.json
@@ -47,7 +47,7 @@
47 "du": "^0.1.0", 47 "du": "^0.1.0",
48 "electron-dl": "1.12.0", 48 "electron-dl": "1.12.0",
49 "electron-fetch": "1.3.0", 49 "electron-fetch": "1.3.0",
50 "electron-hunspell": "1.0.0-beta.7", 50 "electron-hunspell": "0.1.1",
51 "electron-is-dev": "1.0.1", 51 "electron-is-dev": "1.0.1",
52 "electron-react-titlebar": "0.8.1", 52 "electron-react-titlebar": "0.8.1",
53 "electron-updater": "4.0.6", 53 "electron-updater": "4.0.6",
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js
index 967e8e667..a4a6ab899 100644
--- a/src/webview/contextMenu.js
+++ b/src/webview/contextMenu.js
@@ -280,13 +280,12 @@ const buildMenuTpl = (props, suggestions, isSpellcheckEnabled, defaultSpellcheck
280}; 280};
281 281
282export default function contextMenu(spellcheckProvider, isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage) { 282export default function contextMenu(spellcheckProvider, isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage) {
283 webContents.on('context-menu', async (e, props) => { 283 webContents.on('context-menu', (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 debug('Mispelled word', props.misspelledWord); 288 suggestions = spellcheckProvider.getSuggestion(props.misspelledWord);
289 suggestions = await spellcheckProvider.getSuggestion(props.misspelledWord);
290 289
291 debug('Suggestions', suggestions); 290 debug('Suggestions', suggestions);
292 } 291 }
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js
index 417d1ea1a..9158b3b94 100644
--- a/src/webview/spellchecker.js
+++ b/src/webview/spellchecker.js
@@ -1,8 +1,6 @@
1import { webFrame } from 'electron'; 1import { webFrame } from 'electron';
2import { attachSpellCheckProvider, SpellCheckerProvider } from 'electron-hunspell'; 2import { SpellCheckerProvider } from 'electron-hunspell';
3import { ENVIRONMENT } from 'hunspell-asm';
4import path from 'path'; 3import path from 'path';
5import { readFileSync } from 'fs';
6 4
7import { DICTIONARY_PATH } from '../config'; 5import { DICTIONARY_PATH } from '../config';
8import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 6import { SPELLCHECKER_LOCALES } from '../i18n/languages';
@@ -12,12 +10,11 @@ const debug = require('debug')('Franz:spellchecker');
12let provider; 10let provider;
13let currentDict; 11let currentDict;
14let _isEnabled = false; 12let _isEnabled = false;
15let attached;
16 13
17async function loadDictionary(locale) { 14async function loadDictionary(locale) {
18 try { 15 try {
19 const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`); 16 const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`);
20 await provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`)); 17 await provider.loadDictionary(locale, `${fileLocation}.dic`, `${fileLocation}.aff`);
21 debug('Loaded dictionary', locale, 'from', fileLocation); 18 debug('Loaded dictionary', locale, 'from', fileLocation);
22 } catch (err) { 19 } catch (err) {
23 console.error('Could not load dictionary', err); 20 console.error('Could not load dictionary', err);
@@ -44,7 +41,7 @@ export async function switchDict(locale) {
44 provider.unloadDictionary(locale); 41 provider.unloadDictionary(locale);
45 } 42 }
46 loadDictionary(locale); 43 loadDictionary(locale);
47 attached.switchLanguage(locale); 44 provider.switchDictionary(locale);
48 45
49 debug('Switched dictionary to', locale); 46 debug('Switched dictionary to', locale);
50 47
@@ -61,14 +58,12 @@ export default async function initialize(languageCode = 'en-us') {
61 const locale = languageCode.toLowerCase(); 58 const locale = languageCode.toLowerCase();
62 59
63 debug('Init spellchecker'); 60 debug('Init spellchecker');
64 await provider.initialize({ environment: ENVIRONMENT.NODE }); 61 await provider.initialize();
65 62 // await loadDictionaries();
66 debug('Attaching spellcheck provider');
67 attached = await attachSpellCheckProvider(provider);
68 63
69 debug('Available spellchecker dictionaries', provider.availableDictionaries); 64 debug('Available spellchecker dictionaries', provider.availableDictionaries);
70 65
71 attached.switchLanguage(locale); 66 switchDict(locale);
72 67
73 return provider; 68 return provider;
74 } catch (err) { 69 } catch (err) {