Fixed dictionary initialization
This commit is contained in:
parent
326e1b9445
commit
50ef1f3c15
|
@ -47,7 +47,7 @@
|
|||
import Vue from 'vue';
|
||||
import l from '../chat/localize';
|
||||
import {GeneralSettings} from './common';
|
||||
import { getSafeLanguages } from './language';
|
||||
import { getSafeLanguages, updateSupportedLanguages } from './language';
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
|
||||
|
@ -89,7 +89,11 @@
|
|||
@Hook('mounted')
|
||||
async mounted(): Promise<void> {
|
||||
// top bar devtools
|
||||
// browserWindow.webContents.openDevTools({ mode: 'detach' });
|
||||
browserWindow.webContents.openDevTools({ mode: 'detach' });
|
||||
|
||||
updateSupportedLanguages(browserWindow.webContents.session.availableSpellCheckerLanguages);
|
||||
|
||||
// console.log('MOUNT DICTIONARIES', getSafeLanguages(this.settings.spellcheckLang), this.settings.spellcheckLang);
|
||||
|
||||
browserWindow.webContents.session.setSpellCheckerLanguages(getSafeLanguages(this.settings.spellcheckLang));
|
||||
|
||||
|
@ -103,6 +107,8 @@
|
|||
electron.ipcRenderer.on('quit', () => this.destroyAllTabs());
|
||||
|
||||
electron.ipcRenderer.on('update-dictionaries', (_e: Event, langs: string[]) => {
|
||||
// console.log('UPDATE DICTIONARIES', langs);
|
||||
|
||||
browserWindow.webContents.session.setSpellCheckerLanguages(langs);
|
||||
|
||||
for (const t of this.tabs) {
|
||||
|
@ -145,7 +151,7 @@
|
|||
document.addEventListener('click', () => this.activeTab!.view.webContents.focus());
|
||||
window.addEventListener('focus', () => this.activeTab!.view.webContents.focus());
|
||||
|
||||
console.log('SORTABLE', Sortable);
|
||||
// console.log('SORTABLE', Sortable);
|
||||
|
||||
Sortable.create(<HTMLElement>this.$refs['tabs'], {
|
||||
animation: 50,
|
||||
|
@ -216,8 +222,9 @@
|
|||
const view = new electron.remote.BrowserView({webPreferences: {webviewTag: true, nodeIntegration: true, spellcheck: true}});
|
||||
|
||||
// tab devtools
|
||||
// view.webContents.openDevTools();
|
||||
view.webContents.openDevTools();
|
||||
|
||||
// console.log('ADD TAB LANGUAGES', getSafeLanguages(this.settings.spellcheckLang), this.settings.spellcheckLang);
|
||||
view.webContents.session.setSpellCheckerLanguages(getSafeLanguages(this.settings.spellcheckLang));
|
||||
|
||||
view.setAutoResize({width: true, height: true});
|
||||
|
|
|
@ -9,7 +9,7 @@ export function getSafeLanguages(langs: string | string[] | undefined): string[]
|
|||
const initialCount = initialLanguages.length;
|
||||
const safeLanguages = _.filter(initialLanguages, (il) => (_.indexOf(supportedLanguages, il) >= 0));
|
||||
|
||||
if ((initialCount > 0) && (safeLanguages.length)) {
|
||||
if ((initialCount > 0) && (!safeLanguages.length)) {
|
||||
safeLanguages.push('en-GB');
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,8 @@ if(!settings.hwAcceleration) {
|
|||
|
||||
|
||||
export function updateSpellCheckerLanguages(langs: string[]): void {
|
||||
// console.log('UPDATESPELLCHECKERLANGUAGES', langs);
|
||||
|
||||
// console.log('Language support:', langs);
|
||||
electron.session.defaultSession.setSpellCheckerLanguages(langs);
|
||||
|
||||
|
@ -181,7 +183,11 @@ function createWindow(): Electron.BrowserWindow | undefined {
|
|||
const window = new electron.BrowserWindow(windowProperties);
|
||||
windows.push(window);
|
||||
|
||||
const safeLanguages = settings.spellcheckLang ? _.castArray(settings.spellcheckLang) : [];
|
||||
updateSupportedLanguages(electron.session.defaultSession.availableSpellCheckerLanguages);
|
||||
|
||||
const safeLanguages = getSafeLanguages(settings.spellcheckLang);
|
||||
|
||||
// console.log('CREATEWINDOW', safeLanguages);
|
||||
electron.session.defaultSession.setSpellCheckerLanguages(safeLanguages);
|
||||
window.webContents.session.setSpellCheckerLanguages(safeLanguages);
|
||||
|
||||
|
@ -247,8 +253,7 @@ function createWindow(): Electron.BrowserWindow | undefined {
|
|||
}
|
||||
);
|
||||
|
||||
|
||||
console.log('GOT HERE');
|
||||
// console.log('GOT HERE');
|
||||
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
window.loadFile(
|
||||
|
@ -290,8 +295,6 @@ function onReady(): void {
|
|||
log.transports.file.file = path.join(baseDir, 'log.txt');
|
||||
log.info('Starting application.');
|
||||
|
||||
updateSupportedLanguages(electron.session.defaultSession.availableSpellCheckerLanguages);
|
||||
|
||||
app.setAppUserModelId('com.squirrel.fchat.F-Chat');
|
||||
app.on('open-file', createWindow);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ This repository contains a heavily customized version of the mainline F-Chat 3.0
|
|||
* Message search matches character names
|
||||
* PM list shows characters' online status as a colored icon
|
||||
* Technical Details for Nerds
|
||||
* Upgraded to Electron 8.x
|
||||
* Upgraded to Electron 9.x
|
||||
* Replaced `node-spellchecker` with the built-in spellchecker that ships with Electron 8
|
||||
* Multi-language support for spell checking (Windows only – language is autodetected on MacOS)
|
||||
|
||||
|
|
Loading…
Reference in New Issue