Add back type guard on string widget (#2859)

This commit is contained in:
Chenlei Hu
2025-03-04 16:52:58 -05:00
committed by GitHub
parent a415da616c
commit 89b73429b7
2 changed files with 9 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import type { IWidget, LGraphNode } from '@comfyorg/litegraph'
import { type InputSpec } from '@/schemas/nodeDefSchema'
import { type InputSpec, isStringInputSpec } from '@/schemas/nodeDefSchema'
import type { ComfyWidgetConstructor } from '@/scripts/widgets'
import { useSettingStore } from '@/stores/settingStore'
import type { ComfyApp } from '@/types'
@@ -64,6 +64,10 @@ export const useStringWidget = () => {
inputData: InputSpec,
app: ComfyApp
) => {
if (!isStringInputSpec(inputData)) {
throw new Error(`Invalid input data: ${inputData}`)
}
const inputOptions = inputData[1] ?? {}
const defaultVal = inputOptions.default ?? ''
const multiline = inputOptions.multiline

View File

@@ -26,10 +26,9 @@ app.registerExtension({
this.properties = { text: '' }
}
ComfyWidgets.STRING(
// Should we extends LGraphNode? Yesss
this,
'',
['', { default: this.properties.text, multiline: true }],
'text',
['STRING', { default: this.properties.text, multiline: true }],
app
)
@@ -66,8 +65,8 @@ app.registerExtension({
}
ComfyWidgets.MARKDOWN(
this,
'',
['', { default: this.properties.text }],
'text',
['STRING', { default: this.properties.text }],
app
)