update, add PreviewTextNode
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# ExtrasNode node for ComfyUI
|
||||
|
||||
Custom nodes for ComfyUI
|
||||
|
||||
> Includes:
|
||||
> **PreviewTextNode** - The node displays the input text
|
||||
@@ -0,0 +1,22 @@
|
||||
class PreviewTextNode:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"text": ("STRING", {"forceInput": True}),
|
||||
},
|
||||
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
OUTPUT_NODE = True
|
||||
FUNCTION = "preview_text"
|
||||
|
||||
CATEGORY = "AlekPet Nodes/extras"
|
||||
|
||||
def preview_text(self, text, prompt=None, extra_pnginfo=None):
|
||||
return {"ui": {"string": [text,]}}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { ComfyWidgets } from "../../scripts/widgets.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "Comfy.ExtrasNode",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name === "PreviewTextNode") {
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated
|
||||
? onNodeCreated.apply(this, arguments)
|
||||
: undefined;
|
||||
|
||||
let PreviewTextNode = app.graph._nodes.filter(
|
||||
(wi) => wi.type == "PreviewTextNode"
|
||||
),
|
||||
nodeName = `PreviewTextNode_${PreviewTextNode.length}`;
|
||||
|
||||
console.log(`Create PreviewTextNode: ${nodeName}`);
|
||||
|
||||
ComfyWidgets.STRING(
|
||||
this,
|
||||
nodeName,
|
||||
[
|
||||
"STRING",
|
||||
{
|
||||
default: "",
|
||||
placeholder: "Text message output...",
|
||||
multiline: true,
|
||||
},
|
||||
],
|
||||
app
|
||||
);
|
||||
this.onDrawBackground = function () {
|
||||
const output = app.nodeOutputs[this.id + ""];
|
||||
if (output && output.string) {
|
||||
this.widgets[0].inputEl.value = output.string[0];
|
||||
}
|
||||
};
|
||||
return r;
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -4,11 +4,13 @@ Custom nodes that extend the capabilities of [ComfyUI](https://github.com/comfya
|
||||
|
||||
# List Nodes:
|
||||
|
||||
| Name | Description | ComfyUI category |
|
||||
| :-------------- | :--------------------------------------------------------------------------------------------------------------: | :------------------------------------------: |
|
||||
| _PoseNode_ | Set pose ControlNet | AlekPet Node/image |
|
||||
| _PainterNode_ | Set sketch, scrumble image ControlNet and other nodes | AlekPet Node/image |
|
||||
| _TranslateNode_ | Node translate promt from other languages into english. Includes: TranslateCLIPTextEncodeNode, TranslateTextNode | AlekPet Node/conditioning, AlekPet Node/text |
|
||||
| Name | Description | ComfyUI category |
|
||||
| :------------------ | :---------------------------------------------------------------------------------: | :-----------------------: |
|
||||
| _PoseNode_ | The node set pose ControlNet | AlekPet Node/image |
|
||||
| _PainterNode_ | The node set sketch, scrumble image ControlNet and other nodes | AlekPet Node/image |
|
||||
| _TranslateNode_ | The node translate promt from other languages into english, and return conditioning | AlekPet Node/conditioning |
|
||||
| _TranslateTextNode_ | The node translate promt from other languages into english and return string | AlekPet Node/text |
|
||||
| _PreviewTextNode_ | The node displays the input text | AlekPet Node/extras |
|
||||
|
||||
# Installing
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
Custom nodes for ComfyUI, translate promt from other languages into english
|
||||
|
||||
Includes:
|
||||
TranslateCLIPTextEncodeNode - return CONDITIONING
|
||||
TranslateTextNode - return STRING
|
||||
> Includes:
|
||||
> **TranslateCLIPTextEncodeNode** - translate text, and return CONDITIONING
|
||||
> **TranslateTextNode** - translte text and return text (STRING)
|
||||
|
||||
## Image:
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
from googletrans import Translator, LANGUAGES
|
||||
import folder_paths
|
||||
|
||||
translator = Translator()
|
||||
empty_str = re.compile('^\s*$', re.I | re.M)
|
||||
@@ -65,6 +64,7 @@ class TranslateTextNode:
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("text",)
|
||||
FUNCTION = "translate_text"
|
||||
|
||||
CATEGORY = "AlekPet Nodes/text"
|
||||
@@ -72,27 +72,5 @@ class TranslateTextNode:
|
||||
def translate_text(self, from_translate, to_translate, text):
|
||||
text_tranlsated = translate(text, from_translate, to_translate)
|
||||
return (text_tranlsated,)
|
||||
|
||||
# class PreviewTextNode:
|
||||
|
||||
# def __init__(self):
|
||||
# self.output_dir = folder_paths.get_temp_directory()
|
||||
|
||||
# @classmethod
|
||||
# def INPUT_TYPES(s):
|
||||
|
||||
# return {
|
||||
# "required": {
|
||||
# "text": ("STRING", {"forceInput": True}),
|
||||
# }
|
||||
# }
|
||||
# OUTPUT_NODE = True
|
||||
# RETURN_TYPES = ()
|
||||
# FUNCTION = "preview_text"
|
||||
|
||||
# CATEGORY = "AlekPet Nodes/text"
|
||||
|
||||
# def preview_text(self, text):
|
||||
# print(text)
|
||||
# return { "ui": { "string": text } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user