This commit is contained in:
Vanessa 2023-04-13 11:30:34 +08:00
parent 65557328aa
commit 7caf6a5699

View file

@ -82,6 +82,23 @@ export class Background {
};
});
} else {
this.element.addEventListener("dragover", async (event) => {
event.preventDefault();
})
this.element.addEventListener("drop", async (event: DragEvent & { target: HTMLElement }) => {
if (event.dataTransfer.types[0] === "Files" && event.dataTransfer.files[0].type.indexOf("image") !== -1) {
uploadFiles(protyle, [event.dataTransfer.files[0]], undefined, (responseText) => {
const response = JSON.parse(responseText);
const style = `background-image:url("${response.data.succMap[Object.keys(response.data.succMap)[0]]}")`;
this.ial["title-img"] = style;
this.render(this.ial, protyle.block.rootID);
fetchPost("/api/attr/setBlockAttrs", {
id: protyle.block.rootID,
attrs: {"title-img": style}
});
});
}
})
this.imgElement.addEventListener("mousedown", (event: MouseEvent & { target: HTMLElement }) => {
event.preventDefault();
if (!this.element.firstElementChild.querySelector(".protyle-icons").classList.contains("fn__none")) {