mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 13:29:55 +00:00
[Refactor] Move addNodeOnGraph to litegraphService (#2100)
This commit is contained in:
@@ -29,11 +29,7 @@ import {
|
||||
LGraphEventMode
|
||||
} from '@comfyorg/litegraph'
|
||||
import { ExtensionManager } from '@/types/extensionTypes'
|
||||
import {
|
||||
ComfyNodeDefImpl,
|
||||
SYSTEM_NODE_DEFS,
|
||||
useNodeDefStore
|
||||
} from '@/stores/nodeDefStore'
|
||||
import { SYSTEM_NODE_DEFS, useNodeDefStore } from '@/stores/nodeDefStore'
|
||||
import { Vector2 } from '@comfyorg/litegraph'
|
||||
import _ from 'lodash'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
@@ -2049,19 +2045,6 @@ export class ComfyApp {
|
||||
this.lastExecutionError = 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
|
||||
}
|
||||
|
||||
clientPosToCanvasPos(pos: Vector2): Vector2 {
|
||||
const rect = this.canvasContainer.getBoundingClientRect()
|
||||
const containerOffsets = [rect.left, rect.top]
|
||||
@@ -2078,12 +2061,6 @@ export class ComfyApp {
|
||||
) as Vector2
|
||||
}
|
||||
|
||||
getCanvasCenter(): Vector2 {
|
||||
const dpi = Math.max(window.devicePixelRatio ?? 1, 1)
|
||||
const [x, y, w, h] = app.canvas.ds.visible_area
|
||||
return [x + w / dpi / 2, y + h / dpi / 2]
|
||||
}
|
||||
|
||||
public goToNode(nodeId: NodeId) {
|
||||
const graphNode = this.graph.getNodeById(nodeId)
|
||||
if (!graphNode) return
|
||||
|
||||
Reference in New Issue
Block a user