feat(collection/presentation): use content renderer to support other note types

This commit is contained in:
Elian Doran 2025-10-15 22:25:40 +03:00
parent 502e9b86bc
commit b1babd62aa
No known key found for this signature in database
2 changed files with 11 additions and 7 deletions

View File

@ -29,7 +29,7 @@ interface Options {
const CODE_MIME_TYPES = new Set(["application/json"]); const CODE_MIME_TYPES = new Set(["application/json"]);
async function getRenderedContent(this: {} | { ctx: string }, entity: FNote | FAttachment, options: Options = {}) { export async function getRenderedContent(this: {} | { ctx: string }, entity: FNote | FAttachment, options: Options = {}) {
options = Object.assign( options = Object.assign(
{ {

View File

@ -1,4 +1,5 @@
import FNote from "../../../entities/fnote"; import FNote from "../../../entities/fnote";
import contentRenderer from "../../../services/content_renderer";
type DangerouslySetInnerHTML = { __html: string; }; type DangerouslySetInnerHTML = { __html: string; };
@ -25,7 +26,7 @@ export async function buildPresentationModel(note: FNote): Promise<PresentationM
for (const slideNote of slideNotes) { for (const slideNote of slideNotes) {
slides.push({ slides.push({
noteId: slideNote.noteId, noteId: slideNote.noteId,
content: processContent(await slideNote.getContent() ?? ""), content: await processContent(slideNote),
verticalSlides: await buildVerticalSlides(slideNote) verticalSlides: await buildVerticalSlides(slideNote)
}) })
} }
@ -38,15 +39,18 @@ async function buildVerticalSlides(parentSlideNote: FNote): Promise<undefined |
if (!children.length) return; if (!children.length) return;
const slides: PresentationSlideBaseModel[] = []; const slides: PresentationSlideBaseModel[] = [];
for (const child of children) { for (const childNote of children) {
slides.push({ slides.push({
noteId: child.noteId, noteId: childNote.noteId,
content: processContent(await child.getContent()) content: await processContent(childNote)
}); });
} }
return slides; return slides;
} }
function processContent(content: string | undefined): DangerouslySetInnerHTML { async function processContent(note: FNote): Promise<DangerouslySetInnerHTML> {
return { __html: content ?? "" }; const { $renderedContent } = await contentRenderer.getRenderedContent(note, {
});
return { __html: $renderedContent.html() };
} }