From a9fce727d4607926897f630b17365f240e5c2401 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sat, 14 Sep 2024 19:37:25 +0800 Subject: [PATCH] Fix svg not previewing in revisions --- src/public/app/widgets/dialogs/revisions.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/public/app/widgets/dialogs/revisions.js b/src/public/app/widgets/dialogs/revisions.js index 51cd5a83e..cdd37af38 100644 --- a/src/public/app/widgets/dialogs/revisions.js +++ b/src/public/app/widgets/dialogs/revisions.js @@ -138,7 +138,7 @@ export default class RevisionsDialog extends BasicWidget { }); this.$revisionSettingsButton.on('click', async () => { - appContext.tabManager.openContextWithNote('_optionsOther', {activate: true}); + appContext.tabManager.openContextWithNote('_optionsOther', { activate: true }); }); } @@ -268,12 +268,19 @@ export default class RevisionsDialog extends BasicWidget { } else if (revisionItem.type === 'code') { this.$content.html($("
").text(fullRevision.content));
         } else if (revisionItem.type === 'image') {
-            this.$content.html($("")
-                // the reason why we put this inline as base64 is that we do not want to let user copy this
-                // as a URL to be used in a note. Instead, if they copy and paste it into a note, it will be uploaded as a new note
-                .attr("src", `data:${fullRevision.mime};base64,${fullRevision.content}`)
-                .css("max-width", "100%")
-                .css("max-height", "100%"));
+            if (fullRevision.mime === "image/svg+xml") {
+                this.$content.html($("")
+                    .attr("src", `data:${fullRevision.mime};utf8,${fullRevision.content}`)
+                    .css("max-width", "100%")
+                    .css("max-height", "100%"));
+            } else {
+                this.$content.html($("")
+                    // the reason why we put this inline as base64 is that we do not want to let user copy this
+                    // as a URL to be used in a note. Instead, if they copy and paste it into a note, it will be uploaded as a new note
+                    .attr("src", `data:${fullRevision.mime};base64,${fullRevision.content}`)
+                    .css("max-width", "100%")
+                    .css("max-height", "100%"));
+            }
         } else if (revisionItem.type === 'file') {
             const $table = $("")
                 .append($("").append(