Type LGraphNode.onDragOver/onDragDrop (#2389)

This commit is contained in:
Chenlei Hu
2025-01-30 15:50:04 -08:00
committed by GitHub
parent 4699360147
commit 45207dabbc
3 changed files with 16 additions and 6 deletions

View File

@@ -422,7 +422,6 @@ export class ComfyApp {
this.dragOverNode = null
// Node handles file drop, we dont use the built in onDropFile handler as its buggy
// If you drag multiple files it will call it multiple times with the same file
// @ts-expect-error This is not a standard event. TODO fix it.
if (n && n.onDragDrop && (await n.onDragDrop(event))) {
return
}
@@ -462,7 +461,6 @@ export class ComfyApp {
this.canvas.adjustMouseEvent(e)
const node = this.graph.getNodeOnPos(e.canvasX, e.canvasY)
if (node) {
// @ts-expect-error This is not a standard event. TODO fix it.
if (node.onDragOver && node.onDragOver(e)) {
this.dragOverNode = node

View File

@@ -707,8 +707,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
uploadWidget.serialize = false
// Add handler to check if an image is being dragged over our node
// @ts-expect-error
node.onDragOver = function (e) {
node.onDragOver = function (e: DragEvent) {
if (e.dataTransfer && e.dataTransfer.items) {
const image = [...e.dataTransfer.items].find((f) => f.kind === 'file')
return !!image
@@ -718,8 +717,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
}
// On drop upload files
// @ts-expect-error
node.onDragDrop = function (e) {
node.onDragDrop = function (e: DragEvent) {
console.log('onDragDrop called')
let handled = false
for (const file of e.dataTransfer.files) {