Fix image edit not working in Chrome
This commit is contained in:
parent
4193ae14c9
commit
f70af7cc02
26
js/editor.js
26
js/editor.js
@ -51,17 +51,8 @@ window.addEventListener("load", () => {
|
||||
|
||||
// handle changes to card editor
|
||||
document.querySelector('#cardForm').addEventListener('input', event => {
|
||||
let deck = document.querySelector('#deck');
|
||||
let prop = event.target.id.substring(5);
|
||||
if (prop === "image") {
|
||||
let files = event.target.files;
|
||||
let reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
selected.svg.querySelector('#' + prop).setAttribute("href", e.target.result);
|
||||
};
|
||||
reader.readAsDataURL(files[0]);
|
||||
}
|
||||
else if (prop !== "count") {
|
||||
if (prop !== "count") {
|
||||
wrapSVGText(selected.svg.querySelector('#' + prop),
|
||||
String(event.target.value));
|
||||
}
|
||||
@ -72,6 +63,21 @@ window.addEventListener("load", () => {
|
||||
delete selected.json[prop];
|
||||
}
|
||||
});
|
||||
|
||||
// chrome doesn't seem to send input event on file select
|
||||
document.querySelector('#cardForm').addEventListener('change', event => {
|
||||
let prop = event.target.id.substring(5);
|
||||
if (prop === "image") {
|
||||
let files = event.target.files;
|
||||
let reader = new FileReader();
|
||||
reader.onload = e => {
|
||||
selected.svg.querySelector('#' + prop)
|
||||
.setAttributeNS("http://www.w3.org/1999/xlink", "href", e.target.result);
|
||||
selected.json[prop] = e.target.result;
|
||||
};
|
||||
reader.readAsDataURL(files[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function downloadFile(file, name) {
|
||||
|
Loading…
Reference in New Issue
Block a user