Skip to content

Build your personal knowledge base with Trilium Notes

feat(options): add a custom navigator between settings

Elian Doran7e9351759287
diff --git a/apps/client/src/widgets/type_widgets/ContentWidget.css b/apps/client/src/widgets/type_widgets/ContentWidget.css
index d5a0aa8b7b..7945dcd978 100644
--- a/apps/client/src/widgets/type_widgets/ContentWidget.css
+++ b/apps/client/src/widgets/type_widgets/ContentWidget.css
@@ -6,3 +6,14 @@
padding: 0;
height: 100%;
}
+
+/* Options pages: in-content page selector on the left, the page itself on the right. */
+.options-with-nav {
+ display: flex;
+ align-items: flex-start;
+}
+
+.options-with-nav > .note-detail-content-widget-content.options {
+ flex: 1 1 auto;
+ min-width: 0;
+}
diff --git a/apps/client/src/widgets/type_widgets/ContentWidget.tsx b/apps/client/src/widgets/type_widgets/ContentWidget.tsx
index e15bd47853..b524e0b26a 100644
--- a/apps/client/src/widgets/type_widgets/ContentWidget.tsx
+++ b/apps/client/src/widgets/type_widgets/ContentWidget.tsx
@@ -19,6 +19,7 @@ import LlmSettings from "./options/llm";
import "./ContentWidget.css";
import { t } from "../../services/i18n";
import BackendLog from "./code/BackendLog";
+import SettingsNavigation from "./options/components/SettingsNavigation";
export type OptionPages = "_optionsAppearance" | "_optionsShortcuts" | "_optionsTextNotes" | "_optionsCodeNotes" | "_optionsMedia" | "_optionsSpellcheck" | "_optionsPassword" | "_optionsMFA" | "_optionsEtapi" | "_optionsBackup" | "_optionsSync" | "_optionsOther" | "_optionsLocalization" | "_optionsSecurity" | "_optionsAdvanced" | "_optionsLlm";
@@ -50,11 +51,29 @@ const CONTENT_WIDGETS: Record<OptionPages | "_backendLog", (props: TypeWidgetPro
*/
export default function ContentWidget({ note, ...restProps }: TypeWidgetProps) {
const Content = CONTENT_WIDGETS[note.noteId];
+ const isOptions = note.noteId.startsWith("_options");
+ const content = Content
+ ? <Content note={note} {...restProps} />
+ : (t("content_widget.unknown_widget", { id: note.noteId }));
+
+ // For options pages, render an in-content page selector beside the page. The selector
+ // duplicates the (hoisted) note tree's list so users can switch pages without the tree.
+ // `.note-detail-content-widget-content.options` stays the direct parent of the page so the
+ // theme's existing options styling keeps applying.
+ if (isOptions) {
+ return (
+ <div className="options-with-nav">
+ <SettingsNavigation activeNoteId={note.noteId} />
+ <div className="note-detail-content-widget-content options">
+ {content}
+ </div>
+ </div>
+ );
+ }
+
return (
- <div className={`note-detail-content-widget-content ${note.noteId.startsWith("_options") ? "options" : ""}`}>
- {Content
- ? <Content note={note} {...restProps} />
- : (t("content_widget.unknown_widget", { id: note.noteId }))}
+ <div className="note-detail-content-widget-content">
+ {content}
</div>
)
}
diff --git a/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.css b/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.css
new file mode 100644
index 0000000000..fe77c37d83
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.css
@@ -0,0 +1,53 @@
+.settings-navigation {
+ flex: 0 0 auto;
+ align-self: flex-start;
+ position: sticky;
+ top: 0;
+ width: 220px;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ /* Align the first entry with the first card of the page (which has its own top padding/margin). */
+ padding-block-start: calc(15px + 1em);
+ padding-inline: 12px 12px;
+}
+
+.settings-navigation .settings-navigation-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 6px 10px;
+ border-radius: 6px;
+ color: var(--main-text-color);
+ text-decoration: none;
+ cursor: pointer;
+}
+
+.settings-navigation .settings-navigation-item:hover {
+ background: var(--left-pane-item-hover-background, var(--accented-background-color));
+ color: var(--main-text-color);
+ text-decoration: none;
+}
+
+.settings-navigation .settings-navigation-item.active {
+ background: var(--left-pane-item-selected-background, var(--selection-background-color));
+ color: var(--left-pane-item-selected-color, var(--main-text-color));
+}
+
+.settings-navigation .settings-navigation-item .tn-icon {
+ flex: 0 0 auto;
+ font-size: 1.15em;
+}
+
+.settings-navigation .settings-navigation-title {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
+
+/* On narrow screens the tree is the primary navigation, so the in-content list collapses away. */
+@media (max-width: 768px) {
+ .settings-navigation {
+ display: none;
+ }
+}
diff --git a/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx b/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx
new file mode 100644
index 0000000000..25c8292785
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx
@@ -0,0 +1,41 @@
+import "./SettingsNavigation.css";
+
+import clsx from "clsx";
+
+import { useChildNotes } from "../../../react/hooks";
+
+interface SettingsNavigationProps {
+ /** Note ID of the settings page currently being displayed (e.g. `_optionsAppearance`). */
+ activeNoteId: string;
+}
+
+/**
+ * In-content selector for the settings pages, rendered alongside the active options page.
+ *
+ * It mirrors the list of pages otherwise reached through the (hoisted) note tree, reading them
+ * straight from the `_options` subtree so titles, icons and ordering stay in sync. Navigation
+ * reuses the global link handler (`goToLink`) through plain note-path anchors, so clicking an
+ * entry switches the page within the current tab and keeps the tree/hoisting in step.
+ */
+export default function SettingsNavigation({ activeNoteId }: SettingsNavigationProps) {
+ const pages = useChildNotes("_options");
+
+ return (
+ <nav className="settings-navigation">
+ {pages.map((page) => {
+ const isActive = page.noteId === activeNoteId;
+ return (
+ <a
+ key={page.noteId}
+ href={`#root/_hidden/_options/${page.noteId}`}
+ className={clsx("settings-navigation-item no-tooltip-preview", { active: isActive })}
+ aria-current={isActive ? "page" : undefined}
+ >
+ <span className={page.getIcon()} />
+ <span className="settings-navigation-title">{page.title}</span>
+ </a>
+ );
+ })}
+ </nav>
+ );
+}