diff --git a/electron/src/interfaces/locale.ts b/electron/src/interfaces/locale.ts index ed3bf03cd39..48cf5766ce8 100644 --- a/electron/src/interfaces/locale.ts +++ b/electron/src/interfaces/locale.ts @@ -48,6 +48,7 @@ export type i18nLanguageIdentifier = | 'menuDelete' | 'menuDownloadDebugLogs' | 'menuEdit' + | 'menuEnableSpellChecking' | 'menuFullScreen' | 'menuHelp' | 'menuHideApp' diff --git a/electron/src/main.ts b/electron/src/main.ts index 5b2ee6e9ef9..a0ae1076f07 100644 --- a/electron/src/main.ts +++ b/electron/src/main.ts @@ -186,9 +186,9 @@ const initWindowStateKeeper = () => { }; if (showInFullScreen !== 'not-set-in-v0') { - stateKeeperOptions.fullScreen = showInFullScreen; - stateKeeperOptions.maximize = showInFullScreen; - isFullScreen = showInFullScreen; + stateKeeperOptions.fullScreen = showInFullScreen as boolean; + stateKeeperOptions.maximize = showInFullScreen as boolean; + isFullScreen = showInFullScreen as boolean; } return WindowStateKeeper(stateKeeperOptions); @@ -533,6 +533,8 @@ class ElectronWrapperInit { } }; + const enableSpellChecking = settings.restore(SettingsType.ENABLE_SPELL_CHECKING, true); + app.on('web-contents-created', async (_webviewEvent: ElectronEvent, contents: WebContents) => { if (proxyInfoArg?.origin && contents.session) { this.logger.log('Applying proxy settings on a webview...'); @@ -551,7 +553,7 @@ class ElectronWrapperInit { webPreferences.experimentalFeatures = true; webPreferences.nodeIntegration = false; webPreferences.preload = PRELOAD_RENDERER_JS; - webPreferences.spellcheck = true; + webPreferences.spellcheck = enableSpellChecking; webPreferences.webSecurity = true; }); break; @@ -581,15 +583,17 @@ class ElectronWrapperInit { }); } - try { - const availableSpellCheckerLanguages = contents.session.availableSpellCheckerLanguages; - const foundLanguages = locale.supportedSpellCheckLanguages[currentLocale].filter(language => - availableSpellCheckerLanguages.includes(language), - ); - contents.session.setSpellCheckerLanguages(foundLanguages); - } catch (error) { - logger.error(error); - contents.session.setSpellCheckerLanguages([]); + if (enableSpellChecking) { + try { + const availableSpellCheckerLanguages = contents.session.availableSpellCheckerLanguages; + const foundLanguages = locale.supportedSpellCheckLanguages[currentLocale].filter(language => + availableSpellCheckerLanguages.includes(language), + ); + contents.session.setSpellCheckerLanguages(foundLanguages); + } catch (error) { + logger.error(error); + contents.session.setSpellCheckerLanguages([]); + } } contents.session.setCertificateVerifyProc(setCertificateVerifyProc); diff --git a/electron/src/menu/system.ts b/electron/src/menu/system.ts index a2391362713..c1587a4bd41 100644 --- a/electron/src/menu/system.ts +++ b/electron/src/menu/system.ts @@ -78,6 +78,13 @@ const signOutTemplate: MenuItemConstructorOptions = { label: locale.getText('menuSignOut'), }; +const spellingTemplate: MenuItemConstructorOptions = { + checked: settings.restore(SettingsType.ENABLE_SPELL_CHECKING, true), + click: () => toggleSpellChecking(), + label: locale.getText('menuEnableSpellChecking'), + type: 'checkbox', +}; + const conversationTemplate: MenuItemConstructorOptions = { label: `&${locale.getText('menuConversation')}`, submenu: [ @@ -299,6 +306,8 @@ const darwinTemplate: MenuItemConstructorOptions = { role: 'unhide', }, separatorTemplate, + spellingTemplate, + separatorTemplate, signOutTemplate, { accelerator: 'Command+Q', @@ -319,6 +328,8 @@ const win32Template: MenuItemConstructorOptions = { localeTemplate, toggleAutoLaunchTemplate, separatorTemplate, + spellingTemplate, + separatorTemplate, signOutTemplate, { accelerator: 'Alt+F4', @@ -335,6 +346,8 @@ const linuxTemplate: MenuItemConstructorOptions = { separatorTemplate, localeTemplate, separatorTemplate, + spellingTemplate, + separatorTemplate, signOutTemplate, { accelerator: 'Ctrl+Q', @@ -356,8 +369,7 @@ const processMenu = (template: Iterable, language: S } }; -const changeLocale = async (language: SupportedI18nLanguage): Promise => { - locale.setLocale(language); +const showRestartMessageBox = async () => { const {response} = await dialog.showMessageBox({ buttons: [ locale.getText('restartLater'), @@ -368,10 +380,15 @@ const changeLocale = async (language: SupportedI18nLanguage): Promise => { type: 'info', }); if (response === 1) { - return EnvironmentUtil.platform.IS_MAC_OS ? lifecycle.quit() : lifecycle.relaunch(); + await (EnvironmentUtil.platform.IS_MAC_OS ? lifecycle.quit() : lifecycle.relaunch()); } }; +const changeLocale = async (language: SupportedI18nLanguage): Promise => { + locale.setLocale(language); + await showRestartMessageBox(); +}; + export const createMenu = (isFullScreen: boolean): Menu => { const menuTemplate = [conversationTemplate, editTemplate, windowTemplate, helpTemplate]; @@ -463,6 +480,12 @@ export const toggleMenuBar = (): void => { } }; +export const toggleSpellChecking = async (): Promise => { + const enableSpellChecking = settings.restore(SettingsType.ENABLE_SPELL_CHECKING, true); + settings.save(SettingsType.ENABLE_SPELL_CHECKING, !enableSpellChecking); + await showRestartMessageBox(); +}; + export const registerGlobalShortcuts = (): void => { if (!EnvironmentUtil.platform.IS_LINUX) { const muteAccelerator = 'CmdOrCtrl+Alt+M'; diff --git a/electron/src/settings/SettingsType.ts b/electron/src/settings/SettingsType.ts index fdd749f4002..386806b51cd 100644 --- a/electron/src/settings/SettingsType.ts +++ b/electron/src/settings/SettingsType.ts @@ -20,6 +20,7 @@ export enum SettingsType { AUTO_LAUNCH = 'shouldAutoLaunch', CUSTOM_WEBAPP_URL = 'customWebAppURL', + ENABLE_SPELL_CHECKING = 'enableSpellChecking', ENV = 'env', FULL_SCREEN = 'fullscreen', LOCALE = 'locale', diff --git a/package.json b/package.json index 7a36a428597..80c78cc3f0c 100644 --- a/package.json +++ b/package.json @@ -103,8 +103,8 @@ "typescript": "3.9.6", "webpack": "4.43.0", "webpack-cli": "3.3.12", - "wire-web-config-internal": "https://github.com/wireapp/wire-web-config-default#v0.24.85", - "wire-web-config-production": "https://github.com/wireapp/wire-web-config-wire#v0.24.86-0" + "wire-web-config-internal": "https://github.com/wireapp/wire-web-config-default#v0.25.1", + "wire-web-config-production": "https://github.com/wireapp/wire-web-config-wire#v0.25.2-0" }, "homepage": "https://wire.com", "husky": { diff --git a/yarn.lock b/yarn.lock index fda8a27ef1f..ceac365b281 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10990,16 +10990,16 @@ winreg@1.2.4: resolved "https://registry.npmjs.org/winreg/-/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b" integrity sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs= -"wire-web-config-internal@https://github.com/wireapp/wire-web-config-default#v0.24.85": - version "0.24.85" - resolved "https://github.com/wireapp/wire-web-config-default#cfbab94fee1c051ec47a7360209341e5558e8301" +"wire-web-config-internal@https://github.com/wireapp/wire-web-config-default#v0.25.1": + version "0.25.1" + resolved "https://github.com/wireapp/wire-web-config-default#78eb5b4728e64d794bc316f5a8395f699a0b5193" dependencies: adm-zip "0.4.14" sort-json "2.0.0" -"wire-web-config-production@https://github.com/wireapp/wire-web-config-wire#v0.24.86-0": - version "0.24.86-0" - resolved "https://github.com/wireapp/wire-web-config-wire#bb81e99e27e7aaa80eb55549709fff631daa459c" +"wire-web-config-production@https://github.com/wireapp/wire-web-config-wire#v0.25.2-0": + version "0.25.2-0" + resolved "https://github.com/wireapp/wire-web-config-wire#c8148412944e2211ac3e01ae896048ba69abc504" dependencies: adm-zip "0.4.14" sort-json "2.0.0"