import utils from "../../../services/utils.js"; import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; const TPL = `

Spell check

These options apply only for desktop builds, browsers will use their own native spell check. App restart is required after change.


Multiple languages can be separated by comma, e.g. en-US, de-DE, cs. Changes to the spell check options will take effect after application restart.

Available language codes:

`; export default class SpellcheckOptions { constructor() { $("#options-spellcheck").html(TPL); this.$spellCheckEnabled = $("#spell-check-enabled"); this.$spellCheckLanguageCode = $("#spell-check-language-code"); this.$spellCheckEnabled.on('change', () => { const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$spellCheckLanguageCode.on('change', () => { const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$availableLanguageCodes = $("#available-language-codes"); if (utils.isElectron()) { const { webContents } = utils.dynamicRequire('@electron/remote').getCurrentWindow(); this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', ')); } } optionsLoaded(options) { this.$spellCheckEnabled.prop("checked", options['spellCheckEnabled'] === 'true'); this.$spellCheckLanguageCode.val(options['spellCheckLanguageCode']); } }