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: refactor
Adorian Dorancb49781f4c98
diff --git a/apps/client/src/stylesheets/theme-next/pages.css b/apps/client/src/stylesheets/theme-next/pages.cssindex faac56387a..5a53b9a3d5 100644--- a/apps/client/src/stylesheets/theme-next/pages.css+++ b/apps/client/src/stylesheets/theme-next/pages.css@@ -154,8 +154,18 @@ body.experimental-feature-new-layout .note-detail-content-widget-content.optionspadding-inline: 25px;}+/* Every top-level block of an options page is a section of it; only the header spans the full pane. */+.note-detail-content-widget-content.options > *:not(.options-page-header) {+ margin-bottom: 26px;+}++body.desktop .note-detail-content-widget-content.options > *:not(.options-page-header) {+ max-width: var(--options-card-max-width);+ margin-inline: auto;+}+.options-section:not(.tn-no-card) {- margin-bottom: 26px !important;+ margin-bottom: 26px;}body.desktop .options-section:not(.tn-no-card) {diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.css b/apps/client/src/widgets/dialogs/OptionsDialog.cssindex 22abcbac46..5ed10c0614 100644--- a/apps/client/src/widgets/dialogs/OptionsDialog.css+++ b/apps/client/src/widgets/dialogs/OptionsDialog.css@@ -44,10 +44,6 @@ body.desktop .modal.options-dialog > .modal-dialog > .modal-content > .modal-maiz-index: 9999;}-.modal.options-dialog .options-section {- margin: auto;-}-/* The dialog fills the full mobile page (isFullPageOnMobile), so the body stretches instead ofusing the fixed desktop height. Applies to both the master-detail and the tablet layout. */body.mobile .modal.options-dialog > .modal-dialog > .modal-content > .modal-main > .modal-body,diff --git a/apps/client/src/widgets/type_widgets/options/advanced.tsx b/apps/client/src/widgets/type_widgets/options/advanced.tsxindex c755004c41..c12caa48f1 100644--- a/apps/client/src/widgets/type_widgets/options/advanced.tsx+++ b/apps/client/src/widgets/type_widgets/options/advanced.tsx@@ -37,64 +37,60 @@ function ExperimentalOptions() {}return (- <div className="options-section">- <Card- heading={t("experimental_features.title")}- description={t("experimental_features.disclaimer")}- >- {filteredFeatures.map((feature) => (- <CardOption- key={feature.id}- name={`experimental-${feature.id}`}- label={feature.name}- description={feature.description}- >- <FormToggle- currentValue={enabledFeatures.includes(feature.id)}- onChange={(enabled) => toggleFeature(feature.id, enabled)}- />- </CardOption>- ))}- </Card>- </div>+ <Card+ heading={t("experimental_features.title")}+ description={t("experimental_features.disclaimer")}+ >+ {filteredFeatures.map((feature) => (+ <CardOption+ key={feature.id}+ name={`experimental-${feature.id}`}+ label={feature.name}+ description={feature.description}+ >+ <FormToggle+ currentValue={enabledFeatures.includes(feature.id)}+ onChange={(enabled) => toggleFeature(feature.id, enabled)}+ />+ </CardOption>+ ))}+ </Card>);}function AdvancedSyncOptions() {return (- <div className="options-section">- <Card heading={t("sync.title")}>- <CardOption- label={t("sync.force_full_sync_label")}- description={t("sync.force_full_sync_description")}- >- <Button- name="force-full-sync-button"- text={t("sync.force_full_sync_button")}- size="micro"- onClick={async () => {- await server.post("sync/force-full-sync");- toast.showMessage(t("sync.full_sync_triggered"));- }}- />- </CardOption>+ <Card heading={t("sync.title")}>+ <CardOption+ label={t("sync.force_full_sync_label")}+ description={t("sync.force_full_sync_description")}+ >+ <Button+ name="force-full-sync-button"+ text={t("sync.force_full_sync_button")}+ size="micro"+ onClick={async () => {+ await server.post("sync/force-full-sync");+ toast.showMessage(t("sync.full_sync_triggered"));+ }}+ />+ </CardOption>- <CardOption- label={t("sync.fill_entity_changes_label")}- description={t("sync.fill_entity_changes_description")}- >- <Button- name="fill-entity-changes-button"- text={t("sync.fill_entity_changes_button")}- size="micro"- onClick={async () => {- toast.showMessage(t("sync.filling_entity_changes"));- await server.post("sync/fill-entity-changes");- toast.showMessage(t("sync.sync_rows_filled_successfully"));- }}- />- </CardOption>- </Card>- </div>+ <CardOption+ label={t("sync.fill_entity_changes_label")}+ description={t("sync.fill_entity_changes_description")}+ >+ <Button+ name="fill-entity-changes-button"+ text={t("sync.fill_entity_changes_button")}+ size="micro"+ onClick={async () => {+ toast.showMessage(t("sync.filling_entity_changes"));+ await server.post("sync/fill-entity-changes");+ toast.showMessage(t("sync.sync_rows_filled_successfully"));+ }}+ />+ </CardOption>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsxindex 43fe080659..793975b1f5 100644--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx@@ -1,783 +1,773 @@-import "./appearance.css";--import { FontFamily, OptionNames, SYSTEM_MONOSPACE_FONT_STACK, SYSTEM_SANS_SERIF_FONT_STACK } from "@triliumnext/commons";-import clsx from "clsx";-import { Fragment } from "preact";-import { createPortal } from "preact/compat";-import { useEffect, useMemo, useState } from "preact/hooks";--import zoomService from "../../../components/zoom";-import { ColorScheme, resolveColorScheme, THEME_FAMILY_SCHEMES } from "../../../services/color_scheme";-import { t } from "../../../services/i18n";-import server from "../../../services/server";-import { isElectron, isMobile, reloadFrontendApp } from "../../../services/utils";-import { VerticalLayoutIcon } from "../../buttons/global_menu";-import { Card, CardOption, CardSection } from "../../react/Card";-import Dropdown from "../../react/Dropdown";-import FormList, { FormListHeader, FormListItem } from "../../react/FormList";-import { FormTextBoxWithUnit } from "../../react/FormTextBox";-import FormToggle from "../../react/FormToggle";-import HelpButton from "../../react/HelpButton";-import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";-import Icon from "../../react/Icon";-import Modal from "../../react/Modal";-import SegmentedChoice, { SegmentedChoiceOption } from "../../react/SegmentedChoice";-import Slider from "../../react/Slider";-import OptionsPageHeader from "./components/OptionsPageHeader";-import PlatformIndicator from "./components/PlatformIndicator";-import RadioWithIllustration from "./components/RadioWithIllustration";-import RelatedSettings from "./components/RelatedSettings";-import RestartAction from "./components/RestartAction";--const MIN_CONTENT_WIDTH = 640;--interface CustomTheme {- val: string;- title: string;- icon?: string;- noteId?: string;-}--interface ThemeFamily {- key: string;- title: string;- icon: string;- schemes: Record<ColorScheme, string>;-}--const THEME_FAMILIES: ThemeFamily[] = [- {- key: "modern",- title: t("theme.modern_themes"),- icon: "bx bx-star",- schemes: THEME_FAMILY_SCHEMES.modern- },- {- key: "legacy",- title: t("theme.legacy_themes"),- icon: "bx bx-history",- schemes: THEME_FAMILY_SCHEMES.legacy- }-];--const COLOR_SCHEMES: SegmentedChoiceOption<ColorScheme>[] = [- { value: "system", label: t("theme.color_scheme_system"), icon: "bx-brightness-half" },- { value: "light", label: t("theme.color_scheme_light"), icon: "bx-sun" },- { value: "dark", label: t("theme.color_scheme_dark"), icon: "bx-moon" }-];--function resolveTheme(themeVal: string | null): { family: ThemeFamily | null; scheme: ColorScheme; isCustom: boolean } {- const { family: familyKey, scheme, isCustom } = resolveColorScheme(themeVal);- const family = THEME_FAMILIES.find(f => f.key === familyKey) ?? null;- return { family, scheme, isCustom };-}--interface FontFamilyEntry {- value: FontFamily;- label?: string;-}--interface FontGroup {- title: string;- items: FontFamilyEntry[];-}--const FONT_FAMILIES: FontGroup[] = [- {- title: t("fonts.generic-fonts"),- items: [- { value: "theme", label: t("fonts.theme_defined") },- { value: "system", label: t("fonts.system-default") },- { value: "serif", label: t("fonts.serif") },- { value: "sans-serif", label: t("fonts.sans-serif") },- { value: "monospace", label: t("fonts.monospace") }- ]- },- {- title: t("fonts.sans-serif-system-fonts"),- items: [{ value: "Arial" }, { value: "Verdana" }, { value: "Helvetica" }, { value: "Tahoma" }, { value: "Trebuchet MS" }, { value: "Microsoft YaHei" }]- },- {- title: t("fonts.serif-system-fonts"),- items: [{ value: "Times New Roman" }, { value: "Georgia" }, { value: "Garamond" }]- },- {- title: t("fonts.monospace-system-fonts"),- items: [- { value: "Courier New" },- { value: "Brush Script MT" },- { value: "Impact" },- { value: "American Typewriter" },- { value: "Andalé Mono" },- { value: "Lucida Console" },- { value: "Monaco" }- ]- },- {- title: t("fonts.handwriting-system-fonts"),- items: [{ value: "Bradley Hand" }, { value: "Luminari" }, { value: "Comic Sans MS" }]- }-];--export default function AppearanceSettings() {- return (- <>- <OptionsPageHeader />- <UserInterface />- {!isMobile() && <LayoutChoices />}- <Fonts />- {isElectron() && <ElectronIntegration /> }- <Performance />- <MaxContentWidth />- <RelatedSettings items={[- {- title: t("settings_appearance.related_code_blocks"),- targetPage: "_optionsTextNotes"- },- {- title: t("settings_appearance.related_code_notes"),- targetPage: "_optionsCodeNotes"- }- ]} />- </>- );-}--function UserInterface() {- const [ theme, setTheme ] = useTriliumOption("theme");- const [ customThemes, setCustomThemes ] = useState<CustomTheme[]>([]);- const [ newLayout ] = useTriliumOptionBool("newLayout");- const [ editedNotesOpenInRibbon, setEditedNotesOpenInRibbon ] = useTriliumOptionBool("editedNotesOpenInRibbon");-- useEffect(() => {- server.get<CustomTheme[]>("options/user-themes").then((userThemes) => {- setCustomThemes(userThemes);- });- }, []);-- const resolved = useMemo(() => resolveTheme(theme ?? null), [theme]);- const isCustom = resolved.isCustom;-- // Derive display info for the theme family dropdown- const currentFamilyLabel = resolved.family?.title- ?? customThemes.find(ct => ct.val === theme)?.title- ?? theme ?? "";- const currentFamilyIcon = resolved.family?.icon- ?? customThemes.find(ct => ct.val === theme)?.icon- ?? "bx bx-palette";-- const setFamily = (family: ThemeFamily) => {- // Keep current color scheme when switching families- setTheme(family.schemes[resolved.scheme]);- };-- const setColorScheme = (scheme: ColorScheme) => {- if (resolved.family) {- setTheme(resolved.family.schemes[scheme]);- }- };-- return (- <div className="options-section">- <Card heading={t("theme.title")}>- <CardOption name="theme" label={t("theme.theme_label")}>- <Dropdown- text={<>- <span className={currentFamilyIcon} style={{ marginRight: "8px" }} />- {currentFamilyLabel}- </>}- mobileBottomSheet- >- {THEME_FAMILIES.map(family => (- <FormListItem- key={family.key}- icon={family.icon}- selected={resolved.family?.key === family.key}- onClick={() => setFamily(family)}- badges={family.key === "modern" ? [{ text: t("theme.recommended") }] : undefined}- >- {family.title}- </FormListItem>- ))}- {customThemes.length > 0 && (- <>- <FormListHeader text={t("theme.custom_themes")} />- {customThemes.map(ct => (- <FormListItem- key={ct.val}- icon={ct.icon}- selected={theme === ct.val}- onClick={() => setTheme(ct.val)}- >- {ct.title}- </FormListItem>- ))}- </>- )}- </Dropdown>- </CardOption>-- <CardOption- name="color-scheme"- label={t("theme.color_scheme")}- description={isCustom ? t("theme.color_scheme_custom_disabled") : undefined}- >- <SegmentedChoice- options={COLOR_SCHEMES}- // A custom theme brings its own colours, so the group highlights nothing rather- // than naming a scheme it is not following.- currentValue={isCustom ? "" : resolved.scheme}- onChange={setColorScheme}- disabled={isCustom}- collapseOnMobile- />- </CardOption>-- {!isMobile() && !newLayout && (- <CardOption- name="edited-notes-open-in-ribbon"- label={t("ribbon.edited_notes_message")}- >- <FormToggle- currentValue={editedNotesOpenInRibbon}- onChange={setEditedNotesOpenInRibbon}- />- </CardOption>- )}- </Card>- </div>- );-}--/**- * The two choices that decide the shape of the window, each shown as a picture rather than named in- * words. Neither fits a settings row — an illustration is too large to stand as a value beside a- * label — so each takes a card of its own, with what the choice is called as the card's heading.- *- * Side by side, being read against one another rather than one after the other; a pane too narrow to- * hold both puts them on lines of their own instead (see the CSS).- */-function LayoutChoices() {- return (- <div className="options-section appearance-layout-choices">- <LayoutOrientation />- <LayoutStyle />- </div>- );-}--function LayoutStyle() {- const [ newLayout, setNewLayout ] = useTriliumOptionBool("newLayout");-- return (- <Card className="thumbnail-selector-option-card" heading={t("settings_appearance.ui_layout_style")}>- <CardSection>- <RadioWithIllustration- currentValue={newLayout ? "new-layout" : "old-layout"}- onChange={async newValue => {- await setNewLayout(newValue === "new-layout");- reloadFrontendApp();- }}- values={[- { key: "old-layout", text: t("settings_appearance.ui_old_layout"), illustration: <LayoutIllustration /> },- { key: "new-layout", text: t("settings_appearance.ui_new_layout"), illustration: <LayoutIllustration isNewLayout /> }- ]}- />- </CardSection>- </Card>- );-}--function LayoutOrientation() {- const [ layoutOrientation, setLayoutOrientation ] = useTriliumOption("layoutOrientation", true);-- return (- <Card className="thumbnail-selector-option-card" heading={t("settings_appearance.ui_layout_orientation")}>- <CardSection>- <RadioWithIllustration- currentValue={layoutOrientation ?? "vertical"}- onChange={setLayoutOrientation}- values={[- { key: "vertical", text: t("theme.layout-vertical-title"), illustration: <OrientationIllustration orientation="vertical" /> },- { key: "horizontal", text: t("theme.layout-horizontal-title"), illustration: <OrientationIllustration orientation="horizontal" /> }- ]}- />- </CardSection>- </Card>- );-}--function LayoutIllustration({ isNewLayout }: { isNewLayout?: boolean }) {- return (- <div className="old-layout-illustration">- <div className="launcher-pane">- <VerticalLayoutIcon />- <Icon icon="bx bx-send" />- <Icon icon="bx bx-file-blank" />- <Icon icon="bx bx-search" />- </div>-- <div className="tree">- <ul>- <li>Options</li>- <ul>- <li>Appearance</li>- <li>Shortcuts</li>- <li>Text Notes</li>- <li>Code Notes</li>- <li>Images</li>- </ul>- </ul>- </div>-- <div className="main">- <div className="tab-bar" />-- <div className="content">-- {(isNewLayout) ? (- <div className="note-header">- <div className="note-toolbar">- <Icon icon="bx bx-dock-right" />- </div>- <div className="note-inline-title">- <Icon className="note-icon" icon="bx bx-leaf" />- <div className="note-title-row">- <div className="title">Title</div>- <div className="subtitle">Just a sample note</div>- </div>- </div>- </div>- ) : (- <div>- <div className="title-bar">- <Icon icon="bx bx-leaf" />- <span className="title">Title</span>- <Icon icon="bx bx-dock-right" />- </div>- </div>- )}-- {!isNewLayout && <div className="ribbon">- <div className="ribbon-header">- <Icon icon="bx bx-slider" />- <Icon icon="bx bx-list-check" />- <Icon icon="bx bx-list-plus" />- <Icon icon="bx bx-collection" />- </div>-- <div className="ribbon-body">- <div className="ribbon-body-content" />- </div>- </div>}-- {isNewLayout && <div className="note-title-actions">- <Icon icon="bx bx-chevron-down" />{" "}Promoted attributes- </div>}-- <div className="content-inner">- This is a "demo" document packaged with Trilium to showcase some of its features and also give you some ideas on how you might structure your notes. You can play with it, and modify the note content and tree structure as you wish.- </div>-- {isNewLayout && <div className="status-bar">- <div className="status-bar-breadcrumb">- <Icon icon="bx bx-home" />- <Icon icon="bx bx-chevron-right" />- Note- <Icon icon="bx bx-chevron-right" />- Note- </div>-- <div className="status-bar-actions">- <Icon icon="bx bx-list-check" />- <Icon icon="bx bx-info-circle" />- </div>- </div>}- </div>- </div>- </div>- );-}--function OrientationIllustration({ orientation }: { orientation: "vertical" | "horizontal" }) {- const isHorizontal = orientation === "horizontal";-- return (- <div className={`orientation-illustration ${orientation}`}>- {isHorizontal && (- <div className="tab-bar full-width">- <div className="tab active" />- <div className="tab" />- <div className="tab" />- </div>- )}- {isHorizontal && (- <div className="launcher-bar horizontal">- <Icon icon="bx bx-menu" />- <Icon icon="bx bx-send" />- <Icon icon="bx bx-file-blank" />- <Icon icon="bx bx-search" />- </div>- )}- <div className="main-area">- {!isHorizontal && (- <div className="launcher-bar vertical">- <Icon icon="bx bx-menu" />- <Icon icon="bx bx-send" />- <Icon icon="bx bx-file-blank" />- <Icon icon="bx bx-search" />- </div>- )}- <div className="tree-pane">- <div className="tree-content" />- </div>- <div className="content-pane">- {!isHorizontal && (- <div className="tab-bar">- <div className="tab active" />- <div className="tab" />- <div className="tab" />- </div>- )}- <div className="note-content" />- </div>- </div>- </div>- );-}--function Fonts() {- const [ overrideThemeFonts, setOverrideThemeFonts ] = useTriliumOptionBool("overrideThemeFonts");- const [ ligaturesEnabled, setLigaturesEnabled ] = useTriliumOptionBool("monospaceLigaturesEnabled");- const isEnabled = overrideThemeFonts === true;-- return (- <div className="options-section appearance-fonts">- <Card heading={t("fonts.fonts")}>- <CardOption- name="override-theme-fonts"- label={t("fonts.custom_fonts")}- description={t("fonts.not_all_fonts_available")}- // The four fonts stay on show with the switch off, greyed rather than gone: what- // is there to be set is the whole reason for turning it on, and a switch with- // nothing under it says nothing about what it would bring.- subSectionsVisible- subSections={[- <Font key="main" label={t("fonts.main_font")} fontFamilyOption="mainFontFamily" fontSizeOption="mainFontSize" disabled={!isEnabled} />,- <Font key="tree" label={t("fonts.note_tree_font")} sizeDescription={t("fonts.size_relative_to_general")} fontFamilyOption="treeFontFamily" fontSizeOption="treeFontSize" disabled={!isEnabled} />,- <Font key="detail" label={t("fonts.note_detail_font")} sizeDescription={t("fonts.size_relative_to_general")} fontFamilyOption="detailFontFamily" fontSizeOption="detailFontSize" disabled={!isEnabled} />,- <Font key="monospace" label={t("fonts.monospace_font")} description={t("fonts.monospace_font_description")} fontFamilyOption="monospaceFontFamily" fontSizeOption="monospaceFontSize" disabled={!isEnabled} isMonospace />- ]}- >- <FormToggle currentValue={overrideThemeFonts} onChange={setOverrideThemeFonts} />- </CardOption>-- {/*- * Deliberately not nested under `overrideThemeFonts` like the fonts above: the- * ligatures come from the *theme's* monospace font, so the setting is needed exactly- * when custom fonts are off. Gating it would put it out of reach of everyone affected.- */}- <CardOption- name="monospace-ligatures-enabled"- label={t("fonts.monospace_ligatures")}- description={t("fonts.monospace_ligatures_description")}- >- <FormToggle currentValue={ligaturesEnabled} onChange={setLigaturesEnabled} />- </CardOption>- </Card>- </div>- );-}--interface FontProps {- label: string;- description?: string;- sizeDescription?: string;- fontFamilyOption: OptionNames;- fontSizeOption: OptionNames;- disabled?: boolean;- isMonospace?: boolean;-}--function Font({ label, description, sizeDescription, fontFamilyOption, fontSizeOption, disabled, isMonospace }: FontProps) {- const [ fontFamily, setFontFamily ] = useTriliumOption(fontFamilyOption);- const [ fontSize, setFontSize ] = useTriliumOption(fontSizeOption);- const [ showModal, setShowModal ] = useState(false);-- // Find the current font entry to display- const currentFont = FONT_FAMILIES- .flatMap(group => group.items)- .find(item => item.value === fontFamily);- const displayLabel = currentFont?.label ?? currentFont?.value ?? fontFamily ?? "";-- // Map option name to CSS variable- const themeCssVariable = {- mainFontFamily: "var(--main-font-family)",- treeFontFamily: "var(--tree-font-family)",- detailFontFamily: "var(--detail-font-family)",- monospaceFontFamily: "var(--monospace-font-family)"- }[fontFamilyOption] ?? "inherit";-- // Get the CSS font-family value for preview- const getFontFamily = (value: string) => {- if (value === "theme") {- // Use the theme's CSS variable for this font option- return themeCssVariable;- }- if (value === "system") {- // Use the appropriate system font stack- return isMonospace ? SYSTEM_MONOSPACE_FONT_STACK : SYSTEM_SANS_SERIF_FONT_STACK;- }- return value;- };-- return (- <>- <CardOption- className={clsx("font-option", disabled && "disabled")}- label={label}- description={description}- onAction={disabled ? undefined : () => setShowModal(true)}- >- <span className="font-option-preview">- <span className="font-option-specimen" style={{ fontFamily: getFontFamily(fontFamily ?? ""), fontSize: `${fontSize}%` }}>{displayLabel}</span>- <span className="bx bx-chevron-right" />- </span>- </CardOption>-- <FontPickerModal- show={showModal}- onHidden={() => setShowModal(false)}- title={label}- fontFamily={fontFamily ?? ""}- fontSize={parseInt(fontSize ?? "100", 10)}- onFontFamilyChange={setFontFamily}- onFontSizeChange={(size) => setFontSize(String(size))}- getFontFamily={getFontFamily}- sizeDescription={sizeDescription}- />- </>- );-}--const PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog. 0123456789";--interface FontPickerModalProps {- show: boolean;- onHidden: () => void;- title: string;- fontFamily: string;- fontSize: number;- onFontFamilyChange: (value: string) => void;- onFontSizeChange: (value: number) => void;- getFontFamily: (value: string) => string | undefined;- sizeDescription?: string;-}--function FontPickerModal({ show, onHidden, title, fontFamily, fontSize, onFontFamilyChange, onFontSizeChange, getFontFamily, sizeDescription }: FontPickerModalProps) {- return createPortal(- <Modal- className="font-picker-modal"- title={title}- size="lg"- show={show}- onHidden={onHidden}- stackable- sidebar={- <FormList fullHeight wrapperClassName="font-picker-list">- {FONT_FAMILIES.map(group => (- <Fragment key={group.title}>- <FormListHeader text={group.title} />- {group.items.map(item => (- <FormListItem- key={item.value}- onClick={() => onFontFamilyChange(item.value)}- checked={fontFamily === item.value}- selected={fontFamily === item.value}- >- <span style={{ fontFamily: getFontFamily(item.value) }}>- {item.label ?? item.value}- </span>- </FormListItem>- ))}- </Fragment>- ))}- </FormList>- }- >- <div className="font-picker-settings">- <div className="font-size-control">- <label>{t("fonts.size")}</label>- <div className="font-size-slider">- <Slider- value={fontSize}- onChange={onFontSizeChange}- min={50}- max={200}- step={5}- />- <span className="font-size-value">{fontSize}%</span>- </div>- {sizeDescription && <small className="font-size-description">{sizeDescription}</small>}- </div>-- <div className="font-preview">- <label>{t("fonts.preview")}</label>- <div- className="font-preview-text"- style={{- fontFamily: getFontFamily(fontFamily),- fontSize: `${fontSize}%`- }}- >- {PREVIEW_TEXT}- </div>- </div>- </div>- </Modal>,- document.body- );-}--function ElectronIntegration() {- const [ zoomFactor ] = useTriliumOption("zoomFactor");- const [ nativeTitleBarVisible, setNativeTitleBarVisible ] = useTriliumOptionBool("nativeTitleBarVisible");- const [ backgroundEffects, setBackgroundEffects ] = useTriliumOptionBool("backgroundEffects");-- const zoomPercentage = Math.round(parseFloat(zoomFactor || "1") * 100);- // Background effects are only supported on Windows 11 and macOS; on Linux they have no- // visual effect and would only cost the native window shadow.- const backgroundEffectsSupported = window.glob.platform === "win32" || window.glob.platform === "darwin";-- return (- <>- <div className="options-section appearance-electron">- <Card heading={t("electron_integration.desktop-application")}>- <CardOption- name="zoom-factor"- label={t("electron_integration.zoom-factor")}- description={t("zoom_factor.description")}- >- <FormTextBoxWithUnit- type="number"- min={50} max={200} step={10}- currentValue={String(zoomPercentage)}- onChange={(v) => zoomService.setZoomFactorAndSave(parseInt(v, 10) / 100)}- unit={t("units.percentage")}- />- </CardOption>-- <CardOption- name="native-title-bar"- label={t("electron_integration.native-title-bar")}- description={t("electron_integration.native-title-bar-description")}- >- <FormToggle currentValue={nativeTitleBarVisible} onChange={setNativeTitleBarVisible} />- </CardOption>-- <CardOption- name="background-effects"- label={<>{t("electron_integration.background-effects")} <PlatformIndicator windows="11" mac /></>}- description={t("electron_integration.background-effects-description")}- >- <FormToggle- currentValue={backgroundEffects}- onChange={setBackgroundEffects}- disabled={nativeTitleBarVisible || !backgroundEffectsSupported}- />- </CardOption>- </Card>- </div>-- <RestartAction text={t("electron_integration.restart-app-button")} icon="bx-refresh" />- </>- );-}--function Performance() {- const [ motionEnabled, setMotionEnabled ] = useTriliumOptionBool("motionEnabled");- const [ shadowsEnabled, setShadowsEnabled ] = useTriliumOptionBool("shadowsEnabled");- const [ backdropEffectsEnabled, setBackdropEffectsEnabled ] = useTriliumOptionBool("backdropEffectsEnabled");-- return (- <div className="options-section">- <Card heading={t("ui-performance.title")}>- <CardOption name="motion-enabled" label={t("ui-performance.enable-motion")}>- <FormToggle currentValue={motionEnabled} onChange={setMotionEnabled} />- </CardOption>-- <CardOption name="shadows-enabled" label={t("ui-performance.enable-shadows")}>- <FormToggle currentValue={shadowsEnabled} onChange={setShadowsEnabled} />- </CardOption>-- {!isMobile() && (- <CardOption name="backdrop-effects-enabled" label={t("ui-performance.enable-backdrop-effects")}>- <FormToggle currentValue={backdropEffectsEnabled} onChange={setBackdropEffectsEnabled} />- </CardOption>- )}-- {isElectron() && <SmoothScrollEnabledOption />}-- {isElectron() && <HardwareAccelerationOption />}- </Card>- </div>- );-}--function SmoothScrollEnabledOption() {- const [ smoothScrollEnabled, setSmoothScrollEnabled ] = useTriliumOptionBool("smoothScrollEnabled");-- return (- <CardOption- name="smooth-scroll-enabled"- label={t("ui-performance.enable-smooth-scroll")}- description={t("ui-performance.app-restart-required")}- >- <FormToggle currentValue={smoothScrollEnabled} onChange={setSmoothScrollEnabled} />- </CardOption>- );-}--function HardwareAccelerationOption() {- const [ hardwareAccelerationEnabled, setHardwareAccelerationEnabled ] = useTriliumOptionBool("hardwareAccelerationEnabled");-- return (- <CardOption- name="hardware-acceleration-enabled"- label={t("ui-performance.enable-hardware-acceleration")}- description={t("ui-performance.enable-hardware-acceleration-description")}- >- <FormToggle currentValue={hardwareAccelerationEnabled} onChange={setHardwareAccelerationEnabled} />- </CardOption>- );-}--function MaxContentWidth() {- const [maxContentWidth, setMaxContentWidth] = useTriliumOption("maxContentWidth");- const [centerContent, setCenterContent] = useTriliumOptionBool("centerContent");-- return (- <div className="options-section">- <Card- heading={t("max_content_width.title")}- description={t("max_content_width.default_description")}- actions={<HelpButton helpPage="t596jLvPrqkS" />}- >- <CardOption- name="max-content-width"- label={t("max_content_width.max_width_label")}- >- <FormTextBoxWithUnit- type="number" min={MIN_CONTENT_WIDTH} step="10"- currentValue={maxContentWidth} onBlur={setMaxContentWidth}- unit={t("max_content_width.max_width_unit")}- />- </CardOption>-- <CardOption name="center-content" label={t("max_content_width.centerContent")}>- <FormToggle currentValue={centerContent} onChange={setCenterContent} />- </CardOption>- </Card>- </div>- );-}+import "./appearance.css";++import { FontFamily, OptionNames, SYSTEM_MONOSPACE_FONT_STACK, SYSTEM_SANS_SERIF_FONT_STACK } from "@triliumnext/commons";+import clsx from "clsx";+import { Fragment } from "preact";+import { createPortal } from "preact/compat";+import { useEffect, useMemo, useState } from "preact/hooks";++import zoomService from "../../../components/zoom";+import { ColorScheme, resolveColorScheme, THEME_FAMILY_SCHEMES } from "../../../services/color_scheme";+import { t } from "../../../services/i18n";+import server from "../../../services/server";+import { isElectron, isMobile, reloadFrontendApp } from "../../../services/utils";+import { VerticalLayoutIcon } from "../../buttons/global_menu";+import { Card, CardOption, CardSection } from "../../react/Card";+import Dropdown from "../../react/Dropdown";+import FormList, { FormListHeader, FormListItem } from "../../react/FormList";+import { FormTextBoxWithUnit } from "../../react/FormTextBox";+import FormToggle from "../../react/FormToggle";+import HelpButton from "../../react/HelpButton";+import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";+import Icon from "../../react/Icon";+import Modal from "../../react/Modal";+import SegmentedChoice, { SegmentedChoiceOption } from "../../react/SegmentedChoice";+import Slider from "../../react/Slider";+import OptionsPageHeader from "./components/OptionsPageHeader";+import PlatformIndicator from "./components/PlatformIndicator";+import RadioWithIllustration from "./components/RadioWithIllustration";+import RelatedSettings from "./components/RelatedSettings";+import RestartAction from "./components/RestartAction";++const MIN_CONTENT_WIDTH = 640;++interface CustomTheme {+ val: string;+ title: string;+ icon?: string;+ noteId?: string;+}++interface ThemeFamily {+ key: string;+ title: string;+ icon: string;+ schemes: Record<ColorScheme, string>;+}++const THEME_FAMILIES: ThemeFamily[] = [+ {+ key: "modern",+ title: t("theme.modern_themes"),+ icon: "bx bx-star",+ schemes: THEME_FAMILY_SCHEMES.modern+ },+ {+ key: "legacy",+ title: t("theme.legacy_themes"),+ icon: "bx bx-history",+ schemes: THEME_FAMILY_SCHEMES.legacy+ }+];++const COLOR_SCHEMES: SegmentedChoiceOption<ColorScheme>[] = [+ { value: "system", label: t("theme.color_scheme_system"), icon: "bx-brightness-half" },+ { value: "light", label: t("theme.color_scheme_light"), icon: "bx-sun" },+ { value: "dark", label: t("theme.color_scheme_dark"), icon: "bx-moon" }+];++function resolveTheme(themeVal: string | null): { family: ThemeFamily | null; scheme: ColorScheme; isCustom: boolean } {+ const { family: familyKey, scheme, isCustom } = resolveColorScheme(themeVal);+ const family = THEME_FAMILIES.find(f => f.key === familyKey) ?? null;+ return { family, scheme, isCustom };+}++interface FontFamilyEntry {+ value: FontFamily;+ label?: string;+}++interface FontGroup {+ title: string;+ items: FontFamilyEntry[];+}++const FONT_FAMILIES: FontGroup[] = [+ {+ title: t("fonts.generic-fonts"),+ items: [+ { value: "theme", label: t("fonts.theme_defined") },+ { value: "system", label: t("fonts.system-default") },+ { value: "serif", label: t("fonts.serif") },+ { value: "sans-serif", label: t("fonts.sans-serif") },+ { value: "monospace", label: t("fonts.monospace") }+ ]+ },+ {+ title: t("fonts.sans-serif-system-fonts"),+ items: [{ value: "Arial" }, { value: "Verdana" }, { value: "Helvetica" }, { value: "Tahoma" }, { value: "Trebuchet MS" }, { value: "Microsoft YaHei" }]+ },+ {+ title: t("fonts.serif-system-fonts"),+ items: [{ value: "Times New Roman" }, { value: "Georgia" }, { value: "Garamond" }]+ },+ {+ title: t("fonts.monospace-system-fonts"),+ items: [+ { value: "Courier New" },+ { value: "Brush Script MT" },+ { value: "Impact" },+ { value: "American Typewriter" },+ { value: "Andalé Mono" },+ { value: "Lucida Console" },+ { value: "Monaco" }+ ]+ },+ {+ title: t("fonts.handwriting-system-fonts"),+ items: [{ value: "Bradley Hand" }, { value: "Luminari" }, { value: "Comic Sans MS" }]+ }+];++export default function AppearanceSettings() {+ return (+ <>+ <OptionsPageHeader />+ <UserInterface />+ {!isMobile() && <LayoutChoices />}+ <Fonts />+ {isElectron() && <ElectronIntegration /> }+ <Performance />+ <MaxContentWidth />+ <RelatedSettings items={[+ {+ title: t("settings_appearance.related_code_blocks"),+ targetPage: "_optionsTextNotes"+ },+ {+ title: t("settings_appearance.related_code_notes"),+ targetPage: "_optionsCodeNotes"+ }+ ]} />+ </>+ );+}++function UserInterface() {+ const [ theme, setTheme ] = useTriliumOption("theme");+ const [ customThemes, setCustomThemes ] = useState<CustomTheme[]>([]);+ const [ newLayout ] = useTriliumOptionBool("newLayout");+ const [ editedNotesOpenInRibbon, setEditedNotesOpenInRibbon ] = useTriliumOptionBool("editedNotesOpenInRibbon");++ useEffect(() => {+ server.get<CustomTheme[]>("options/user-themes").then((userThemes) => {+ setCustomThemes(userThemes);+ });+ }, []);++ const resolved = useMemo(() => resolveTheme(theme ?? null), [theme]);+ const isCustom = resolved.isCustom;++ // Derive display info for the theme family dropdown+ const currentFamilyLabel = resolved.family?.title+ ?? customThemes.find(ct => ct.val === theme)?.title+ ?? theme ?? "";+ const currentFamilyIcon = resolved.family?.icon+ ?? customThemes.find(ct => ct.val === theme)?.icon+ ?? "bx bx-palette";++ const setFamily = (family: ThemeFamily) => {+ // Keep current color scheme when switching families+ setTheme(family.schemes[resolved.scheme]);+ };++ const setColorScheme = (scheme: ColorScheme) => {+ if (resolved.family) {+ setTheme(resolved.family.schemes[scheme]);+ }+ };++ return (+ <Card heading={t("theme.title")}>+ <CardOption name="theme" label={t("theme.theme_label")}>+ <Dropdown+ text={<>+ <span className={currentFamilyIcon} style={{ marginRight: "8px" }} />+ {currentFamilyLabel}+ </>}+ mobileBottomSheet+ >+ {THEME_FAMILIES.map(family => (+ <FormListItem+ key={family.key}+ icon={family.icon}+ selected={resolved.family?.key === family.key}+ onClick={() => setFamily(family)}+ badges={family.key === "modern" ? [{ text: t("theme.recommended") }] : undefined}+ >+ {family.title}+ </FormListItem>+ ))}+ {customThemes.length > 0 && (+ <>+ <FormListHeader text={t("theme.custom_themes")} />+ {customThemes.map(ct => (+ <FormListItem+ key={ct.val}+ icon={ct.icon}+ selected={theme === ct.val}+ onClick={() => setTheme(ct.val)}+ >+ {ct.title}+ </FormListItem>+ ))}+ </>+ )}+ </Dropdown>+ </CardOption>++ <CardOption+ name="color-scheme"+ label={t("theme.color_scheme")}+ description={isCustom ? t("theme.color_scheme_custom_disabled") : undefined}+ >+ <SegmentedChoice+ options={COLOR_SCHEMES}+ // A custom theme brings its own colours, so the group highlights nothing rather+ // than naming a scheme it is not following.+ currentValue={isCustom ? "" : resolved.scheme}+ onChange={setColorScheme}+ disabled={isCustom}+ collapseOnMobile+ />+ </CardOption>++ {!isMobile() && !newLayout && (+ <CardOption+ name="edited-notes-open-in-ribbon"+ label={t("ribbon.edited_notes_message")}+ >+ <FormToggle+ currentValue={editedNotesOpenInRibbon}+ onChange={setEditedNotesOpenInRibbon}+ />+ </CardOption>+ )}+ </Card>+ );+}++/**+ * The two choices that decide the shape of the window, each shown as a picture rather than named in+ * words. Neither fits a settings row — an illustration is too large to stand as a value beside a+ * label — so each takes a card of its own, with what the choice is called as the card's heading.+ *+ * Side by side, being read against one another rather than one after the other; a pane too narrow to+ * hold both puts them on lines of their own instead (see the CSS).+ */+function LayoutChoices() {+ return (+ <div className="appearance-layout-choices">+ <LayoutOrientation />+ <LayoutStyle />+ </div>+ );+}++function LayoutStyle() {+ const [ newLayout, setNewLayout ] = useTriliumOptionBool("newLayout");++ return (+ <Card className="thumbnail-selector-option-card" heading={t("settings_appearance.ui_layout_style")}>+ <CardSection>+ <RadioWithIllustration+ currentValue={newLayout ? "new-layout" : "old-layout"}+ onChange={async newValue => {+ await setNewLayout(newValue === "new-layout");+ reloadFrontendApp();+ }}+ values={[+ { key: "old-layout", text: t("settings_appearance.ui_old_layout"), illustration: <LayoutIllustration /> },+ { key: "new-layout", text: t("settings_appearance.ui_new_layout"), illustration: <LayoutIllustration isNewLayout /> }+ ]}+ />+ </CardSection>+ </Card>+ );+}++function LayoutOrientation() {+ const [ layoutOrientation, setLayoutOrientation ] = useTriliumOption("layoutOrientation", true);++ return (+ <Card className="thumbnail-selector-option-card" heading={t("settings_appearance.ui_layout_orientation")}>+ <CardSection>+ <RadioWithIllustration+ currentValue={layoutOrientation ?? "vertical"}+ onChange={setLayoutOrientation}+ values={[+ { key: "vertical", text: t("theme.layout-vertical-title"), illustration: <OrientationIllustration orientation="vertical" /> },+ { key: "horizontal", text: t("theme.layout-horizontal-title"), illustration: <OrientationIllustration orientation="horizontal" /> }+ ]}+ />+ </CardSection>+ </Card>+ );+}++function LayoutIllustration({ isNewLayout }: { isNewLayout?: boolean }) {+ return (+ <div className="old-layout-illustration">+ <div className="launcher-pane">+ <VerticalLayoutIcon />+ <Icon icon="bx bx-send" />+ <Icon icon="bx bx-file-blank" />+ <Icon icon="bx bx-search" />+ </div>++ <div className="tree">+ <ul>+ <li>Options</li>+ <ul>+ <li>Appearance</li>+ <li>Shortcuts</li>+ <li>Text Notes</li>+ <li>Code Notes</li>+ <li>Images</li>+ </ul>+ </ul>+ </div>++ <div className="main">+ <div className="tab-bar" />++ <div className="content">++ {(isNewLayout) ? (+ <div className="note-header">+ <div className="note-toolbar">+ <Icon icon="bx bx-dock-right" />+ </div>+ <div className="note-inline-title">+ <Icon className="note-icon" icon="bx bx-leaf" />+ <div className="note-title-row">+ <div className="title">Title</div>+ <div className="subtitle">Just a sample note</div>+ </div>+ </div>+ </div>+ ) : (+ <div>+ <div className="title-bar">+ <Icon icon="bx bx-leaf" />+ <span className="title">Title</span>+ <Icon icon="bx bx-dock-right" />+ </div>+ </div>+ )}++ {!isNewLayout && <div className="ribbon">+ <div className="ribbon-header">+ <Icon icon="bx bx-slider" />+ <Icon icon="bx bx-list-check" />+ <Icon icon="bx bx-list-plus" />+ <Icon icon="bx bx-collection" />+ </div>++ <div className="ribbon-body">+ <div className="ribbon-body-content" />+ </div>+ </div>}++ {isNewLayout && <div className="note-title-actions">+ <Icon icon="bx bx-chevron-down" />{" "}Promoted attributes+ </div>}++ <div className="content-inner">+ This is a "demo" document packaged with Trilium to showcase some of its features and also give you some ideas on how you might structure your notes. You can play with it, and modify the note content and tree structure as you wish.+ </div>++ {isNewLayout && <div className="status-bar">+ <div className="status-bar-breadcrumb">+ <Icon icon="bx bx-home" />+ <Icon icon="bx bx-chevron-right" />+ Note+ <Icon icon="bx bx-chevron-right" />+ Note+ </div>++ <div className="status-bar-actions">+ <Icon icon="bx bx-list-check" />+ <Icon icon="bx bx-info-circle" />+ </div>+ </div>}+ </div>+ </div>+ </div>+ );+}++function OrientationIllustration({ orientation }: { orientation: "vertical" | "horizontal" }) {+ const isHorizontal = orientation === "horizontal";++ return (+ <div className={`orientation-illustration ${orientation}`}>+ {isHorizontal && (+ <div className="tab-bar full-width">+ <div className="tab active" />+ <div className="tab" />+ <div className="tab" />+ </div>+ )}+ {isHorizontal && (+ <div className="launcher-bar horizontal">+ <Icon icon="bx bx-menu" />+ <Icon icon="bx bx-send" />+ <Icon icon="bx bx-file-blank" />+ <Icon icon="bx bx-search" />+ </div>+ )}+ <div className="main-area">+ {!isHorizontal && (+ <div className="launcher-bar vertical">+ <Icon icon="bx bx-menu" />+ <Icon icon="bx bx-send" />+ <Icon icon="bx bx-file-blank" />+ <Icon icon="bx bx-search" />+ </div>+ )}+ <div className="tree-pane">+ <div className="tree-content" />+ </div>+ <div className="content-pane">+ {!isHorizontal && (+ <div className="tab-bar">+ <div className="tab active" />+ <div className="tab" />+ <div className="tab" />+ </div>+ )}+ <div className="note-content" />+ </div>+ </div>+ </div>+ );+}++function Fonts() {+ const [ overrideThemeFonts, setOverrideThemeFonts ] = useTriliumOptionBool("overrideThemeFonts");+ const [ ligaturesEnabled, setLigaturesEnabled ] = useTriliumOptionBool("monospaceLigaturesEnabled");+ const isEnabled = overrideThemeFonts === true;++ return (+ <Card className="appearance-fonts" heading={t("fonts.fonts")}>+ <CardOption+ name="override-theme-fonts"+ label={t("fonts.custom_fonts")}+ description={t("fonts.not_all_fonts_available")}+ // The four fonts stay on show with the switch off, greyed rather than gone: what+ // is there to be set is the whole reason for turning it on, and a switch with+ // nothing under it says nothing about what it would bring.+ subSectionsVisible+ subSections={[+ <Font key="main" label={t("fonts.main_font")} fontFamilyOption="mainFontFamily" fontSizeOption="mainFontSize" disabled={!isEnabled} />,+ <Font key="tree" label={t("fonts.note_tree_font")} sizeDescription={t("fonts.size_relative_to_general")} fontFamilyOption="treeFontFamily" fontSizeOption="treeFontSize" disabled={!isEnabled} />,+ <Font key="detail" label={t("fonts.note_detail_font")} sizeDescription={t("fonts.size_relative_to_general")} fontFamilyOption="detailFontFamily" fontSizeOption="detailFontSize" disabled={!isEnabled} />,+ <Font key="monospace" label={t("fonts.monospace_font")} description={t("fonts.monospace_font_description")} fontFamilyOption="monospaceFontFamily" fontSizeOption="monospaceFontSize" disabled={!isEnabled} isMonospace />+ ]}+ >+ <FormToggle currentValue={overrideThemeFonts} onChange={setOverrideThemeFonts} />+ </CardOption>++ {/*+ * Deliberately not nested under `overrideThemeFonts` like the fonts above: the+ * ligatures come from the *theme's* monospace font, so the setting is needed exactly+ * when custom fonts are off. Gating it would put it out of reach of everyone affected.+ */}+ <CardOption+ name="monospace-ligatures-enabled"+ label={t("fonts.monospace_ligatures")}+ description={t("fonts.monospace_ligatures_description")}+ >+ <FormToggle currentValue={ligaturesEnabled} onChange={setLigaturesEnabled} />+ </CardOption>+ </Card>+ );+}++interface FontProps {+ label: string;+ description?: string;+ sizeDescription?: string;+ fontFamilyOption: OptionNames;+ fontSizeOption: OptionNames;+ disabled?: boolean;+ isMonospace?: boolean;+}++function Font({ label, description, sizeDescription, fontFamilyOption, fontSizeOption, disabled, isMonospace }: FontProps) {+ const [ fontFamily, setFontFamily ] = useTriliumOption(fontFamilyOption);+ const [ fontSize, setFontSize ] = useTriliumOption(fontSizeOption);+ const [ showModal, setShowModal ] = useState(false);++ // Find the current font entry to display+ const currentFont = FONT_FAMILIES+ .flatMap(group => group.items)+ .find(item => item.value === fontFamily);+ const displayLabel = currentFont?.label ?? currentFont?.value ?? fontFamily ?? "";++ // Map option name to CSS variable+ const themeCssVariable = {+ mainFontFamily: "var(--main-font-family)",+ treeFontFamily: "var(--tree-font-family)",+ detailFontFamily: "var(--detail-font-family)",+ monospaceFontFamily: "var(--monospace-font-family)"+ }[fontFamilyOption] ?? "inherit";++ // Get the CSS font-family value for preview+ const getFontFamily = (value: string) => {+ if (value === "theme") {+ // Use the theme's CSS variable for this font option+ return themeCssVariable;+ }+ if (value === "system") {+ // Use the appropriate system font stack+ return isMonospace ? SYSTEM_MONOSPACE_FONT_STACK : SYSTEM_SANS_SERIF_FONT_STACK;+ }+ return value;+ };++ return (+ <>+ <CardOption+ className={clsx("font-option", disabled && "disabled")}+ label={label}+ description={description}+ onAction={disabled ? undefined : () => setShowModal(true)}+ >+ <span className="font-option-preview">+ <span className="font-option-specimen" style={{ fontFamily: getFontFamily(fontFamily ?? ""), fontSize: `${fontSize}%` }}>{displayLabel}</span>+ <span className="bx bx-chevron-right" />+ </span>+ </CardOption>++ <FontPickerModal+ show={showModal}+ onHidden={() => setShowModal(false)}+ title={label}+ fontFamily={fontFamily ?? ""}+ fontSize={parseInt(fontSize ?? "100", 10)}+ onFontFamilyChange={setFontFamily}+ onFontSizeChange={(size) => setFontSize(String(size))}+ getFontFamily={getFontFamily}+ sizeDescription={sizeDescription}+ />+ </>+ );+}++const PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog. 0123456789";++interface FontPickerModalProps {+ show: boolean;+ onHidden: () => void;+ title: string;+ fontFamily: string;+ fontSize: number;+ onFontFamilyChange: (value: string) => void;+ onFontSizeChange: (value: number) => void;+ getFontFamily: (value: string) => string | undefined;+ sizeDescription?: string;+}++function FontPickerModal({ show, onHidden, title, fontFamily, fontSize, onFontFamilyChange, onFontSizeChange, getFontFamily, sizeDescription }: FontPickerModalProps) {+ return createPortal(+ <Modal+ className="font-picker-modal"+ title={title}+ size="lg"+ show={show}+ onHidden={onHidden}+ stackable+ sidebar={+ <FormList fullHeight wrapperClassName="font-picker-list">+ {FONT_FAMILIES.map(group => (+ <Fragment key={group.title}>+ <FormListHeader text={group.title} />+ {group.items.map(item => (+ <FormListItem+ key={item.value}+ onClick={() => onFontFamilyChange(item.value)}+ checked={fontFamily === item.value}+ selected={fontFamily === item.value}+ >+ <span style={{ fontFamily: getFontFamily(item.value) }}>+ {item.label ?? item.value}+ </span>+ </FormListItem>+ ))}+ </Fragment>+ ))}+ </FormList>+ }+ >+ <div className="font-picker-settings">+ <div className="font-size-control">+ <label>{t("fonts.size")}</label>+ <div className="font-size-slider">+ <Slider+ value={fontSize}+ onChange={onFontSizeChange}+ min={50}+ max={200}+ step={5}+ />+ <span className="font-size-value">{fontSize}%</span>+ </div>+ {sizeDescription && <small className="font-size-description">{sizeDescription}</small>}+ </div>++ <div className="font-preview">+ <label>{t("fonts.preview")}</label>+ <div+ className="font-preview-text"+ style={{+ fontFamily: getFontFamily(fontFamily),+ fontSize: `${fontSize}%`+ }}+ >+ {PREVIEW_TEXT}+ </div>+ </div>+ </div>+ </Modal>,+ document.body+ );+}++function ElectronIntegration() {+ const [ zoomFactor ] = useTriliumOption("zoomFactor");+ const [ nativeTitleBarVisible, setNativeTitleBarVisible ] = useTriliumOptionBool("nativeTitleBarVisible");+ const [ backgroundEffects, setBackgroundEffects ] = useTriliumOptionBool("backgroundEffects");++ const zoomPercentage = Math.round(parseFloat(zoomFactor || "1") * 100);+ // Background effects are only supported on Windows 11 and macOS; on Linux they have no+ // visual effect and would only cost the native window shadow.+ const backgroundEffectsSupported = window.glob.platform === "win32" || window.glob.platform === "darwin";++ return (+ <>+ <Card className="appearance-electron" heading={t("electron_integration.desktop-application")}>+ <CardOption+ name="zoom-factor"+ label={t("electron_integration.zoom-factor")}+ description={t("zoom_factor.description")}+ >+ <FormTextBoxWithUnit+ type="number"+ min={50} max={200} step={10}+ currentValue={String(zoomPercentage)}+ onChange={(v) => zoomService.setZoomFactorAndSave(parseInt(v, 10) / 100)}+ unit={t("units.percentage")}+ />+ </CardOption>++ <CardOption+ name="native-title-bar"+ label={t("electron_integration.native-title-bar")}+ description={t("electron_integration.native-title-bar-description")}+ >+ <FormToggle currentValue={nativeTitleBarVisible} onChange={setNativeTitleBarVisible} />+ </CardOption>++ <CardOption+ name="background-effects"+ label={<>{t("electron_integration.background-effects")} <PlatformIndicator windows="11" mac /></>}+ description={t("electron_integration.background-effects-description")}+ >+ <FormToggle+ currentValue={backgroundEffects}+ onChange={setBackgroundEffects}+ disabled={nativeTitleBarVisible || !backgroundEffectsSupported}+ />+ </CardOption>+ </Card>++ <RestartAction text={t("electron_integration.restart-app-button")} icon="bx-refresh" />+ </>+ );+}++function Performance() {+ const [ motionEnabled, setMotionEnabled ] = useTriliumOptionBool("motionEnabled");+ const [ shadowsEnabled, setShadowsEnabled ] = useTriliumOptionBool("shadowsEnabled");+ const [ backdropEffectsEnabled, setBackdropEffectsEnabled ] = useTriliumOptionBool("backdropEffectsEnabled");++ return (+ <Card heading={t("ui-performance.title")}>+ <CardOption name="motion-enabled" label={t("ui-performance.enable-motion")}>+ <FormToggle currentValue={motionEnabled} onChange={setMotionEnabled} />+ </CardOption>++ <CardOption name="shadows-enabled" label={t("ui-performance.enable-shadows")}>+ <FormToggle currentValue={shadowsEnabled} onChange={setShadowsEnabled} />+ </CardOption>++ {!isMobile() && (+ <CardOption name="backdrop-effects-enabled" label={t("ui-performance.enable-backdrop-effects")}>+ <FormToggle currentValue={backdropEffectsEnabled} onChange={setBackdropEffectsEnabled} />+ </CardOption>+ )}++ {isElectron() && <SmoothScrollEnabledOption />}++ {isElectron() && <HardwareAccelerationOption />}+ </Card>+ );+}++function SmoothScrollEnabledOption() {+ const [ smoothScrollEnabled, setSmoothScrollEnabled ] = useTriliumOptionBool("smoothScrollEnabled");++ return (+ <CardOption+ name="smooth-scroll-enabled"+ label={t("ui-performance.enable-smooth-scroll")}+ description={t("ui-performance.app-restart-required")}+ >+ <FormToggle currentValue={smoothScrollEnabled} onChange={setSmoothScrollEnabled} />+ </CardOption>+ );+}++function HardwareAccelerationOption() {+ const [ hardwareAccelerationEnabled, setHardwareAccelerationEnabled ] = useTriliumOptionBool("hardwareAccelerationEnabled");++ return (+ <CardOption+ name="hardware-acceleration-enabled"+ label={t("ui-performance.enable-hardware-acceleration")}+ description={t("ui-performance.enable-hardware-acceleration-description")}+ >+ <FormToggle currentValue={hardwareAccelerationEnabled} onChange={setHardwareAccelerationEnabled} />+ </CardOption>+ );+}++function MaxContentWidth() {+ const [maxContentWidth, setMaxContentWidth] = useTriliumOption("maxContentWidth");+ const [centerContent, setCenterContent] = useTriliumOptionBool("centerContent");++ return (+ <Card+ heading={t("max_content_width.title")}+ description={t("max_content_width.default_description")}+ actions={<HelpButton helpPage="t596jLvPrqkS" />}+ >+ <CardOption+ name="max-content-width"+ label={t("max_content_width.max_width_label")}+ >+ <FormTextBoxWithUnit+ type="number" min={MIN_CONTENT_WIDTH} step="10"+ currentValue={maxContentWidth} onBlur={setMaxContentWidth}+ unit={t("max_content_width.max_width_unit")}+ />+ </CardOption>++ <CardOption name="center-content" label={t("max_content_width.centerContent")}>+ <FormToggle currentValue={centerContent} onChange={setCenterContent} />+ </CardOption>+ </Card>+ );+}diff --git a/apps/client/src/widgets/type_widgets/options/backup.css b/apps/client/src/widgets/type_widgets/options/backup.cssindex 5caa7ef8d1..1f1f427106 100644--- a/apps/client/src/widgets/type_widgets/options/backup.css+++ b/apps/client/src/widgets/type_widgets/options/backup.css@@ -24,7 +24,7 @@/* The standalone page is this one block, so the setup form is asked to sit in a page among cardsrather than fill a note's pane the way it does where it came from. */-.options-section.standalone-backup {+.standalone-backup {.setup-form {height: auto;padding-inline: 0;diff --git a/apps/client/src/widgets/type_widgets/options/backup.tsx b/apps/client/src/widgets/type_widgets/options/backup.tsxindex 2608ecf931..aa92405df7 100644--- a/apps/client/src/widgets/type_widgets/options/backup.tsx+++ b/apps/client/src/widgets/type_widgets/options/backup.tsx@@ -89,7 +89,7 @@ function StandaloneBackupSettings() {*/export function StandaloneBackupSection() {return (- <div className="options-section standalone-backup">+ <div className="standalone-backup"><SetupForm icon="bx bx-data"><h3>{t("backup.standalone_heading")}</h3><p>{t("backup.standalone_description")}</p>@@ -206,33 +206,31 @@ export function BackupConfiguration() {const [monthlyBackupEnabled, setMonthlyBackupEnabled] = useTriliumOptionBool("monthlyBackupEnabled");return (- <div className="options-section backup-configuration">- <Card- heading={t("backup.automatic_backups_title")}- description={t("backup.automatic_backups_description")}- >- <CardOption name="daily-backup-enabled" label={t("backup.enable_daily_backup")}>- <FormToggle- currentValue={dailyBackupEnabled}- onChange={setDailyBackupEnabled}- />- </CardOption>+ <Card className="backup-configuration"+ heading={t("backup.automatic_backups_title")}+ description={t("backup.automatic_backups_description")}+ >+ <CardOption name="daily-backup-enabled" label={t("backup.enable_daily_backup")}>+ <FormToggle+ currentValue={dailyBackupEnabled}+ onChange={setDailyBackupEnabled}+ />+ </CardOption>- <CardOption name="weekly-backup-enabled" label={t("backup.enable_weekly_backup")}>- <FormToggle- currentValue={weeklyBackupEnabled}- onChange={setWeeklyBackupEnabled}- />- </CardOption>+ <CardOption name="weekly-backup-enabled" label={t("backup.enable_weekly_backup")}>+ <FormToggle+ currentValue={weeklyBackupEnabled}+ onChange={setWeeklyBackupEnabled}+ />+ </CardOption>- <CardOption name="monthly-backup-enabled" label={t("backup.enable_monthly_backup")}>- <FormToggle- currentValue={monthlyBackupEnabled}- onChange={setMonthlyBackupEnabled}- />- </CardOption>- </Card>- </div>+ <CardOption name="monthly-backup-enabled" label={t("backup.enable_monthly_backup")}>+ <FormToggle+ currentValue={monthlyBackupEnabled}+ onChange={setMonthlyBackupEnabled}+ />+ </CardOption>+ </Card>);}@@ -264,36 +262,34 @@ export function BackupLocation({ backupFolderPath, refreshCallback }: { backupFo}return (- <div className="options-section backup-location">- <Card heading={t("backup.location_title")}>- <CardSection>- <Icon icon="bx bx-folder" className="backup-location-icon" />-- <div className="backup-location-label">{t("backup.saved_in")}</div>- <div className="backup-location-path"><DirectoryLink directory={backupFolderPath} /></div>+ <Card className="backup-location" heading={t("backup.location_title")}>+ <CardSection>+ <Icon icon="bx bx-folder" className="backup-location-icon" />++ <div className="backup-location-label">{t("backup.saved_in")}</div>+ <div className="backup-location-path"><DirectoryLink directory={backupFolderPath} /></div>++ <div className="backup-location-actions">+ <Button+ name="select-backup-location-button"+ text={t("backup.select_location")}+ size="micro"+ disabled={!canSelect}+ disabledTooltip={t("backup.select_location_desktop_only")}+ onClick={selectLocation}+ />- <div className="backup-location-actions">+ {customDir && (<Button- name="select-backup-location-button"- text={t("backup.select_location")}+ name="reset-backup-location-button"+ text={t("backup.reset_location")}size="micro"- disabled={!canSelect}- disabledTooltip={t("backup.select_location_desktop_only")}- onClick={selectLocation}+ onClick={resetToDefault}/>-- {customDir && (- <Button- name="reset-backup-location-button"- text={t("backup.reset_location")}- size="micro"- onClick={resetToDefault}- />- )}- </div>- </CardSection>- </Card>- </div>+ )}+ </div>+ </CardSection>+ </Card>);}@@ -369,7 +365,7 @@ export function BackupOptions() {}return (- <div className="options-section backup-options">+ <><Card heading={t("backup.options_title")}><CardOptionlabel={t("backup.enable_encryption")}@@ -418,7 +414,7 @@ export function BackupOptions() {onHidden={() => setPasswordModalShown(false)}onSave={storePassword}/>- </div>+ </>);}diff --git a/apps/client/src/widgets/type_widgets/options/code_notes.tsx b/apps/client/src/widgets/type_widgets/options/code_notes.tsxindex ee3af09672..14da7db2fc 100644--- a/apps/client/src/widgets/type_widgets/options/code_notes.tsx+++ b/apps/client/src/widgets/type_widgets/options/code_notes.tsx@@ -42,48 +42,46 @@ function Editor({ wordWrapping, setWordWrapping }: EditorProps) {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>+ <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>);}@@ -119,44 +117,42 @@ function Appearance({ wordWrapping, indentSize }: AppearanceProps) {: 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")}>+ <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={allThemes}+ values={darkThemes}keyProperty="id" titleProperty="name"- currentValue={codeNoteTheme} onChange={setCodeNoteTheme}+ currentValue={darkTheme} onChange={setDarkTheme}/></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>+ </>+ ) : (+ <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>);}@@ -222,13 +218,11 @@ function reindentSample(sample: string, indentSize: number): string {function CodeMimeTypes() {return (- <div className="options-section">- <Card heading={t("code_mime_types.title")}>- <CardSection>- <CodeMimeTypesList />- </CardSection>- </Card>- </div>+ <Card heading={t("code_mime_types.title")}>+ <CardSection>+ <CodeMimeTypesList />+ </CardSection>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsx b/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsxindex b25d455a79..4167a6122f 100644--- a/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/DatabaseFileList.tsx@@ -49,47 +49,45 @@ export default function DatabaseFileList<T extends DatabaseFile>(props: Database}), [files]);return (- <div className="options-section database-file-list">- <Card heading={title} description={description}>- {sortedFiles.length > 0 ? (- sortedFiles.map((file) => (- <CardOption- key={file.filePath}- label={- <span className="database-file-label">- <span className="selectable-text">{file.fileName}</span>- <DatabaseFileBadges badges={fileBadges?.(file) ?? []} />- </span>- }- description={describeDatabaseFile(file)}- >+ <Card className="database-file-list" heading={title} description={description}>+ {sortedFiles.length > 0 ? (+ sortedFiles.map((file) => (+ <CardOption+ key={file.filePath}+ label={+ <span className="database-file-label">+ <span className="selectable-text">{file.fileName}</span>+ <DatabaseFileBadges badges={fileBadges?.(file) ?? []} />+ </span>+ }+ description={describeDatabaseFile(file)}+ >+ <ActionButton+ icon="bx bx-download"+ text={downloadText}+ onClick={() => downloadFile(downloadEndpoint, file.filePath)}+ />++ {/* Labelled from the shared catalogue rather than per list: removing a+ file is the same act whichever list it is in. */}+ {onDelete && (<ActionButton- icon="bx bx-download"- text={downloadText}- onClick={() => downloadFile(downloadEndpoint, file.filePath)}+ className="destructive-action-icon"+ icon="bx bx-trash"+ text={t("database_file_list.delete")}+ onClick={() => onDelete(file)}/>+ )}+ </CardOption>+ ))+ ) : (+ <CardSection>+ <NoItems icon={emptyIcon} text={emptyText} size="small" />+ </CardSection>+ )}- {/* Labelled from the shared catalogue rather than per list: removing a- file is the same act whichever list it is in. */}- {onDelete && (- <ActionButton- className="destructive-action-icon"- icon="bx bx-trash"- text={t("database_file_list.delete")}- onClick={() => onDelete(file)}- />- )}- </CardOption>- ))- ) : (- <CardSection>- <NoItems icon={emptyIcon} text={emptyText} size="small" />- </CardSection>- )}-- {children}- </Card>- </div>+ {children}+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx b/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsxindex e10a86742f..aa7650947e 100644--- a/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx@@ -34,33 +34,31 @@ export default function RelatedSettings({ items, title }: RelatedSettingsProps)}return (- <div className="options-section">- <Card heading={title ?? t("settings.related_settings")}>- {filteredItems.map((item) => {- const { targetPage, targetNoteId, onClick } = item;- return (- <CardOption- key={targetPage ?? targetNoteId}- label={item.title}- description={item.description}- href={targetNoteId- ? `#root/_hidden/${targetNoteId}`- : `#root/_hidden/_options/${targetPage}`}- noContainedNavigation={!!targetNoteId || !!onClick}- onAction={onClick ?? (targetNoteId- ? (e) => {- // Hidden-subtree config notes open hoisted, in a tree-sidebar popup.- // stopPropagation keeps the global `a` click handler- // (link.ts `goToLink`) from navigating by href instead.- e.preventDefault();- e.stopPropagation();- void appContext.triggerCommand("openInTreePopup", { noteIdOrPath: targetNoteId, hoistedNoteId: targetNoteId });- }- : undefined)}- />- );- })}- </Card>- </div>+ <Card heading={title ?? t("settings.related_settings")}>+ {filteredItems.map((item) => {+ const { targetPage, targetNoteId, onClick } = item;+ return (+ <CardOption+ key={targetPage ?? targetNoteId}+ label={item.title}+ description={item.description}+ href={targetNoteId+ ? `#root/_hidden/${targetNoteId}`+ : `#root/_hidden/_options/${targetPage}`}+ noContainedNavigation={!!targetNoteId || !!onClick}+ onAction={onClick ?? (targetNoteId+ ? (e) => {+ // Hidden-subtree config notes open hoisted, in a tree-sidebar popup.+ // stopPropagation keeps the global `a` click handler+ // (link.ts `goToLink`) from navigating by href instead.+ e.preventDefault();+ e.stopPropagation();+ void appContext.triggerCommand("openInTreePopup", { noteIdOrPath: targetNoteId, hoistedNoteId: targetNoteId });+ }+ : undefined)}+ />+ );+ })}+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/components/RestartAction.tsx b/apps/client/src/widgets/type_widgets/options/components/RestartAction.tsxindex 2fcbb42853..bc9d5b5b23 100644--- a/apps/client/src/widgets/type_widgets/options/components/RestartAction.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/RestartAction.tsx@@ -19,7 +19,7 @@ interface RestartActionProps {*/export default function RestartAction({ text, icon }: RestartActionProps) {return (- <div className="options-section restart-action">+ <div className="restart-action"><Buttonname="restart-app-button"text={text}diff --git a/apps/client/src/widgets/type_widgets/options/components/options_components.spec.tsx b/apps/client/src/widgets/type_widgets/options/components/options_components.spec.tsxindex 963d72c8b8..3e43ab091f 100644--- a/apps/client/src/widgets/type_widgets/options/components/options_components.spec.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/options_components.spec.tsx@@ -131,8 +131,8 @@ describe("RestartAction", () => {const container = renderInto(<RestartAction text="Restart" icon="bx-refresh" />);const block = container.querySelector(".restart-action");- // `options-section` is what gives it the cards' width; `restart-action` puts it at their end.- expect(block?.className).toContain("options-section");+ // A top-level block of the page, so it takes the cards' width; `restart-action` puts the+ // button where their controls end.expect(block?.querySelector("button[name='restart-app-button']")).not.toBeNull();expect(container.querySelector(".tn-card")).toBeNull();});diff --git a/apps/client/src/widgets/type_widgets/options/database.tsx b/apps/client/src/widgets/type_widgets/options/database.tsxindex 340163ca6f..9cca2630c2 100644--- a/apps/client/src/widgets/type_widgets/options/database.tsx+++ b/apps/client/src/widgets/type_widgets/options/database.tsx@@ -107,42 +107,40 @@ function DatabaseInfo({ refreshToken }: { refreshToken: number }) {}return (- <div className="options-section database-info">- <Card heading={t("database.info")}>- <CardOption label={t("database.info_location")}>- <span className="database-info-value">- {/* Revealed rather than opened: a file manager is what a path is useful in,- and the database's own reader is Trilium. Where there is no path, the- storage holding it is named instead — nothing there can be pointed at. */}- {info.filePath- ? <FileLink filePath={info.filePath} />- : t("database.info_location_opfs")}- </span>- </CardOption>-- <CardOption label={t("database.info_content")}>- <span className="database-info-value">- {t("database.info_notes", { count: info.noteCount })}- {", "}- {t("database.info_attachments", { count: info.attachmentCount })}- </span>- </CardOption>-- <CardOption label={t("database.info_created")}>- <span className="database-info-value">- {formatDateTime(info.utcDateCreated, "long", "none")}- </span>- </CardOption>-- <CardOption label={t("database.info_size")}>- <span className="database-info-value">{formatSize(info.sizeBytes)}</span>- </CardOption>-- {/* Absent where backups are not kept at all: the browser build's one backup is a- download, taken there and then, so there is nothing standing to state. */}- {!isBackupDownloadSupported() && <BackupStanding refreshToken={refreshToken} />}- </Card>- </div>+ <Card className="database-info" heading={t("database.info")}>+ <CardOption label={t("database.info_location")}>+ <span className="database-info-value">+ {/* Revealed rather than opened: a file manager is what a path is useful in,+ and the database's own reader is Trilium. Where there is no path, the+ storage holding it is named instead — nothing there can be pointed at. */}+ {info.filePath+ ? <FileLink filePath={info.filePath} />+ : t("database.info_location_opfs")}+ </span>+ </CardOption>++ <CardOption label={t("database.info_content")}>+ <span className="database-info-value">+ {t("database.info_notes", { count: info.noteCount })}+ {", "}+ {t("database.info_attachments", { count: info.attachmentCount })}+ </span>+ </CardOption>++ <CardOption label={t("database.info_created")}>+ <span className="database-info-value">+ {formatDateTime(info.utcDateCreated, "long", "none")}+ </span>+ </CardOption>++ <CardOption label={t("database.info_size")}>+ <span className="database-info-value">{formatSize(info.sizeBytes)}</span>+ </CardOption>++ {/* Absent where backups are not kept at all: the browser build's one backup is a+ download, taken there and then, so there is nothing standing to state. */}+ {!isBackupDownloadSupported() && <BackupStanding refreshToken={refreshToken} />}+ </Card>);}@@ -186,93 +184,91 @@ function MaintenanceOptions({ onDatabaseChanged }: { onDatabaseChanged: () => voconst { noteContext } = useNoteContext();return (- <div className="options-section database-maintenance">- <Card heading={t("database.maintenance")}>+ <Card heading={t("database.maintenance")}>+ <CardOption+ label={t("database.cleanup")}+ description={t("database.cleanup_description")}+ >+ {/* Named after the tool it opens, so the button and the dialog's own heading+ cannot come to say different things. */}+ <Button+ name="cleanup-button"+ text={t("space_usage.cleanup_title")}+ size="micro"+ onClick={() => void showCleanupDialog().then((reclaimed) => {+ // Erasing frees pages inside the file rather than shrinking it, so what+ // the card above has to re-read is what the database holds.+ if (reclaimed !== null) {+ onDatabaseChanged();+ }+ })}+ />+ </CardOption>++ <CardOption+ label={t("database.analyze_space_usage")}+ description={t("database.analyze_space_usage_description")}+ >+ <Button+ name="analyze-space-usage-button"+ text={t("database.analyze_space_usage_button")}+ size="micro"+ onClick={() => {+ // The Content Manager opens on Active Content unless asked otherwise,+ // and navigating by hand rather than by link is what lets us ask first.+ requestContentManagerSection("spaceUsage");+ // Kept in whichever context this page is shown in — the settings dialog+ // holds a note context of its own, outside the tab manager.+ void noteContext?.setNote("_optionsContentManager", { keepActiveDialog: true });+ }}+ />+ </CardOption>++ <CardOption+ label={t("consistency_checks.find_and_fix_label")}+ description={t("consistency_checks.find_and_fix_description")}+ >+ <Button+ name="fix-consistency-issues-button"+ text={t("consistency_checks.find_and_fix_button")}+ size="micro"+ onClick={fixConsistencyIssues}+ />+ </CardOption>++ <CardOption+ label={t("database_integrity_check.check_integrity_label")}+ description={t("database_integrity_check.check_integrity_description")}+ >+ <Button+ name="check-integrity-button"+ text={t("database_integrity_check.check_button")}+ size="micro"+ onClick={checkIntegrity}+ />+ </CardOption>++ {/* Offered everywhere the rebuild has somewhere to happen. The browser build keeps+ the temporary store in memory, so compacting would ask it for the size of the+ database over again at the very moment there is too little room — which is why+ the cleanup tool leaves compaction out there as well. */}+ {!isStandalone && (<CardOption- label={t("database.cleanup")}- description={t("database.cleanup_description")}+ label={t("vacuum_database.vacuum_label")}+ description={t("vacuum_database.vacuum_description")}>- {/* Named after the tool it opens, so the button and the dialog's own heading- cannot come to say different things. */}<Button- name="cleanup-button"- text={t("space_usage.cleanup_title")}+ name="vacuum-database-button"+ text={t("vacuum_database.button_text")}size="micro"- onClick={() => void showCleanupDialog().then((reclaimed) => {- // Erasing frees pages inside the file rather than shrinking it, so what- // the card above has to re-read is what the database holds.- if (reclaimed !== null) {- onDatabaseChanged();- }- })}- />- </CardOption>-- <CardOption- label={t("database.analyze_space_usage")}- description={t("database.analyze_space_usage_description")}- >- <Button- name="analyze-space-usage-button"- text={t("database.analyze_space_usage_button")}- size="micro"- onClick={() => {- // The Content Manager opens on Active Content unless asked otherwise,- // and navigating by hand rather than by link is what lets us ask first.- requestContentManagerSection("spaceUsage");- // Kept in whichever context this page is shown in — the settings dialog- // holds a note context of its own, outside the tab manager.- void noteContext?.setNote("_optionsContentManager", { keepActiveDialog: true });+ onClick={async () => {+ await vacuumDatabase();+ onDatabaseChanged();}}/></CardOption>-- <CardOption- label={t("consistency_checks.find_and_fix_label")}- description={t("consistency_checks.find_and_fix_description")}- >- <Button- name="fix-consistency-issues-button"- text={t("consistency_checks.find_and_fix_button")}- size="micro"- onClick={fixConsistencyIssues}- />- </CardOption>-- <CardOption- label={t("database_integrity_check.check_integrity_label")}- description={t("database_integrity_check.check_integrity_description")}- >- <Button- name="check-integrity-button"- text={t("database_integrity_check.check_button")}- size="micro"- onClick={checkIntegrity}- />- </CardOption>-- {/* Offered everywhere the rebuild has somewhere to happen. The browser build keeps- the temporary store in memory, so compacting would ask it for the size of the- database over again at the very moment there is too little room — which is why- the cleanup tool leaves compaction out there as well. */}- {!isStandalone && (- <CardOption- label={t("vacuum_database.vacuum_label")}- description={t("vacuum_database.vacuum_description")}- >- <Button- name="vacuum-database-button"- text={t("vacuum_database.button_text")}- size="micro"- onClick={async () => {- await vacuumDatabase();- onDatabaseChanged();- }}- />- </CardOption>- )}- </Card>- </div>+ )}+ </Card>);}@@ -365,38 +361,36 @@ function AnonymizationOptions() {return (<>- <div className="options-section database-anonymization">- <Card- heading={t("database_anonymization.title")}- description={t("database_anonymization.description")}+ <Card className="database-anonymization"+ heading={t("database_anonymization.title")}+ description={t("database_anonymization.description")}+ >+ <CardOption+ label={t("database_anonymization.full_anonymization")}+ description={t("database_anonymization.full_anonymization_description")}>- <CardOption- label={t("database_anonymization.full_anonymization")}- description={t("database_anonymization.full_anonymization_description")}- >- <Button- name="full-anonymization-button"- text={t("database_anonymization.save_fully_anonymized_database")}- size="micro"- disabled={anonymizationInProgress}- onClick={() => void anonymize("full")}- />- </CardOption>-- <CardOption- label={t("database_anonymization.light_anonymization")}- description={t("database_anonymization.light_anonymization_description")}- >- <Button- name="light-anonymization-button"- text={t("database_anonymization.save_lightly_anonymized_database")}- size="micro"- disabled={anonymizationInProgress}- onClick={() => void anonymize("light")}- />- </CardOption>- </Card>- </div>+ <Button+ name="full-anonymization-button"+ text={t("database_anonymization.save_fully_anonymized_database")}+ size="micro"+ disabled={anonymizationInProgress}+ onClick={() => void anonymize("full")}+ />+ </CardOption>++ <CardOption+ label={t("database_anonymization.light_anonymization")}+ description={t("database_anonymization.light_anonymization_description")}+ >+ <Button+ name="light-anonymization-button"+ text={t("database_anonymization.save_lightly_anonymized_database")}+ size="micro"+ disabled={anonymizationInProgress}+ onClick={() => void anonymize("light")}+ />+ </CardOption>+ </Card>{/* Where the copies are kept is stated only once there is one to find there: an emptylist saying where it would have been answers a question nobody asked. */}@@ -428,23 +422,21 @@ function AnonymizationOptions() {/** Headingless: the row names the feature itself, and nothing else belongs beside it. */function StartOverOption({ state }: { state: ReturnType<typeof useStartOver> }) {return (- <div className="options-section start-over">- <Card>- <CardOption- label={t("database.start_over")}- description={t("database.start_over_description")}- >- <Button- name="start-over-button"- text={t("database.start_over")}- icon="bx-reset"- size="micro"- disabled={state.busy || state.pending}- onClick={() => void state.begin()}- />- </CardOption>- </Card>- </div>+ <Card className="start-over">+ <CardOption+ label={t("database.start_over")}+ description={t("database.start_over_description")}+ >+ <Button+ name="start-over-button"+ text={t("database.start_over")}+ icon="bx-reset"+ size="micro"+ disabled={state.busy || state.pending}+ onClick={() => void state.begin()}+ />+ </CardOption>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/desktop.tsx b/apps/client/src/widgets/type_widgets/options/desktop.tsxindex 82c441f955..3f9ed341fb 100644--- a/apps/client/src/widgets/type_widgets/options/desktop.tsx+++ b/apps/client/src/widgets/type_widgets/options/desktop.tsx@@ -20,9 +20,7 @@ export default function DesktopSettings() {return (<><OptionsPageHeader />- <div className="options-section">- <NoItems text={t("desktop.web_placeholder")} icon="bx bx-desktop" />- </div>+ <NoItems text={t("desktop.web_placeholder")} icon="bx bx-desktop" /></>);}@@ -42,37 +40,35 @@ function TrayOptionsSettings() {const [ closeToTray, setCloseToTray ] = useTriliumOptionBool("closeToTray");return (- <div className="options-section">- <Card heading={t("tray.title")}>- <CardOption- name="tray-enabled"- label={t("tray.enable_tray")}- description={t("tray.enable_tray_description")}- >- <FormToggle- currentValue={!disableTray}- onChange={async trayEnabled => {- await setDisableTray(!trayEnabled);- // Apply the change immediately so the user doesn't have to restart the app.- utils.reloadTray();- }}- />- </CardOption>+ <Card heading={t("tray.title")}>+ <CardOption+ name="tray-enabled"+ label={t("tray.enable_tray")}+ description={t("tray.enable_tray_description")}+ >+ <FormToggle+ currentValue={!disableTray}+ onChange={async trayEnabled => {+ await setDisableTray(!trayEnabled);+ // Apply the change immediately so the user doesn't have to restart the app.+ utils.reloadTray();+ }}+ />+ </CardOption>- <CardOption- name="close-to-tray"- label={t("tray.close_to_tray")}- description={t("tray.close_to_tray_description")}- >- <FormToggle- currentValue={closeToTray}- // Close-to-tray with no tray icon would hide the app with no way back.- disabled={disableTray}- onChange={setCloseToTray}- />- </CardOption>- </Card>- </div>+ <CardOption+ name="close-to-tray"+ label={t("tray.close_to_tray")}+ description={t("tray.close_to_tray_description")}+ >+ <FormToggle+ currentValue={closeToTray}+ // Close-to-tray with no tray icon would hide the app with no way back.+ disabled={disableTray}+ onChange={setCloseToTray}+ />+ </CardOption>+ </Card>);}@@ -82,42 +78,40 @@ function StartupSettings() {const [ disableTray ] = useTriliumOptionBool("disableTray");return (- <div className="options-section">- <Card heading={t("startup.title")}>- <CardOption- name="launch-on-startup"- label={t("startup.launch_on_startup")}- description={t("startup.launch_on_startup_description")}- >- <FormToggle- currentValue={launchOnStartup}- onChange={async enabled => {- await setLaunchOnStartup(enabled);- // Apply the change immediately so the user doesn't have to restart the app.- utils.reapplyLaunchOnStartup();- }}- />- </CardOption>+ <Card heading={t("startup.title")}>+ <CardOption+ name="launch-on-startup"+ label={t("startup.launch_on_startup")}+ description={t("startup.launch_on_startup_description")}+ >+ <FormToggle+ currentValue={launchOnStartup}+ onChange={async enabled => {+ await setLaunchOnStartup(enabled);+ // Apply the change immediately so the user doesn't have to restart the app.+ utils.reapplyLaunchOnStartup();+ }}+ />+ </CardOption>- <CardOption- name="hide-on-auto-start"- label={t("startup.hide_on_auto_start")}- description={t("startup.hide_on_auto_start_description")}- >- <FormToggle- currentValue={hideOnAutoStart}- // Only meaningful when launched at login, and the tray must exist to- // bring the hidden window back.- disabled={!launchOnStartup || disableTray}- onChange={async enabled => {- await setHideOnAutoStart(enabled);- // Re-tag the autostart entry so it launches hidden (or not).- utils.reapplyLaunchOnStartup();- }}- />- </CardOption>- </Card>- </div>+ <CardOption+ name="hide-on-auto-start"+ label={t("startup.hide_on_auto_start")}+ description={t("startup.hide_on_auto_start_description")}+ >+ <FormToggle+ currentValue={hideOnAutoStart}+ // Only meaningful when launched at login, and the tray must exist to+ // bring the hidden window back.+ disabled={!launchOnStartup || disableTray}+ onChange={async enabled => {+ await setHideOnAutoStart(enabled);+ // Re-tag the autostart entry so it launches hidden (or not).+ utils.reapplyLaunchOnStartup();+ }}+ />+ </CardOption>+ </Card>);}@@ -135,51 +129,49 @@ function SearchEngineSettings() {}, []);return (- <div className="options-section">- <Card- heading={t("search_engine.title")}- description={t("search_engine.custom_search_engine_info")}- >- <CardOption label={t("search_engine.predefined_templates_label")}>- <div className="search-engine-templates">- {searchEngines.map(engine => (- <Badge- key={engine.url}- icon={engine.icon}- text={engine.name}- className={customSearchEngineUrl === engine.url ? "selected" : ""}- onClick={() => {- setCustomSearchEngineName(engine.name);- setCustomSearchEngineUrl(engine.url);- }}- />- ))}- </div>- </CardOption>+ <Card+ heading={t("search_engine.title")}+ description={t("search_engine.custom_search_engine_info")}+ >+ <CardOption label={t("search_engine.predefined_templates_label")}>+ <div className="search-engine-templates">+ {searchEngines.map(engine => (+ <Badge+ key={engine.url}+ icon={engine.icon}+ text={engine.name}+ className={customSearchEngineUrl === engine.url ? "selected" : ""}+ onClick={() => {+ setCustomSearchEngineName(engine.name);+ setCustomSearchEngineUrl(engine.url);+ }}+ />+ ))}+ </div>+ </CardOption>- <CardOption- className="desktop-search-name"- name="custom-name"- label={t("search_engine.custom_name_label")}- >- <FormTextBox- currentValue={customSearchEngineName} onBlur={setCustomSearchEngineName}- placeholder={t("search_engine.custom_name_placeholder")}- />- </CardOption>+ <CardOption+ className="desktop-search-name"+ name="custom-name"+ label={t("search_engine.custom_name_label")}+ >+ <FormTextBox+ currentValue={customSearchEngineName} onBlur={setCustomSearchEngineName}+ placeholder={t("search_engine.custom_name_placeholder")}+ />+ </CardOption>- <CardOption- name="custom-url"- label={t("search_engine.custom_url_label")}- description={t("search_engine.custom_url_description")}- stacked- >- <FormTextBox- currentValue={customSearchEngineUrl} onBlur={setCustomSearchEngineUrl}- placeholder={t("search_engine.custom_url_placeholder")}- />- </CardOption>- </Card>- </div>+ <CardOption+ name="custom-url"+ label={t("search_engine.custom_url_label")}+ description={t("search_engine.custom_url_description")}+ stacked+ >+ <FormTextBox+ currentValue={customSearchEngineUrl} onBlur={setCustomSearchEngineUrl}+ placeholder={t("search_engine.custom_url_placeholder")}+ />+ </CardOption>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/etapi.tsx b/apps/client/src/widgets/type_widgets/options/etapi.tsxindex 0094f9f218..8e0b374fb7 100644--- a/apps/client/src/widgets/type_widgets/options/etapi.tsx+++ b/apps/client/src/widgets/type_widgets/options/etapi.tsx@@ -106,40 +106,36 @@ function TokenList({ tokens }: { tokens: EtapiToken[] }) {// empty card being a statement of its own.if (!tokens.length) {return (- <div className="options-section">- <NoItems icon="bx bx-key" text={t("etapi.no_tokens")} />- </div>+ <NoItems icon="bx bx-key" text={t("etapi.no_tokens")} />);}return (- <div className="options-section">- <Card>- {tokens.map(({ etapiTokenId, name, utcDateCreated }) => (- <CardOption- key={etapiTokenId ?? name}- label={name}- description={formatDateTime(utcDateCreated)}- >- {etapiTokenId && (- <span className="etapi-token-actions">- <ActionButton- icon="bx bx-edit-alt"- text={t("etapi.rename_token")}- onClick={() => renameCallback(etapiTokenId, name)}- />-- <ActionButton- className="destructive-action-icon"- icon="bx bx-trash"- text={t("etapi.delete_token")}- onClick={() => deleteCallback(etapiTokenId, name)}- />- </span>- )}- </CardOption>- ))}- </Card>- </div>+ <Card>+ {tokens.map(({ etapiTokenId, name, utcDateCreated }) => (+ <CardOption+ key={etapiTokenId ?? name}+ label={name}+ description={formatDateTime(utcDateCreated)}+ >+ {etapiTokenId && (+ <span className="etapi-token-actions">+ <ActionButton+ icon="bx bx-edit-alt"+ text={t("etapi.rename_token")}+ onClick={() => renameCallback(etapiTokenId, name)}+ />++ <ActionButton+ className="destructive-action-icon"+ icon="bx bx-trash"+ text={t("etapi.delete_token")}+ onClick={() => deleteCallback(etapiTokenId, name)}+ />+ </span>+ )}+ </CardOption>+ ))}+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/i18n.tsx b/apps/client/src/widgets/type_widgets/options/i18n.tsxindex 66dddb8a91..e4257ad30f 100644--- a/apps/client/src/widgets/type_widgets/options/i18n.tsx+++ b/apps/client/src/widgets/type_widgets/options/i18n.tsx@@ -64,35 +64,33 @@ function LocalizationOptions() {const [ defaultContentLanguage, setDefaultContentLanguage ] = useTriliumOption("defaultContentLanguage");return (- <div className="options-section">- <Card heading={t("i18n.title")}>- <CardOption name="language" label={t("i18n.language")}>- <LocaleSelector locales={uiLocales} currentValue={locale} onChange={setLocale} />- </CardOption>-- <CardOption name="formatting-locale" label={t("i18n.formatting-locale")}>- <LocaleSelector- locales={contentLocales}- currentValue={formattingLocale}- onChange={setFormattingLocale}- defaultLocale={{ id: "", name: t("i18n.formatting-locale-auto") }}- />- </CardOption>-- <CardOption- name="default-content-language"- label={t("i18n.default-content-language")}- description={t("i18n.default-content-language-description")}- >- <LocaleSelector- locales={writingLocales}- currentValue={defaultContentLanguage}- onChange={setDefaultContentLanguage}- defaultLocale={{ id: "", name: t("i18n.default-content-language-auto") }}- />- </CardOption>- </Card>- </div>+ <Card heading={t("i18n.title")}>+ <CardOption name="language" label={t("i18n.language")}>+ <LocaleSelector locales={uiLocales} currentValue={locale} onChange={setLocale} />+ </CardOption>++ <CardOption name="formatting-locale" label={t("i18n.formatting-locale")}>+ <LocaleSelector+ locales={contentLocales}+ currentValue={formattingLocale}+ onChange={setFormattingLocale}+ defaultLocale={{ id: "", name: t("i18n.formatting-locale-auto") }}+ />+ </CardOption>++ <CardOption+ name="default-content-language"+ label={t("i18n.default-content-language")}+ description={t("i18n.default-content-language-description")}+ >+ <LocaleSelector+ locales={writingLocales}+ currentValue={defaultContentLanguage}+ onChange={setDefaultContentLanguage}+ defaultLocale={{ id: "", name: t("i18n.default-content-language-auto") }}+ />+ </CardOption>+ </Card>)}@@ -107,73 +105,69 @@ function DateSettings() {const [ minDaysInFirstWeek, setMinDaysInFirstWeek ] = useTriliumOption("minDaysInFirstWeek");return (- <div className="options-section">- <Card heading={t("i18n.dates-title")}>- <CardOption name="first-day-of-week" label={t("i18n.first-day-of-the-week")}>- <FormSelect- name="first-day-of-week"- currentValue={firstDayOfWeek}- onChange={setFirstDayOfWeek}- keyProperty="value"- titleProperty="label"- values={[- { value: "1", label: t("i18n.monday") },- { value: "2", label: t("i18n.tuesday") },- { value: "3", label: t("i18n.wednesday") },- { value: "4", label: t("i18n.thursday") },- { value: "5", label: t("i18n.friday") },- { value: "6", label: t("i18n.saturday") },- { value: "7", label: t("i18n.sunday") },- ]}- />- </CardOption>-- <CardOption+ <Card heading={t("i18n.dates-title")}>+ <CardOption name="first-day-of-week" label={t("i18n.first-day-of-the-week")}>+ <FormSelect+ name="first-day-of-week"+ currentValue={firstDayOfWeek}+ onChange={setFirstDayOfWeek}+ keyProperty="value"+ titleProperty="label"+ values={[+ { value: "1", label: t("i18n.monday") },+ { value: "2", label: t("i18n.tuesday") },+ { value: "3", label: t("i18n.wednesday") },+ { value: "4", label: t("i18n.thursday") },+ { value: "5", label: t("i18n.friday") },+ { value: "6", label: t("i18n.saturday") },+ { value: "7", label: t("i18n.sunday") },+ ]}+ />+ </CardOption>++ <CardOption+ name="first-week-of-year"+ label={t("i18n.first-week-of-the-year")}+ description={t("i18n.first-week-warning")}+ >+ <FormSelectname="first-week-of-year"- label={t("i18n.first-week-of-the-year")}- description={t("i18n.first-week-warning")}- >+ currentValue={firstWeekOfYear}+ onChange={setFirstWeekOfYear}+ keyProperty="value"+ titleProperty="label"+ values={[+ { value: "0", label: t("i18n.first-week-contains-first-day") },+ { value: "1", label: t("i18n.first-week-contains-first-thursday") },+ { value: "2", label: t("i18n.first-week-has-minimum-days") }+ ]}+ />+ </CardOption>++ {firstWeekOfYear === "2" && (+ <CardOption name="min-days-in-first-week" label={t("i18n.min-days-in-first-week")}><FormSelect- name="first-week-of-year"- currentValue={firstWeekOfYear}- onChange={setFirstWeekOfYear}- keyProperty="value"- titleProperty="label"- values={[- { value: "0", label: t("i18n.first-week-contains-first-day") },- { value: "1", label: t("i18n.first-week-contains-first-thursday") },- { value: "2", label: t("i18n.first-week-has-minimum-days") }- ]}- />+ keyProperty="days"+ currentValue={minDaysInFirstWeek} onChange={setMinDaysInFirstWeek}+ values={Array.from(+ { length: 7 },+ (_, i) => ({ days: String(i + 1) }))} /></CardOption>-- {firstWeekOfYear === "2" && (- <CardOption name="min-days-in-first-week" label={t("i18n.min-days-in-first-week")}>- <FormSelect- keyProperty="days"- currentValue={minDaysInFirstWeek} onChange={setMinDaysInFirstWeek}- values={Array.from(- { length: 7 },- (_, i) => ({ days: String(i + 1) }))} />- </CardOption>- )}- </Card>- </div>+ )}+ </Card>)}function ContentLanguages() {return (- <div className="options-section">- <Card- heading={t("content_language.title")}- description={t("content_language.description")}- >- <CardSection className="i18n-content-languages">- <ContentLanguagesList />- </CardSection>- </Card>- </div>+ <Card+ heading={t("content_language.title")}+ description={t("content_language.description")}+ >+ <CardSection className="i18n-content-languages">+ <ContentLanguagesList />+ </CardSection>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/llm.tsx b/apps/client/src/widgets/type_widgets/options/llm.tsxindex e6ad10db1b..915c8df2ad 100644--- a/apps/client/src/widgets/type_widgets/options/llm.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm.tsx@@ -89,34 +89,32 @@ function ProviderSettings() {setProviders(providers.filter(p => p.id !== providerId));}, [providers, setProviders]);- return (- <div className="options-section">- <Card heading={t("llm.configured_providers")}>- <ProviderList- providers={providers}- onEdit={openModal}- onDelete={handleDeleteProvider}- />+ return (<>+ <Card heading={t("llm.configured_providers")}>+ <ProviderList+ providers={providers}+ onEdit={openModal}+ onDelete={handleDeleteProvider}+ />- <CardSection className="llm-add-provider">- <Button- name="add-llm-provider-button"- size="micro" icon="bx-plus"- text={t("llm.add_provider")}- onClick={() => openModal()}- />- </CardSection>- </Card>+ <CardSection className="llm-add-provider">+ <Button+ name="add-llm-provider-button"+ size="micro" icon="bx-plus"+ text={t("llm.add_provider")}+ onClick={() => openModal()}+ />+ </CardSection>+ </Card>- <AddProviderModal- key={openToken}- show={modalOpen}- existingProvider={modalProvider}- onHidden={() => setModalOpen(false)}- onSave={handleSaveProvider}- />- </div>- );+ <AddProviderModal+ key={openToken}+ show={modalOpen}+ existingProvider={modalProvider}+ onHidden={() => setModalOpen(false)}+ onSave={handleSaveProvider}+ />+ </>);}function McpSettings() {@@ -159,61 +157,59 @@ function McpSettings() {}, [networkInfo, localUrl]);return (- <div className="options-section">- <Card heading={t("llm.mcp_title")}>- <CardOption- name="mcp-enabled"- label={t("llm.mcp_enabled")}- description={mcpUnavailable ? t("llm.mcp_unavailable_standalone") : t("llm.mcp_enabled_description")}- >- <FormToggle- currentValue={mcpServing}- onChange={setMcpEnabled}- disabled={mcpUnavailable}- />- </CardOption>+ <Card heading={t("llm.mcp_title")}>+ <CardOption+ name="mcp-enabled"+ label={t("llm.mcp_enabled")}+ description={mcpUnavailable ? t("llm.mcp_unavailable_standalone") : t("llm.mcp_enabled_description")}+ >+ <FormToggle+ currentValue={mcpServing}+ onChange={setMcpEnabled}+ disabled={mcpUnavailable}+ />+ </CardOption>- {mcpServing && (- <>- <CardOption- name="mcp-endpoint"- label={t("llm.mcp_endpoint_title")}- description={t("llm.mcp_endpoint_description")}- stacked- >- <div class="mcp-endpoint-list">- <McpEndpointGroup label={t("llm.mcp_endpoint_this_device")} urls={[localUrl]} />- {networkUrls.length > 0 && (- <McpEndpointGroup label={t("llm.mcp_endpoint_network")} urls={networkUrls} />- )}- {networkInfo && !networkInfo.reachableOnNetwork && (- <p class="mcp-endpoint-note">{t("llm.mcp_endpoint_loopback_only")}</p>- )}- </div>- </CardOption>+ {mcpServing && (+ <>+ <CardOption+ name="mcp-endpoint"+ label={t("llm.mcp_endpoint_title")}+ description={t("llm.mcp_endpoint_description")}+ stacked+ >+ <div class="mcp-endpoint-list">+ <McpEndpointGroup label={t("llm.mcp_endpoint_this_device")} urls={[localUrl]} />+ {networkUrls.length > 0 && (+ <McpEndpointGroup label={t("llm.mcp_endpoint_network")} urls={networkUrls} />+ )}+ {networkInfo && !networkInfo.reachableOnNetwork && (+ <p class="mcp-endpoint-note">{t("llm.mcp_endpoint_loopback_only")}</p>+ )}+ </div>+ </CardOption>- <CardSection>- <Collapsible title={t("llm.mcp_config_title")} initiallyExpanded>- <p>{t("llm.mcp_config_description")}</p>- <CodeBlock- mimeType="application/json"- code={buildMcpClientConfig(localUrl, tokenPlaceholder)}- placeholder={tokenPlaceholder}- />- <p>{t("llm.mcp_config_cli_description")}</p>- <CodeBlock- mimeType="text/x-sh"- code={buildMcpClientCommand(localUrl, tokenPlaceholder)}- placeholder={tokenPlaceholder}- wrap- />- <p class="mcp-config-warning">{t("llm.mcp_config_warning")}</p>- </Collapsible>- </CardSection>- </>- )}- </Card>- </div>+ <CardSection>+ <Collapsible title={t("llm.mcp_config_title")} initiallyExpanded>+ <p>{t("llm.mcp_config_description")}</p>+ <CodeBlock+ mimeType="application/json"+ code={buildMcpClientConfig(localUrl, tokenPlaceholder)}+ placeholder={tokenPlaceholder}+ />+ <p>{t("llm.mcp_config_cli_description")}</p>+ <CodeBlock+ mimeType="text/x-sh"+ code={buildMcpClientCommand(localUrl, tokenPlaceholder)}+ placeholder={tokenPlaceholder}+ wrap+ />+ <p class="mcp-config-warning">{t("llm.mcp_config_warning")}</p>+ </Collapsible>+ </CardSection>+ </>+ )}+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/media.tsx b/apps/client/src/widgets/type_widgets/options/media.tsxindex 754a353ac7..47a03ff881 100644--- a/apps/client/src/widgets/type_widgets/options/media.tsx+++ b/apps/client/src/widgets/type_widgets/options/media.tsx@@ -66,37 +66,35 @@ function ImageSettings() {};return (- <div className="options-section media-images">- <Card heading={t("images.images_section_title")}>- <CardOption- name="download-images-automatically"- label={t("images.download_images_automatically")}- description={t("images.download_images_description")}- >- <FormToggle- currentValue={downloadImagesAutomatically}- onChange={setDownloadImagesAutomatically}- />- </CardOption>+ <Card className="media-images" heading={t("images.images_section_title")}>+ <CardOption+ name="download-images-automatically"+ label={t("images.download_images_automatically")}+ description={t("images.download_images_description")}+ >+ <FormToggle+ currentValue={downloadImagesAutomatically}+ onChange={setDownloadImagesAutomatically}+ />+ </CardOption>- {/* Not the tool's own "Compress images": that is something the user does to images- already stored, where this is a standing instruction about every image still to- arrive. Saying which is which is the whole of the label. */}- <CardOption- name="compress-images"- label={t("images.automatic_image_compression")}- description={t("images.enable_image_compression_description")}- subSectionsVisible={compressImages}- subSections={[- <ResizeImageSection key="resize" {...sectionProps} />,- <JpegHandlingSection key="jpeg" {...sectionProps} />,- <PngHandlingSection key="png" {...sectionProps} />- ]}- >- <FormToggle currentValue={compressImages} onChange={setCompressImages} />- </CardOption>- </Card>- </div>+ {/* Not the tool's own "Compress images": that is something the user does to images+ already stored, where this is a standing instruction about every image still to+ arrive. Saying which is which is the whole of the label. */}+ <CardOption+ name="compress-images"+ label={t("images.automatic_image_compression")}+ description={t("images.enable_image_compression_description")}+ subSectionsVisible={compressImages}+ subSections={[+ <ResizeImageSection key="resize" {...sectionProps} />,+ <JpegHandlingSection key="jpeg" {...sectionProps} />,+ <PngHandlingSection key="png" {...sectionProps} />+ ]}+ >+ <FormToggle currentValue={compressImages} onChange={setCompressImages} />+ </CardOption>+ </Card>);}@@ -147,36 +145,34 @@ function OcrSettings() {return (<>- <div className="options-section media-ocr">- <Card- heading={t("images.ocr_section_title")}- actions={<HelpButton helpPage="TiQbQDgP8L5t" />}+ <Card className="media-ocr"+ heading={t("images.ocr_section_title")}+ actions={<HelpButton helpPage="TiQbQDgP8L5t" />}+ >+ <CardOption+ name="ocr-auto-process"+ label={t("images.ocr_auto_process")}+ description={t("images.ocr_auto_process_description")}>- <CardOption- name="ocr-auto-process"- label={t("images.ocr_auto_process")}- description={t("images.ocr_auto_process_description")}- >- <FormToggle currentValue={ocrAutoProcess} onChange={setOcrAutoProcess} />- </CardOption>+ <FormToggle currentValue={ocrAutoProcess} onChange={setOcrAutoProcess} />+ </CardOption>- <CardOption- name="ocr-min-confidence"- label={`${t("images.ocr_min_confidence")} (${confidence}%)`}- description={t("images.ocr_confidence_description")}- >- <Slider- min={0} max={100} step={5}- value={confidence}- onChange={(value) => setOcrMinConfidence(String(value / 100))}- />- </CardOption>+ <CardOption+ name="ocr-min-confidence"+ label={`${t("images.ocr_min_confidence")} (${confidence}%)`}+ description={t("images.ocr_confidence_description")}+ >+ <Slider+ min={0} max={100} step={5}+ value={confidence}+ onChange={(value) => setOcrMinConfidence(String(value / 100))}+ />+ </CardOption>- {/* Running OCR needs the engine the server holds; a standalone client only ever- reads text extracted elsewhere and synced to it. */}- {!isStandalone && <BatchProcessing />}- </Card>- </div>+ {/* Running OCR needs the engine the server holds; a standalone client only ever+ reads text extracted elsewhere and synced to it. */}+ {!isStandalone && <BatchProcessing />}+ </Card><RelatedSettings items={[{diff --git a/apps/client/src/widgets/type_widgets/options/other.tsx b/apps/client/src/widgets/type_widgets/options/other.tsxindex 2116eba468..1054f89233 100644--- a/apps/client/src/widgets/type_widgets/options/other.tsx+++ b/apps/client/src/widgets/type_widgets/options/other.tsx@@ -64,101 +64,95 @@ function SearchSettings() {const [ autocompleteFuzzy, setAutocompleteFuzzy ] = useTriliumOptionBool("searchAutocompleteFuzzy");return (- <div className="options-section">- <Card heading={t("search.title")}>- <CardOption- name="search-fuzzy-matching"- label={t("search.fuzzy_matching_label")}- description={t("search.fuzzy_matching_description")}- >- <FormToggle currentValue={fuzzyEnabled} onChange={setFuzzyEnabled} />- </CardOption>+ <Card heading={t("search.title")}>+ <CardOption+ name="search-fuzzy-matching"+ label={t("search.fuzzy_matching_label")}+ description={t("search.fuzzy_matching_description")}+ >+ <FormToggle currentValue={fuzzyEnabled} onChange={setFuzzyEnabled} />+ </CardOption>- <CardOption- name="search-autocomplete-fuzzy"- label={t("search.autocomplete_fuzzy_label")}- description={t("search.autocomplete_fuzzy_description")}- >- <FormToggle currentValue={autocompleteFuzzy} onChange={setAutocompleteFuzzy} />- </CardOption>- </Card>- </div>+ <CardOption+ name="search-autocomplete-fuzzy"+ label={t("search.autocomplete_fuzzy_label")}+ description={t("search.autocomplete_fuzzy_description")}+ >+ <FormToggle currentValue={autocompleteFuzzy} onChange={setAutocompleteFuzzy} />+ </CardOption>+ </Card>);}function NoteErasureTimeout() {return (- <div className="options-section">- <Card- heading={t("note_erasure_timeout.note_erasure_timeout_title")}- description={t("note_erasure_timeout.description")}+ <Card+ heading={t("note_erasure_timeout.note_erasure_timeout_title")}+ description={t("note_erasure_timeout.description")}+ >+ <CardOption+ name="erase-entities-after"+ label={t("note_erasure_timeout.erase_notes_after")}+ description={t("note_erasure_timeout.erase_notes_after_description")}>- <CardOption+ <TimeSelectorname="erase-entities-after"- label={t("note_erasure_timeout.erase_notes_after")}- description={t("note_erasure_timeout.erase_notes_after_description")}- >- <TimeSelector- name="erase-entities-after"- optionValueId="eraseEntitiesAfterTimeInSeconds" optionTimeScaleId="eraseEntitiesAfterTimeScale"- />- </CardOption>+ optionValueId="eraseEntitiesAfterTimeInSeconds" optionTimeScaleId="eraseEntitiesAfterTimeScale"+ />+ </CardOption>- <CardOption- label={t("note_erasure_timeout.erase_deleted_notes_now")}- description={t("note_erasure_timeout.manual_erasing_description")}- >- <Button- name="erase-deleted-notes-now-button"- text={t("note_erasure_timeout.erase_now_button")}- size="micro"- onClick={() => {- server.post("notes/erase-deleted-notes-now").then(() => {- toast.showMessage(t("note_erasure_timeout.deleted_notes_erased"));- });- }}- />- </CardOption>- </Card>- </div>+ <CardOption+ label={t("note_erasure_timeout.erase_deleted_notes_now")}+ description={t("note_erasure_timeout.manual_erasing_description")}+ >+ <Button+ name="erase-deleted-notes-now-button"+ text={t("note_erasure_timeout.erase_now_button")}+ size="micro"+ onClick={() => {+ server.post("notes/erase-deleted-notes-now").then(() => {+ toast.showMessage(t("note_erasure_timeout.deleted_notes_erased"));+ });+ }}+ />+ </CardOption>+ </Card>);}function AttachmentErasureTimeout() {return (- <div className="options-section">- <Card- heading={t("attachment_erasure_timeout.attachment_erasure_timeout")}- description={t("attachment_erasure_timeout.description")}+ <Card+ heading={t("attachment_erasure_timeout.attachment_erasure_timeout")}+ description={t("attachment_erasure_timeout.description")}+ >+ <CardOption+ name="erase-unused-attachments-after"+ label={t("attachment_erasure_timeout.erase_attachments_after")}+ description={t("attachment_erasure_timeout.erase_attachments_after_description")}>- <CardOption+ <TimeSelectorname="erase-unused-attachments-after"- label={t("attachment_erasure_timeout.erase_attachments_after")}- description={t("attachment_erasure_timeout.erase_attachments_after_description")}- >- <TimeSelector- name="erase-unused-attachments-after"- optionValueId="eraseUnusedAttachmentsAfterSeconds" optionTimeScaleId="eraseUnusedAttachmentsAfterTimeScale"- />- </CardOption>+ optionValueId="eraseUnusedAttachmentsAfterSeconds" optionTimeScaleId="eraseUnusedAttachmentsAfterTimeScale"+ />+ </CardOption>- <CardOption- label={t("attachment_erasure_timeout.erase_unused_attachments_now")}- description={t("attachment_erasure_timeout.manual_erasing_description")}- >- <Button- name="erase-unused-attachments-now-button"- text={t("attachment_erasure_timeout.erase_now_button")}- size="micro"- onClick={() => {- server.post("notes/erase-unused-attachments-now").then(() => {- toast.showMessage(t("attachment_erasure_timeout.unused_attachments_erased"));- });- }}- />- </CardOption>- </Card>- </div>+ <CardOption+ label={t("attachment_erasure_timeout.erase_unused_attachments_now")}+ description={t("attachment_erasure_timeout.manual_erasing_description")}+ >+ <Button+ name="erase-unused-attachments-now-button"+ text={t("attachment_erasure_timeout.erase_now_button")}+ size="micro"+ onClick={() => {+ server.post("notes/erase-unused-attachments-now").then(() => {+ toast.showMessage(t("attachment_erasure_timeout.unused_attachments_erased"));+ });+ }}+ />+ </CardOption>+ </Card>);}@@ -167,66 +161,64 @@ function RevisionSettings() {const [ revisionIgnoreNamedSnapshots, setRevisionIgnoreNamedSnapshots ] = useTriliumOptionBool("revisionIgnoreNamedSnapshots");return (- <div className="options-section">- <Card heading={t("revisions_snapshot.title")}>- <CardOption+ <Card heading={t("revisions_snapshot.title")}>+ <CardOption+ name="revision-snapshot-time-interval"+ label={t("revisions_snapshot_interval.snapshot_time_interval_label")}+ description={t("revisions_snapshot_interval.note_revisions_snapshot_description_short")}+ >+ <TimeSelectorname="revision-snapshot-time-interval"- label={t("revisions_snapshot_interval.snapshot_time_interval_label")}- description={t("revisions_snapshot_interval.note_revisions_snapshot_description_short")}- >- <TimeSelector- name="revision-snapshot-time-interval"- optionValueId="revisionSnapshotTimeInterval" optionTimeScaleId="revisionSnapshotTimeIntervalTimeScale"- minimumSeconds={10}- />- </CardOption>+ optionValueId="revisionSnapshotTimeInterval" optionTimeScaleId="revisionSnapshotTimeIntervalTimeScale"+ minimumSeconds={10}+ />+ </CardOption>- <CardOption- name="revision-snapshot-number-limit"- label={t("revisions_snapshot_limit.snapshot_number_limit_label")}- description={t("revisions_snapshot_limit.note_revisions_snapshot_limit_description_short")}- >- <FormTextBoxWithUnit- type="number" min={-1}- currentValue={revisionSnapshotNumberLimit}- unit={t("revisions_snapshot_limit.snapshot_number_limit_unit")}- onBlur={value => {- const newValue = parseInt(value, 10);- if (!isNaN(newValue) && newValue >= -1) {- setRevisionSnapshotNumberLimit(newValue);- }- }}- />- </CardOption>+ <CardOption+ name="revision-snapshot-number-limit"+ label={t("revisions_snapshot_limit.snapshot_number_limit_label")}+ description={t("revisions_snapshot_limit.note_revisions_snapshot_limit_description_short")}+ >+ <FormTextBoxWithUnit+ type="number" min={-1}+ currentValue={revisionSnapshotNumberLimit}+ unit={t("revisions_snapshot_limit.snapshot_number_limit_unit")}+ onBlur={value => {+ const newValue = parseInt(value, 10);+ if (!isNaN(newValue) && newValue >= -1) {+ setRevisionSnapshotNumberLimit(newValue);+ }+ }}+ />+ </CardOption>- <CardOption- name="revision-keep-named-snapshots"- label={t("revisions_snapshot_limit.keep_named_revisions_label")}- description={t("revisions_snapshot_limit.keep_named_revisions_description")}- >- <FormToggle currentValue={revisionIgnoreNamedSnapshots} onChange={setRevisionIgnoreNamedSnapshots} />- </CardOption>+ <CardOption+ name="revision-keep-named-snapshots"+ label={t("revisions_snapshot_limit.keep_named_revisions_label")}+ description={t("revisions_snapshot_limit.keep_named_revisions_description")}+ >+ <FormToggle currentValue={revisionIgnoreNamedSnapshots} onChange={setRevisionIgnoreNamedSnapshots} />+ </CardOption>- <CardOption- label={t("revisions_snapshot_limit.erase_excess_revision_snapshots")}- description={t("revisions_snapshot_limit.erase_excess_revision_snapshots_description")}- >- <Button- name="erase-excess-revisions-button"- text={t("revisions_snapshot_limit.erase_now_button")}- size="micro"- // A negative limit keeps every snapshot, so nothing is excess and the erasure- // would report success having dropped nothing. Offered again as soon as a- // limit is set.- disabled={parseInt(revisionSnapshotNumberLimit, 10) < 0}- onClick={async () => {- await server.post("revisions/erase-all-excess-revisions");- toast.showMessage(t("revisions_snapshot_limit.erase_excess_revision_snapshots_prompt"));- }}- />- </CardOption>- </Card>- </div>+ <CardOption+ label={t("revisions_snapshot_limit.erase_excess_revision_snapshots")}+ description={t("revisions_snapshot_limit.erase_excess_revision_snapshots_description")}+ >+ <Button+ name="erase-excess-revisions-button"+ text={t("revisions_snapshot_limit.erase_now_button")}+ size="micro"+ // A negative limit keeps every snapshot, so nothing is excess and the erasure+ // would report success having dropped nothing. Offered again as soon as a+ // limit is set.+ disabled={parseInt(revisionSnapshotNumberLimit, 10) < 0}+ onClick={async () => {+ await server.post("revisions/erase-all-excess-revisions");+ toast.showMessage(t("revisions_snapshot_limit.erase_excess_revision_snapshots_prompt"));+ }}+ />+ </CardOption>+ </Card>);}@@ -235,35 +227,33 @@ function HtmlImportTags() {const parsedValue = allowedHtmlTags.join(" ");return (- <div className="options-section">- <Card- heading={t("import.html_import_tags.title")}- description={t("import.html_import_tags.description")}- >- <CardSection className="other-html-tags">- <textarea- className="allowed-html-tags"- spellcheck={false}- placeholder={t("import.html_import_tags.placeholder")}- value={parsedValue}- onBlur={e => {- const tags = e.currentTarget.value- .split(/[\n,\s]+/) // Split on newlines, commas, or spaces- .map((tag) => tag.trim())- .filter((tag) => tag.length > 0);- setAllowedHtmlTags(tags);- }}- />+ <Card+ heading={t("import.html_import_tags.title")}+ description={t("import.html_import_tags.description")}+ >+ <CardSection className="other-html-tags">+ <textarea+ className="allowed-html-tags"+ spellcheck={false}+ placeholder={t("import.html_import_tags.placeholder")}+ value={parsedValue}+ onBlur={e => {+ const tags = e.currentTarget.value+ .split(/[\n,\s]+/) // Split on newlines, commas, or spaces+ .map((tag) => tag.trim())+ .filter((tag) => tag.length > 0);+ setAllowedHtmlTags(tags);+ }}+ />- <Button- name="reset-allowed-html-tags-button"- text={t("import.html_import_tags.reset_button")}- size="micro"- onClick={() => setAllowedHtmlTags(SANITIZER_DEFAULT_ALLOWED_TAGS)}- />- </CardSection>- </Card>- </div>+ <Button+ name="reset-allowed-html-tags-button"+ text={t("import.html_import_tags.reset_button")}+ size="micro"+ onClick={() => setAllowedHtmlTags(SANITIZER_DEFAULT_ALLOWED_TAGS)}+ />+ </CardSection>+ </Card>);}@@ -272,42 +262,40 @@ function ShareSettings() {const [ showLogInShareTheme, setShowLogInShareTheme ] = useTriliumOptionBool("showLoginInShareTheme");return (- <div className="options-section">- <Card heading={t("share.title")}>- <CardOption- name="redirect-bare-domain"- label={t("share.redirect_bare_domain")}- description={t("share.redirect_bare_domain_description")}- >- <FormToggle- currentValue={redirectBareDomain}- onChange={async value => {- if (value) {- const shareRootNotes = await search.searchForNotes("#shareRoot");- const sharedShareRootNote = shareRootNotes.find((note) => note.isShared());+ <Card heading={t("share.title")}>+ <CardOption+ name="redirect-bare-domain"+ label={t("share.redirect_bare_domain")}+ description={t("share.redirect_bare_domain_description")}+ >+ <FormToggle+ currentValue={redirectBareDomain}+ onChange={async value => {+ if (value) {+ const shareRootNotes = await search.searchForNotes("#shareRoot");+ const sharedShareRootNote = shareRootNotes.find((note) => note.isShared());- if (sharedShareRootNote) {- toast.showMessage(t("share.share_root_found", { noteTitle: sharedShareRootNote.title }));- } else if (shareRootNotes.length > 0) {- toast.showError(t("share.share_root_not_shared", { noteTitle: shareRootNotes[0].title }));- } else {- toast.showError(t("share.share_root_not_found"));- }+ if (sharedShareRootNote) {+ toast.showMessage(t("share.share_root_found", { noteTitle: sharedShareRootNote.title }));+ } else if (shareRootNotes.length > 0) {+ toast.showError(t("share.share_root_not_shared", { noteTitle: shareRootNotes[0].title }));+ } else {+ toast.showError(t("share.share_root_not_found"));}- setRedirectBareDomain(value);- }}- />- </CardOption>+ }+ setRedirectBareDomain(value);+ }}+ />+ </CardOption>- <CardOption- name="show-login-in-share-theme"- label={t("share.show_login_link")}- description={t("share.show_login_link_description")}- >- <FormToggle currentValue={showLogInShareTheme} onChange={setShowLogInShareTheme} />- </CardOption>- </Card>- </div>+ <CardOption+ name="show-login-in-share-theme"+ label={t("share.show_login_link")}+ description={t("share.show_login_link_description")}+ >+ <FormToggle currentValue={showLogInShareTheme} onChange={setShowLogInShareTheme} />+ </CardOption>+ </Card>);}@@ -315,16 +303,14 @@ function NetworkSettings() {const [ checkForUpdates, setCheckForUpdates ] = useTriliumOptionBool("checkForUpdates");return (- <div className="options-section">- <Card heading={t("network_connections.network_connections_title")}>- <CardOption- name="check-for-updates"- label={t("network_connections.check_for_updates")}- description={t("network_connections.check_for_updates_description")}- >- <FormToggle currentValue={checkForUpdates} onChange={setCheckForUpdates} />- </CardOption>- </Card>- </div>+ <Card heading={t("network_connections.network_connections_title")}>+ <CardOption+ name="check-for-updates"+ label={t("network_connections.check_for_updates")}+ description={t("network_connections.check_for_updates_description")}+ >+ <FormToggle currentValue={checkForUpdates} onChange={setCheckForUpdates} />+ </CardOption>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/password.tsx b/apps/client/src/widgets/type_widgets/options/password.tsxindex b2e40db06a..a05e7f93b5 100644--- a/apps/client/src/widgets/type_widgets/options/password.tsx+++ b/apps/client/src/widgets/type_widgets/options/password.tsx@@ -1,448 +1,440 @@-import "./password.css";--import { ChangePasswordResponse, OAuthStatus, TOTPStatus } from "@triliumnext/commons";-import { createPortal } from "preact/compat";-import { useCallback, useEffect, useState } from "preact/hooks";--import dialog from "../../../services/dialog";-import { t } from "../../../services/i18n";-import { oauthAccountLabel, oauthProviderDisplayName } from "../../../services/oauth_status";-import protected_session_holder from "../../../services/protected_session_holder";-import server from "../../../services/server";-import toast from "../../../services/toast";-import { isElectron } from "../../../services/utils";-import { ExtendedAdmonition } from "../../react/Admonition";-import Button from "../../react/Button";-import { Card, CardOption, CardSection } from "../../react/Card";-import FormGroup from "../../react/FormGroup";-import FormSelect from "../../react/FormSelect";-import FormText from "../../react/FormText";-import FormTextBox from "../../react/FormTextBox";-import { useTriliumOption } from "../../react/hooks";-import Modal from "../../react/Modal";-import RawHtml from "../../react/RawHtml";-import MfaStatusBadge, { MfaStatusTone } from "./components/MfaStatusBadge";-import OptionsPageHeader from "./components/OptionsPageHeader";-import TimeSelector from "./components/TimeSelector";-import { TotpSettings } from "./totp";--export default function PasswordSettings() {- return (- <>- <OptionsPageHeader />- {/* The sign-in method (and its two-factor / OAuth settings) is only available on the server- build — the desktop app authenticates differently — matching the former MFA page's- serverOnly scope. */}- {!isElectron() && <SignInMethod />}- <ChangePassword />- <ProtectedSessionTimeout />- </>- );-}--function ChangePassword() {- const [showModal, setShowModal] = useState(false);-- return (- <div className="options-section">- <Card heading={t("password.heading")}>- <CardOption- label={t("password.change_password")}- description={t("password.change_password_description")}- >- <Button- name="change-password-button"- text={t("password.change_password_button")}- size="micro"- onClick={() => setShowModal(true)}- />- </CardOption>-- <CardOption- label={t("password.reset_password")}- description={t("password.reset_password_description")}- >- <Button- name="reset-password-button"- text={t("password.reset_password_button")}- size="micro"- onClick={async () => {- if (!await dialog.confirm(t("password.reset_confirmation"))) {- return;- }-- await server.post("password/reset?really=yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes");- toast.showError(t("password.reset_success_message"));- }}- />- </CardOption>- </Card>-- {createPortal(- <ChangePasswordModal show={showModal} onHidden={() => setShowModal(false)} />,- document.body- )}- </div>- );-}--interface ChangePasswordModalProps {- show: boolean;- onHidden: () => void;-}--function ChangePasswordModal({ show, onHidden }: ChangePasswordModalProps) {- const [oldPassword, setOldPassword] = useState("");- const [newPassword1, setNewPassword1] = useState("");- const [newPassword2, setNewPassword2] = useState("");-- const handleSubmit = async () => {- if (newPassword1 !== newPassword2) {- toast.showError(t("password.password_mismatch"));- return;- }-- const result = await server.post<ChangePasswordResponse>("password/change", {- current_password: oldPassword,- new_password: newPassword1- });-- if (result.success) {- onHidden();- setOldPassword("");- setNewPassword1("");- setNewPassword2("");- toast.showMessage(t("password.password_changed_success"));-- // password changed so current protected session is invalid and needs to be cleared- protected_session_holder.resetProtectedSession();- } else if (result.message) {- toast.showError(result.message);- }- };-- const handleHidden = () => {- setOldPassword("");- setNewPassword1("");- setNewPassword2("");- onHidden();- };-- return (- <Modal- show={show}- onHidden={handleHidden}- onSubmit={handleSubmit}- title={t("password.change_password_heading")}- className="change-password-modal"- size="md"- stackable- footer={- <>- <Button text={t("password.cancel")} onClick={handleHidden} />- <Button text={t("password.change_password")} kind="primary" />- </>- }- >- <FormGroup name="old-password" label={t("password.old_password")}>- <FormTextBox- type="password"- currentValue={oldPassword}- onChange={setOldPassword}- />- </FormGroup>-- <FormGroup name="new-password1" label={t("password.new_password")}>- <FormTextBox- type="password"- currentValue={newPassword1}- onChange={setNewPassword1}- />- </FormGroup>-- <FormGroup name="new-password2" label={t("password.new_password_confirmation")}>- <FormTextBox- type="password"- currentValue={newPassword2}- onChange={setNewPassword2}- />- </FormGroup>- </Modal>- );-}--function ProtectedSessionTimeout() {- return (- <div className="options-section">- <Card heading={t("password.protected_session_timeout")}>- <CardOption- name="protected-session-timeout"- label={t("password.protected_session_timeout_label")}- description={<>{t("password.protected_session_timeout_description")} <a class="tn-link" href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html">{t("password.wiki")}</a> {t("password.for_more_info")}</>}- >- <TimeSelector- name="protected-session-timeout"- optionValueId="protectedSessionTimeout"- optionTimeScaleId="protectedSessionTimeoutTimeScale"- minimumSeconds={60}- />- </CardOption>- </Card>- </div>- );-}--/**- * Two-factor authentication settings. Owns the live TOTP/OAuth status (the method selector needs- * `totpStatus.set` to know whether to offer switching methods) and delegates the heavier TOTP UI to- * its own module; OAuth is small and read-only, so it lives here.- */-function SignInMethod() {- // `mfaMethod` is the persisted choice: "oauth" means sign in via an OAuth provider, anything else- // ("totp") means the local password (with TOTP as optional second factor). The dropdown speaks in- // the user-facing "local"/"oauth" terms and maps back to the option here.- const [ mfaMethod, setMfaMethod ] = useTriliumOption("mfaMethod");- const [ totpStatus, setTotpStatus ] = useState<TOTPStatus>();- const [ oauthStatus, setOauthStatus ] = useState<OAuthStatus>();-- const refreshTotpStatus = useCallback(() => {- server.get<TOTPStatus>("totp/status").then(setTotpStatus);- }, []);-- const refreshOauthStatus = useCallback(() => {- server.get<OAuthStatus>("oauth/status").then(setOauthStatus);- }, []);-- useEffect(() => {- refreshTotpStatus();- refreshOauthStatus();- }, [ refreshTotpStatus, refreshOauthStatus ]);-- const usingOAuth = mfaMethod === "oauth";-- return (- <>- <div className="options-section signin-method">- <Card heading={t("multi_factor_authentication.authentication_title")}>- <CardOption name="signin-method" label={t("multi_factor_authentication.signin_method")}>- <FormSelect- values={[- { value: "local", label: t("multi_factor_authentication.signin_local") },- { value: "oauth", label: t("multi_factor_authentication.signin_oauth") }- ]}- keyProperty="value" titleProperty="label"- currentValue={usingOAuth ? "oauth" : "local"}- onChange={(value) => setMfaMethod(value === "oauth" ? "oauth" : "totp")}- />- </CardOption>-- {/* What the chosen method means, below the choice rather than above it — it- describes what was picked, not what is on offer. */}- <CardSection className="signin-method-description">- <FormText>- { usingOAuth- ? <RawHtml html={t("multi_factor_authentication.oauth_description")} />- : t("multi_factor_authentication.signin_local_description") }- </FormText>- </CardSection>- </Card>- </div>-- { usingOAuth- ? <OAuthStatusCard status={oauthStatus} refreshStatus={refreshOauthStatus} />- : <TotpSettings totpStatus={totpStatus} refreshTotpStatus={refreshTotpStatus} /> }- </>- );-}--/**- * OAuth status card, shown when OAuth is the selected sign-in method. The provider credentials are- * configured server-side (env vars / config.ini), but binding an account is an explicit in-app step —- * mirroring TOTP's verify-before-enable. Three states:- * - **not configured** → show the config hint (the server vars are missing);- * - **configured, not enrolled** → offer "Connect account", which runs the provider round-trip and- * binds the returned identity. SSO only becomes the live login method once this completes;- * - **enrolled** → show the connected account and a "Disconnect" action.- */-function OAuthStatusCard({ status, refreshStatus }: { status?: OAuthStatus, refreshStatus: () => void }) {- // "Configured" is purely about the server-side variables being present (the server's `enabled` flag- // additionally requires mfaMethod === 'oauth', which is implied here since this card only renders then).- const configured = (status?.missingVars?.length ?? 1) === 0;- const enrolled = status?.enrolled ?? false;-- // The status badge mirrors the card's three states: an account is bound (green "Connected"),- // the server is set up but no account is bound yet (amber "Not connected"), or the server-side- // variables are missing entirely (muted "Not configured").- const badge: { tone: MfaStatusTone, text: string } = enrolled- ? { tone: "active", text: t("multi_factor_authentication.oauth_status_connected") }- : configured- ? { tone: "pending", text: t("multi_factor_authentication.oauth_status_not_connected") }- : { tone: "inactive", text: t("multi_factor_authentication.oauth_status_not_configured") };-- // Enrollment is a full-page provider round-trip (not an XHR): navigate to the OIDC login route,- // which on return binds the identity to this still-authenticated session (see open_id afterCallback).- // The return lands on the app root and drops this modal; the resulting "connected" toast is driven by- // a one-shot bootstrap flag (see showOAuthEnrollmentResultToast), so nothing is tracked here.- const connectAccount = useCallback(() => {- window.location.href = "authenticate";- }, []);-- const disconnectAccount = useCallback(async () => {- if (!await dialog.confirm(t("multi_factor_authentication.oauth_disconnect_confirm"))) {- return;- }-- // Resolve the labels before disconnecting, while the account is still bound.- const account = oauthAccountLabel(status);- const provider = oauthProviderDisplayName(status);-- await server.post("oauth/disconnect");- toast.showMessage(t("multi_factor_authentication.oauth_disconnected", { account, provider }));- refreshStatus();- }, [ status, refreshStatus ]);-- return (- <div className="options-section">- <Card- heading={t("multi_factor_authentication.oauth_title")}- actions={<MfaStatusBadge tone={badge.tone} text={badge.text} />}- >- { !configured ? (- <CardSection className="mfa-notice">- <ExtendedAdmonition- type="note"- icon="bx bx-info-circle"- title={t("multi_factor_authentication.oauth_not_configured_title")}- detailsLabel={t("multi_factor_authentication.oauth_how_to_enable")}- details={<OAuthConfigInstructions />}- >- <p>{t("multi_factor_authentication.oauth_not_configured_hint")}</p>-- { status?.missingVars && status.missingVars.length > 0 && (- <p>- {t("multi_factor_authentication.oauth_missing_vars", {- variables: status.missingVars.map(v => `"${v}"`).join(", ")- })}- </p>- )}- </ExtendedAdmonition>- </CardSection>- ) : enrolled ? (- <>- <OAuthProviderRows status={status} />- <CardOption label={t("multi_factor_authentication.oauth_user_account")}>- <span>{status?.name ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span>- </CardOption>- <CardOption label={t("multi_factor_authentication.oauth_user_email")}>- <span>{status?.email ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span>- </CardOption>-- <CardOption- label={t("multi_factor_authentication.oauth_disconnect_label")}- description={t("multi_factor_authentication.oauth_disconnect_description")}- >- <Button- name="oauth-disconnect-button"- className="oauth-disconnect-button"- icon="bx-trash"- text={t("multi_factor_authentication.oauth_disconnect_button")}- size="micro"- onClick={() => void disconnectAccount()}- />- </CardOption>- </>- ) : (- <>- <CardSection className="mfa-notice">- <ExtendedAdmonition- type="note"- icon="bx bx-info-circle"- title={t("multi_factor_authentication.oauth_not_enrolled_title")}- detailsLabel={t("multi_factor_authentication.oauth_not_enrolled_details_label")}- details={t("multi_factor_authentication.oauth_not_enrolled_details")}- >- {t("multi_factor_authentication.oauth_not_enrolled_hint")}- </ExtendedAdmonition>- </CardSection>-- <OAuthProviderRows status={status} />-- <CardOption- label={t("multi_factor_authentication.oauth_connect_label")}- description={t("multi_factor_authentication.oauth_connect_description")}- >- <Button- name="oauth-connect-button"- icon="bx-log-in"- text={t("multi_factor_authentication.oauth_connect_button")}- size="micro"- onClick={connectAccount}- />- </CardOption>- </>- )}- </Card>- </div>- );-}--/**- * Identifies the configured OAuth provider: its icon and display name, plus the issuer URL. Shown- * whenever OAuth is configured so the owner can confirm which server they'll be redirected to.- */-function OAuthProviderRows({ status }: { status?: OAuthStatus }) {- const displayName = oauthProviderDisplayName(status);- return (- <>- <CardOption label={t("multi_factor_authentication.oauth_provider")}>- <span className="oauth-provider">- <OAuthProviderIcon src={status?.issuerIcon} />- <span>{displayName}</span>- </span>- </CardOption>- { status?.issuerUrl && (- <CardOption label={t("multi_factor_authentication.oauth_provider_url")}>- <span>{status.issuerUrl}</span>- </CardOption>- )}- </>- );-}--/**- * Provider icon for the OAuth status card. Renders the configured/derived issuer icon, falling back- * to a neutral key glyph when no icon is available or the image fails to load (e.g. a derived- * favicon URL that the issuer doesn't actually serve).- */-function OAuthProviderIcon({ src }: { src?: string }) {- const [ failed, setFailed ] = useState(false);-- // Reset the fallback flag when the source changes (e.g. the user switches providers), otherwise a- // previously-failed load would keep showing the key glyph even when the new URL is perfectly valid.- useEffect(() => setFailed(false), [src]);-- if (!src || failed) {- return <span className="bx bx-key oauth-provider-icon" />;- }-- return <img className="oauth-provider-icon" src={src} alt="" onError={() => setFailed(true)} />;-}--/**- * "How to enable" instructions for OAuth, shown in the not-configured admonition's collapsible. Lists- * the config.ini section and the equivalent environment variables the server reads — OAuth has no- * in-app setup, so this is the only place the values are documented in the UI.- */-function OAuthConfigInstructions() {- // oauthBaseUrl is the app's externally-reachable base URL, which for the user reading this is- // exactly the origin they're browsing from — so prefill it as a sensible example value.- const baseUrl = window.location.origin;- return (- <>- <p>{t("multi_factor_authentication.oauth_server_config_hint")}</p>- <pre><code>{`[MultiFactorAuthentication]\noauthBaseUrl=${baseUrl}\noauthClientId=\noauthClientSecret=`}</code></pre>- <p>{t("multi_factor_authentication.oauth_server_env_hint")}</p>- <pre><code>{`TRILIUM_OAUTH_BASE_URL=${baseUrl}\nTRILIUM_OAUTH_CLIENT_ID=\nTRILIUM_OAUTH_CLIENT_SECRET=`}</code></pre>- </>- );-}+import "./password.css";++import { ChangePasswordResponse, OAuthStatus, TOTPStatus } from "@triliumnext/commons";+import { createPortal } from "preact/compat";+import { useCallback, useEffect, useState } from "preact/hooks";++import dialog from "../../../services/dialog";+import { t } from "../../../services/i18n";+import { oauthAccountLabel, oauthProviderDisplayName } from "../../../services/oauth_status";+import protected_session_holder from "../../../services/protected_session_holder";+import server from "../../../services/server";+import toast from "../../../services/toast";+import { isElectron } from "../../../services/utils";+import { ExtendedAdmonition } from "../../react/Admonition";+import Button from "../../react/Button";+import { Card, CardOption, CardSection } from "../../react/Card";+import FormGroup from "../../react/FormGroup";+import FormSelect from "../../react/FormSelect";+import FormText from "../../react/FormText";+import FormTextBox from "../../react/FormTextBox";+import { useTriliumOption } from "../../react/hooks";+import Modal from "../../react/Modal";+import RawHtml from "../../react/RawHtml";+import MfaStatusBadge, { MfaStatusTone } from "./components/MfaStatusBadge";+import OptionsPageHeader from "./components/OptionsPageHeader";+import TimeSelector from "./components/TimeSelector";+import { TotpSettings } from "./totp";++export default function PasswordSettings() {+ return (+ <>+ <OptionsPageHeader />+ {/* The sign-in method (and its two-factor / OAuth settings) is only available on the server+ build — the desktop app authenticates differently — matching the former MFA page's+ serverOnly scope. */}+ {!isElectron() && <SignInMethod />}+ <ChangePassword />+ <ProtectedSessionTimeout />+ </>+ );+}++function ChangePassword() {+ const [showModal, setShowModal] = useState(false);++ return (<>+ <Card heading={t("password.heading")}>+ <CardOption+ label={t("password.change_password")}+ description={t("password.change_password_description")}+ >+ <Button+ name="change-password-button"+ text={t("password.change_password_button")}+ size="micro"+ onClick={() => setShowModal(true)}+ />+ </CardOption>++ <CardOption+ label={t("password.reset_password")}+ description={t("password.reset_password_description")}+ >+ <Button+ name="reset-password-button"+ text={t("password.reset_password_button")}+ size="micro"+ onClick={async () => {+ if (!await dialog.confirm(t("password.reset_confirmation"))) {+ return;+ }++ await server.post("password/reset?really=yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes");+ toast.showError(t("password.reset_success_message"));+ }}+ />+ </CardOption>+ </Card>++ {createPortal(+ <ChangePasswordModal show={showModal} onHidden={() => setShowModal(false)} />,+ document.body+ )}+ </>);+}++interface ChangePasswordModalProps {+ show: boolean;+ onHidden: () => void;+}++function ChangePasswordModal({ show, onHidden }: ChangePasswordModalProps) {+ const [oldPassword, setOldPassword] = useState("");+ const [newPassword1, setNewPassword1] = useState("");+ const [newPassword2, setNewPassword2] = useState("");++ const handleSubmit = async () => {+ if (newPassword1 !== newPassword2) {+ toast.showError(t("password.password_mismatch"));+ return;+ }++ const result = await server.post<ChangePasswordResponse>("password/change", {+ current_password: oldPassword,+ new_password: newPassword1+ });++ if (result.success) {+ onHidden();+ setOldPassword("");+ setNewPassword1("");+ setNewPassword2("");+ toast.showMessage(t("password.password_changed_success"));++ // password changed so current protected session is invalid and needs to be cleared+ protected_session_holder.resetProtectedSession();+ } else if (result.message) {+ toast.showError(result.message);+ }+ };++ const handleHidden = () => {+ setOldPassword("");+ setNewPassword1("");+ setNewPassword2("");+ onHidden();+ };++ return (+ <Modal+ show={show}+ onHidden={handleHidden}+ onSubmit={handleSubmit}+ title={t("password.change_password_heading")}+ className="change-password-modal"+ size="md"+ stackable+ footer={+ <>+ <Button text={t("password.cancel")} onClick={handleHidden} />+ <Button text={t("password.change_password")} kind="primary" />+ </>+ }+ >+ <FormGroup name="old-password" label={t("password.old_password")}>+ <FormTextBox+ type="password"+ currentValue={oldPassword}+ onChange={setOldPassword}+ />+ </FormGroup>++ <FormGroup name="new-password1" label={t("password.new_password")}>+ <FormTextBox+ type="password"+ currentValue={newPassword1}+ onChange={setNewPassword1}+ />+ </FormGroup>++ <FormGroup name="new-password2" label={t("password.new_password_confirmation")}>+ <FormTextBox+ type="password"+ currentValue={newPassword2}+ onChange={setNewPassword2}+ />+ </FormGroup>+ </Modal>+ );+}++function ProtectedSessionTimeout() {+ return (+ <Card heading={t("password.protected_session_timeout")}>+ <CardOption+ name="protected-session-timeout"+ label={t("password.protected_session_timeout_label")}+ description={<>{t("password.protected_session_timeout_description")} <a class="tn-link" href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html">{t("password.wiki")}</a> {t("password.for_more_info")}</>}+ >+ <TimeSelector+ name="protected-session-timeout"+ optionValueId="protectedSessionTimeout"+ optionTimeScaleId="protectedSessionTimeoutTimeScale"+ minimumSeconds={60}+ />+ </CardOption>+ </Card>+ );+}++/**+ * Two-factor authentication settings. Owns the live TOTP/OAuth status (the method selector needs+ * `totpStatus.set` to know whether to offer switching methods) and delegates the heavier TOTP UI to+ * its own module; OAuth is small and read-only, so it lives here.+ */+function SignInMethod() {+ // `mfaMethod` is the persisted choice: "oauth" means sign in via an OAuth provider, anything else+ // ("totp") means the local password (with TOTP as optional second factor). The dropdown speaks in+ // the user-facing "local"/"oauth" terms and maps back to the option here.+ const [ mfaMethod, setMfaMethod ] = useTriliumOption("mfaMethod");+ const [ totpStatus, setTotpStatus ] = useState<TOTPStatus>();+ const [ oauthStatus, setOauthStatus ] = useState<OAuthStatus>();++ const refreshTotpStatus = useCallback(() => {+ server.get<TOTPStatus>("totp/status").then(setTotpStatus);+ }, []);++ const refreshOauthStatus = useCallback(() => {+ server.get<OAuthStatus>("oauth/status").then(setOauthStatus);+ }, []);++ useEffect(() => {+ refreshTotpStatus();+ refreshOauthStatus();+ }, [ refreshTotpStatus, refreshOauthStatus ]);++ const usingOAuth = mfaMethod === "oauth";++ return (+ <>+ <Card className="signin-method" heading={t("multi_factor_authentication.authentication_title")}>+ <CardOption name="signin-method" label={t("multi_factor_authentication.signin_method")}>+ <FormSelect+ values={[+ { value: "local", label: t("multi_factor_authentication.signin_local") },+ { value: "oauth", label: t("multi_factor_authentication.signin_oauth") }+ ]}+ keyProperty="value" titleProperty="label"+ currentValue={usingOAuth ? "oauth" : "local"}+ onChange={(value) => setMfaMethod(value === "oauth" ? "oauth" : "totp")}+ />+ </CardOption>++ {/* What the chosen method means, below the choice rather than above it — it+ describes what was picked, not what is on offer. */}+ <CardSection className="signin-method-description">+ <FormText>+ { usingOAuth+ ? <RawHtml html={t("multi_factor_authentication.oauth_description")} />+ : t("multi_factor_authentication.signin_local_description") }+ </FormText>+ </CardSection>+ </Card>++ { usingOAuth+ ? <OAuthStatusCard status={oauthStatus} refreshStatus={refreshOauthStatus} />+ : <TotpSettings totpStatus={totpStatus} refreshTotpStatus={refreshTotpStatus} /> }+ </>+ );+}++/**+ * OAuth status card, shown when OAuth is the selected sign-in method. The provider credentials are+ * configured server-side (env vars / config.ini), but binding an account is an explicit in-app step —+ * mirroring TOTP's verify-before-enable. Three states:+ * - **not configured** → show the config hint (the server vars are missing);+ * - **configured, not enrolled** → offer "Connect account", which runs the provider round-trip and+ * binds the returned identity. SSO only becomes the live login method once this completes;+ * - **enrolled** → show the connected account and a "Disconnect" action.+ */+function OAuthStatusCard({ status, refreshStatus }: { status?: OAuthStatus, refreshStatus: () => void }) {+ // "Configured" is purely about the server-side variables being present (the server's `enabled` flag+ // additionally requires mfaMethod === 'oauth', which is implied here since this card only renders then).+ const configured = (status?.missingVars?.length ?? 1) === 0;+ const enrolled = status?.enrolled ?? false;++ // The status badge mirrors the card's three states: an account is bound (green "Connected"),+ // the server is set up but no account is bound yet (amber "Not connected"), or the server-side+ // variables are missing entirely (muted "Not configured").+ const badge: { tone: MfaStatusTone, text: string } = enrolled+ ? { tone: "active", text: t("multi_factor_authentication.oauth_status_connected") }+ : configured+ ? { tone: "pending", text: t("multi_factor_authentication.oauth_status_not_connected") }+ : { tone: "inactive", text: t("multi_factor_authentication.oauth_status_not_configured") };++ // Enrollment is a full-page provider round-trip (not an XHR): navigate to the OIDC login route,+ // which on return binds the identity to this still-authenticated session (see open_id afterCallback).+ // The return lands on the app root and drops this modal; the resulting "connected" toast is driven by+ // a one-shot bootstrap flag (see showOAuthEnrollmentResultToast), so nothing is tracked here.+ const connectAccount = useCallback(() => {+ window.location.href = "authenticate";+ }, []);++ const disconnectAccount = useCallback(async () => {+ if (!await dialog.confirm(t("multi_factor_authentication.oauth_disconnect_confirm"))) {+ return;+ }++ // Resolve the labels before disconnecting, while the account is still bound.+ const account = oauthAccountLabel(status);+ const provider = oauthProviderDisplayName(status);++ await server.post("oauth/disconnect");+ toast.showMessage(t("multi_factor_authentication.oauth_disconnected", { account, provider }));+ refreshStatus();+ }, [ status, refreshStatus ]);++ return (+ <Card+ heading={t("multi_factor_authentication.oauth_title")}+ actions={<MfaStatusBadge tone={badge.tone} text={badge.text} />}+ >+ { !configured ? (+ <CardSection className="mfa-notice">+ <ExtendedAdmonition+ type="note"+ icon="bx bx-info-circle"+ title={t("multi_factor_authentication.oauth_not_configured_title")}+ detailsLabel={t("multi_factor_authentication.oauth_how_to_enable")}+ details={<OAuthConfigInstructions />}+ >+ <p>{t("multi_factor_authentication.oauth_not_configured_hint")}</p>++ { status?.missingVars && status.missingVars.length > 0 && (+ <p>+ {t("multi_factor_authentication.oauth_missing_vars", {+ variables: status.missingVars.map(v => `"${v}"`).join(", ")+ })}+ </p>+ )}+ </ExtendedAdmonition>+ </CardSection>+ ) : enrolled ? (+ <>+ <OAuthProviderRows status={status} />+ <CardOption label={t("multi_factor_authentication.oauth_user_account")}>+ <span>{status?.name ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span>+ </CardOption>+ <CardOption label={t("multi_factor_authentication.oauth_user_email")}>+ <span>{status?.email ?? t("multi_factor_authentication.oauth_user_not_logged_in")}</span>+ </CardOption>++ <CardOption+ label={t("multi_factor_authentication.oauth_disconnect_label")}+ description={t("multi_factor_authentication.oauth_disconnect_description")}+ >+ <Button+ name="oauth-disconnect-button"+ className="oauth-disconnect-button"+ icon="bx-trash"+ text={t("multi_factor_authentication.oauth_disconnect_button")}+ size="micro"+ onClick={() => void disconnectAccount()}+ />+ </CardOption>+ </>+ ) : (+ <>+ <CardSection className="mfa-notice">+ <ExtendedAdmonition+ type="note"+ icon="bx bx-info-circle"+ title={t("multi_factor_authentication.oauth_not_enrolled_title")}+ detailsLabel={t("multi_factor_authentication.oauth_not_enrolled_details_label")}+ details={t("multi_factor_authentication.oauth_not_enrolled_details")}+ >+ {t("multi_factor_authentication.oauth_not_enrolled_hint")}+ </ExtendedAdmonition>+ </CardSection>++ <OAuthProviderRows status={status} />++ <CardOption+ label={t("multi_factor_authentication.oauth_connect_label")}+ description={t("multi_factor_authentication.oauth_connect_description")}+ >+ <Button+ name="oauth-connect-button"+ icon="bx-log-in"+ text={t("multi_factor_authentication.oauth_connect_button")}+ size="micro"+ onClick={connectAccount}+ />+ </CardOption>+ </>+ )}+ </Card>+ );+}++/**+ * Identifies the configured OAuth provider: its icon and display name, plus the issuer URL. Shown+ * whenever OAuth is configured so the owner can confirm which server they'll be redirected to.+ */+function OAuthProviderRows({ status }: { status?: OAuthStatus }) {+ const displayName = oauthProviderDisplayName(status);+ return (+ <>+ <CardOption label={t("multi_factor_authentication.oauth_provider")}>+ <span className="oauth-provider">+ <OAuthProviderIcon src={status?.issuerIcon} />+ <span>{displayName}</span>+ </span>+ </CardOption>+ { status?.issuerUrl && (+ <CardOption label={t("multi_factor_authentication.oauth_provider_url")}>+ <span>{status.issuerUrl}</span>+ </CardOption>+ )}+ </>+ );+}++/**+ * Provider icon for the OAuth status card. Renders the configured/derived issuer icon, falling back+ * to a neutral key glyph when no icon is available or the image fails to load (e.g. a derived+ * favicon URL that the issuer doesn't actually serve).+ */+function OAuthProviderIcon({ src }: { src?: string }) {+ const [ failed, setFailed ] = useState(false);++ // Reset the fallback flag when the source changes (e.g. the user switches providers), otherwise a+ // previously-failed load would keep showing the key glyph even when the new URL is perfectly valid.+ useEffect(() => setFailed(false), [src]);++ if (!src || failed) {+ return <span className="bx bx-key oauth-provider-icon" />;+ }++ return <img className="oauth-provider-icon" src={src} alt="" onError={() => setFailed(true)} />;+}++/**+ * "How to enable" instructions for OAuth, shown in the not-configured admonition's collapsible. Lists+ * the config.ini section and the equivalent environment variables the server reads — OAuth has no+ * in-app setup, so this is the only place the values are documented in the UI.+ */+function OAuthConfigInstructions() {+ // oauthBaseUrl is the app's externally-reachable base URL, which for the user reading this is+ // exactly the origin they're browsing from — so prefill it as a sensible example value.+ const baseUrl = window.location.origin;+ return (+ <>+ <p>{t("multi_factor_authentication.oauth_server_config_hint")}</p>+ <pre><code>{`[MultiFactorAuthentication]\noauthBaseUrl=${baseUrl}\noauthClientId=\noauthClientSecret=`}</code></pre>+ <p>{t("multi_factor_authentication.oauth_server_env_hint")}</p>+ <pre><code>{`TRILIUM_OAUTH_BASE_URL=${baseUrl}\nTRILIUM_OAUTH_CLIENT_ID=\nTRILIUM_OAUTH_CLIENT_SECRET=`}</code></pre>+ </>+ );+}diff --git a/apps/client/src/widgets/type_widgets/options/security.tsx b/apps/client/src/widgets/type_widgets/options/security.tsxindex abcd46ba60..0131e39c12 100644--- a/apps/client/src/widgets/type_widgets/options/security.tsx+++ b/apps/client/src/widgets/type_widgets/options/security.tsx@@ -93,28 +93,26 @@ function BackendScriptingSettings({ liveValue, pendingValue, setPendingValue }:}return (- <div className="options-section">- <Card- heading={t("security.backend_scripting_title")}- description={t("security.backend_scripting_section_description")}- actions={<HelpButton helpPage="SPirpZypehBG" />}+ <Card+ heading={t("security.backend_scripting_title")}+ description={t("security.backend_scripting_section_description")}+ actions={<HelpButton helpPage="SPirpZypehBG" />}+ >+ <CardOption+ name="backend-scripting-enabled"+ label={t("security.backend_scripting_label")}+ description={hasPendingChange+ ? t("security.restart_required")+ : t("security.backend_scripting_description")}>- <CardOption- name="backend-scripting-enabled"- label={t("security.backend_scripting_label")}- description={hasPendingChange- ? t("security.restart_required")- : t("security.backend_scripting_description")}- >- <FormToggle currentValue={displayValue} onChange={handleToggle} disabled={!isDesktop} />- </CardOption>-- <ServerConfigHint- configKey="backendScriptingEnabled"- envVar="TRILIUM_SECURITY_BACKEND_SCRIPTING_ENABLED"- />- </Card>- </div>+ <FormToggle currentValue={displayValue} onChange={handleToggle} disabled={!isDesktop} />+ </CardOption>++ <ServerConfigHint+ configKey="backendScriptingEnabled"+ envVar="TRILIUM_SECURITY_BACKEND_SCRIPTING_ENABLED"+ />+ </Card>);}@@ -131,28 +129,26 @@ function SqlConsoleSettings({ liveValue, pendingValue, setPendingValue }: Toggle}return (- <div className="options-section">- <Card- heading={t("security.sql_console_title")}- description={t("security.sql_console_section_description")}- actions={<HelpButton helpPage="YKWqdJhzi2VY" />}+ <Card+ heading={t("security.sql_console_title")}+ description={t("security.sql_console_section_description")}+ actions={<HelpButton helpPage="YKWqdJhzi2VY" />}+ >+ <CardOption+ name="sql-console-enabled"+ label={t("security.sql_console_label")}+ description={hasPendingChange+ ? t("security.restart_required")+ : t("security.sql_console_description")}>- <CardOption- name="sql-console-enabled"- label={t("security.sql_console_label")}- description={hasPendingChange- ? t("security.restart_required")- : t("security.sql_console_description")}- >- <FormToggle currentValue={displayValue} onChange={handleToggle} disabled={!isDesktop} />- </CardOption>-- <ServerConfigHint- configKey="sqlConsoleEnabled"- envVar="TRILIUM_SECURITY_SQL_CONSOLE_ENABLED"- />- </Card>- </div>+ <FormToggle currentValue={displayValue} onChange={handleToggle} disabled={!isDesktop} />+ </CardOption>++ <ServerConfigHint+ configKey="sqlConsoleEnabled"+ envVar="TRILIUM_SECURITY_SQL_CONSOLE_ENABLED"+ />+ </Card>);}@@ -171,22 +167,20 @@ function LanAccessSettings({ liveValue, pendingValue, setPendingValue }: ToggleS}return (- <div className="options-section">- <Card- heading={t("security.lan_access_title")}- description={t("security.lan_access_section_description")}- actions={<HelpButton helpPage="swSFivWk6KkA" />}+ <Card+ heading={t("security.lan_access_title")}+ description={t("security.lan_access_section_description")}+ actions={<HelpButton helpPage="swSFivWk6KkA" />}+ >+ <CardOption+ name="lan-access-enabled"+ label={t("security.lan_access_label")}+ description={hasPendingChange+ ? t("security.restart_required")+ : t("security.lan_access_description")}>- <CardOption- name="lan-access-enabled"- label={t("security.lan_access_label")}- description={hasPendingChange- ? t("security.restart_required")- : t("security.lan_access_description")}- >- <FormToggle currentValue={displayValue} onChange={handleToggle} />- </CardOption>- </Card>- </div>+ <FormToggle currentValue={displayValue} onChange={handleToggle} />+ </CardOption>+ </Card>);}diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.css b/apps/client/src/widgets/type_widgets/options/shortcuts.cssindex 8d861c9010..df93ba060d 100644--- a/apps/client/src/widgets/type_widgets/options/shortcuts.css+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.css@@ -39,7 +39,12 @@}}+/* The cards are grouped one level in, out of reach of the page's own stacking rule. */.shortcuts-options-section {+ display: flex;+ flex-direction: column;+ gap: 26px;+.shortcut-modified-indicator {display: inline-block;width: 0.5em;diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.tsxindex db0de1fe8c..bf4a07cec0 100644--- a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx@@ -170,13 +170,11 @@ export default function ShortcutSettings() {<div className="shortcuts-options-section">{filteredGroups.length > 0? filteredGroups.map((group) => (- <div key={group.title} className="options-section">- <Card heading={group.title}>- {group.actions.map((action) => (- <ShortcutRow key={action.actionName} action={action} conflicts={conflicts.get(action.actionName)} />- ))}- </Card>- </div>+ <Card heading={group.title}>+ {group.actions.map((action) => (+ <ShortcutRow key={action.actionName} action={action} conflicts={conflicts.get(action.actionName)} />+ ))}+ </Card>)): filter? (diff --git a/apps/client/src/widgets/type_widgets/options/spellcheck.tsx b/apps/client/src/widgets/type_widgets/options/spellcheck.tsxindex be44281644..466d940856 100644--- a/apps/client/src/widgets/type_widgets/options/spellcheck.tsx+++ b/apps/client/src/widgets/type_widgets/options/spellcheck.tsx@@ -99,19 +99,17 @@ function SpellcheckLanguages() {}, []);return (- <div className="options-section spellcheck-languages">- <Card heading={t("spellcheck.language_code_label")}>- <CardSection>- <CheckboxList- values={availableLanguages}- keyProperty="code" titleProperty="name"- currentValue={selectedCodes}- onChange={setSelectedCodes}- columnWidth="200px"- />- </CardSection>- </Card>- </div>+ <Card className="spellcheck-languages" heading={t("spellcheck.language_code_label")}>+ <CardSection>+ <CheckboxList+ values={availableLanguages}+ keyProperty="code" titleProperty="name"+ currentValue={selectedCodes}+ onChange={setSelectedCodes}+ columnWidth="200px"+ />+ </CardSection>+ </Card>);}@@ -121,35 +119,31 @@ function CustomDictionary() {}return (- <div className="options-section">- <Card- heading={t("spellcheck.custom_dictionary_title")}- description={t("spellcheck.custom_dictionary_description")}+ <Card+ heading={t("spellcheck.custom_dictionary_title")}+ description={t("spellcheck.custom_dictionary_description")}+ >+ <CardOption+ label={t("spellcheck.custom_dictionary_edit")}+ description={t("spellcheck.custom_dictionary_edit_description")}>- <CardOption- 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-edit"- size="micro"- onClick={openDictionary}- />- </CardOption>- </Card>- </div>+ <Button+ name="open-custom-dictionary"+ text={t("spellcheck.custom_dictionary_open")}+ icon="bx-edit"+ size="micro"+ onClick={openDictionary}+ />+ </CardOption>+ </Card>);}function WebSpellcheckSettings() {return (- <div className="options-section">- <NoItems- text={t("spellcheck.description")}- icon="bx bx-check-double"- />- </div>+ <NoItems+ text={t("spellcheck.description")}+ icon="bx bx-check-double"+ />);}diff --git a/apps/client/src/widgets/type_widgets/options/sync.tsx b/apps/client/src/widgets/type_widgets/options/sync.tsxindex c172946b23..941e127f15 100644--- a/apps/client/src/widgets/type_widgets/options/sync.tsx+++ b/apps/client/src/widgets/type_widgets/options/sync.tsx@@ -52,66 +52,62 @@ export function SyncConfiguration() {return (<>- <div className="options-section">- <Card heading={t("sync_2.config_title")}>- <CardOption- name="sync-server-host"- label={t("sync_2.server_address")}- description={t("sync_2.server_address_description")}- stacked- >- <FormTextBox- placeholder="https://<host>:<port>"- currentValue={localHost}- onChange={setLocalHost}- onBlur={setSyncServerHost}- />- </CardOption>+ <Card heading={t("sync_2.config_title")}>+ <CardOption+ name="sync-server-host"+ label={t("sync_2.server_address")}+ description={t("sync_2.server_address_description")}+ stacked+ >+ <FormTextBox+ placeholder="https://<host>:<port>"+ currentValue={localHost}+ onChange={setLocalHost}+ onBlur={setSyncServerHost}+ />+ </CardOption>- <CardOption- name="sync-proxy"- label={t("sync_2.proxy_label")}- description={t("sync_2.proxy_description")}- stacked- >- <FormTextBox- placeholder="https://<host>:<port>"- currentValue={localProxy}- onChange={setLocalProxy}- onBlur={setSyncProxy}- />- </CardOption>+ <CardOption+ name="sync-proxy"+ label={t("sync_2.proxy_label")}+ description={t("sync_2.proxy_description")}+ stacked+ >+ <FormTextBox+ placeholder="https://<host>:<port>"+ currentValue={localProxy}+ onChange={setLocalProxy}+ onBlur={setSyncProxy}+ />+ </CardOption>- <CardOption+ <CardOption+ name="sync-server-timeout"+ label={t("sync_2.timeout")}+ description={t("sync_2.timeout_description")}+ >+ <TimeSelectorname="sync-server-timeout"- label={t("sync_2.timeout")}- description={t("sync_2.timeout_description")}- >- <TimeSelector- name="sync-server-timeout"- optionValueId="syncServerTimeout"- optionTimeScaleId="syncServerTimeoutTimeScale"- minimumSeconds={1}- />- </CardOption>- </Card>- </div>+ optionValueId="syncServerTimeout"+ optionTimeScaleId="syncServerTimeoutTimeScale"+ minimumSeconds={1}+ />+ </CardOption>+ </Card>- <div className="options-section">- <Card>- <CardOption- label={t("sync_2.test_title")}- description={t("sync_2.test_description")}- >- <Button- name="test-sync-button"- text={t("sync_2.test_button")}- size="micro"- onClick={() => void testConnection()}- />- </CardOption>- </Card>- </div>+ <Card>+ <CardOption+ label={t("sync_2.test_title")}+ description={t("sync_2.test_description")}+ >+ <Button+ name="test-sync-button"+ text={t("sync_2.test_button")}+ size="micro"+ onClick={() => void testConnection()}+ />+ </CardOption>+ </Card></>);}diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsxindex 4ce563acd4..7ff496dfc4 100644--- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx+++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx@@ -57,21 +57,19 @@ function FormattingToolbar() {const [ textNoteEditorMultilineToolbar, setTextNoteEditorMultilineToolbar ] = useTriliumOptionBool("textNoteEditorMultilineToolbar");return (- <div className="options-section">- <Card heading={t("editing.editor_type.label")}>- <CardOption- name="multiline-toolbar"- label={t("editing.editor_type.multiline-toolbar")}- >- <FormToggle- currentValue={textNoteEditorMultilineToolbar}- onChange={setTextNoteEditorMultilineToolbar}- // Nothing to wrap onto a second line where the toolbar follows the cursor.- disabled={textNoteEditorType === "ckeditor-balloon"}- />- </CardOption>- </Card>- </div>+ <Card heading={t("editing.editor_type.label")}>+ <CardOption+ name="multiline-toolbar"+ label={t("editing.editor_type.multiline-toolbar")}+ >+ <FormToggle+ currentValue={textNoteEditorMultilineToolbar}+ onChange={setTextNoteEditorMultilineToolbar}+ // Nothing to wrap onto a second line where the toolbar follows the cursor.+ disabled={textNoteEditorType === "ckeditor-balloon"}+ />+ </CardOption>+ </Card>);}@@ -84,28 +82,26 @@ function ToolbarStyle() {const [ textNoteEditorType, setTextNoteEditorType ] = useTriliumOption("textNoteEditorType");return (- <div className="options-section">- <Card className="thumbnail-selector-option-card" heading={t("editing.editor_type.toolbar_style")}>- <CardSection>- <RadioWithIllustration- currentValue={textNoteEditorType}- onChange={setTextNoteEditorType}- values={[- {- key: "ckeditor-balloon",- text: t("editing.editor_type.floating.title"),- illustration: <ToolbarIllustration type="floating" />- },- {- key: "ckeditor-classic",- text: t("editing.editor_type.fixed.title"),- illustration: <ToolbarIllustration type="fixed" />- }- ]}- />- </CardSection>- </Card>- </div>+ <Card className="thumbnail-selector-option-card" heading={t("editing.editor_type.toolbar_style")}>+ <CardSection>+ <RadioWithIllustration+ currentValue={textNoteEditorType}+ onChange={setTextNoteEditorType}+ values={[+ {+ key: "ckeditor-balloon",+ text: t("editing.editor_type.floating.title"),+ illustration: <ToolbarIllustration type="floating" />+ },+ {+ key: "ckeditor-classic",+ text: t("editing.editor_type.fixed.title"),+ illustration: <ToolbarIllustration type="fixed" />+ }+ ]}+ />+ </CardSection>+ </Card>);}@@ -160,57 +156,55 @@ function EditorFeatures() {const [htmlSupportEnabled, setHtmlSupportEnabled] = useTriliumOptionBool("textNoteHtmlSupportEnabled");return (- <div className="options-section">- <Card heading={t("editorfeatures.title")}>- <CardOption- name="emoji-completion-enabled"- label={t("editorfeatures.emoji_completion_enabled")}- description={t("editorfeatures.emoji_completion_description")}- >- <FormToggle currentValue={emojiCompletionEnabled} onChange={setEmojiCompletionEnabled} />- </CardOption>+ <Card heading={t("editorfeatures.title")}>+ <CardOption+ name="emoji-completion-enabled"+ label={t("editorfeatures.emoji_completion_enabled")}+ description={t("editorfeatures.emoji_completion_description")}+ >+ <FormToggle currentValue={emojiCompletionEnabled} onChange={setEmojiCompletionEnabled} />+ </CardOption>- <CardOption- name="auto-link-previews-enabled"- label={t("editorfeatures.auto_link_previews_enabled")}- description={t("editorfeatures.auto_link_previews_description")}- >- <FormToggle currentValue={autoLinkPreviewsEnabled} onChange={setAutoLinkPreviewsEnabled} />- </CardOption>+ <CardOption+ name="auto-link-previews-enabled"+ label={t("editorfeatures.auto_link_previews_enabled")}+ description={t("editorfeatures.auto_link_previews_description")}+ >+ <FormToggle currentValue={autoLinkPreviewsEnabled} onChange={setAutoLinkPreviewsEnabled} />+ </CardOption>- <CardOption- name="note-completion-enabled"- label={t("editorfeatures.note_completion_enabled")}- description={t("editorfeatures.note_completion_description")}- >- <FormToggle currentValue={noteCompletionEnabled} onChange={setNoteCompletionEnabled} />- </CardOption>+ <CardOption+ name="note-completion-enabled"+ label={t("editorfeatures.note_completion_enabled")}+ description={t("editorfeatures.note_completion_description")}+ >+ <FormToggle currentValue={noteCompletionEnabled} onChange={setNoteCompletionEnabled} />+ </CardOption>- <CardOption- name="slash-commands-enabled"- label={t("editorfeatures.slash_commands_enabled")}- description={t("editorfeatures.slash_commands_description")}- >- <FormToggle currentValue={slashCommandsEnabled} onChange={setSlashCommandsEnabled} />- </CardOption>+ <CardOption+ name="slash-commands-enabled"+ label={t("editorfeatures.slash_commands_enabled")}+ description={t("editorfeatures.slash_commands_description")}+ >+ <FormToggle currentValue={slashCommandsEnabled} onChange={setSlashCommandsEnabled} />+ </CardOption>- <CardOption- name="content-hints-enabled"- label={t("editorfeatures.content_hints_enabled")}- description={t("editorfeatures.content_hints_description")}- >- <FormToggle currentValue={contentHintsEnabled} onChange={setContentHintsEnabled} />- </CardOption>+ <CardOption+ name="content-hints-enabled"+ label={t("editorfeatures.content_hints_enabled")}+ description={t("editorfeatures.content_hints_description")}+ >+ <FormToggle currentValue={contentHintsEnabled} onChange={setContentHintsEnabled} />+ </CardOption>- <CardOption- name="html-support-enabled"- label={t("editorfeatures.html_support_enabled")}- description={t("editorfeatures.html_support_description")}- >- <FormToggle currentValue={htmlSupportEnabled} onChange={setHtmlSupportEnabled} />- </CardOption>- </Card>- </div>+ <CardOption+ name="html-support-enabled"+ label={t("editorfeatures.html_support_enabled")}+ description={t("editorfeatures.html_support_description")}+ >+ <FormToggle currentValue={htmlSupportEnabled} onChange={setHtmlSupportEnabled} />+ </CardOption>+ </Card>);}@@ -227,54 +221,52 @@ function AutomaticReplacements() {const [symbolsEnabled, setSymbolsEnabled] = useTriliumOptionBool("textNoteSymbolReplacementsEnabled");return (- <div className="options-section text-notes-replacements">- <Card- heading={t("automatic_replacements.title")}- description={t("automatic_replacements.description")}+ <Card className="text-notes-replacements"+ heading={t("automatic_replacements.title")}+ description={t("automatic_replacements.description")}+ >+ <CardOption+ name="double-quote-style"+ label={t("automatic_replacements.double_quotes")}+ description={t("automatic_replacements.double_quotes_description")}>- <CardOption- name="double-quote-style"- label={t("automatic_replacements.double_quotes")}- description={t("automatic_replacements.double_quotes_description")}- >- <QuoteStyleSelect currentValue={doubleQuoteStyle} onChange={setDoubleQuoteStyle} />- </CardOption>+ <QuoteStyleSelect currentValue={doubleQuoteStyle} onChange={setDoubleQuoteStyle} />+ </CardOption>- <CardOption- name="single-quote-style"- label={t("automatic_replacements.single_quotes")}- description={t("automatic_replacements.single_quotes_description")}- >- <QuoteStyleSelect currentValue={singleQuoteStyle} onChange={setSingleQuoteStyle} />- </CardOption>+ <CardOption+ name="single-quote-style"+ label={t("automatic_replacements.single_quotes")}+ description={t("automatic_replacements.single_quotes_description")}+ >+ <QuoteStyleSelect currentValue={singleQuoteStyle} onChange={setSingleQuoteStyle} />+ </CardOption>- <CardOption- name="punctuation-replacements-enabled"- label={t("automatic_replacements.punctuation")}- description={t("automatic_replacements.punctuation_description")}- >- <FormToggle currentValue={punctuationEnabled} onChange={setPunctuationEnabled} />- </CardOption>+ <CardOption+ name="punctuation-replacements-enabled"+ label={t("automatic_replacements.punctuation")}+ description={t("automatic_replacements.punctuation_description")}+ >+ <FormToggle currentValue={punctuationEnabled} onChange={setPunctuationEnabled} />+ </CardOption>- <CardOption- name="math-replacements-enabled"- label={t("automatic_replacements.math")}- description={t("automatic_replacements.math_description")}- >- <FormToggle currentValue={mathEnabled} onChange={setMathEnabled} />- </CardOption>+ <CardOption+ name="math-replacements-enabled"+ label={t("automatic_replacements.math")}+ description={t("automatic_replacements.math_description")}+ >+ <FormToggle currentValue={mathEnabled} onChange={setMathEnabled} />+ </CardOption>- <CardOption- name="symbol-replacements-enabled"- label={t("automatic_replacements.symbols")}- description={t("automatic_replacements.symbols_description")}- >- <FormToggle currentValue={symbolsEnabled} onChange={setSymbolsEnabled} />- </CardOption>+ <CardOption+ name="symbol-replacements-enabled"+ label={t("automatic_replacements.symbols")}+ description={t("automatic_replacements.symbols_description")}+ >+ <FormToggle currentValue={symbolsEnabled} onChange={setSymbolsEnabled} />+ </CardOption>- <CustomReplacements />- </Card>- </div>+ <CustomReplacements />+ </Card>);}@@ -424,41 +416,39 @@ function Editor() {}, [headingStyle]);return (- <div className="options-section text-notes-editor">- <Card heading={t("text_editor.title")}>- <CardOption- name="heading-style"- label={t("heading_style.title")}- description={t("heading_style.description")}- >- <HeadingStyleSelector currentValue={headingStyle} onChange={setHeadingStyle} />- </CardOption>-- <CardOption- name="auto-readonly-size-text"- label={t("text_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>+ <Card className="text-notes-editor" heading={t("text_editor.title")}>+ <CardOption+ name="heading-style"+ label={t("heading_style.title")}+ description={t("heading_style.description")}+ >+ <HeadingStyleSelector currentValue={headingStyle} onChange={setHeadingStyle} />+ </CardOption>- <CardOption- name="custom-date-time-format"- label={t("custom_date_time_format.title")}- description={<>{t("custom_date_time_format.description_short")} {t("custom_date_time_format.preview", { preview: formatDateTime(new Date(), customDateTimeFormat) })}</>}- >- <FormTextBox- placeholder="YYYY-MM-DD HH:mm"- currentValue={customDateTimeFormat || "YYYY-MM-DD HH:mm"} onBlur={setCustomDateTimeFormat}- />- </CardOption>- </Card>- </div>+ <CardOption+ name="auto-readonly-size-text"+ label={t("text_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="custom-date-time-format"+ label={t("custom_date_time_format.title")}+ description={<>{t("custom_date_time_format.description_short")} {t("custom_date_time_format.preview", { preview: formatDateTime(new Date(), customDateTimeFormat) })}</>}+ >+ <FormTextBox+ placeholder="YYYY-MM-DD HH:mm"+ currentValue={customDateTimeFormat || "YYYY-MM-DD HH:mm"} onBlur={setCustomDateTimeFormat}+ />+ </CardOption>+ </Card>);}@@ -561,57 +551,55 @@ function CodeBlockStyle() {}, [effectiveTheme]);return (- <div className="options-section text-notes-code-blocks">- <Card heading={t("highlighting.title")}>- <ThemeModeSelector matchesApp={matchesApp} onMatchesAppChange={setMatchesApp} />-- {matchesApp ? (- <>- <CardOption name="light-theme" label={t("code_theme.light_theme")}>- <FormSelect- values={lightThemes}- keyProperty="val" titleProperty="title"- currentValue={lightTheme} onChange={setLightTheme}- />- </CardOption>- <CardOption name="dark-theme" label={t("code_theme.dark_theme")}>- <FormSelect- values={darkThemes}- keyProperty="val" titleProperty="title"- currentValue={darkTheme} onChange={setDarkTheme}- />- </CardOption>- </>- ) : (- <CardOption name="code-block-theme" label={t("highlighting.color-scheme")}>- <FormSelectWithGroups- values={groupedThemes}+ <Card heading={t("highlighting.title")}>+ <ThemeModeSelector matchesApp={matchesApp} onMatchesAppChange={setMatchesApp} />++ {matchesApp ? (+ <>+ <CardOption name="light-theme" label={t("code_theme.light_theme")}>+ <FormSelect+ values={lightThemes}keyProperty="val" titleProperty="title"- currentValue={codeBlockTheme} onChange={setCodeBlockTheme}+ currentValue={lightTheme} onChange={setLightTheme}/></CardOption>- )}-- <CardOption name="code-block-word-wrap" label={t("code_block.word_wrapping")}>- <FormToggle currentValue={codeBlockWordWrap} onChange={setCodeBlockWordWrap} />- </CardOption>-- {/* Avoid using "code" in the name of numeric inputs to prevent KeepassXC from triggering. */}- <CardOption name="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}- onChange={setCodeBlockTabWidth}- onBlur={setCodeBlockTabWidth}+ <CardOption name="dark-theme" label={t("code_theme.dark_theme")}>+ <FormSelect+ values={darkThemes}+ keyProperty="val" titleProperty="title"+ currentValue={darkTheme} onChange={setDarkTheme}+ />+ </CardOption>+ </>+ ) : (+ <CardOption name="code-block-theme" label={t("highlighting.color-scheme")}>+ <FormSelectWithGroups+ values={groupedThemes}+ keyProperty="val" titleProperty="title"+ currentValue={codeBlockTheme} onChange={setCodeBlockTheme}/></CardOption>+ )}- <CardSection className="code-block-preview">- <CodeBlockPreview theme={effectiveTheme} wordWrap={codeBlockWordWrap} tabWidth={codeBlockTabWidth} />- </CardSection>- </Card>- </div>+ <CardOption name="code-block-word-wrap" label={t("code_block.word_wrapping")}>+ <FormToggle currentValue={codeBlockWordWrap} onChange={setCodeBlockWordWrap} />+ </CardOption>++ {/* Avoid using "code" in the name of numeric inputs to prevent KeepassXC from triggering. */}+ <CardOption name="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}+ onChange={setCodeBlockTabWidth}+ onBlur={setCodeBlockTabWidth}+ />+ </CardOption>++ <CardSection className="code-block-preview">+ <CodeBlockPreview theme={effectiveTheme} wordWrap={codeBlockWordWrap} tabWidth={codeBlockTabWidth} />+ </CardSection>+ </Card>);}@@ -676,51 +664,45 @@ function TableOfContent() {const [ minTocHeadings, setMinTocHeadings ] = useTriliumOption("minTocHeadings");return (!isNewLayout &&- <div className="options-section text-notes-toc">- <Card- heading={t("table_of_contents.title")}- description={t("table_of_contents.description")}- >- <CardSection>- <FormGroup name="min-toc-headings">- <FormTextBoxWithUnit- type="number"- min={0} max={999999999999999} step={1}- unit={t("table_of_contents.unit")}- currentValue={minTocHeadings} onChange={setMinTocHeadings}- />- </FormGroup>+ <Card className="text-notes-toc"+ heading={t("table_of_contents.title")}+ description={t("table_of_contents.description")}+ >+ <CardSection>+ <FormGroup name="min-toc-headings">+ <FormTextBoxWithUnit+ type="number"+ min={0} max={999999999999999} step={1}+ unit={t("table_of_contents.unit")}+ currentValue={minTocHeadings} onChange={setMinTocHeadings}+ />+ </FormGroup>- <FormText>{t("table_of_contents.disable_info")}</FormText>- <FormText>{t("table_of_contents.shortcut_info")}</FormText>- </CardSection>- </Card>- </div>+ <FormText>{t("table_of_contents.disable_info")}</FormText>+ <FormText>{t("table_of_contents.shortcut_info")}</FormText>+ </CardSection>+ </Card>);}function HighlightsList() {return (<>- <div className="options-section text-notes-highlights">- <Card heading={t("highlights_list.title")}>- <CardSection>- <HighlightsListOptions />- </CardSection>- </Card>- </div>+ <Card heading={t("highlights_list.title")}>+ <CardSection>+ <HighlightsListOptions />+ </CardSection>+ </Card>{/* Its own card rather than a heading inside the one above: what the list is made of andwhere it is shown are two subjects, and a card heading is what tells them apart. */}{!isNewLayout && (- <div className="options-section">- <Card heading={t("highlights_list.visibility_title")}>- <CardSection>- <FormText>{t("highlights_list.visibility_description")}</FormText>- <FormText>{t("highlights_list.shortcut_info")}</FormText>- </CardSection>- </Card>- </div>+ <Card heading={t("highlights_list.visibility_title")}>+ <CardSection>+ <FormText>{t("highlights_list.visibility_description")}</FormText>+ <FormText>{t("highlights_list.shortcut_info")}</FormText>+ </CardSection>+ </Card>)}</>);diff --git a/apps/client/src/widgets/type_widgets/options/totp.tsx b/apps/client/src/widgets/type_widgets/options/totp.tsxindex 4b0d32080b..742337e4cd 100644--- a/apps/client/src/widgets/type_widgets/options/totp.tsx+++ b/apps/client/src/widgets/type_widgets/options/totp.tsx@@ -124,22 +124,20 @@ export function TotpSettings({ totpStatus, refreshTotpStatus }: {onRegenerate={regenerateRecoveryCodes}onRemoveTotp={removeTotp}/>- : <div className="options-section">- <Card heading={t("multi_factor_authentication.totp_section_title")} actions={totpBadge}>- <CardOption- label={t("multi_factor_authentication.totp_setup_label")}- description={t("multi_factor_authentication.totp_setup_description")}- >- <Button- name="totp-setup-button"- icon="bx-plus"- text={t("multi_factor_authentication.totp_setup_button")}- size="micro"- onClick={() => setShowEnroll(true)}- />- </CardOption>- </Card>- </div>}+ : <Card heading={t("multi_factor_authentication.totp_section_title")} actions={totpBadge}>+ <CardOption+ label={t("multi_factor_authentication.totp_setup_label")}+ description={t("multi_factor_authentication.totp_setup_description")}+ >+ <Button+ name="totp-setup-button"+ icon="bx-plus"+ text={t("multi_factor_authentication.totp_setup_button")}+ size="micro"+ onClick={() => setShowEnroll(true)}+ />+ </CardOption>+ </Card>}{createPortal(<TotpEnrollmentModal@@ -506,43 +504,41 @@ function TotpRecoveryKeys({ badge, status, onRegenerate, onRemoveTotp }: {const remaining = status?.filter(isUnusedRecoveryCode).length ?? 0;return (- <div className="options-section">- <Card heading={t("multi_factor_authentication.totp_section_title")} actions={badge}>- <CardOption- label={- <span className="recovery-codes-title">- {t("multi_factor_authentication.recovery_keys_label")}- {status && status.length > 0 && <RecoveryCodeDots status={status} />}- </span>- }- description={status && status.length > 0- ? t("multi_factor_authentication.recovery_keys_remaining", { remaining, total: status.length })- : t("multi_factor_authentication.recovery_keys_no_key_set")}- >- <Button- name="regenerate-recovery-keys-button"- icon="bx-refresh"- text={t("multi_factor_authentication.recovery_keys_regenerate")}- size="micro"- onClick={onRegenerate}- />- </CardOption>+ <Card heading={t("multi_factor_authentication.totp_section_title")} actions={badge}>+ <CardOption+ label={+ <span className="recovery-codes-title">+ {t("multi_factor_authentication.recovery_keys_label")}+ {status && status.length > 0 && <RecoveryCodeDots status={status} />}+ </span>+ }+ description={status && status.length > 0+ ? t("multi_factor_authentication.recovery_keys_remaining", { remaining, total: status.length })+ : t("multi_factor_authentication.recovery_keys_no_key_set")}+ >+ <Button+ name="regenerate-recovery-keys-button"+ icon="bx-refresh"+ text={t("multi_factor_authentication.recovery_keys_regenerate")}+ size="micro"+ onClick={onRegenerate}+ />+ </CardOption>- <CardOption- label={t("multi_factor_authentication.totp_remove_label")}- description={t("multi_factor_authentication.totp_remove_description")}- >- <Button- name="totp-remove-button"- className="totp-remove-button"- icon="bx-trash"- text={t("multi_factor_authentication.totp_remove_button")}- size="micro"- onClick={onRemoveTotp}- />- </CardOption>- </Card>- </div>+ <CardOption+ label={t("multi_factor_authentication.totp_remove_label")}+ description={t("multi_factor_authentication.totp_remove_description")}+ >+ <Button+ name="totp-remove-button"+ className="totp-remove-button"+ icon="bx-trash"+ text={t("multi_factor_authentication.totp_remove_button")}+ size="micro"+ onClick={onRemoveTotp}+ />+ </CardOption>+ </Card>);}