From 5828062915dfa62318f1570351887a750f65e8c1 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 24 May 2019 10:04:03 +0200 Subject: feat(App): Bump electron to 5.0.1 --- src/index.html | 4 ++-- src/index.js | 1 + src/models/Service.js | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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 @@ if (isDevMode) { const debugging = require('debug'); debugging.enable(process.env.DEBUG); - + const debug = debugging('Index'); document.querySelector('body').classList.add('isDevMode'); @@ -36,7 +36,7 @@ window._onLiveReloadFileChanged = (file) => { if (!file.path.includes('/build/webview/') && !file.path.includes('/build/index.js') && !file.path.includes('/build/electron/')) { originalReloadBehaviour(file); - } else { + } else { if (file.path.includes('/build/webview/')) { debug('Livereload: Reloading all webvies'); 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 = () => { backgroundColor: !settings.get('darkMode') ? '#3498db' : '#1E1E1E', webPreferences: { nodeIntegration: true, + webviewTag: true, }, }); 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 { options, })); - this.webview.addEventListener('did-start-loading', () => { + this.webview.addEventListener('did-start-loading', (event) => { + debug('Did start load', this.name, event); + this.hasCrashed = false; this.isLoading = true; this.isError = false; -- cgit v1.2.3-70-g09d2 From 830b6f88f3d30708cf0264375b8db5b2e5714218 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 5 Jun 2019 17:18:52 +0200 Subject: Fix spellchecker integration --- package-lock.json | 50 ++++++++++++++++++++++++++++++--------------- package.json | 2 +- src/webview/contextMenu.js | 5 +++-- src/webview/spellchecker.js | 18 ++++++++++------ 4 files changed, 50 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/package-lock.json b/package-lock.json index 54f49fd0d..2a2c83bc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7036,14 +7036,12 @@ } }, "electron-hunspell": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/electron-hunspell/-/electron-hunspell-0.1.1.tgz", - "integrity": "sha512-B3nOQqHexIX+8bz72FZkNk+iFBrdqS9DpV2SaH+t7T9SLbONBVBRLJ2Jj2ytXFUzvw81q7vz2dfxPCddh/E3ww==", + "version": "1.0.0-beta.7", + "resolved": "https://registry.npmjs.org/electron-hunspell/-/electron-hunspell-1.0.0-beta.7.tgz", + "integrity": "sha512-BByCXqU8sZbuzyoxKcBYjycp8ORiqjeYZd2OT8RNjVW+XGPmZkHewXUu4tUa1IXW6ij6IqojV5kr+xhYKLN1DA==", "requires": { - "hunspell-asm": "1.0.2", - "lodash": "^4.17.11", - "tslib": "1.9.3", - "unixify": "1.0.0" + "hunspell-asm": "^2.0.0", + "tslib": "1.9.3" } }, "electron-is-dev": { @@ -11374,14 +11372,34 @@ } }, "hunspell-asm": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hunspell-asm/-/hunspell-asm-1.0.2.tgz", - "integrity": "sha512-UTLBvc0yZiIcHl9qrgxnFTZbX3zF4CprzEY+u+N0iXlUKZnUJRIgvgppTdgiQTsucm5b0aN/rHsgXz2q/0kBRA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hunspell-asm/-/hunspell-asm-2.0.0.tgz", + "integrity": "sha512-FMIUBpy+bRREFAvC63RcYEK9U6+FdlEojGSVsvMTpuZ2CekYyUBwEfG4+ExIQOQyEN0U6f1MoVgrFqvgPNSA2g==", "requires": { - "emscripten-wasm-loader": "^1.0.0", - "nanoid": "^1.0.2", - "tslib": "^1.9.0", + "emscripten-wasm-loader": "^2.2.3", + "nanoid": "^2.0.1", + "tslib": "^1.9.3", "unixify": "^1.0.0" + }, + "dependencies": { + "emscripten-wasm-loader": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/emscripten-wasm-loader/-/emscripten-wasm-loader-2.2.3.tgz", + "integrity": "sha512-//gI0afvtVnY7smttrPOW/BM+pTJLmdIcXAQV3fgRdQ0o6wm2vdSI0kjLYVOeo/rbtRsGgVuMLu6fT+O//EfaA==", + "requires": { + "getroot": "^1.0.0", + "nanoid": "^1.3.4", + "tslib": "^1.9.3", + "unixify": "^1.0.0" + }, + "dependencies": { + "nanoid": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.3.4.tgz", + "integrity": "sha512-4ug4BsuHxiVHoRUe1ud6rUFT3WUMmjXt1W0quL0CviZQANdan7D8kqN5/maw53hmAApY/jfzMRkC57BNNs60ZQ==" + } + } + } } }, "husky": { @@ -14360,9 +14378,9 @@ "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==" }, "nanoid": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.3.4.tgz", - "integrity": "sha512-4ug4BsuHxiVHoRUe1ud6rUFT3WUMmjXt1W0quL0CviZQANdan7D8kqN5/maw53hmAApY/jfzMRkC57BNNs60ZQ==" + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.0.3.tgz", + "integrity": "sha512-NbaoqdhIYmY6FXDRB4eYtDVC9Z9eCbn8TyaiC16LNKtpPv/aqa0tOPD8y6gNE4yUNnaZ7LLhYtXOev/6+cBtfw==" }, "nanomatch": { "version": "1.2.13", diff --git a/package.json b/package.json index 245eb71d6..d03de2f20 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "du": "^0.1.0", "electron-dl": "1.12.0", "electron-fetch": "1.3.0", - "electron-hunspell": "0.1.1", + "electron-hunspell": "1.0.0-beta.7", "electron-is-dev": "1.0.1", "electron-react-titlebar": "0.8.1", "electron-updater": "4.0.6", 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 }; export default function contextMenu(spellcheckProvider, isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage) { - webContents.on('context-menu', (e, props) => { + webContents.on('context-menu', async (e, props) => { e.preventDefault(); let suggestions = []; if (spellcheckProvider && props.misspelledWord) { - suggestions = spellcheckProvider.getSuggestion(props.misspelledWord); + debug('Mispelled word', props.misspelledWord); + suggestions = await spellcheckProvider.getSuggestion(props.misspelledWord); debug('Suggestions', suggestions); } 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 @@ import { webFrame } from 'electron'; -import { SpellCheckerProvider } from 'electron-hunspell'; +import { attachSpellCheckProvider, SpellCheckerProvider } from 'electron-hunspell'; +import { ENVIRONMENT } from 'hunspell-asm'; import path from 'path'; +import { readFileSync } from 'fs'; import { DICTIONARY_PATH } from '../config'; import { SPELLCHECKER_LOCALES } from '../i18n/languages'; @@ -10,11 +12,12 @@ const debug = require('debug')('Franz:spellchecker'); let provider; let currentDict; let _isEnabled = false; +let attached; async function loadDictionary(locale) { try { const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`); - await provider.loadDictionary(locale, `${fileLocation}.dic`, `${fileLocation}.aff`); + await provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`)); debug('Loaded dictionary', locale, 'from', fileLocation); } catch (err) { console.error('Could not load dictionary', err); @@ -41,7 +44,7 @@ export async function switchDict(locale) { provider.unloadDictionary(locale); } loadDictionary(locale); - provider.switchDictionary(locale); + attached.switchLanguage(locale); debug('Switched dictionary to', locale); @@ -58,12 +61,15 @@ export default async function initialize(languageCode = 'en-us') { const locale = languageCode.toLowerCase(); debug('Init spellchecker'); - await provider.initialize(); - // await loadDictionaries(); + await provider.initialize({ environment: ENVIRONMENT.NODE }); + + debug('Attaching spellcheck provider'); + attached = await attachSpellCheckProvider(provider); debug('Available spellchecker dictionaries', provider.availableDictionaries); - switchDict(locale); + attached.switchLanguage(locale); + console.log('seas oida', attached, provider); return provider; } catch (err) { -- cgit v1.2.3-70-g09d2