mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	saving / viewing canvas revisions
This commit is contained in:
		| @@ -274,26 +274,11 @@ export default class RevisionsDialog extends BasicWidget { | ||||
|  | ||||
|             this.$content.html($table); | ||||
|         } else if (revisionItem.type === 'canvas') { | ||||
|             /** | ||||
|              * FIXME: We load a font called Virgil.wof2, which originates from excalidraw.com | ||||
|              *        REMOVE external dependency!!!! This is defined in the svg in defs.style | ||||
|              */ | ||||
|             const content = fullRevision.content; | ||||
|             const sanitizedTitle = revisionItem.title.replace(/[^a-z0-9-.]/gi, ""); | ||||
|  | ||||
|             try { | ||||
|                 const data = JSON.parse(content) | ||||
|                 const svg = data.svg || "no svg present." | ||||
|  | ||||
|                 /** | ||||
|                  * maxWidth: 100% use full width of container but do not enlarge! | ||||
|                  * height:auto to ensure that height scales with width | ||||
|                  */ | ||||
|                 const $svgHtml = $(svg).css({maxWidth: "100%", height: "auto"}); | ||||
|                 this.$content.html($('<div>').append($svgHtml)); | ||||
|             } catch (err) { | ||||
|                 console.error("error parsing fullRevision.content as JSON", fullRevision.content, err); | ||||
|                 this.$content.html($("<div>").text("Error parsing content. Please check console.error() for more details.")); | ||||
|             } | ||||
|             this.$content.html($("<img>") | ||||
|                 .attr("src", `api/revisions/${revisionItem.revisionId}/image/${sanitizedTitle}?${Math.random()}`) | ||||
|                 .css("max-width", "100%")); | ||||
|         } else { | ||||
|             this.$content.text("Preview isn't available for this note type."); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user