mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-31 13:58:49 +01:00
This commit is contained in:
parent
65557328aa
commit
7caf6a5699
1 changed files with 17 additions and 0 deletions
|
|
@ -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")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue