diff --git a/src/core/Utils.mjs b/src/core/Utils.mjs index 24f2d66..f70e294 100755 --- a/src/core/Utils.mjs +++ b/src/core/Utils.mjs @@ -5,7 +5,7 @@ */ import utf8 from "utf8"; -import {fromBase64} from "./lib/Base64"; +import {fromBase64, toBase64} from "./lib/Base64"; import {fromHex} from "./lib/Hex"; import {fromDecimal} from "./lib/Decimal"; import {fromBinary} from "./lib/Binary"; @@ -817,6 +817,17 @@ class Utils { return html; }; + const formatContent = function (buff, type) { + if (type.startsWith("image")) { + let dataURI = "data:"; + dataURI += type + ";"; + dataURI += "base64," + toBase64(buff); + return ""; + } else { + return `
${Utils.escapeHtml(Utils.arrayBufferToStr(buff.buffer))}`; + } + }; + const formatFile = async function(file, i) { const buff = await Utils.readFile(file); const blob = new Blob( @@ -846,7 +857,7 @@ class Utils {
${Utils.escapeHtml(Utils.arrayBufferToStr(buff.buffer))}+ ${formatContent(buff, file.type)}