aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-10-19 22:25:40 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-10-19 22:25:40 +0200
commit64824a692f566a01cc208dd82239ad643b69093e (patch)
tree37ef1a1cfd30333a1d5d169a9f1febc973c9f532
parentMerge pull request #134 from getferdi/l10n_develop (diff)
downloadferdium-app-64824a692f566a01cc208dd82239ad643b69093e.tar.gz
ferdium-app-64824a692f566a01cc208dd82239ad643b69093e.tar.zst
ferdium-app-64824a692f566a01cc208dd82239ad643b69093e.zip
Use electron-spellchecker instead of electron-hunspell
-rw-r--r--electron-builder.yml1
-rw-r--r--gulpfile.babel.js25
-rw-r--r--package-lock.json214
-rw-r--r--package.json1
-rw-r--r--src/config.js1
-rw-r--r--src/i18n/locales/zh-Hant.json4
-rw-r--r--src/webview/spellchecker.js78
7 files changed, 240 insertions, 84 deletions
diff --git a/electron-builder.yml b/electron-builder.yml
index df7d2223a..f6dceabce 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -53,6 +53,5 @@ protocols:
53 schemes: [ferdi] 53 schemes: [ferdi]
54 54
55asarUnpack: 55asarUnpack:
56 - ./dictionaries
57 - ./recipes 56 - ./recipes
58 - ./assets/images/taskbar 57 - ./assets/images/taskbar
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 4932d56f8..dda198c18 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -39,7 +39,6 @@ const paths = {
39 src: 'src', 39 src: 'src',
40 dest: 'build', 40 dest: 'build',
41 tmp: '.tmp', 41 tmp: '.tmp',
42 dictionaries: 'dictionaries',
43 package: `out/${config.version}`, 42 package: `out/${config.version}`,
44 recipes: { 43 recipes: {
45 src: 'recipes/*.tar.gz', 44 src: 'recipes/*.tar.gz',
@@ -194,29 +193,6 @@ export function webserver() {
194 ); 193 );
195} 194}
196 195
197export function dictionaries(done) {
198 const { SPELLCHECKER_LOCALES } = require('./build/i18n/languages');
199
200 let packages = '';
201 Object.keys(SPELLCHECKER_LOCALES).forEach((key) => {
202 packages = `${packages} hunspell-dict-${key}`;
203 });
204
205 _shell(
206 `npm install --prefix "${path.join(__dirname, 'temp')}" ${packages}`,
207 () => {
208 moveSync(
209 path.join(__dirname, 'temp', 'node_modules'),
210 path.join(__dirname, 'build', paths.dictionaries),
211 );
212
213 removeSync(path.join(__dirname, 'temp'));
214
215 done();
216 },
217 );
218}
219
220export function recipes() { 196export function recipes() {
221 return gulp.src(paths.recipes.src, { since: gulp.lastRun(recipes) }) 197 return gulp.src(paths.recipes.src, { since: gulp.lastRun(recipes) })
222 .pipe(gulp.dest(paths.recipes.dest)); 198 .pipe(gulp.dest(paths.recipes.dest));
@@ -230,7 +206,6 @@ const build = gulp.series(
230 clean, 206 clean,
231 gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages), 207 gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages),
232 gulp.parallel(html, scripts, styles, recipes, recipeInfo), 208 gulp.parallel(html, scripts, styles, recipes, recipeInfo),
233 dictionaries,
234); 209);
235export { build }; 210export { build };
236 211
diff --git a/package-lock.json b/package-lock.json
index e037c9133..2cbbe8939 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,6 +10,52 @@
10 "integrity": "sha512-GLyWIFBbGvpKPGo55JyRZAo4lVbnBiD52cKlw/0Vt+wnmKvWJkpZvsjVoaIolyBXDeAQKSicRtqFNPem9w0WYA==", 10 "integrity": "sha512-GLyWIFBbGvpKPGo55JyRZAo4lVbnBiD52cKlw/0Vt+wnmKvWJkpZvsjVoaIolyBXDeAQKSicRtqFNPem9w0WYA==",
11 "dev": true 11 "dev": true
12 }, 12 },
13 "@aabuhijleh/electron-remote": {
14 "version": "1.4.0",
15 "resolved": "https://registry.npmjs.org/@aabuhijleh/electron-remote/-/electron-remote-1.4.0.tgz",
16 "integrity": "sha512-EG4ZXxqbFY4lpX55vctwz14mFrEOcOHFCMLH5z5lOl6fiviTqscy86tSlKwEE3/o3ExtdPr2tECgCogYYL7d+g==",
17 "requires": {
18 "debug": "^2.5.1",
19 "hashids": "^1.1.1",
20 "lodash.get": "^4.4.2",
21 "pify": "^2.3.0",
22 "rxjs": "^5.0.0-beta.12",
23 "xmlhttprequest": "^1.8.0"
24 },
25 "dependencies": {
26 "debug": {
27 "version": "2.6.9",
28 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
29 "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
30 "requires": {
31 "ms": "2.0.0"
32 }
33 },
34 "ms": {
35 "version": "2.0.0",
36 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
37 "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
38 },
39 "pify": {
40 "version": "2.3.0",
41 "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
42 "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
43 },
44 "rxjs": {
45 "version": "5.5.12",
46 "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.12.tgz",
47 "integrity": "sha512-xx2itnL5sBbqeeiVgNPVuQQ1nC8Jp2WfNJhXWHmElW9YmrpS9UVnNzhP3EH3HFqexO5Tlp8GhYY+WEcqcVMvGw==",
48 "requires": {
49 "symbol-observable": "1.0.1"
50 }
51 },
52 "symbol-observable": {
53 "version": "1.0.1",
54 "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
55 "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
56 }
57 }
58 },
13 "@adlk/misty": { 59 "@adlk/misty": {
14 "version": "0.1.1", 60 "version": "0.1.1",
15 "resolved": "https://registry.npmjs.org/@adlk/misty/-/misty-0.1.1.tgz", 61 "resolved": "https://registry.npmjs.org/@adlk/misty/-/misty-0.1.1.tgz",
@@ -1518,6 +1564,14 @@
1518 } 1564 }
1519 } 1565 }
1520 }, 1566 },
1567 "@felixrieseberg/spellchecker": {
1568 "version": "4.0.10",
1569 "resolved": "https://registry.npmjs.org/@felixrieseberg/spellchecker/-/spellchecker-4.0.10.tgz",
1570 "integrity": "sha512-b+BlHcBXjx+W7yGNAtoVpAv8dvmAQ8Tp2YhNjqxIgocb6Wq1nKLl4jfu9DG60UWC0hTNvvQ74ny9ojiUFNqGSA==",
1571 "requires": {
1572 "nan": "^2.13.2"
1573 }
1574 },
1521 "@fimbul/bifrost": { 1575 "@fimbul/bifrost": {
1522 "version": "0.17.0", 1576 "version": "0.17.0",
1523 "resolved": "https://registry.npmjs.org/@fimbul/bifrost/-/bifrost-0.17.0.tgz", 1577 "resolved": "https://registry.npmjs.org/@fimbul/bifrost/-/bifrost-0.17.0.tgz",
@@ -5041,6 +5095,11 @@
5041 "integrity": "sha1-NqS6tZTAUP17UHvKDbMMLZKvT/I=", 5095 "integrity": "sha1-NqS6tZTAUP17UHvKDbMMLZKvT/I=",
5042 "dev": true 5096 "dev": true
5043 }, 5097 },
5098 "bcp47": {
5099 "version": "1.1.2",
5100 "resolved": "https://registry.npmjs.org/bcp47/-/bcp47-1.1.2.tgz",
5101 "integrity": "sha1-NUvjMH/9CEM6ePXh4glYRfifx/4="
5102 },
5044 "bcrypt-pbkdf": { 5103 "bcrypt-pbkdf": {
5045 "version": "1.0.2", 5104 "version": "1.0.2",
5046 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 5105 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
@@ -5973,6 +6032,31 @@
5973 "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz", 6032 "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz",
5974 "integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==" 6033 "integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q=="
5975 }, 6034 },
6035 "cld": {
6036 "version": "2.5.1",
6037 "resolved": "https://registry.npmjs.org/cld/-/cld-2.5.1.tgz",
6038 "integrity": "sha512-DwdvvcFVizwDdPCocoPPReFk3BwLEaTZ3RzFgJ4jLzsBzJKUC3cTna0ZmAZG4tFtMmQdl0ciso3+ijkH3OPZPA==",
6039 "requires": {
6040 "glob": "^5.0.10",
6041 "nan": "^2.9.2",
6042 "rimraf": "^2.4.0",
6043 "underscore": "^1.6.0"
6044 },
6045 "dependencies": {
6046 "glob": {
6047 "version": "5.0.15",
6048 "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz",
6049 "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=",
6050 "requires": {
6051 "inflight": "^1.0.4",
6052 "inherits": "2",
6053 "minimatch": "2 || 3",
6054 "once": "^1.3.0",
6055 "path-is-absolute": "^1.0.0"
6056 }
6057 }
6058 }
6059 },
5976 "cld3-asm": { 6060 "cld3-asm": {
5977 "version": "1.0.1", 6061 "version": "1.0.1",
5978 "resolved": "https://registry.npmjs.org/cld3-asm/-/cld3-asm-1.0.1.tgz", 6062 "resolved": "https://registry.npmjs.org/cld3-asm/-/cld3-asm-1.0.1.tgz",
@@ -8428,6 +8512,78 @@
8428 } 8512 }
8429 } 8513 }
8430 }, 8514 },
8515 "electron-spellchecker": {
8516 "version": "2.2.0",
8517 "resolved": "https://registry.npmjs.org/electron-spellchecker/-/electron-spellchecker-2.2.0.tgz",
8518 "integrity": "sha512-QkOVgjmjx6bDkqNshRTfVzEz9ctjiKVPZw77YLS0sQReP320QNtTXAKyo+01TORWk58RFT/LdxPZ/aejLdPmOA==",
8519 "requires": {
8520 "@aabuhijleh/electron-remote": "^1.4.0",
8521 "@felixrieseberg/spellchecker": "^4.0.10",
8522 "bcp47": "^1.1.2",
8523 "cld": "^2.5.1",
8524 "debug": "^4.1.1",
8525 "keyboard-layout": "^2.0.16",
8526 "lru-cache": "^5.1.1",
8527 "mkdirp": "^0.5.1",
8528 "pify": "^4.0.1",
8529 "rxjs": "^5.0.1",
8530 "rxjs-serial-subscription": "^0.1.1",
8531 "spawn-rx": "^2.0.7"
8532 },
8533 "dependencies": {
8534 "lru-cache": {
8535 "version": "5.1.1",
8536 "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
8537 "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
8538 "requires": {
8539 "yallist": "^3.0.2"
8540 }
8541 },
8542 "ms": {
8543 "version": "2.0.0",
8544 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
8545 "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
8546 },
8547 "pify": {
8548 "version": "4.0.1",
8549 "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
8550 "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
8551 },
8552 "rxjs": {
8553 "version": "5.5.12",
8554 "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.12.tgz",
8555 "integrity": "sha512-xx2itnL5sBbqeeiVgNPVuQQ1nC8Jp2WfNJhXWHmElW9YmrpS9UVnNzhP3EH3HFqexO5Tlp8GhYY+WEcqcVMvGw==",
8556 "requires": {
8557 "symbol-observable": "1.0.1"
8558 }
8559 },
8560 "spawn-rx": {
8561 "version": "2.0.12",
8562 "resolved": "https://registry.npmjs.org/spawn-rx/-/spawn-rx-2.0.12.tgz",
8563 "integrity": "sha512-gOPXiQQFQ9lTOLuys0iMn3jfxxv9c7zzwhbYLOEbQGvEShHVJ5sSR1oD3Daj88os7jKArDYT7rbOKdvNhe7iEg==",
8564 "requires": {
8565 "debug": "^2.5.1",
8566 "lodash.assign": "^4.2.0",
8567 "rxjs": "^5.1.1"
8568 },
8569 "dependencies": {
8570 "debug": {
8571 "version": "2.6.9",
8572 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
8573 "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
8574 "requires": {
8575 "ms": "2.0.0"
8576 }
8577 }
8578 }
8579 },
8580 "symbol-observable": {
8581 "version": "1.0.1",
8582 "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
8583 "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
8584 }
8585 }
8586 },
8431 "electron-to-chromium": { 8587 "electron-to-chromium": {
8432 "version": "1.3.261", 8588 "version": "1.3.261",
8433 "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.261.tgz", 8589 "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.261.tgz",
@@ -9321,6 +9477,11 @@
9321 "es5-ext": "~0.10.14" 9477 "es5-ext": "~0.10.14"
9322 } 9478 }
9323 }, 9479 },
9480 "event-kit": {
9481 "version": "2.5.3",
9482 "resolved": "https://registry.npmjs.org/event-kit/-/event-kit-2.5.3.tgz",
9483 "integrity": "sha512-b7Qi1JNzY4BfAYfnIRanLk0DOD1gdkWHT4GISIn8Q2tAf3LpU8SP2CMwWaq40imYoKWbtN4ZhbSRxvsnikooZQ=="
9484 },
9324 "eventemitter2": { 9485 "eventemitter2": {
9325 "version": "5.0.1", 9486 "version": "5.0.1",
9326 "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz", 9487 "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz",
@@ -13360,6 +13521,11 @@
13360 "minimalistic-assert": "^1.0.1" 13521 "minimalistic-assert": "^1.0.1"
13361 } 13522 }
13362 }, 13523 },
13524 "hashids": {
13525 "version": "1.2.2",
13526 "resolved": "https://registry.npmjs.org/hashids/-/hashids-1.2.2.tgz",
13527 "integrity": "sha512-dEHCG2LraR6PNvSGxosZHIRgxF5sNLOIBFEHbj8lfP9WWmu/PWPMzsip1drdVSOFi51N2pU7gZavrgn7sbGFuw=="
13528 },
13363 "haye": { 13529 "haye": {
13364 "version": "2.0.2", 13530 "version": "2.0.2",
13365 "resolved": "https://registry.npmjs.org/haye/-/haye-2.0.2.tgz", 13531 "resolved": "https://registry.npmjs.org/haye/-/haye-2.0.2.tgz",
@@ -15576,6 +15742,15 @@
15576 "integrity": "sha1-P55JkK3K0MaGwOcB92RYaPdfkes=", 15742 "integrity": "sha1-P55JkK3K0MaGwOcB92RYaPdfkes=",
15577 "dev": true 15743 "dev": true
15578 }, 15744 },
15745 "keyboard-layout": {
15746 "version": "2.0.16",
15747 "resolved": "https://registry.npmjs.org/keyboard-layout/-/keyboard-layout-2.0.16.tgz",
15748 "integrity": "sha512-eGrxmlV6jbm/mbPEOpYGuH53XEC7wIUj9ZxKcT2z9QHJ/RwrT9iVkvxka9zRxqHZHwQzcffgsa5OxoVAKnhK9w==",
15749 "requires": {
15750 "event-kit": "^2.0.0",
15751 "nan": "^2.13.2"
15752 }
15753 },
15579 "keyv": { 15754 "keyv": {
15580 "version": "3.1.0", 15755 "version": "3.1.0",
15581 "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", 15756 "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz",
@@ -16036,8 +16211,7 @@
16036 "lodash.assign": { 16211 "lodash.assign": {
16037 "version": "4.2.0", 16212 "version": "4.2.0",
16038 "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", 16213 "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
16039 "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", 16214 "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc="
16040 "dev": true
16041 }, 16215 },
16042 "lodash.camelcase": { 16216 "lodash.camelcase": {
16043 "version": "4.3.0", 16217 "version": "4.3.0",
@@ -16062,8 +16236,7 @@
16062 "lodash.get": { 16236 "lodash.get": {
16063 "version": "4.4.2", 16237 "version": "4.4.2",
16064 "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", 16238 "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
16065 "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", 16239 "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
16066 "dev": true
16067 }, 16240 },
16068 "lodash.includes": { 16241 "lodash.includes": {
16069 "version": "4.3.0", 16242 "version": "4.3.0",
@@ -21457,6 +21630,29 @@
21457 "tslib": "^1.9.0" 21630 "tslib": "^1.9.0"
21458 } 21631 }
21459 }, 21632 },
21633 "rxjs-serial-subscription": {
21634 "version": "0.1.1",
21635 "resolved": "https://registry.npmjs.org/rxjs-serial-subscription/-/rxjs-serial-subscription-0.1.1.tgz",
21636 "integrity": "sha1-pCsdsL8QlLCSMRkeJ3jKP8+e0Uc=",
21637 "requires": {
21638 "rxjs": "^5.0.0-beta.12"
21639 },
21640 "dependencies": {
21641 "rxjs": {
21642 "version": "5.5.12",
21643 "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.12.tgz",
21644 "integrity": "sha512-xx2itnL5sBbqeeiVgNPVuQQ1nC8Jp2WfNJhXWHmElW9YmrpS9UVnNzhP3EH3HFqexO5Tlp8GhYY+WEcqcVMvGw==",
21645 "requires": {
21646 "symbol-observable": "1.0.1"
21647 }
21648 },
21649 "symbol-observable": {
21650 "version": "1.0.1",
21651 "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
21652 "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
21653 }
21654 }
21655 },
21460 "safe-buffer": { 21656 "safe-buffer": {
21461 "version": "5.2.0", 21657 "version": "5.2.0",
21462 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", 21658 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
@@ -24198,6 +24394,11 @@
24198 "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", 24394 "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz",
24199 "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" 24395 "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo="
24200 }, 24396 },
24397 "underscore": {
24398 "version": "1.9.1",
24399 "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
24400 "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg=="
24401 },
24201 "undertaker": { 24402 "undertaker": {
24202 "version": "1.2.1", 24403 "version": "1.2.1",
24203 "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz", 24404 "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz",
@@ -25582,6 +25783,11 @@
25582 "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", 25783 "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==",
25583 "dev": true 25784 "dev": true
25584 }, 25785 },
25786 "xmlhttprequest": {
25787 "version": "1.8.0",
25788 "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
25789 "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw="
25790 },
25585 "xmlhttprequest-ssl": { 25791 "xmlhttprequest-ssl": {
25586 "version": "1.5.3", 25792 "version": "1.5.3",
25587 "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", 25793 "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz",
diff --git a/package.json b/package.json
index 09675fa62..526a16947 100644
--- a/package.json
+++ b/package.json
@@ -72,6 +72,7 @@
72 "electron-process-manager": "git+https://git@github.com/dizer/electron-process-manager.git", 72 "electron-process-manager": "git+https://git@github.com/dizer/electron-process-manager.git",
73 "electron-process-reporter": "git+https://git@github.com/dizer/electron-process-reporter.git", 73 "electron-process-reporter": "git+https://git@github.com/dizer/electron-process-reporter.git",
74 "electron-react-titlebar": "0.8.1", 74 "electron-react-titlebar": "0.8.1",
75 "electron-spellchecker": "2.2.0",
75 "electron-updater": "4.1.2", 76 "electron-updater": "4.1.2",
76 "electron-window-state": "5.0.3", 77 "electron-window-state": "5.0.3",
77 "fs-extra": "7.0.1", 78 "fs-extra": "7.0.1",
diff --git a/src/config.js b/src/config.js
index b1dbab1ff..e762f879f 100644
--- a/src/config.js
+++ b/src/config.js
@@ -116,7 +116,6 @@ export const LOCAL_SERVER = 'You are using Ferdi without a server';
116export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); 116export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config');
117 117
118// Replacing app.asar is not beautiful but unforunately necessary 118// Replacing app.asar is not beautiful but unforunately necessary
119export const DICTIONARY_PATH = asarPath(path.join(__dirname, 'dictionaries'));
120export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes')); 119export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes'));
121 120
122export const ALLOWED_PROTOCOLS = [ 121export const ALLOWED_PROTOCOLS = [
diff --git a/src/i18n/locales/zh-Hant.json b/src/i18n/locales/zh-Hant.json
index c64830574..678554c05 100644
--- a/src/i18n/locales/zh-Hant.json
+++ b/src/i18n/locales/zh-Hant.json
@@ -54,7 +54,6 @@
54 "locked.invalidCredentials": "Password invalid", 54 "locked.invalidCredentials": "Password invalid",
55 "locked.password.label": "Password", 55 "locked.password.label": "Password",
56 "locked.submit.label": "Unlock", 56 "locked.submit.label": "Unlock",
57 "login.changeServer": "Change server",
58 "login.customServerQuestion": "Using a custom Ferdi server?", 57 "login.customServerQuestion": "Using a custom Ferdi server?",
59 "login.customServerSuggestion": "Try importing your Franz account", 58 "login.customServerSuggestion": "Try importing your Franz account",
60 "login.email.label": "電子郵件信箱", 59 "login.email.label": "電子郵件信箱",
@@ -187,7 +186,6 @@
187 "services.getStarted": "開始使用", 186 "services.getStarted": "開始使用",
188 "services.login": "Please login to use Ferdi.", 187 "services.login": "Please login to use Ferdi.",
189 "services.serverInfo": "Optionally, you can change your Ferdi server by clicking the cog in the bottom left corner.", 188 "services.serverInfo": "Optionally, you can change your Ferdi server by clicking the cog in the bottom left corner.",
190 "services.serverless": "Use Ferdi without an Account",
191 "services.welcome": "歡迎使用 Ferdi", 189 "services.welcome": "歡迎使用 Ferdi",
192 "settings.account.account.editButton": "更改帳戶資訊", 190 "settings.account.account.editButton": "更改帳戶資訊",
193 "settings.account.accountType.basic": "基本帳戶", 191 "settings.account.accountType.basic": "基本帳戶",
@@ -356,8 +354,6 @@
356 "settings.team.headline": "Team", 354 "settings.team.headline": "Team",
357 "settings.team.intro": "You and your team use Ferdi? You can now manage Premium subscriptions for as many colleagues, friends or family members as you want, all from within one account.", 355 "settings.team.intro": "You and your team use Ferdi? You can now manage Premium subscriptions for as many colleagues, friends or family members as you want, all from within one account.",
358 "settings.team.manageAction": "Manage your Team on getferdi.com", 356 "settings.team.manageAction": "Manage your Team on getferdi.com",
359 "settings.team.teamsUnavailible": "Teams are unavailible",
360 "settings.team.teamsUnavailibleInfo": "Teams are currently only availible when using the Franz Server and after paying for Franz Professional. Please change your server to https://api.franzinfra.com to use teams.",
361 "settings.team.upgradeAction": "Upgrade your Account", 357 "settings.team.upgradeAction": "Upgrade your Account",
362 "settings.user.form.accountType.company": "公司", 358 "settings.user.form.accountType.company": "公司",
363 "settings.user.form.accountType.individual": "個人", 359 "settings.user.form.accountType.individual": "個人",
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js
index 1cb449110..2062429fd 100644
--- a/src/webview/spellchecker.js
+++ b/src/webview/spellchecker.js
@@ -1,36 +1,21 @@
1import { webFrame } from 'electron'; 1import { webFrame } from 'electron';
2import { attachSpellCheckProvider, SpellCheckerProvider } from 'electron-hunspell'; 2import {SpellCheckHandler, ContextMenuListener, ContextMenuBuilder} from 'electron-spellchecker';
3import path from 'path';
4import { readFileSync } from 'fs';
5 3
6import { DICTIONARY_PATH } from '../config';
7import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 4import { SPELLCHECKER_LOCALES } from '../i18n/languages';
8 5
9const debug = require('debug')('Ferdi:spellchecker'); 6const debug = require('debug')('Franz:spellchecker');
10 7
11let provider; 8let handler;
12let currentDict; 9let currentDict;
10let contextMenuBuilder;
13let _isEnabled = false; 11let _isEnabled = false;
14let attached;
15 12
16const DEFAULT_LOCALE = 'en-us'; 13export async function switchDict(locale) {
17
18async function loadDictionary(locale) {
19 try {
20 const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`);
21 debug('Loaded dictionary', locale, 'from', fileLocation);
22 return provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`));
23 } catch (err) {
24 console.error('Could not load dictionary', err);
25 }
26}
27
28export async function switchDict(locale = DEFAULT_LOCALE) {
29 try { 14 try {
30 debug('Trying to load dictionary', locale); 15 debug('Trying to load dictionary', locale);
31 16
32 if (!provider) { 17 if (!handler) {
33 console.warn('SpellcheckProvider not initialized'); 18 console.warn('SpellcheckHandler not initialized');
34 19
35 return; 20 return;
36 } 21 }
@@ -41,11 +26,7 @@ export async function switchDict(locale = DEFAULT_LOCALE) {
41 return; 26 return;
42 } 27 }
43 28
44 if (currentDict) { 29 handler.switchLanguage(locale);
45 provider.unloadDictionary(locale);
46 }
47 await loadDictionary(locale);
48 await attached.switchLanguage(locale);
49 30
50 debug('Switched dictionary to', locale); 31 debug('Switched dictionary to', locale);
51 32
@@ -56,34 +37,22 @@ export async function switchDict(locale = DEFAULT_LOCALE) {
56 } 37 }
57} 38}
58 39
59export function getSpellcheckerLocaleByFuzzyIdentifier(identifier) { 40export default async function initialize(languageCode = 'en-us') {
60 const locales = Object.keys(SPELLCHECKER_LOCALES).filter(key => key === identifier.toLowerCase() || key.split('-')[0] === identifier.toLowerCase());
61
62 if (locales.length >= 1) {
63 return locales[0];
64 }
65
66 return null;
67}
68
69export default async function initialize(languageCode = DEFAULT_LOCALE) {
70 try { 41 try {
71 provider = new SpellCheckerProvider(); 42 handler = new SpellCheckHandler();
72 const locale = getSpellcheckerLocaleByFuzzyIdentifier(languageCode); 43 handler.attachToInput();
44 const locale = languageCode.toLowerCase();
73 45
74 debug('Init spellchecker'); 46 debug('Init spellchecker');
75 await provider.initialize();
76
77 debug('Attaching spellcheck provider');
78 attached = await attachSpellCheckProvider(provider);
79
80 const availableDictionaries = await provider.getAvailableDictionaries();
81 47
82 debug('Available spellchecker dictionaries', availableDictionaries); 48 switchDict(locale);
83 49
84 await switchDict(locale); 50 contextMenuBuilder = new ContextMenuBuilder(handler);
51 new ContextMenuListener((info) => {
52 contextMenuBuilder.showPopupMenu(info);
53 });
85 54
86 return provider; 55 return handler;
87 } catch (err) { 56 } catch (err) {
88 console.error(err); 57 console.error(err);
89 return false; 58 return false;
@@ -96,8 +65,19 @@ export function isEnabled() {
96 65
97export function disable() { 66export function disable() {
98 if (isEnabled()) { 67 if (isEnabled()) {
68 handler.unsubscribe();
99 webFrame.setSpellCheckProvider(currentDict, { spellCheck: () => true }); 69 webFrame.setSpellCheckProvider(currentDict, { spellCheck: () => true });
100 _isEnabled = false; 70 _isEnabled = false;
101 currentDict = null; 71 currentDict = null;
102 } 72 }
103} 73}
74
75export function getSpellcheckerLocaleByFuzzyIdentifier(identifier) {
76 const locales = Object.keys(SPELLCHECKER_LOCALES).filter(key => key === identifier.toLowerCase() || key.split('-')[0] === identifier.toLowerCase());
77
78 if (locales.length >= 1) {
79 return locales[0];
80 }
81
82 return null;
83}