Add support for LiteGraph to convert to classes (#334)

* Add support for LiteGraph to convert to classes

* Fix large context menu search regression

* Remove debug code

* Fix regression from rename & prototype change

* Fix super() calls to match LGraphNode
This commit is contained in:
filtered
2024-08-11 23:46:54 +10:00
committed by GitHub
parent 0f3b58b610
commit e2141a81e2
7 changed files with 49 additions and 37 deletions

View File

@@ -1,32 +1,32 @@
import { LiteGraph, LGraphCanvas } from '@comfyorg/litegraph'
import { app } from '../../scripts/app'
import { ComfyWidgets } from '../../scripts/widgets'
import { LGraphNode } from '@comfyorg/litegraph'
// Node that add notes to your project
app.registerExtension({
name: 'Comfy.NoteNode',
registerCustomNodes() {
class NoteNode {
class NoteNode extends LGraphNode {
static category: string
color = LGraphCanvas.node_colors.yellow.color
bgcolor = LGraphCanvas.node_colors.yellow.bgcolor
groupcolor = LGraphCanvas.node_colors.yellow.groupcolor
properties: { text: string }
serialize_widgets: boolean
isVirtualNode: boolean
collapsable: boolean
title_mode: number
constructor() {
constructor(title?: string) {
super(title)
if (!this.properties) {
this.properties = { text: '' }
}
ComfyWidgets.STRING(
// @ts-expect-error
// Should we extends LGraphNode?
// Should we extends LGraphNode? Yesss
this,
'',
// @ts-expect-error
['', { default: this.properties.text, multiline: true }],
app
)
@@ -40,7 +40,6 @@ app.registerExtension({
LiteGraph.registerNodeType(
'Note',
// @ts-expect-error
Object.assign(NoteNode, {
title_mode: LiteGraph.NORMAL_TITLE,
title: 'Note',