kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Refactor the image parser to avoid generating badly formed image src's
Previously, a transclusion of a skinny image tiddler (ie one where the body has yet to be loaded) would render a broken image.print-window-tiddler
rodzic
29c4ed20ce
commit
0c20092644
|
@ -13,23 +13,23 @@ The image parser parses an image into an embeddable HTML element
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var ImageParser = function(type,text,options) {
|
var ImageParser = function(type,text,options) {
|
||||||
var element = "img",
|
var element = {
|
||||||
|
type: "element",
|
||||||
|
tag: "img",
|
||||||
|
attributes: {}
|
||||||
|
},
|
||||||
src;
|
src;
|
||||||
if(type === "application/pdf" || type === ".pdf") {
|
if(text) {
|
||||||
src = "data:application/pdf;base64," + text;
|
if(type === "application/pdf" || type === ".pdf") {
|
||||||
element = "embed";
|
element.attributes.src = {type: "string", value: "data:application/pdf;base64," + text};
|
||||||
} else if(type === "image/svg+xml" || type === ".svg") {
|
element.tag = "embed";
|
||||||
src = "data:image/svg+xml," + encodeURIComponent(text);
|
} else if(type === "image/svg+xml" || type === ".svg") {
|
||||||
} else {
|
element.attributes.src = {type: "string", value: "data:image/svg+xml," + encodeURIComponent(text)};
|
||||||
src = "data:" + type + ";base64," + text;
|
} else {
|
||||||
}
|
element.attributes.src = {type: "string", value: "data:" + type + ";base64," + text};
|
||||||
this.tree = [{
|
|
||||||
type: "element",
|
|
||||||
tag: element,
|
|
||||||
attributes: {
|
|
||||||
"src": {type: "string", value: src}
|
|
||||||
}
|
}
|
||||||
}];
|
}
|
||||||
|
this.tree = [element];
|
||||||
};
|
};
|
||||||
|
|
||||||
exports["image/svg+xml"] = ImageParser;
|
exports["image/svg+xml"] = ImageParser;
|
||||||
|
|
Ładowanie…
Reference in New Issue