Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(options/spellcheck): add button to edit custom words
Elian Dorana70142a4dcd3
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex b6b8ae6281..4c3a555ef1 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1500,7 +1500,12 @@"description": "These options apply only for desktop builds, browsers will use their own native spell check.","enable": "Check spelling","language_code_label": "Spell Check Languages",- "restart-required": "Changes to the spell check options will take effect after application restart."+ "restart-required": "Changes to the spell check options will take effect after application restart.",+ "custom_dictionary_title": "Custom Dictionary",+ "custom_dictionary_description": "Words added to the dictionary are synced across all your devices.",+ "custom_dictionary_edit": "Custom words",+ "custom_dictionary_edit_description": "Edit the list of words that should not be flagged by the spell checker. Changes will be visible after a restart.",+ "custom_dictionary_open": "Edit dictionary"},"sync_2": {"config_title": "Sync Configuration",diff --git a/apps/client/src/widgets/type_widgets/options/spellcheck.tsx b/apps/client/src/widgets/type_widgets/options/spellcheck.tsxindex 5949e820ce..df79f2402f 100644--- a/apps/client/src/widgets/type_widgets/options/spellcheck.tsx+++ b/apps/client/src/widgets/type_widgets/options/spellcheck.tsx@@ -1,7 +1,9 @@import { useCallback, useMemo } from "preact/hooks";+import appContext from "../../../components/app_context";import { t } from "../../../services/i18n";import { dynamicRequire, isElectron } from "../../../services/utils";+import Button from "../../react/Button";import FormText from "../../react/FormText";import FormToggle from "../../react/FormToggle";import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";@@ -25,19 +27,23 @@ function ElectronSpellcheckSettings() {const [ spellCheckEnabled, setSpellCheckEnabled ] = useTriliumOptionBool("spellCheckEnabled");return (- <OptionsSection title={t("spellcheck.title")}>- <FormText>{t("spellcheck.restart-required")}</FormText>+ <>+ <OptionsSection title={t("spellcheck.title")}>+ <FormText>{t("spellcheck.restart-required")}</FormText>- <OptionsRow name="spell-check-enabled" label={t("spellcheck.enable")}>- <FormToggle- switchOnName="" switchOffName=""- currentValue={spellCheckEnabled}- onChange={setSpellCheckEnabled}- />- </OptionsRow>+ <OptionsRow name="spell-check-enabled" label={t("spellcheck.enable")}>+ <FormToggle+ switchOnName="" switchOffName=""+ currentValue={spellCheckEnabled}+ onChange={setSpellCheckEnabled}+ />+ </OptionsRow>- {spellCheckEnabled && <SpellcheckLanguages />}- </OptionsSection>+ {spellCheckEnabled && <SpellcheckLanguages />}+ </OptionsSection>++ {spellCheckEnabled && <CustomDictionary />}+ </>);}@@ -84,6 +90,27 @@ function SpellcheckLanguages() {);}+function CustomDictionary() {+ function openDictionary() {+ appContext.triggerCommand("openInPopup", { noteIdOrPath: "_customDictionary" });+ }++ return (+ <OptionsSection title={t("spellcheck.custom_dictionary_title")}>+ <FormText>{t("spellcheck.custom_dictionary_description")}</FormText>++ <OptionsRow name="custom-dictionary" label={t("spellcheck.custom_dictionary_edit")} description={t("spellcheck.custom_dictionary_edit_description")}>+ <Button+ name="open-custom-dictionary"+ text={t("spellcheck.custom_dictionary_open")}+ icon="bx bx-edit"+ onClick={openDictionary}+ />+ </OptionsRow>+ </OptionsSection>+ );+}+function WebSpellcheckSettings() {return (<OptionsSection title={t("spellcheck.title")}>