mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
feat(collection/presentation): add support for vertical slides
This commit is contained in:
parent
8f9ee3c1a9
commit
cd7a1af729
@ -85,9 +85,18 @@ function Presentation({ presentation } : { presentation: PresentationModel }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Slide({ slide }: { slide: PresentationSlideModel }) {
|
function Slide({ slide }: { slide: PresentationSlideModel }) {
|
||||||
|
if (!slide.verticalSlides) {
|
||||||
|
// Normal slide.
|
||||||
|
return <section dangerouslySetInnerHTML={slide.content} />;
|
||||||
|
} else {
|
||||||
|
// Slide with sub notes (show as vertical slides).
|
||||||
return (
|
return (
|
||||||
<section dangerouslySetInnerHTML={slide.content}>
|
<section>
|
||||||
{slide.content}
|
<section dangerouslySetInnerHTML={slide.content} />
|
||||||
|
{slide.verticalSlides.map((slide) => (
|
||||||
|
<section dangerouslySetInnerHTML={slide.content} />
|
||||||
|
))}
|
||||||
</section>
|
</section>
|
||||||
);
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
import FNote from "../../../entities/fnote";
|
import FNote from "../../../entities/fnote";
|
||||||
|
|
||||||
|
type DangerouslySetInnerHTML = { __html: string; };
|
||||||
|
|
||||||
export interface PresentationSlideModel {
|
export interface PresentationSlideModel {
|
||||||
content: { __html: string; };
|
content: DangerouslySetInnerHTML;
|
||||||
|
verticalSlides: PresentationVerticalSlideModel[] | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PresentationVerticalSlideModel {
|
||||||
|
content: DangerouslySetInnerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PresentationModel {
|
export interface PresentationModel {
|
||||||
@ -15,13 +22,27 @@ export async function buildPresentationModel(note: FNote): Promise<PresentationM
|
|||||||
|
|
||||||
for (const slideNote of slideNotes) {
|
for (const slideNote of slideNotes) {
|
||||||
slides.push({
|
slides.push({
|
||||||
content: {
|
content: processContent(await slideNote.getContent() ?? ""),
|
||||||
__html: await slideNote.getContent() ?? ""
|
verticalSlides: await buildVerticalSlides(slideNote)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return { slides };
|
||||||
slides
|
}
|
||||||
};
|
|
||||||
|
async function buildVerticalSlides(parentSlideNote: FNote): Promise<undefined | PresentationVerticalSlideModel[]> {
|
||||||
|
const children = await parentSlideNote.getChildNotes();
|
||||||
|
if (!children.length) return;
|
||||||
|
|
||||||
|
const slides: PresentationVerticalSlideModel[] = [];
|
||||||
|
for (const child of children) {
|
||||||
|
slides.push({
|
||||||
|
content: processContent(await child.getContent())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return slides;
|
||||||
|
}
|
||||||
|
|
||||||
|
function processContent(content: string | undefined): DangerouslySetInnerHTML {
|
||||||
|
return { __html: content ?? "" };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user