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): add tab width selector
Elian Doranc35bc6fbd27e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 653e7dd0b2..0e335e4da0 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1930,7 +1930,9 @@"theme_group_light": "Light themes","theme_group_dark": "Dark themes","copy_title": "Copy to clipboard",- "click_to_copy": "Click to copy"+ "click_to_copy": "Click to copy",+ "tab_width": "Tab width",+ "tab_width_unit": "spaces"},"classic_editor_toolbar": {"title": "Formatting"diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsxindex 009def29a9..00c66d92b5 100644--- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx+++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx@@ -264,6 +264,7 @@ function CodeBlockStyle() {}, []);const [ codeBlockTheme, setCodeBlockTheme ] = useTriliumOption("codeBlockTheme");const [ codeBlockWordWrap, setCodeBlockWordWrap ] = useTriliumOptionBool("codeBlockWordWrap");+ const [ codeBlockTabWidth, setCodeBlockTabWidth ] = useTriliumOption("codeBlockTabWidth");return (<OptionsSection title={t("highlighting.title")}>@@ -285,6 +286,15 @@ function CodeBlockStyle() {onChange={setCodeBlockWordWrap}/>+ <OptionsRow name="code-block-tab-width" label={t("code_block.tab_width")}>+ <FormTextBoxWithUnit+ type="number" min={1} max={16} step={1}+ unit={t("code_block.tab_width_unit")}+ currentValue={codeBlockTabWidth}+ onBlur={setCodeBlockTabWidth}+ />+ </OptionsRow>+<CodeBlockPreview theme={codeBlockTheme} wordWrap={codeBlockWordWrap} /></OptionsSection>);diff --git a/apps/server/src/routes/api/options.ts b/apps/server/src/routes/api/options.tsindex f9c92c9718..8191b6812e 100644--- a/apps/server/src/routes/api/options.ts+++ b/apps/server/src/routes/api/options.ts@@ -30,6 +30,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>(["theme","codeBlockTheme","codeBlockWordWrap",+ "codeBlockTabWidth","codeNoteTheme","syncServerHost","syncServerTimeout",diff --git a/apps/server/src/services/options_init.ts b/apps/server/src/services/options_init.tsindex 4bff15d91e..bdab81af62 100644--- a/apps/server/src/services/options_init.ts+++ b/apps/server/src/services/options_init.ts@@ -216,6 +216,7 @@ const defaultOptions: DefaultOption[] = [isSynced: false},{ name: "codeBlockWordWrap", value: "false", isSynced: true },+ { name: "codeBlockTabWidth", value: "4", isSynced: true },// Text note configuration{ name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true },diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.tsindex 9f7db1d04b..b64ae1e568 100644--- a/packages/commons/src/lib/options_interface.ts+++ b/packages/commons/src/lib/options_interface.ts@@ -160,6 +160,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActidisableTray: boolean;editedNotesOpenInRibbon: boolean;codeBlockWordWrap: boolean;+ codeBlockTabWidth: number;textNoteEditorMultilineToolbar: boolean;/** Whether keyboard auto-completion for emojis is triggered when typing `:`. */textNoteEmojiCompletionEnabled: boolean;