mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 14:50:49 +08:00
commit
5a644488d6
@ -7139,7 +7139,8 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
LGraphCanvas.prototype.copyToClipboard = function(nodes) {
|
||||
var clipboard_info = {
|
||||
nodes: [],
|
||||
links: []
|
||||
links: [],
|
||||
groups: []
|
||||
};
|
||||
var index = 0;
|
||||
var selected_nodes_array = [];
|
||||
@ -7162,6 +7163,8 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
continue;
|
||||
}
|
||||
clipboard_info.nodes.push(cloned.serialize());
|
||||
|
||||
|
||||
if (node.inputs && node.inputs.length) {
|
||||
for (var j = 0; j < node.inputs.length; ++j) {
|
||||
var input = node.inputs[j];
|
||||
@ -7188,6 +7191,17 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if every node in the group are selected, then the group is "selected"
|
||||
for (var group of this.graph._groups) {
|
||||
group.recomputeInsideNodes();
|
||||
if (group._nodes?.every(function(node){
|
||||
return selected_nodes_array.includes(node)
|
||||
})) {
|
||||
clipboard_info.groups.push(group.serialize());
|
||||
}
|
||||
}
|
||||
|
||||
localStorage.setItem(
|
||||
"litegrapheditor_clipboard",
|
||||
JSON.stringify(clipboard_info)
|
||||
@ -7243,6 +7257,21 @@ LGraphNode.prototype.executeAction = function(action)
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
//restore groups
|
||||
if (clipboard_info.groups) {
|
||||
for (var i = 0; i < clipboard_info.groups.length; ++i) {
|
||||
var group = new LiteGraph.LGraphGroup();
|
||||
var group_data = clipboard_info.groups[i];
|
||||
group.configure(group_data);
|
||||
|
||||
group.pos[0] += this.graph_mouse[0] - posMin[0]; //+= 5;
|
||||
group.pos[1] += this.graph_mouse[1] - posMin[1]; //+= 5;
|
||||
app.graph.add(group,{doProcessChange:false});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//create links
|
||||
for (var i = 0; i < clipboard_info.links.length; ++i) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user