mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-01 19:20:10 +00:00
Type addDOMWidget (#2705)
This commit is contained in:
@@ -28,6 +28,12 @@ export interface DOMWidget<T extends HTMLElement, V extends object | string>
|
||||
options: DOMWidgetOptions<T, V>
|
||||
value: V
|
||||
y?: number
|
||||
/**
|
||||
* @deprecated Legacy property used by some extensions for customtext
|
||||
* (textarea) widgets. Use `element` instead as it provides the same
|
||||
* functionality and works for all DOMWidget types.
|
||||
*/
|
||||
inputEl?: T
|
||||
callback?: (value: V) => void
|
||||
/**
|
||||
* Draw the widget on the canvas.
|
||||
|
||||
@@ -432,11 +432,14 @@ export const useLitegraphService = () => {
|
||||
host.el,
|
||||
{
|
||||
host,
|
||||
// @ts-expect-error `getHeight` of image host returns void instead of number.
|
||||
getHeight: host.getHeight,
|
||||
onDraw: host.onDraw,
|
||||
hideOnZoom: false
|
||||
}
|
||||
)
|
||||
) as IWidget & {
|
||||
options: { host: ReturnType<typeof createImageHost> }
|
||||
}
|
||||
widget.serializeValue = () => undefined
|
||||
widget.options.host.updateImages(this.imgs)
|
||||
}
|
||||
|
||||
13
src/types/litegraph-augmentation.d.ts
vendored
13
src/types/litegraph-augmentation.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import '@comfyorg/litegraph'
|
||||
import type { LLink, Size } from '@comfyorg/litegraph'
|
||||
|
||||
import type { DOMWidget } from '@/scripts/domWidget'
|
||||
import type { DOMWidget, DOMWidgetOptions } from '@/scripts/domWidget'
|
||||
import type { ComfyNodeDef } from '@/types/apiTypes'
|
||||
|
||||
import type { NodeId } from './comfyWorkflow'
|
||||
@@ -112,12 +112,15 @@ declare module '@comfyorg/litegraph' {
|
||||
*/
|
||||
isVirtualNode?: boolean
|
||||
|
||||
addDOMWidget(
|
||||
addDOMWidget<
|
||||
T extends HTMLElement = HTMLElement,
|
||||
V extends object | string = string
|
||||
>(
|
||||
name: string,
|
||||
type: string,
|
||||
element: HTMLElement,
|
||||
options?: Record<string, any>
|
||||
): DOMWidget
|
||||
element: T,
|
||||
options?: DOMWidgetOptions<T, V>
|
||||
): DOMWidget<T, V>
|
||||
|
||||
animatedImages?: boolean
|
||||
imgs?: HTMLImageElement[]
|
||||
|
||||
Reference in New Issue
Block a user