This commit is contained in:
AlekPet
2023-09-06 17:12:45 +03:00
parent a73d0f1aa7
commit e4a7ffbb7f
2 changed files with 11 additions and 6 deletions
+2 -2
View File
@@ -12,11 +12,11 @@ class PreviewTextNode:
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
}
RETURN_TYPES = ()
RETURN_TYPES = ("STRING",)
OUTPUT_NODE = True
FUNCTION = "preview_text"
CATEGORY = "AlekPet Nodes/extras"
def preview_text(self, text, prompt=None, extra_pnginfo=None):
return {"ui": {"string": [text,]}}
return {"ui": {"string": [text,]}, "result": (text,)}
+9 -4
View File
@@ -4,11 +4,12 @@ import { ComfyWidgets } from "/scripts/widgets.js";
app.registerExtension({
name: "Comfy.ExtrasNode",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
// --- Preview Text Node
if (nodeData.name === "PreviewTextNode") {
// Node Created
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
const r = onNodeCreated
const ret = onNodeCreated
? onNodeCreated.apply(this, arguments)
: undefined;
@@ -19,7 +20,7 @@ app.registerExtension({
console.log(`Create PreviewTextNode: ${nodeName}`);
ComfyWidgets.STRING(
const wi = ComfyWidgets.STRING(
this,
nodeName,
[
@@ -32,13 +33,15 @@ app.registerExtension({
],
app
);
return r;
wi.widget.inputEl.readOnly = true;
return ret;
};
// On drawforeground
const onDrawForeground = nodeType.prototype.onDrawForeground;
nodeType.prototype.onDrawForeground = function () {
onDrawForeground?.apply(this, arguments);
const ret = onDrawForeground?.apply(this, arguments);
const output = app.nodeOutputs[this.id + ""];
if (
@@ -48,7 +51,9 @@ app.registerExtension({
) {
this.widgets[0].inputEl.value = output.string[0];
}
return ret;
};
}
// --- Preview Text Node
},
});