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
custom task states: add a link to the "Text Notes" options page
Adorian Doran1bd9689d6124
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 9752bfb9c3..038f19f92b 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1462,7 +1462,8 @@"enable_tray_description": "Trilium needs to be restarted for this change to take effect."},"text_editor": {- "title": "Editor"+ "title": "Editor",+ "related_task_states": "Custom checkbox states for to-do lists"},"heading_style": {"title": "Heading style",diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsx b/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsxindex 0db0b62655..df4e461682 100644--- a/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsRow.tsx@@ -38,11 +38,12 @@ interface OptionsRowLinkProps {label: string;description?: string;href: string;+ onClick?: (e: MouseEvent) => void;}-export function OptionsRowLink({ label, description, href }: OptionsRowLinkProps) {+export function OptionsRowLink({ label, description, href, onClick }: OptionsRowLinkProps) {return (- <a href={href} className="option-row option-row-link no-tooltip-preview">+ <a href={href} className="option-row option-row-link no-tooltip-preview" onClick={onClick}><div className="option-row-label"><label style={{ cursor: "pointer" }}>{label}</label>{description && <small className="option-row-description">{description}</small>}diff --git a/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx b/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsxindex 660a0df973..7647e29bd1 100644--- a/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/RelatedSettings.tsx@@ -1,3 +1,4 @@+import appContext from "../../../../components/app_context";import { t } from "../../../../services/i18n";import type { OptionPages } from "../../ContentWidget";import { OptionsRowLink } from "./OptionsRow";@@ -6,7 +7,10 @@ import OptionsSection from "./OptionsSection";interface RelatedSettingsItem {title: string;description?: string;- targetPage: OptionPages;+ /** Link to another options page. */+ targetPage?: OptionPages;+ /** Link to an arbitrary hidden-subtree note (e.g. `_taskStates`). */+ targetNoteId?: string;enabled?: boolean;}@@ -23,14 +27,29 @@ export default function RelatedSettings({ items }: RelatedSettingsProps) {return (<OptionsSection title={t("settings.related_settings")}>- {filteredItems.map((item) => (- <OptionsRowLink- key={item.targetPage}- label={item.title}- description={item.description}- href={`#root/_hidden/_options/${item.targetPage}`}- />- ))}+ {filteredItems.map((item) => {+ const { targetPage, targetNoteId } = item;+ return (+ <OptionsRowLink+ key={targetPage ?? targetNoteId}+ label={item.title}+ description={item.description}+ href={targetNoteId+ ? `#root/_hidden/${targetNoteId}`+ : `#root/_hidden/_options/${targetPage}`}+ onClick={targetNoteId+ ? (e) => {+ // Hidden-subtree config notes open hoisted, in their own tab.+ // stopPropagation keeps the global `a` click handler+ // (link.ts `goToLink`) from navigating by href instead.+ e.preventDefault();+ e.stopPropagation();+ void appContext.tabManager.openInNewTab(targetNoteId, targetNoteId, true);+ }+ : undefined}+ />+ );+ })}</OptionsSection>);}diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsxindex 15506b1196..f5660db3e2 100644--- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx+++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx@@ -21,6 +21,7 @@ import CheckboxList from "./components/CheckboxList";import OptionsRow, { OptionsRowWithToggle } from "./components/OptionsRow";import OptionsSection from "./components/OptionsSection";import RadioWithIllustration from "./components/RadioWithIllustration";+import RelatedSettings from "./components/RelatedSettings";import ThemeModeSelector from "./components/ThemeModeSelector";const isNewLayout = isExperimentalFeatureEnabled("new-layout");@@ -34,6 +35,12 @@ export default function TextNoteSettings() {<CodeBlockStyle /><TableOfContent /><HighlightsList />+ <RelatedSettings items={[+ {+ title: t("text_editor.related_task_states"),+ targetNoteId: "_taskStates"+ }+ ]} /></>);}