Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(attachments): render JSON content
Elian Doran3ad67a93c193
diff --git a/src/public/app/services/content_renderer.ts b/src/public/app/services/content_renderer.tsindex 2ff796b4c2..3f5115669b 100644--- a/src/public/app/services/content_renderer.ts+++ b/src/public/app/services/content_renderer.ts@@ -22,6 +22,10 @@ interface Options {imageHasZoom?: boolean;}+const CODE_MIME_TYPES = new Set([+ "application/json"+]);+async function getRenderedContent(this: {} | { ctx: string }, entity: FNote, options: Options = {}) {options = Object.assign({tooltip: false@@ -31,6 +35,7 @@ async function getRenderedContent(this: {} | { ctx: string }, entity: FNote, opt// attachment supports only image and file/pdf/audio/videoconst $renderedContent = $('<div class="rendered-content">');+ console.log(type);if (type === 'text') {await renderText(entity, $renderedContent);@@ -284,9 +289,12 @@ function getRenderingType(entity: FNote | FAttachment) {}const mime = ("mime" in entity && entity.mime);+ console.log("MIME ", mime);if (type === 'file' && mime === 'application/pdf') {type = 'pdf';+ } else if (type === "file" && mime && CODE_MIME_TYPES.has(mime) ) {+ type = "code";} else if (type === 'file' && mime && mime.startsWith('audio/')) {type = 'audio';} else if (type === 'file' && mime && mime.startsWith('video/')) {