on-codemerge
Version:
A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product
25 lines (24 loc) • 657 B
JavaScript
import { createInputField as a } from "../../../utils/helpers.mjs";
class s {
async selectFile() {
return new Promise((t) => {
const r = a("file", "select file", "", () => {
var e;
const l = ((e = r.files) == null ? void 0 : e[0]) || null;
t(l);
});
r.accept = "image/*", r.click();
});
}
readFileAsDataUrl(t) {
return new Promise((r, l) => {
const e = new FileReader();
e.onload = () => {
typeof e.result == "string" ? r(e.result) : l(new Error("Failed to read file"));
}, e.onerror = () => l(e.error), e.readAsDataURL(t);
});
}
}
export {
s as ImageUploader
};