mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-03-15 14:09:36 +00:00
Support linking converted inputs from api json
This commit is contained in:
parent
236bda2683
commit
d2e7f1b04b
@ -260,6 +260,12 @@ app.registerExtension({
|
|||||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
// Add menu options to conver to/from widgets
|
// Add menu options to conver to/from widgets
|
||||||
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
|
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
|
||||||
|
nodeType.prototype.convertWidgetToInput = function (widget) {
|
||||||
|
const config = getConfig.call(this, widget.name) ?? [widget.type, widget.options || {}];
|
||||||
|
if (!isConvertableWidget(widget, config)) return false;
|
||||||
|
convertToInput(this, widget, config);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
nodeType.prototype.getExtraMenuOptions = function (_, options) {
|
nodeType.prototype.getExtraMenuOptions = function (_, options) {
|
||||||
const r = origGetExtraMenuOptions ? origGetExtraMenuOptions.apply(this, arguments) : undefined;
|
const r = origGetExtraMenuOptions ? origGetExtraMenuOptions.apply(this, arguments) : undefined;
|
||||||
|
|
||||||
|
@ -2162,8 +2162,17 @@ export class ComfyApp {
|
|||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
const [fromId, fromSlot] = value;
|
const [fromId, fromSlot] = value;
|
||||||
const fromNode = app.graph.getNodeById(fromId);
|
const fromNode = app.graph.getNodeById(fromId);
|
||||||
const toSlot = node.inputs?.findIndex((inp) => inp.name === input);
|
let toSlot = node.inputs?.findIndex((inp) => inp.name === input);
|
||||||
if (toSlot !== -1) {
|
if (toSlot == null || toSlot === -1) {
|
||||||
|
try {
|
||||||
|
// Target has no matching input, most likely a converted widget
|
||||||
|
const widget = node.widgets?.find((w) => w.name === input);
|
||||||
|
if (widget && node.convertWidgetToInput?.(widget)) {
|
||||||
|
toSlot = node.inputs?.length - 1;
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
}
|
||||||
|
if (toSlot != null || toSlot !== -1) {
|
||||||
fromNode.connect(fromSlot, node, toSlot);
|
fromNode.connect(fromSlot, node, toSlot);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user