Add node_fixer (recreate) functionality (#892)

Recreated node now copies the following:
- Widgets converted to inputs
- Output links
- Custom size
- Title colour
- Background colour
This commit is contained in:
filtered 2024-07-22 23:02:22 +10:00 committed by GitHub
parent 229edefb1f
commit d1a86b36f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,6 +105,10 @@ function node_info_copy(src, dest, connect_both) {
// copy input connections
for(let i in src.inputs) {
let input = src.inputs[i];
if (input.widget !== undefined) {
const destWidget = dest.widgets.find(x => x.name === input.widget.name);
dest.convertWidgetToInput(destWidget);
}
if(input.link) {
let link = app.graph.links[input.link];
let src_node = app.graph.getNodeById(link.origin_id);
@ -138,6 +142,10 @@ function node_info_copy(src, dest, connect_both) {
}
}
dest.color = src.color;
dest.bgcolor = src.bgcolor;
dest.size = src.size;
app.graph.afterChange();
}
@ -202,7 +210,7 @@ app.registerExtension({
let new_node = LiteGraph.createNode(nodeType.comfyClass);
new_node.pos = [this.pos[0], this.pos[1]];
app.canvas.graph.add(new_node, false);
node_info_copy(this, new_node);
node_info_copy(this, new_node, true);
app.canvas.graph.remove(this);
},
});