mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
refactor(collection/presentation): deduplicate slide building
This commit is contained in:
parent
3f3b8893a3
commit
f377df32ed
@ -21,8 +21,7 @@ export interface PresentationModel {
|
|||||||
export async function buildPresentationModel(note: FNote): Promise<PresentationModel> {
|
export async function buildPresentationModel(note: FNote): Promise<PresentationModel> {
|
||||||
const slideNotes = await note.getChildNotes();
|
const slideNotes = await note.getChildNotes();
|
||||||
const slides: PresentationSlideModel[] = await Promise.all(slideNotes.map(async slideNote => ({
|
const slides: PresentationSlideModel[] = await Promise.all(slideNotes.map(async slideNote => ({
|
||||||
noteId: slideNote.noteId,
|
...(await buildSlideModel(slideNote)),
|
||||||
content: await processContent(slideNote),
|
|
||||||
verticalSlides: await buildVerticalSlides(slideNote)
|
verticalSlides: await buildVerticalSlides(slideNote)
|
||||||
})))
|
})))
|
||||||
|
|
||||||
@ -33,14 +32,18 @@ async function buildVerticalSlides(parentSlideNote: FNote): Promise<undefined |
|
|||||||
const children = await parentSlideNote.getChildNotes();
|
const children = await parentSlideNote.getChildNotes();
|
||||||
if (!children.length) return;
|
if (!children.length) return;
|
||||||
|
|
||||||
const slides: PresentationSlideBaseModel[] = await Promise.all(children.map(async childNote => ({
|
const slides: PresentationSlideBaseModel[] = await Promise.all(children.map(buildSlideModel));
|
||||||
noteId: childNote.noteId,
|
|
||||||
content: await processContent(childNote)
|
|
||||||
})));
|
|
||||||
|
|
||||||
return slides;
|
return slides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function buildSlideModel(note: FNote): Promise<PresentationSlideBaseModel> {
|
||||||
|
return {
|
||||||
|
noteId: note.noteId,
|
||||||
|
content: await processContent(note)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function processContent(note: FNote): Promise<DangerouslySetInnerHTML> {
|
async function processContent(note: FNote): Promise<DangerouslySetInnerHTML> {
|
||||||
const { $renderedContent } = await contentRenderer.getRenderedContent(note, {
|
const { $renderedContent } = await contentRenderer.getRenderedContent(note, {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user