mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-20 03:13:30 +00:00
Add support for dropping images from urls
This commit is contained in:
parent
f15b4a7ffa
commit
d6a3c0d424
@ -362,8 +362,20 @@ class ComfyApp {
|
|||||||
if (n && n.onDragDrop && (await n.onDragDrop(event))) {
|
if (n && n.onDragDrop && (await n.onDragDrop(event))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Dragging from Chrome->Firefox there is a file but its a bmp, so ignore that
|
||||||
|
if (event.dataTransfer.files.length && event.dataTransfer.files[0].type !== "image/bmp") {
|
||||||
await this.handleFile(event.dataTransfer.files[0]);
|
await this.handleFile(event.dataTransfer.files[0]);
|
||||||
|
} else {
|
||||||
|
// Try loading the first URI in the transfer list
|
||||||
|
const validTypes = ["text/uri-list", "text/x-moz-url"];
|
||||||
|
const match = [...event.dataTransfer.types].find((t) => validTypes.find(v => t === v));
|
||||||
|
if (match) {
|
||||||
|
const uri = event.dataTransfer.getData(match)?.split("\n")?.[0];
|
||||||
|
if (uri) {
|
||||||
|
await this.handleFile(await (await fetch(uri)).blob());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Always clear over node on drag leave
|
// Always clear over node on drag leave
|
||||||
@ -1090,7 +1102,7 @@ class ComfyApp {
|
|||||||
importA1111(this.graph, pngInfo.parameters);
|
importA1111(this.graph, pngInfo.parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (file.type === "application/json" || file.name.endsWith(".json")) {
|
} else if (file.type === "application/json" || file.name?.endsWith(".json")) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
this.loadGraphData(JSON.parse(reader.result));
|
this.loadGraphData(JSON.parse(reader.result));
|
||||||
|
Loading…
Reference in New Issue
Block a user