mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-22 07:36:59 +08:00
Allow label display in litegraph based on node definition in python
This commit is contained in:
parent
ece5acb8e8
commit
699f54d740
@ -75,6 +75,7 @@ function convertToInput(node, widget, config) {
|
|||||||
const sz = node.size;
|
const sz = node.size;
|
||||||
node.addInput(widget.name, type, {
|
node.addInput(widget.name, type, {
|
||||||
widget: { name: widget.name, [GET_CONFIG]: () => config },
|
widget: { name: widget.name, [GET_CONFIG]: () => config },
|
||||||
|
label: widget.element?.placeholder ? widget.element?.placeholder : widget.name
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const widget of node.widgets) {
|
for (const widget of node.widgets) {
|
||||||
|
|||||||
@ -3379,7 +3379,7 @@
|
|||||||
* @param {Object} extra_info this can be used to have special properties of an output (label, special color, position, etc)
|
* @param {Object} extra_info this can be used to have special properties of an output (label, special color, position, etc)
|
||||||
*/
|
*/
|
||||||
LGraphNode.prototype.addOutput = function(name, type, extra_info) {
|
LGraphNode.prototype.addOutput = function(name, type, extra_info) {
|
||||||
var output = { name: name, type: type, links: null };
|
var output = { name: name, label: extra_info.label, type: type, link: null };
|
||||||
if (extra_info) {
|
if (extra_info) {
|
||||||
for (var i in extra_info) {
|
for (var i in extra_info) {
|
||||||
output[i] = extra_info[i];
|
output[i] = extra_info[i];
|
||||||
@ -3470,7 +3470,7 @@
|
|||||||
*/
|
*/
|
||||||
LGraphNode.prototype.addInput = function(name, type, extra_info) {
|
LGraphNode.prototype.addInput = function(name, type, extra_info) {
|
||||||
type = type || 0;
|
type = type || 0;
|
||||||
var input = { name: name, type: type, link: null };
|
var input = { name: name, label: extra_info.label, type: type, link: null };
|
||||||
if (extra_info) {
|
if (extra_info) {
|
||||||
for (var i in extra_info) {
|
for (var i in extra_info) {
|
||||||
input[i] = extra_info[i];
|
input[i] = extra_info[i];
|
||||||
|
|||||||
@ -1646,6 +1646,8 @@ export class ComfyApp {
|
|||||||
for (const inputName in inputs) {
|
for (const inputName in inputs) {
|
||||||
const inputData = inputs[inputName];
|
const inputData = inputs[inputName];
|
||||||
const type = inputData[0];
|
const type = inputData[0];
|
||||||
|
const extra_infos = inputData[1];
|
||||||
|
const inputLabel = extra_infos?.label ? extra_infos.label : inputName
|
||||||
|
|
||||||
let widgetCreated = true;
|
let widgetCreated = true;
|
||||||
const widgetType = self.getWidgetType(inputData, inputName);
|
const widgetType = self.getWidgetType(inputData, inputName);
|
||||||
@ -1657,7 +1659,7 @@ export class ComfyApp {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Node connection inputs
|
// Node connection inputs
|
||||||
this.addInput(inputName, type);
|
this.addInput(inputName, type, { label: inputLabel });
|
||||||
widgetCreated = false;
|
widgetCreated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1674,9 +1676,17 @@ export class ComfyApp {
|
|||||||
for (const o in nodeData["output"]) {
|
for (const o in nodeData["output"]) {
|
||||||
let output = nodeData["output"][o];
|
let output = nodeData["output"][o];
|
||||||
if(output instanceof Array) output = "COMBO";
|
if(output instanceof Array) output = "COMBO";
|
||||||
const outputName = nodeData["output_name"][o] || output;
|
let outputName = output;
|
||||||
|
let outputLabel = outputName;
|
||||||
|
if(nodeData["output_name"][o] instanceof Array) {
|
||||||
|
outputName = nodeData["output_name"][o][0] || output;
|
||||||
|
outputLabel = nodeData["output_name"][o][1]
|
||||||
|
} else {
|
||||||
|
outputName = nodeData["output_name"][o] || output;
|
||||||
|
outputLabel = outputName
|
||||||
|
}
|
||||||
const outputShape = nodeData["output_is_list"][o] ? LiteGraph.GRID_SHAPE : LiteGraph.CIRCLE_SHAPE ;
|
const outputShape = nodeData["output_is_list"][o] ? LiteGraph.GRID_SHAPE : LiteGraph.CIRCLE_SHAPE ;
|
||||||
this.addOutput(outputName, output, { shape: outputShape });
|
this.addOutput(outputName, output, { shape: outputShape, label: outputLabel });
|
||||||
}
|
}
|
||||||
|
|
||||||
const s = this.computeSize();
|
const s = this.computeSize();
|
||||||
|
|||||||
@ -346,6 +346,7 @@ export const ComfyWidgets = {
|
|||||||
STRING(node, inputName, inputData, app) {
|
STRING(node, inputName, inputData, app) {
|
||||||
const defaultVal = inputData[1].default || "";
|
const defaultVal = inputData[1].default || "";
|
||||||
const multiline = !!inputData[1].multiline;
|
const multiline = !!inputData[1].multiline;
|
||||||
|
inputData[1].placeholder = inputData[1].placeholder || inputData[1].label || inputName;
|
||||||
|
|
||||||
let res;
|
let res;
|
||||||
if (multiline) {
|
if (multiline) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user