Add pp.addNodeOnGraph to simplify adding node on canvas (#239)

This commit is contained in:
Chenlei Hu
2024-07-27 17:44:17 -04:00
committed by GitHub
parent 424a5f7a86
commit 76be537351
2 changed files with 27 additions and 14 deletions

View File

@@ -36,7 +36,12 @@ import { StorageLocation } from '@/types/settingTypes'
import '@comfyorg/litegraph/css/litegraph.css'
import '../assets/css/style.css'
import { ExtensionManager } from '@/types/extensionTypes'
import { SYSTEM_NODE_DEFS, useNodeDefStore } from '@/stores/nodeDefStore'
import {
ComfyNodeDefImpl,
SYSTEM_NODE_DEFS,
useNodeDefStore
} from '@/stores/nodeDefStore'
import { Vector2 } from '@comfyorg/litegraph'
export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview'
@@ -2933,6 +2938,19 @@ export class ComfyApp {
this.lastExecutionError = null
this.runningNodeId = null
}
addNodeOnGraph(
nodeDef: ComfyNodeDef | ComfyNodeDefImpl,
options: Record<string, any> = {}
): LGraphNode {
const node = LiteGraph.createNode(
nodeDef.name,
nodeDef.display_name,
options
)
this.graph.add(node)
return node
}
}
export const app = new ComfyApp()