diff --git a/comfy-nodes/input_text.py b/comfy-nodes/input_text.py index cdf1eed..f499322 100755 --- a/comfy-nodes/input_text.py +++ b/comfy-nodes/input_text.py @@ -22,10 +22,10 @@ class ShellAgentPluginInputText: "STRING", {"multiline": True, "default": ""}, ), - # "choices": ( - # "STRING", - # {"multiline": False, "default": ""}, - # ), + "choices": ( + "STRING", + {"multiline": False, "default": ""}, + ), } } @@ -79,10 +79,10 @@ class ShellAgentPluginInputFloat: "STRING", {"default": ""}, ), - # "choices": ( - # "STRING", - # {"multiline": False, "default": ""}, - # ), + "choices": ( + "STRING", + {"multiline": False, "default": ""}, + ), } } @@ -146,7 +146,11 @@ class ShellAgentPluginInputInteger: "description": ( "STRING", {"multiline": True, "default": ""}, - ) + ), + "choices": ( + "STRING", + {"multiline": False, "default": ""}, + ), } } diff --git a/web/shellagent.js b/web/shellagent.js index cdd0f25..662d9b6 100644 --- a/web/shellagent.js +++ b/web/shellagent.js @@ -1,21 +1,6 @@ import { app } from "../../scripts/app.js"; import { api } from "../../scripts/api.js"; -const id = "ShellAgent.InputText.Choices"; - -const getPresets = () => { - let items; - try { - items = JSON.parse(localStorage.getItem(id)); - } catch (error) { } - if (!items || !items.length) { - items = [""]; - } - return items; -}; - -let presets = getPresets(); - app.registerExtension({ name: "Shellagent.extension", async setup() { @@ -55,9 +40,7 @@ app.registerExtension({ if (["ShellAgentPluginInputText", "ShellAgentPluginInputFloat", "ShellAgentPluginInputInteger"].indexOf(nodeData.name) > -1) { chainCallback(nodeType.prototype, "onNodeCreated", function () { - const widget = this.addWidget("string", "choices", presets, () => { }, { - value: presets, - }); + const widget = this.widgets.find(w => w.name === 'choices') this.addWidget('button', 'manage choices', null, () => { const container = document.createElement("div"); @@ -104,12 +87,22 @@ app.registerExtension({ addNew.before(valueLbl); } - for (const p of presets) { - addRow(p); + + let arr = [] + if (typeof widget.value === 'string') { + try { + arr = JSON.parse(widget.value) + } catch { } + } else if(Array.isArray(widget.value)) { + arr = widget.value + } + + for (const a of arr) { + addRow(a); } const help = document.createElement("span"); - help.textContent = "To remove a preset set the value to blank"; + help.textContent = "To remove a item set the value to blank"; help.style.gridColumn = "1 / 3"; container.append(help); @@ -137,9 +130,6 @@ app.registerExtension({ widget.value = p; - presets = p; - localStorage.setItem(id, JSON.stringify(presets)); - dialog.close(); };