Add IBaseWidget.serialize flag (#915)

https://github.com/Comfy-Org/ComfyUI_frontend/pull/3323

Some widgets are only used for display purpose (The preview image
widget), their value shouldn't be serialized into the workflow. This PR
adds a flag to allow widget to skip value serialization.
This commit is contained in:
Chenlei Hu
2025-04-09 16:06:05 -04:00
committed by GitHub
parent 04b4485cc9
commit 197a6cbae8
2 changed files with 7 additions and 0 deletions

View File

@@ -777,6 +777,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
if (widgets && this.serialize_widgets) {
o.widgets_values = []
for (const [i, widget] of widgets.entries()) {
if (widget.serialize === false) continue
// @ts-expect-error #595 No-null
o.widgets_values[i] = widget ? widget.value : null
}

View File

@@ -150,6 +150,12 @@ export interface IBaseWidget {
type: TWidgetType
value?: TWidgetValue
/**
* Whether the widget value should be serialized on node serialization.
* @default true
*/
serialize?: boolean
/**
* The computed height of the widget. Used by customized node resize logic.
* See scripts/domWidget.ts for more details.