mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
feat(collection/presentation): use content renderer to support other note types
This commit is contained in:
parent
502e9b86bc
commit
b1babd62aa
@ -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(
|
||||||
{
|
{
|
||||||
|
@ -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() };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user