1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-23 15:36:52 +00:00

Fix saving SVG images

This commit is contained in:
Jeremy Ruston 2024-12-10 09:23:53 +00:00
parent 2c271077aa
commit c9ce9b192d

View File

@ -58,12 +58,21 @@ exports.startup = function() {
} }
// Save the tiddler // Save the tiddler
if(params["save-title"]) { if(params["save-title"]) {
var parts = dataUrl.split(";base64,"); if(dataUrl.indexOf("data:image/svg+xml;") === 0) {
$tw.wiki.addTiddler(new $tw.Tiddler({ var commaIndex = dataUrl.indexOf(",");
title: params["save-title"], $tw.wiki.addTiddler(new $tw.Tiddler({
type: parts[0].split(":")[1], title: params["save-title"],
"text": parts[1] type: "image/svg+xml",
})); "text": decodeURIComponent(dataUrl.substring(commaIndex + 1))
}));
} else {
var parts = dataUrl.split(";base64,");
$tw.wiki.addTiddler(new $tw.Tiddler({
title: params["save-title"],
type: parts[0].split(":")[1],
"text": parts[1]
}));
}
} }
}) })
.catch(function(error) { .catch(function(error) {