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
style/options: tweak style
Adorian Doran5ea02e798da9
diff --git a/apps/client/src/widgets/react/Card.css b/apps/client/src/widgets/react/Card.cssindex c71f5605b5..e26d7def88 100644--- a/apps/client/src/widgets/react/Card.css+++ b/apps/client/src/widgets/react/Card.css@@ -32,8 +32,6 @@text-transform: uppercase;}-/* Kept at the far end of the heading line, where the options page's own sections keep theirs, and- sized against the heading rather than against a full-height toolbar. */.tn-card-heading-actions {--icon-button-size: 28px;display: flex;@@ -56,8 +54,7 @@align-items: center;gap: 8px;- /* The controls keep their natural width. Left to shrink, a button's nowrap label spills across- its own padding and ends up reading as though it had none; the label below gives instead. */+ /* The controls keep their natural width; the label gives instead. */> * {flex-shrink: 0;}@@ -70,7 +67,6 @@margin-bottom: 0;min-width: 0;- /* Tied to a control, so that the text operates it too. */&[for] {cursor: pointer;}@@ -86,8 +82,6 @@}}-/* A segment that leads somewhere rather than holding a control: it keeps the page's own text colour- and gives up the underline, the chevron at its end standing in for both. */.tn-card-section-link {display: flex;align-items: center;@@ -108,28 +102,18 @@font-size: 1.3em;}-/*- * Bootstrap sizes a form control to whatever holds it, and a card option's controls do not shrink —- * so left alone, a select or a figure takes the whole row and leaves the label a word to the line.- * Each is sized to what it actually holds instead.- *- * Only a control the option holds directly: a select nested inside one (the scale beside a duration)- * is sized by whatever built it.- */+/* Bootstrap sizes a form control to whatever holds it, so left alone a select or a figure takes the+ whole row. Direct children only: a select nested in one (the scale beside a duration) is not ours. */.tn-card-option {> select {width: auto;min-width: 150px;- /* A choice too long to show is cut short rather than carried off the card. The arrow is a- background image with padding reserved for it (forms.css), so it keeps its place. */max-width: min(260px, 100%);overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}- /* A figure is a few characters wherever it appears — a duration, a count, a percentage — and- where a unit sits beside it, the pair belongs to the figure rather than to the row. */input[type="number"] {width: 7em;}@@ -143,22 +127,17 @@flex-direction: column;align-items: stretch;- /* Given a line of its own, the control uses all of it — including a slider, which otherwise- carries a width of its own (200px) that `stretch` cannot override. */+ /* Explicit, since a slider's own 200px width overrides `stretch`. */> * {width: 100%;}}-/* On a phone, a control too wide to sit beside the text takes the line below it. A switch is narrow- enough to stay put; a button labelled with a sentence is not, and left the description beside it- reading a word to the line. */+/* On a phone, a control too wide to sit beside the text takes the line below it. */body.mobile .tn-card-option:has(> .btn, > .slider) {flex-direction: column;align-items: stretch;- /* A slider carries its own width (200px), which `stretch` cannot override — and having been- given a line, it may as well use it. */> .slider {width: 100%;}diff --git a/apps/client/src/widgets/react/Card.spec.tsx b/apps/client/src/widgets/react/Card.spec.tsxindex 3c53fce65e..979ff673a2 100644--- a/apps/client/src/widgets/react/Card.spec.tsx+++ b/apps/client/src/widgets/react/Card.spec.tsx@@ -85,6 +85,22 @@ describe("CardOption", () => {expect(label?.querySelector(".tn-card-option-description")?.textContent).toBe("Wraps long lines.");});+ it("holds a name made of several things together, rather than stacking its parts", () => {+ const container = renderInto(+ <CardOption+ label={<>Background effects <span className="platforms" /></>}+ description="Blurs the window behind."+ />+ );++ // The label lays the sentence out under the name, so a name in pieces would be laid out+ // the same way — a badge marking which platforms a setting applies to would end up on a+ // line of its own.+ const title = container.querySelector(".tn-card-option-title");+ expect(title?.textContent).toContain("Background effects");+ expect(title?.querySelector(".platforms")).not.toBeNull();+ });+it("puts the control on the line below when stacked", () => {const inline = renderInto(<CardOption label="Address"><input /></CardOption>);expect(inline.querySelector(".tn-card-option")?.className).not.toContain("tn-card-option-stacked");diff --git a/apps/client/src/widgets/react/Card.tsx b/apps/client/src/widgets/react/Card.tsxindex 06930061f6..b99d540270 100644--- a/apps/client/src/widgets/react/Card.tsx+++ b/apps/client/src/widgets/react/Card.tsx@@ -159,7 +159,10 @@ export function CardOption(props: CardOptionProps) {"tn-card-option-stacked": stacked})} {...rest}><label className="tn-card-option-label" for={bound ? id : undefined}>- {label}+ {/* Held together as one thing, because the label stacks the sentence under the name and+ would otherwise stack whatever the name is made of too — a badge marking which+ platforms a setting applies to belongs after the words, not under them. */}+ <span className="tn-card-option-title">{label}</span>{description && <small className="tn-card-option-description">{description}</small>}</label>diff --git a/apps/client/src/widgets/type_widgets/options/appearance.css b/apps/client/src/widgets/type_widgets/options/appearance.cssindex 83883deb47..48e4dc3322 100644--- a/apps/client/src/widgets/type_widgets/options/appearance.css+++ b/apps/client/src/widgets/type_widgets/options/appearance.css@@ -1,5 +1,3 @@-/* The two layout choices, read against one another. Each keeps enough width to draw its pictures- side by side; a pane with no room for both puts them on lines of their own. */.appearance-layout-choices {display: flex;flex-wrap: wrap;@@ -14,8 +12,7 @@.font-option {cursor: pointer;- /* Left on show with custom fonts off, so that what the switch above would put in force can still- be read; greyed and inert, since until then none of it is in force. */+ /* Shown rather than hidden with custom fonts off, so the settings can still be read. */&.disabled {opacity: 0.5;pointer-events: none;@@ -29,16 +26,8 @@color: var(--muted-text-color);}-/*- * On a narrow card the font takes a line of its own, under the name rather than beside it.- *- * The value in this row is not a word but a specimen — the family drawn in itself, at the size it is- * set to — so its width is the user's to decide and can exceed the screen's: "American Typewriter"- * at 150% measures 400px on a 412px phone. A card option's controls do not shrink, so beside a name- * there was nowhere for that to go but off the card, taking the chevron with it.- *- * The card is made the container the width is read from: the page's own cards no longer carry one.- */+/* The specimen is drawn at the user's own family and size, so it can outgrow the screen: on a narrow+ card it takes the line below the name instead of being carried off the edge. */.appearance-fonts .tn-card {container-type: inline-size;}@@ -50,13 +39,11 @@}.font-option .font-option-preview {- /* The chevron stays at the far edge, where it is on every other row that leads somewhere. */justify-content: space-between;}.font-option .font-option-specimen {- /* A long name breaks rather than overflowing: `anywhere` because a family name is one word- as often as not, and there is no break the browser would take on its own. */+ /* `anywhere`: a family name is often one word, with no break the browser would take. */min-width: 0;overflow-wrap: anywhere;}diff --git a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.css b/apps/client/src/widgets/type_widgets/options/code_mime_types_list.cssindex ca9cd9b34a..2df32b10cd 100644--- a/apps/client/src/widgets/type_widgets/options/code_mime_types_list.css+++ b/apps/client/src/widgets/type_widgets/options/code_mime_types_list.css@@ -8,8 +8,7 @@break-inside: avoid-column;}- /* The initial the group is filed under, marked the way a card marks its heading: it names a- column of entries rather than introducing a subject of its own. */+ /* The initial the group is filed under, marked the way a card marks its heading. */h5 {margin-bottom: 0.25em;font-size: .75rem;diff --git a/apps/client/src/widgets/type_widgets/options/code_notes.css b/apps/client/src/widgets/type_widgets/options/code_notes.cssindex 6866eaa38e..532384d9fe 100644--- a/apps/client/src/widgets/type_widgets/options/code_notes.css+++ b/apps/client/src/widgets/type_widgets/options/code_notes.css@@ -1,4 +1,6 @@-/* Clipped to the corners the last segment rounds, which the editor inside would otherwise paint over. */-.code-note-preview {+/* The frame a code block has inside a note (theme-next/notes/text.css). */+.code-note-preview .note-detail-readonly-code-content {+ border-radius: 6px;+ box-shadow: var(--code-block-box-shadow);overflow: hidden;}diff --git a/apps/client/src/widgets/type_widgets/options/code_notes.spec.tsx b/apps/client/src/widgets/type_widgets/options/code_notes.spec.tsxindex 1588c74de0..712891596f 100644--- a/apps/client/src/widgets/type_widgets/options/code_notes.spec.tsx+++ b/apps/client/src/widgets/type_widgets/options/code_notes.spec.tsx@@ -113,11 +113,13 @@ describe("the code note theme", () => {});describe("the code note editor settings", () => {- it("shows the preview as its own segment, filling it edge to edge", () => {+ it("shows the preview as a segment of its own, framed the way a code block is", () => {open();+ // A segment of its own, holding the editor rather than a control beside a label — and a+ // padded one, so the sample sits in the card the way a code block sits in a note.const preview = host.querySelector(".code-note-preview");- expect(preview?.className).toContain("tn-no-padding");+ expect(preview?.className).not.toContain("tn-no-padding");expect(preview?.querySelector(".note-detail-readonly-code-content")).not.toBeNull();});diff --git a/apps/client/src/widgets/type_widgets/options/code_notes.tsx b/apps/client/src/widgets/type_widgets/options/code_notes.tsxindex 615c68ca87..ee3af09672 100644--- a/apps/client/src/widgets/type_widgets/options/code_notes.tsx+++ b/apps/client/src/widgets/type_widgets/options/code_notes.tsx@@ -1,234 +1,234 @@-import "./code_notes.css";--import CodeMirror, { ColorThemes, getThemeById, type ThemeVariant } from "@triliumnext/codemirror";-import { useEffect, useMemo, useRef } from "preact/hooks";--import { t } from "../../../services/i18n";-import { Card, CardOption, CardSection } from "../../react/Card";-import FormSelect from "../../react/FormSelect";-import { FormTextBoxWithUnit } from "../../react/FormTextBox";-import FormToggle from "../../react/FormToggle";-import { useColorScheme, useTriliumOption, useTriliumOptionBool } from "../../react/hooks";-import { CODE_THEME_DEFAULT_PREFIX as DEFAULT_PREFIX } from "../constants";-import { CodeMimeTypesList } from "./code_mime_types_list";-import OptionsPageHeader from "./components/OptionsPageHeader";-import ThemeModeSelector from "./components/ThemeModeSelector";-import codeNoteSample from "./samples/code_note.txt?raw";--const SAMPLE_MIME = "application/typescript";--export default function CodeNoteSettings() {- const [codeLineWrapEnabled, setCodeLineWrapEnabled] = useTriliumOptionBool("codeLineWrapEnabled");- const [codeNoteTabWidth] = useTriliumOption("codeNoteTabWidth");-- return (- <>- <OptionsPageHeader />- <Editor wordWrapping={codeLineWrapEnabled} setWordWrapping={setCodeLineWrapEnabled} />- <Appearance wordWrapping={codeLineWrapEnabled} indentSize={parseInt(codeNoteTabWidth) || 4} />- <CodeMimeTypes />- </>- );-}--interface EditorProps {- wordWrapping: boolean;- setWordWrapping: (newValue: boolean) => void;-}--function Editor({ wordWrapping, setWordWrapping }: EditorProps) {- const [vimKeymapEnabled, setVimKeymapEnabled] = useTriliumOptionBool("vimKeymapEnabled");- const [autoReadonlySize, setAutoReadonlySize] = useTriliumOption("autoReadonlySizeCode");- const [codeNoteTabWidth, setCodeNoteTabWidth] = useTriliumOption("codeNoteTabWidth");-- return (- <div className="options-section">- <Card heading={t("code-editor-options.title")}>- <CardOption name="word-wrap" label={t("code_theme.word_wrapping")}>- <FormToggle currentValue={wordWrapping} onChange={setWordWrapping} />- </CardOption>-- {/* Avoid using "code" in the name of numeric inputs to prevent KeepassXC from triggering. */}- <CardOption- name="editor-tab-width"- label={t("code-editor-options.tab_width")}- >- <FormTextBoxWithUnit- type="number" min={1} max={16} step={1}- unit={t("code-editor-options.tab_width_unit")}- currentValue={codeNoteTabWidth}- onChange={setCodeNoteTabWidth}- onBlur={setCodeNoteTabWidth}- />- </CardOption>-- <CardOption- name="source-readonly-threshold"- label={t("code_auto_read_only_size.label")}- description={t("text_auto_read_only_size.description")}- >- <FormTextBoxWithUnit- type="number" min={0}- unit={t("text_auto_read_only_size.unit")}- currentValue={autoReadonlySize}- onBlur={setAutoReadonlySize}- />- </CardOption>-- <CardOption- name="vim-keymap-enabled"- label={t("vim_key_bindings.use_vim_keybindings_in_code_notes")}- description={t("vim_key_bindings.enable_vim_keybindings")}- >- <FormToggle currentValue={vimKeymapEnabled} onChange={setVimKeymapEnabled} />- </CardOption>- </Card>- </div>- );-}--interface AppearanceProps {- wordWrapping: boolean;- indentSize: number;-}--function useFilteredThemes(variant?: ThemeVariant) {- return useMemo(() => {- return ColorThemes- .filter((theme) => !variant || theme.variant === variant)- .map(({ id, name }) => ({- id: `default:${id}`,- name- }));- }, [variant]);-}--function Appearance({ wordWrapping, indentSize }: AppearanceProps) {- const [codeNoteTheme, setCodeNoteTheme] = useTriliumOption("codeNoteTheme");- const [matchesApp, setMatchesApp] = useTriliumOptionBool("codeNoteThemeMatchesApp");- const [lightTheme, setLightTheme] = useTriliumOption("codeNoteThemeLight");- const [darkTheme, setDarkTheme] = useTriliumOption("codeNoteThemeDark");-- const colorScheme = useColorScheme();- const allThemes = useFilteredThemes();- const lightThemes = useFilteredThemes("light");- const darkThemes = useFilteredThemes("dark");-- const effectiveTheme = matchesApp- ? (colorScheme === "dark" ? darkTheme : lightTheme)- : codeNoteTheme;-- return (- <div className="options-section">- <Card heading={t("code_theme.title")}>- <ThemeModeSelector matchesApp={matchesApp} onMatchesAppChange={setMatchesApp} />-- {matchesApp ? (- <>- <CardOption name="light-theme" label={t("code_theme.light_theme")}>- <FormSelect- values={lightThemes}- keyProperty="id" titleProperty="name"- currentValue={lightTheme} onChange={setLightTheme}- />- </CardOption>- <CardOption name="dark-theme" label={t("code_theme.dark_theme")}>- <FormSelect- values={darkThemes}- keyProperty="id" titleProperty="name"- currentValue={darkTheme} onChange={setDarkTheme}- />- </CardOption>- </>- ) : (- <CardOption name="color-scheme" label={t("code_theme.color-scheme")}>- <FormSelect- values={allThemes}- keyProperty="id" titleProperty="name"- currentValue={codeNoteTheme} onChange={setCodeNoteTheme}- />- </CardOption>- )}-- {/* The whole segment, edge to edge: a specimen of the editor rather than a control- standing beside a label. */}- <CardSection className="code-note-preview" noPadding>- <CodeNotePreview wordWrapping={wordWrapping} themeName={effectiveTheme} indentSize={indentSize} />- </CardSection>- </Card>- </div>- );-}--function CodeNotePreview({ themeName, wordWrapping, indentSize }: { themeName: string, wordWrapping: boolean, indentSize: number }) {- const editorRef = useRef<CodeMirror>(null);- const containerRef = useRef<HTMLDivElement>(null);-- useEffect(() => {- if (!containerRef.current) {- return;- }-- // Clean up previous instance.- editorRef.current?.destroy();- containerRef.current.innerHTML = "";-- // Set up a new instance.- const editor = new CodeMirror({- parent: containerRef.current- });- editor.setText(codeNoteSample);- editor.setMimeType(SAMPLE_MIME);- editorRef.current = editor;- }, []);-- useEffect(() => {- editorRef.current?.setLineWrapping(wordWrapping);- }, [ wordWrapping ]);-- useEffect(() => {- const editor = editorRef.current;- if (!editor) return;- editor.setIndentSize(indentSize);- editor.setText(reindentSample(codeNoteSample, indentSize));- }, [ indentSize ]);-- useEffect(() => {- if (themeName?.startsWith(DEFAULT_PREFIX)) {- const theme = getThemeById(themeName.substring(DEFAULT_PREFIX.length));- if (theme) {- editorRef.current?.setTheme(theme);- }- }- }, [ themeName ]);-- return (- <div- ref={containerRef}- class="note-detail-readonly-code-content"- style={{ margin: 0, height: "200px" }}- />- );-}--const SAMPLE_BASE_INDENT = 4;--function reindentSample(sample: string, indentSize: number): string {- return sample.replace(/^( +)/gm, (match) => {- const level = match.length / SAMPLE_BASE_INDENT;- return " ".repeat(Math.round(level) * indentSize);- });-}--function CodeMimeTypes() {- return (- <div className="options-section">- <Card heading={t("code_mime_types.title")}>- <CardSection>- <CodeMimeTypesList />- </CardSection>- </Card>- </div>- );-}-+import "./code_notes.css";++import CodeMirror, { ColorThemes, getThemeById, type ThemeVariant } from "@triliumnext/codemirror";+import { useEffect, useMemo, useRef } from "preact/hooks";++import { t } from "../../../services/i18n";+import { Card, CardOption, CardSection } from "../../react/Card";+import FormSelect from "../../react/FormSelect";+import { FormTextBoxWithUnit } from "../../react/FormTextBox";+import FormToggle from "../../react/FormToggle";+import { useColorScheme, useTriliumOption, useTriliumOptionBool } from "../../react/hooks";+import { CODE_THEME_DEFAULT_PREFIX as DEFAULT_PREFIX } from "../constants";+import { CodeMimeTypesList } from "./code_mime_types_list";+import OptionsPageHeader from "./components/OptionsPageHeader";+import ThemeModeSelector from "./components/ThemeModeSelector";+import codeNoteSample from "./samples/code_note.txt?raw";++const SAMPLE_MIME = "application/typescript";++export default function CodeNoteSettings() {+ const [codeLineWrapEnabled, setCodeLineWrapEnabled] = useTriliumOptionBool("codeLineWrapEnabled");+ const [codeNoteTabWidth] = useTriliumOption("codeNoteTabWidth");++ return (+ <>+ <OptionsPageHeader />+ <Editor wordWrapping={codeLineWrapEnabled} setWordWrapping={setCodeLineWrapEnabled} />+ <Appearance wordWrapping={codeLineWrapEnabled} indentSize={parseInt(codeNoteTabWidth) || 4} />+ <CodeMimeTypes />+ </>+ );+}++interface EditorProps {+ wordWrapping: boolean;+ setWordWrapping: (newValue: boolean) => void;+}++function Editor({ wordWrapping, setWordWrapping }: EditorProps) {+ const [vimKeymapEnabled, setVimKeymapEnabled] = useTriliumOptionBool("vimKeymapEnabled");+ const [autoReadonlySize, setAutoReadonlySize] = useTriliumOption("autoReadonlySizeCode");+ const [codeNoteTabWidth, setCodeNoteTabWidth] = useTriliumOption("codeNoteTabWidth");++ return (+ <div className="options-section">+ <Card heading={t("code-editor-options.title")}>+ <CardOption name="word-wrap" label={t("code_theme.word_wrapping")}>+ <FormToggle currentValue={wordWrapping} onChange={setWordWrapping} />+ </CardOption>++ {/* Avoid using "code" in the name of numeric inputs to prevent KeepassXC from triggering. */}+ <CardOption+ name="editor-tab-width"+ label={t("code-editor-options.tab_width")}+ >+ <FormTextBoxWithUnit+ type="number" min={1} max={16} step={1}+ unit={t("code-editor-options.tab_width_unit")}+ currentValue={codeNoteTabWidth}+ onChange={setCodeNoteTabWidth}+ onBlur={setCodeNoteTabWidth}+ />+ </CardOption>++ <CardOption+ name="source-readonly-threshold"+ label={t("code_auto_read_only_size.label")}+ description={t("text_auto_read_only_size.description")}+ >+ <FormTextBoxWithUnit+ type="number" min={0}+ unit={t("text_auto_read_only_size.unit")}+ currentValue={autoReadonlySize}+ onBlur={setAutoReadonlySize}+ />+ </CardOption>++ <CardOption+ name="vim-keymap-enabled"+ label={t("vim_key_bindings.use_vim_keybindings_in_code_notes")}+ description={t("vim_key_bindings.enable_vim_keybindings")}+ >+ <FormToggle currentValue={vimKeymapEnabled} onChange={setVimKeymapEnabled} />+ </CardOption>+ </Card>+ </div>+ );+}++interface AppearanceProps {+ wordWrapping: boolean;+ indentSize: number;+}++function useFilteredThemes(variant?: ThemeVariant) {+ return useMemo(() => {+ return ColorThemes+ .filter((theme) => !variant || theme.variant === variant)+ .map(({ id, name }) => ({+ id: `default:${id}`,+ name+ }));+ }, [variant]);+}++function Appearance({ wordWrapping, indentSize }: AppearanceProps) {+ const [codeNoteTheme, setCodeNoteTheme] = useTriliumOption("codeNoteTheme");+ const [matchesApp, setMatchesApp] = useTriliumOptionBool("codeNoteThemeMatchesApp");+ const [lightTheme, setLightTheme] = useTriliumOption("codeNoteThemeLight");+ const [darkTheme, setDarkTheme] = useTriliumOption("codeNoteThemeDark");++ const colorScheme = useColorScheme();+ const allThemes = useFilteredThemes();+ const lightThemes = useFilteredThemes("light");+ const darkThemes = useFilteredThemes("dark");++ const effectiveTheme = matchesApp+ ? (colorScheme === "dark" ? darkTheme : lightTheme)+ : codeNoteTheme;++ return (+ <div className="options-section">+ <Card heading={t("code_theme.title")}>+ <ThemeModeSelector matchesApp={matchesApp} onMatchesAppChange={setMatchesApp} />++ {matchesApp ? (+ <>+ <CardOption name="light-theme" label={t("code_theme.light_theme")}>+ <FormSelect+ values={lightThemes}+ keyProperty="id" titleProperty="name"+ currentValue={lightTheme} onChange={setLightTheme}+ />+ </CardOption>+ <CardOption name="dark-theme" label={t("code_theme.dark_theme")}>+ <FormSelect+ values={darkThemes}+ keyProperty="id" titleProperty="name"+ currentValue={darkTheme} onChange={setDarkTheme}+ />+ </CardOption>+ </>+ ) : (+ <CardOption name="color-scheme" label={t("code_theme.color-scheme")}>+ <FormSelect+ values={allThemes}+ keyProperty="id" titleProperty="name"+ currentValue={codeNoteTheme} onChange={setCodeNoteTheme}+ />+ </CardOption>+ )}++ {/* A specimen of the editor rather than a control standing beside a label, shown+ the way a code block is shown in a note. */}+ <CardSection className="code-note-preview">+ <CodeNotePreview wordWrapping={wordWrapping} themeName={effectiveTheme} indentSize={indentSize} />+ </CardSection>+ </Card>+ </div>+ );+}++function CodeNotePreview({ themeName, wordWrapping, indentSize }: { themeName: string, wordWrapping: boolean, indentSize: number }) {+ const editorRef = useRef<CodeMirror>(null);+ const containerRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ if (!containerRef.current) {+ return;+ }++ // Clean up previous instance.+ editorRef.current?.destroy();+ containerRef.current.innerHTML = "";++ // Set up a new instance.+ const editor = new CodeMirror({+ parent: containerRef.current+ });+ editor.setText(codeNoteSample);+ editor.setMimeType(SAMPLE_MIME);+ editorRef.current = editor;+ }, []);++ useEffect(() => {+ editorRef.current?.setLineWrapping(wordWrapping);+ }, [ wordWrapping ]);++ useEffect(() => {+ const editor = editorRef.current;+ if (!editor) return;+ editor.setIndentSize(indentSize);+ editor.setText(reindentSample(codeNoteSample, indentSize));+ }, [ indentSize ]);++ useEffect(() => {+ if (themeName?.startsWith(DEFAULT_PREFIX)) {+ const theme = getThemeById(themeName.substring(DEFAULT_PREFIX.length));+ if (theme) {+ editorRef.current?.setTheme(theme);+ }+ }+ }, [ themeName ]);++ return (+ <div+ ref={containerRef}+ class="note-detail-readonly-code-content"+ style={{ margin: 0, height: "200px" }}+ />+ );+}++const SAMPLE_BASE_INDENT = 4;++function reindentSample(sample: string, indentSize: number): string {+ return sample.replace(/^( +)/gm, (match) => {+ const level = match.length / SAMPLE_BASE_INDENT;+ return " ".repeat(Math.round(level) * indentSize);+ });+}++function CodeMimeTypes() {+ return (+ <div className="options-section">+ <Card heading={t("code_mime_types.title")}>+ <CardSection>+ <CodeMimeTypesList />+ </CardSection>+ </Card>+ </div>+ );+}+diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.cssindex 9daad61a10..e76aac93ae 100644--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css@@ -69,8 +69,7 @@justify-content: flex-end;}-/* A page whose settings all hang off one switch carries it here rather than in a card of its own.- It is a card option without a card, so it needs the room a segment would have given it. */+/* A card option without a card, so it needs the room a segment would have given it. */.options-header-switch {padding-block: 4px;}diff --git a/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css b/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.cssindex 324d0dbb47..47a4ec57f6 100644--- a/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css+++ b/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css@@ -1,9 +1,4 @@-/*- * A card given over to a single illustrated choice, its heading standing in for the label such a- * choice is too large to sit beside: no ground of its own, so the thumbnails read as the drawings- * they are rather than as a filled-in control, and more room above and below than a row of text asks- * for.- */+/* A card given over to a single illustrated choice, its heading standing in for the label. */.thumbnail-selector-option-card {--card-padding-block: 12px;--card-background-color: transparent;diff --git a/apps/client/src/widgets/type_widgets/options/components/RestartAction.css b/apps/client/src/widgets/type_widgets/options/components/RestartAction.cssindex 725131e3a3..ba7608f37c 100644--- a/apps/client/src/widgets/type_widgets/options/components/RestartAction.css+++ b/apps/client/src/widgets/type_widgets/options/components/RestartAction.css@@ -1,5 +1,3 @@-/* Where the controls of the cards above it end, rather than under the labels it has nothing to do- with. */.restart-action {text-align: end;}diff --git a/apps/client/src/widgets/type_widgets/options/desktop.css b/apps/client/src/widgets/type_widgets/options/desktop.cssindex f603d6c4ec..7e3b050cde 100644--- a/apps/client/src/widgets/type_widgets/options/desktop.css+++ b/apps/client/src/widgets/type_widgets/options/desktop.css@@ -1,5 +1,4 @@-/* The engines offered ready-made, as a set of chips rather than a list. A card option holds its- controls at their natural width; this one is a set that wraps, so it gives way to the label. */+/* Overrides the card option's no-shrink rule: a wrapping set of chips gives way instead. */.tn-card-option > .search-engine-templates {flex-shrink: 1;min-width: 0;@@ -26,9 +25,7 @@outline-offset: -2px;}-/* A name is a word or two, so the box is sized to what is typed in it rather than to the row:- Bootstrap would otherwise give it the whole width of what holds it. Not said of the URL below it,- which is stacked and wants the line it was given. */+/* A name is a word or two. Not said of the URL below it, which is stacked and uses its whole line. */.desktop-search-name input {width: auto;max-width: 100%;diff --git a/apps/client/src/widgets/type_widgets/options/etapi.css b/apps/client/src/widgets/type_widgets/options/etapi.cssindex ba06c49f98..fcdc2d2358 100644--- a/apps/client/src/widgets/type_widgets/options/etapi.css+++ b/apps/client/src/widgets/type_widgets/options/etapi.css@@ -1,5 +1,3 @@-/* What the page is for, and the one thing it offers, on the row below the title — a narrow header- puts the button on a line of its own rather than squeezing the sentence to a word. */.etapi-header-row {display: flex;flex-wrap: wrap;@@ -13,8 +11,7 @@}}-/* Carried by the page's header rather than by a card, so it states its own type: the size and colour- a card's own introducing sentence is set in. */+/* Carried by the header rather than a card, so it repeats what .tn-card-description would give it. */.etapi-description {flex: 1 1 auto;margin: 0;diff --git a/apps/client/src/widgets/type_widgets/options/i18n.css b/apps/client/src/widgets/type_widgets/options/i18n.cssindex 949e8cfaf2..3141241400 100644--- a/apps/client/src/widgets/type_widgets/options/i18n.css+++ b/apps/client/src/widgets/type_widgets/options/i18n.css@@ -1,5 +1,4 @@-/* Many lines rather than a control on one, so it is given room from the section's own edges.- `!important` because CheckboxList zeroes its bottom margin inline, which no selector outweighs. */+/* `!important` because CheckboxList zeroes its bottom margin inline. */.i18n-content-languages ul {margin-block: 1em !important;}diff --git a/apps/client/src/widgets/type_widgets/options/llm.css b/apps/client/src/widgets/type_widgets/options/llm.cssindex 3b2c2e3bf4..98b8e07776 100644--- a/apps/client/src/widgets/type_widgets/options/llm.css+++ b/apps/client/src/widgets/type_widgets/options/llm.css@@ -9,7 +9,6 @@gap: 4px;}-/* The way to add one, at the end of the list it adds to. */.llm-add-provider {text-align: end;}diff --git a/apps/client/src/widgets/type_widgets/options/password.css b/apps/client/src/widgets/type_widgets/options/password.cssindex 0a1fc597ae..3ee16dec86 100644--- a/apps/client/src/widgets/type_widgets/options/password.css+++ b/apps/client/src/widgets/type_widgets/options/password.css@@ -1,9 +1,7 @@-/* Sentences rather than a control, so the segment carries them with no margin of their own. */.signin-method-description p {margin-bottom: 0;}-/* An admonition brings its own frame and spacing; the segment holding it adds none. */.mfa-notice .admonition {margin-bottom: 0;}diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.css b/apps/client/src/widgets/type_widgets/options/shortcuts.cssindex 960e563f7f..8d861c9010 100644--- a/apps/client/src/widgets/type_widgets/options/shortcuts.css+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.css@@ -52,8 +52,7 @@.shortcut-editor {display: flex;- /* A card option holds its controls at their natural width; this one is a set that wraps, so- it gives way to the name beside it instead of carrying the chips off the card. */+ /* Overrides the card option's no-shrink rule: a wrapping set of chips gives way instead. */flex-shrink: 1;flex-wrap: wrap;align-items: center;@@ -157,8 +156,7 @@}}- /* On mobile, stack each segment so the shortcut editor sits underneath the action label. A card- option only stacks itself for a button or a slider, and this is neither. */+ /* A card option stacks itself only for a button or a slider, and the editor is neither. */body.mobile & {.tn-card-option {flex-direction: column;diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.css b/apps/client/src/widgets/type_widgets/options/text_notes.cssindex 6f4925b110..b6bf372303 100644--- a/apps/client/src/widgets/type_widgets/options/text_notes.css+++ b/apps/client/src/widgets/type_widgets/options/text_notes.css@@ -124,15 +124,13 @@}}-/* A format string of known length rather than a sentence: `auto` is the browser's own twenty- characters, which is what the format written in it needs. */+/* A date format, not a sentence: the browser's default twenty characters is the right width. */.text-notes-editor input[type="text"] {width: auto;max-width: 100%;}-/* The heading threshold stands in a plain segment rather than a settings row, so the figure sizing a- card option gets does not reach it. */+/* A plain segment rather than a card option, so it is sized here instead. */.text-notes-toc .tn-number-unit-pair {width: auto;@@ -141,8 +139,6 @@}}-/* Each pair held, and the boxes the next one is typed into: one segment apiece, what is written on- the leading edge and the way to be rid of it on the trailing one. */.custom-replacement {display: flex;align-items: center;@@ -155,11 +151,6 @@overflow-wrap: anywhere;}-/*- * The two boxes, the arrow between them and the button asking for what they hold, kept together as- * the one thing they are: a pair is entered, not a value, so they take the segment between them- * rather than the `to` box stranding itself on a line of its own.- */.custom-replacement-entry {display: flex;align-items: center;@@ -179,11 +170,7 @@opacity: 0.5;}-/*- * Both sized to the segment rather than to an icon button anywhere else, so a segment does not grow- * the moment a pair is complete and shrink again once it is taken — a row is as tall as the tallest- * thing in it.- */+/* Sized alike, so a segment's height does not change as a pair is completed or removed. */.custom-replacement-add,.custom-replacement-remove {--icon-button-size: 20px;