ahora que el js ya crea un cuadro preview, sabes porque no pone en su interior no muestra el contenido de return (self.Label,) al hacer queue?
class AlphaTextCopy:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {"ID": ("STRING", {"default": "", "multiline": False})},
"hidden": {"UpDate": "PROMPT"}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "COPYTEXT"
CATEGORY = "🔻 AlphaNodes"
def COPYTEXT(self, ID, UpDate=None):
self.Label = ""
if "." in ID:
node_id_str, field_name = ID.split(".", 1)
try:
if UpDate and node_id_str in UpDate:
node_data = UpDate[node_id_str]
value = node_data.get("inputs", {}).get(field_name, "")
self.Label = str(value)
except Exception as e:
self.Label = f"Error: {e}"
else:
self.Label = ID
return (self.Label,)
@classmethod
def IS_CHANGED(cls, *args, **kwargs):
return float("NaN")
import { app } from "../../scripts/app.js";
import { ComfyWidgets } from "../../scripts/widgets.js";
app.registerExtension({
name: "AlphaTextCopyPreview",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "AlphaTextCopy") {
const originalOnNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
if (originalOnNodeCreated) originalOnNodeCreated.apply(this, []);
this.previewWidget = ComfyWidgets["STRING"](this, "preview", ["STRING", { multiline: true }], app).widget;
this.previewWidget.inputEl.readOnly = true;
this.previewWidget.value = "";
this.previewWidget.serializeValue = async () => "";
// Mostrar valor inicial si existe
if (this.Label) {
this.previewWidget.value = this.Label;
}
};
const originalOnExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function (message) {
if (originalOnExecuted) originalOnExecuted.apply(this, [message]);
if (message && message.text && message.text.length > 0) {
this.previewWidget.value = message.text[0];
this.Label = message.text[0];
}
};
const originalOnUpdate = nodeType.prototype.onUpdate;
nodeType.prototype.onUpdate = function () {
if (originalOnUpdate) originalOnUpdate.apply(this, []);
if (this.Label && this.previewWidget.value !== this.Label) {
this.previewWidget.value = this.Label;
}
};
}
},
});