diff --git a/apps/client/src/services/content_renderer.ts b/apps/client/src/services/content_renderer.ts index c5d93fd51..b0a10b868 100644 --- a/apps/client/src/services/content_renderer.ts +++ b/apps/client/src/services/content_renderer.ts @@ -23,6 +23,8 @@ interface Options { tooltip?: boolean; trim?: boolean; imageHasZoom?: boolean; + /** If enabled, it will prevent the default behavior in which an empty note would display a list of children. */ + noChildrenList?: boolean; } const CODE_MIME_TYPES = new Set(["application/json"]); @@ -42,7 +44,7 @@ async function getRenderedContent(this: {} | { ctx: string }, entity: FNote | FA const $renderedContent = $('
'); if (type === "text" || type === "book") { - await renderText(entity, $renderedContent); + await renderText(entity, $renderedContent, options); } else if (type === "code") { await renderCode(entity, $renderedContent); } else if (["image", "canvas", "mindMap"].includes(type)) { @@ -114,7 +116,7 @@ async function getRenderedContent(this: {} | { ctx: string }, entity: FNote | FA }; } -async function renderText(note: FNote | FAttachment, $renderedContent: JQuery) { +async function renderText(note: FNote | FAttachment, $renderedContent: JQuery, options: Options = {}) { // entity must be FNote const blob = await note.getBlob(); @@ -135,7 +137,7 @@ async function renderText(note: FNote | FAttachment, $renderedContent: JQuery {isExpanded && <> - + }
@@ -110,7 +110,11 @@ function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, pa {noteTitle} - + ) } @@ -126,12 +130,15 @@ function NoteAttributes({ note }: { note: FNote }) { return } -function NoteContent({ note, trim, highlightedTokens }: { note: FNote, trim?: boolean, highlightedTokens }) { +function NoteContent({ note, trim, noChildrenList, highlightedTokens }: { note: FNote, trim?: boolean, noChildrenList?: boolean, highlightedTokens: string[] | null | undefined }) { const contentRef = useRef(null); const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens); useEffect(() => { - content_renderer.getRenderedContent(note, { trim }) + content_renderer.getRenderedContent(note, { + trim, + noChildrenList + }) .then(({ $renderedContent, type }) => { if (!contentRef.current) return; contentRef.current.replaceChildren(...$renderedContent);