Skip to content

Build your personal knowledge base with Trilium Notes

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

Elian Doranb1babd62aab0
diff --git a/apps/client/src/services/content_renderer.ts b/apps/client/src/services/content_renderer.ts
index b0a10b8685..e891b96d7c 100644
--- a/apps/client/src/services/content_renderer.ts
+++ b/apps/client/src/services/content_renderer.ts
@@ -29,7 +29,7 @@ interface Options {
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(
{
diff --git a/apps/client/src/widgets/collections/presentation/model.ts b/apps/client/src/widgets/collections/presentation/model.ts
index ba95dbc9f0..2d53f4ef7c 100644
--- a/apps/client/src/widgets/collections/presentation/model.ts
+++ b/apps/client/src/widgets/collections/presentation/model.ts
@@ -1,4 +1,5 @@
import FNote from "../../../entities/fnote";
+import contentRenderer from "../../../services/content_renderer";
type DangerouslySetInnerHTML = { __html: string; };
@@ -25,7 +26,7 @@ export async function buildPresentationModel(note: FNote): Promise<PresentationM
for (const slideNote of slideNotes) {
slides.push({
noteId: slideNote.noteId,
- content: processContent(await slideNote.getContent() ?? ""),
+ content: await processContent(slideNote),
verticalSlides: await buildVerticalSlides(slideNote)
})
}
@@ -38,15 +39,18 @@ async function buildVerticalSlides(parentSlideNote: FNote): Promise<undefined |
if (!children.length) return;
const slides: PresentationSlideBaseModel[] = [];
- for (const child of children) {
+ for (const childNote of children) {
slides.push({
- noteId: child.noteId,
- content: processContent(await child.getContent())
+ noteId: childNote.noteId,
+ content: await processContent(childNote)
});
}
return slides;
}
-function processContent(content: string | undefined): DangerouslySetInnerHTML {
- return { __html: content ?? "" };
+async function processContent(note: FNote): Promise<DangerouslySetInnerHTML> {
+ const { $renderedContent } = await contentRenderer.getRenderedContent(note, {
+
+ });
+ return { __html: $renderedContent.html() };
}