From 629ac63f064b9d8bd0db43785ca67816032b19a4 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Thu, 6 Feb 2025 13:50:48 -0500 Subject: [PATCH] Type LGraphNode.pasteFile (#2455) --- src/composables/usePaste.ts | 3 +-- src/scripts/widgets.ts | 3 +-- src/types/litegraph-augmentation.d.ts | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/composables/usePaste.ts b/src/composables/usePaste.ts index 5e8c31b17..31b8d71f3 100644 --- a/src/composables/usePaste.ts +++ b/src/composables/usePaste.ts @@ -54,8 +54,7 @@ export const usePaste = () => { graph.change() } const blob = item.getAsFile() - // @ts-expect-error: Property 'pasteFile' does not exist on type 'LGraphNode'. - imageNode?.pasteFile(blob) + imageNode?.pasteFile?.(blob) return } } diff --git a/src/scripts/widgets.ts b/src/scripts/widgets.ts index 12e6e5aeb..df7965d2a 100644 --- a/src/scripts/widgets.ts +++ b/src/scripts/widgets.ts @@ -730,8 +730,7 @@ export const ComfyWidgets: Record = { return handled } - // @ts-expect-error - node.pasteFile = function (file) { + node.pasteFile = function (file: File) { if (file.type.startsWith('image/')) { const is_pasted = file.name === 'image.png' && file.lastModified - Date.now() < 2000 diff --git a/src/types/litegraph-augmentation.d.ts b/src/types/litegraph-augmentation.d.ts index 5c916fb2d..e276884d1 100644 --- a/src/types/litegraph-augmentation.d.ts +++ b/src/types/litegraph-augmentation.d.ts @@ -102,6 +102,8 @@ declare module '@comfyorg/litegraph' { imageOffset?: number /** Set by DOM widgets */ freeWidgetSpace?: number + /** Callback for pasting an image file into the node */ + pasteFile?(file: File): void } interface INodeSlot {