mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Added support for PDF images
This commit is contained in:
parent
59b00e88c0
commit
fc19a77353
@ -81,6 +81,9 @@ $tw.modules = $tw.modules || {};
|
||||
$tw.modules.titles = $tw.modules.titles || {}; // hashmap by module title of {fn:, exports:, moduleType:}
|
||||
$tw.modules.types = $tw.modules.types || {}; // hashmap by module type of array of exports
|
||||
|
||||
// Plugin information
|
||||
$tw.plugins = $tw.plugins || {};
|
||||
|
||||
// Config object
|
||||
$tw.config = $tw.config || {};
|
||||
|
||||
@ -102,6 +105,7 @@ $tw.config.fileExtensionInfo = {
|
||||
".html": {type: "text/html"},
|
||||
".js": {type: "application/javascript"},
|
||||
".json": {type: "application/json"},
|
||||
".pdf": {type: "application/pdf"},
|
||||
".jpg": {type: "image/jpeg"},
|
||||
".jpeg": {type: "image/jpeg"},
|
||||
".png": {type: "image/png"},
|
||||
@ -119,6 +123,7 @@ $tw.config.contentTypeInfo = {
|
||||
"text/html": {encoding: "utf8"},
|
||||
"application/javascript": {encoding: "utf8"},
|
||||
"application/json": {encoding: "utf8"},
|
||||
"application/pdf": {encoding: "base64"},
|
||||
"image/jpeg": {encoding: "base64"},
|
||||
"image/png": {encoding: "base64"},
|
||||
"image/gif": {encoding: "base64"},
|
||||
|
@ -17,13 +17,17 @@ var ImageParser = function(options) {
|
||||
};
|
||||
|
||||
ImageParser.prototype.parse = function(type,text) {
|
||||
var src;
|
||||
if(type === "image/svg+xml" || type === ".svg") {
|
||||
var element = "img",
|
||||
src;
|
||||
if(type === "application/pdf" || type === ".pdf") {
|
||||
src = "data:application/pdf;base64," + text;
|
||||
element = "embed";
|
||||
} else if(type === "image/svg+xml" || type === ".svg") {
|
||||
src = "data:image/svg+xml," + encodeURIComponent(text);
|
||||
} else {
|
||||
src = "data:" + type + ";base64," + text;
|
||||
}
|
||||
return new $tw.Renderer([$tw.Tree.Element("img",{src: src})],new $tw.Dependencies());
|
||||
return new $tw.Renderer([$tw.Tree.Element(element,{src: src})],new $tw.Dependencies());
|
||||
};
|
||||
|
||||
exports["image/svg+xml"] = ImageParser;
|
||||
@ -31,5 +35,6 @@ exports["image/jpg"] = ImageParser;
|
||||
exports["image/jpeg"] = ImageParser;
|
||||
exports["image/png"] = ImageParser;
|
||||
exports["image/gif"] = ImageParser;
|
||||
exports["application/pdf"] = ImageParser;
|
||||
|
||||
})();
|
||||
|
@ -5103,10 +5103,16 @@ canvas.tw-edit-field {
|
||||
}
|
||||
|
||||
img,
|
||||
canvas {
|
||||
canvas,
|
||||
embed {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
embed {
|
||||
width: 100%;
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
a.tw-tiddlylink {
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
|
@ -119,10 +119,15 @@ canvas.tw-edit-field {
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
img, canvas {
|
||||
img, canvas, embed {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
embed {
|
||||
width: 100%;
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
a.tw-tiddlylink {
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
|
Loading…
Reference in New Issue
Block a user