Skip to content

Build your personal knowledge base with Trilium Notes

feat(collection/presentation): support custom background color per slide

Elian Doranbbda8d33570c
diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx
index 1d9896d35f..d9fabff100 100644
--- a/apps/client/src/widgets/collections/presentation/index.tsx
+++ b/apps/client/src/widgets/collections/presentation/index.tsx
@@ -174,7 +174,13 @@ function Presentation({ presentation, setApi } : { presentation: PresentationMod
}
function Slide({ slide }: { slide: PresentationSlideBaseModel }) {
- return <section data-note-id={slide.noteId} dangerouslySetInnerHTML={slide.content} />;
+ return (
+ <section
+ data-note-id={slide.noteId}
+ data-background-color={slide.backgroundColor}
+ dangerouslySetInnerHTML={slide.content}
+ />
+ );
}
function getNoteIdFromSlide(slide: HTMLElement | undefined) {
diff --git a/apps/client/src/widgets/collections/presentation/model.ts b/apps/client/src/widgets/collections/presentation/model.ts
index 346adc505e..b0b4aa12c7 100644
--- a/apps/client/src/widgets/collections/presentation/model.ts
+++ b/apps/client/src/widgets/collections/presentation/model.ts
@@ -12,6 +12,7 @@ interface PresentationSlideModel extends PresentationSlideBaseModel {
export interface PresentationSlideBaseModel {
noteId: string;
content: DangerouslySetInnerHTML;
+ backgroundColor?: string;
}
export interface PresentationModel {
@@ -40,7 +41,8 @@ async function buildVerticalSlides(parentSlideNote: FNote): Promise<undefined |
async function buildSlideModel(note: FNote): Promise<PresentationSlideBaseModel> {
return {
noteId: note.noteId,
- content: await processContent(note)
+ content: await processContent(note),
+ backgroundColor: note.getLabelValue("slide:background") ?? undefined
}
}
diff --git a/packages/commons/src/lib/attribute_names.ts b/packages/commons/src/lib/attribute_names.ts
index 314cc8c9c9..d55d4e3757 100644
--- a/packages/commons/src/lib/attribute_names.ts
+++ b/packages/commons/src/lib/attribute_names.ts
@@ -40,6 +40,7 @@ type Labels = {
maxNestingDepth: number;
includeArchived: boolean;
"presentation:theme": string;
+ "slide:background": string;
}
/**