Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(badges/content): adjustable base for app theme
Elian Doran1e5b294eb399
diff --git a/apps/client/src/widgets/layout/ActiveContentBadges.tsx b/apps/client/src/widgets/layout/ActiveContentBadges.tsxindex 26360afaea..689854237d 100644--- a/apps/client/src/widgets/layout/ActiveContentBadges.tsx+++ b/apps/client/src/widgets/layout/ActiveContentBadges.tsx@@ -10,6 +10,7 @@ import { BadgeWithDropdown } from "../react/Badge";import { FormDropdownDivider, FormDropdownSubmenu, FormListItem } from "../react/FormList";import FormToggle from "../react/FormToggle";import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } from "../react/hooks";+import { BookProperty, ViewProperty } from "../react/NotePropertyMenu";const NON_DANGEROUS_ACTIVE_CONTENT = [ "appCss", "appTheme" ];const DANGEROUS_ATTRIBUTES = BUILTIN_ATTRIBUTES.filter(a => a.isDangerous || NON_DANGEROUS_ACTIVE_CONTENT.includes(a.name));@@ -26,6 +27,7 @@ const typeMappings: Record<ActiveContentInfo["type"], {helpPage: string;apiDocsPage?: string;isExecutable?: boolean;+ additionalOptions?: BookProperty[];}> = {iconPack: {icon: "bx bx-package",@@ -61,7 +63,22 @@ const typeMappings: Record<ActiveContentInfo["type"], {},appTheme: {icon: "bx bx-palette",- helpPage: "7NfNr5pZpVKV"+ helpPage: "7NfNr5pZpVKV",+ additionalOptions: [+ {+ type: "combobox",+ bindToLabel: "appThemeBase",+ label: "Theme base",+ icon: "bx bx-layer",+ dropStart: true,+ options: [+ { label: "Legacy", value: "" },+ { label: "Trilium (Auto)", value: "next" },+ { label: "Trilium (Light)", value: "next-light" },+ { label: "Trilium (Dark)", value: "next-dark" }+ ]+ }+ ]}};@@ -78,7 +95,7 @@ export function ActiveContentBadges() {}function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentInfo }) {- const { icon, helpPage, apiDocsPage, isExecutable } = typeMappings[info.type];+ const { icon, helpPage, apiDocsPage, isExecutable, additionalOptions } = typeMappings[info.type];return (<BadgeWithDropdownclassName={clsx("active-content-badge", info.canToggleEnabled && !info.isEnabled && "disabled")}@@ -103,6 +120,15 @@ function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentIn</>)}+ {additionalOptions?.length && (+ <>+ {additionalOptions?.map((property, i) => (+ <ViewProperty key={i} note={note} property={property} />+ ))}+ <FormDropdownDivider />+ </>+ )}+<FormListItemicon="bx bx-help-circle"onClick={() => openInAppHelpFromUrl(helpPage)}diff --git a/apps/client/src/widgets/react/NotePropertyMenu.tsx b/apps/client/src/widgets/react/NotePropertyMenu.tsxindex 3c01f7e192..15f3723943 100644--- a/apps/client/src/widgets/react/NotePropertyMenu.tsx+++ b/apps/client/src/widgets/react/NotePropertyMenu.tsx@@ -65,6 +65,7 @@ export interface ComboBoxProperty {*/defaultValue?: string;options: (ComboBoxItem | ComboBoxGroup)[];+ dropStart?: boolean;}export type BookProperty = CheckBoxProperty | ButtonProperty | NumberProperty | ComboBoxProperty | SplitButtonProperty;@@ -163,6 +164,7 @@ function ComboBoxPropertyView({ note, property }: { note: FNote, property: Combo<FormDropdownSubmenutitle={property.label}icon={property.icon ?? "bx bx-empty"}+ dropStart={property.dropStart}>{(property.options).map((option, index) => {if ("items" in option) {diff --git a/packages/commons/src/lib/attribute_names.ts b/packages/commons/src/lib/attribute_names.tsindex 31997489ce..da3b890c9c 100644--- a/packages/commons/src/lib/attribute_names.ts+++ b/packages/commons/src/lib/attribute_names.ts@@ -64,6 +64,9 @@ type Labels = {readOnly: boolean;mapType: string;mapRootNoteId: string;++ appTheme: string;+ appThemeBase: string;}/**