UNPKG

@cairn214/fluent-editor

Version:

A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.

27 lines (26 loc) 839 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); function imgToBase64(imageUrl) { return new Promise((resolve, reject) => { const canvas = document.createElement("canvas"); const img = new Image(); img.crossOrigin = "Anonymous"; img.src = imageUrl; img.onload = function() { const ctx = canvas.getContext("2d"); if (ctx) { canvas.height = img.height; canvas.width = img.width; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.drawImage(img, 0, 0); const dataURL = canvas.toDataURL("image/png", 1); resolve(dataURL); } }; img.onerror = function() { reject(new Error(`Could not load image at ${imageUrl}`)); }; }); } exports.imgToBase64 = imgToBase64; //# sourceMappingURL=image.cjs.js.map