mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	client,server: Set up SVG rendering for mindmap
This commit is contained in:
		
							parent
							
								
									ad88042e5b
								
							
						
					
					
						commit
						1437df7de1
					
				| @ -34,7 +34,7 @@ async function getRenderedContent(entity, options = {}) { | |||||||
|     else if (type === 'code') { |     else if (type === 'code') { | ||||||
|         await renderCode(entity, $renderedContent); |         await renderCode(entity, $renderedContent); | ||||||
|     } |     } | ||||||
|     else if (type === 'image' || type === 'canvas') { |     else if (['image', 'canvas', 'mindMap'].includes(type)) { | ||||||
|         renderImage(entity, $renderedContent, options); |         renderImage(entity, $renderedContent, options); | ||||||
|     } |     } | ||||||
|     else if (!options.tooltip && ['file', 'pdf', 'audio', 'video'].includes(type)) { |     else if (!options.tooltip && ['file', 'pdf', 'audio', 'video'].includes(type)) { | ||||||
|  | |||||||
| @ -83,8 +83,18 @@ export default class MindMapWidget extends TypeWidget { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         const svgContent = await this.mind.exportSvg().text();    | ||||||
|         return { |         return { | ||||||
|             content: mind.getDataString() |             content: mind.getDataString(), | ||||||
|  |             attachments: [ | ||||||
|  |                 { | ||||||
|  |                     role: "image", | ||||||
|  |                     title: "mindmap-export.svg", | ||||||
|  |                     mime: "image/svg+xml", | ||||||
|  |                     content: svgContent, | ||||||
|  |                     position: 0 | ||||||
|  |                 } | ||||||
|  |             ] | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ function returnImageInt(image: BNote | BRevision | null, res: Response) { | |||||||
|     if (!image) { |     if (!image) { | ||||||
|         res.set('Content-Type', 'image/png'); |         res.set('Content-Type', 'image/png'); | ||||||
|         return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`)); |         return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`)); | ||||||
|     } else if (!["image", "canvas", "mermaid"].includes(image.type)) { |     } else if (![ "image", "canvas", "mermaid", "mindMap" ].includes(image.type)) { | ||||||
|         return res.sendStatus(400); |         return res.sendStatus(400); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -33,6 +33,8 @@ function returnImageInt(image: BNote | BRevision | null, res: Response) { | |||||||
|         renderSvgAttachment(image, res, 'canvas-export.svg'); |         renderSvgAttachment(image, res, 'canvas-export.svg'); | ||||||
|     } else if (image.type === 'mermaid') { |     } else if (image.type === 'mermaid') { | ||||||
|         renderSvgAttachment(image, res, 'mermaid-export.svg'); |         renderSvgAttachment(image, res, 'mermaid-export.svg'); | ||||||
|  |     } else if (image.type === "mindMap") { | ||||||
|  |         renderSvgAttachment(image, res, 'mindmap-export.svg'); | ||||||
|     } else { |     } else { | ||||||
|         res.set('Content-Type', image.mime); |         res.set('Content-Type', image.mime); | ||||||
|         res.set("Cache-Control", "no-cache, no-store, must-revalidate"); |         res.set("Cache-Control", "no-cache, no-store, must-revalidate"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran