mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 06:19:58 +00:00
Add back type guard on string widget (#2859)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user