Files
moonwhaler fdbda1ebf8 fix: Prompt Library entries wiped on workflow reload
Entries lived in a hidden widget, but this ComfyUI build's configure()
restores widget values by array position keyed off each widget's raw
.serialize flag - our custom row widget only set the ineffective
options.serialize, and removing it before restoring shifted the text
widget onto the wrong saved value on every reload (e.g. switching
tabs). Move entries to node.properties, which serializes as a plain
named field, and stop removing the row widget in configure() so the
text widget's slot stays aligned.
2026-08-11 23:21:25 +02:00

40 lines
1.2 KiB
Python

class PromptLibrary:
"""A managed text box: pick a saved prompt from the dropdown, or add/delete one."""
DESCRIPTION = (
"A multiline text box that doubles as a prompt library. Pick a saved "
"prompt from the dropdown to load it, edit it in place (auto-saved), or use "
"the +/- buttons to add or remove entries. Entries are stored on the node "
"itself, so they travel with the workflow file. The STRING output is "
"always whatever is currently in the text box."
)
SEARCH_ALIASES = ["prompt", "library", "preset", "text", "multiline"]
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"text": ("STRING", {
"default": "", "multiline": True,
"tooltip": "The prompt text. This is exactly what gets output.",
}),
},
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("text",)
FUNCTION = "get_text"
CATEGORY = "MoonPack/string"
def get_text(self, text=""):
return (text,)
NODE_CLASS_MAPPINGS = {
"MoonPack_PromptLibrary": PromptLibrary,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"MoonPack_PromptLibrary": "Prompt Library",
}