Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/7945

Vanessa7caf6a5699bf
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index 90798f65e2..b2460bb1f8 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -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")) {