mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	feat(attachments): render JSON content
This commit is contained in:
		
							parent
							
								
									0bb573022a
								
							
						
					
					
						commit
						3ad67a93c1
					
				| @ -22,6 +22,10 @@ interface Options { | |||||||
|     imageHasZoom?: boolean; |     imageHasZoom?: boolean; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const CODE_MIME_TYPES = new Set([ | ||||||
|  |     "application/json" | ||||||
|  | ]); | ||||||
|  | 
 | ||||||
| async function getRenderedContent(this: {} | { ctx: string }, entity: FNote, options: Options = {}) { | async function getRenderedContent(this: {} | { ctx: string }, entity: FNote, options: Options = {}) { | ||||||
|     options = Object.assign({ |     options = Object.assign({ | ||||||
|         tooltip: false |         tooltip: false | ||||||
| @ -31,6 +35,7 @@ async function getRenderedContent(this: {} | { ctx: string }, entity: FNote, opt | |||||||
|     // attachment supports only image and file/pdf/audio/video
 |     // attachment supports only image and file/pdf/audio/video
 | ||||||
| 
 | 
 | ||||||
|     const $renderedContent = $('<div class="rendered-content">'); |     const $renderedContent = $('<div class="rendered-content">'); | ||||||
|  |     console.log(type); | ||||||
| 
 | 
 | ||||||
|     if (type === 'text') { |     if (type === 'text') { | ||||||
|         await renderText(entity, $renderedContent); |         await renderText(entity, $renderedContent); | ||||||
| @ -284,9 +289,12 @@ function getRenderingType(entity: FNote | FAttachment) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const mime = ("mime" in entity && entity.mime); |     const mime = ("mime" in entity && entity.mime); | ||||||
|  |     console.log("MIME ", mime); | ||||||
| 
 | 
 | ||||||
|     if (type === 'file' && mime === 'application/pdf') { |     if (type === 'file' && mime === 'application/pdf') { | ||||||
|         type = 'pdf'; |         type = 'pdf'; | ||||||
|  |     } else if (type === "file" && mime && CODE_MIME_TYPES.has(mime) ) { | ||||||
|  |         type = "code"; | ||||||
|     } else if (type === 'file' && mime && mime.startsWith('audio/')) { |     } else if (type === 'file' && mime && mime.startsWith('audio/')) { | ||||||
|         type = 'audio'; |         type = 'audio'; | ||||||
|     } else if (type === 'file' && mime && mime.startsWith('video/')) { |     } else if (type === 'file' && mime && mime.startsWith('video/')) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran