mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-16 10:02:28 +08:00
feat: Copy the connections of the nearest node by double-clicking.
This commit is contained in:
parent
9ab66cf1ae
commit
8b3d71fbcf
@ -63,6 +63,7 @@ This repository provides Colab notebooks that allow you to install and use Comfy
|
||||
* Support for automatically installing dependencies of custom nodes upon restarting Colab notebooks.
|
||||
|
||||
## Changes
|
||||
* **2.4** Copy the connections of the nearest node by double-clicking.
|
||||
* **2.2.3** Support Components System
|
||||
* **0.29** Add `Update all` feature
|
||||
* **0.25** support db channel
|
||||
@ -253,6 +254,13 @@ NODE_CLASS_MAPPINGS.update({
|
||||

|
||||
|
||||
|
||||
## Additional Feature
|
||||
* Fix node(recreate): When right-clicking on a node and selecting `Fix node (recreate)`, you can recreate the node. The widget's values are reset, while the connections maintain those with the same names.
|
||||
* It is used to correct errors in nodes of old workflows created before, which are incompatible with the version changes of custom nodes.
|
||||
* Connection copy: Double-clicking a node copies the connections of the nearest node.
|
||||
* However, this action is only possible when there are no existing connections, and since duplicate connections are not allowed in the output, connections from the existing node's output will disappear.
|
||||
* This feature copies only the input and output that match the names.
|
||||
|
||||
## Troubleshooting
|
||||
* If your `git.exe` is installed in a specific location other than system git, please install ComfyUI-Manager and run ComfyUI. Then, specify the path including the file name in `git_exe = ` in the ComfyUI-Manager/config.ini file that is generated.
|
||||
* If updating ComfyUI-Manager itself fails, please go to the **ComfyUI-Manager** directory and execute the command `git update-ref refs/remotes/origin/main a361cc1 && git fetch --all && git pull`.
|
||||
|
||||
@ -29,7 +29,7 @@ except:
|
||||
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
|
||||
|
||||
|
||||
version = [2, 3, 2]
|
||||
version = [2, 4]
|
||||
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
||||
print(f"### Loading: ComfyUI-Manager ({version_str})")
|
||||
|
||||
|
||||
@ -10,6 +10,41 @@ function addMenuHandler(nodeType, cb) {
|
||||
};
|
||||
}
|
||||
|
||||
function distance(node1, node2) {
|
||||
let dx = node1.pos[0] - node2.pos[0];
|
||||
let dy = node1.pos[1] - node2.pos[1];
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
function lookup_nearest_nodes(node) {
|
||||
let x = node.pos[0] + node.size[0]/2;
|
||||
let y = node.pos[1] + node.size[1]/2;
|
||||
|
||||
let nearest_distance = Infinity;
|
||||
let nearest_node = null;
|
||||
for(let other of app.graph._nodes) {
|
||||
if(other === node)
|
||||
continue;
|
||||
|
||||
let dist = distance(node, other);
|
||||
if (dist < nearest_distance) {
|
||||
nearest_distance = dist;
|
||||
nearest_node = other;
|
||||
}
|
||||
}
|
||||
|
||||
return nearest_node;
|
||||
}
|
||||
|
||||
function copy_connections(src, dest) {
|
||||
if(src.inputs && dest.inputs) {
|
||||
|
||||
}
|
||||
|
||||
if(src.outputs && dest.outputs) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function node_info_copy(src, dest) {
|
||||
// copy input connections
|
||||
@ -52,6 +87,19 @@ function node_info_copy(src, dest) {
|
||||
app.registerExtension({
|
||||
name: "Comfy.Manager.NodeFixer",
|
||||
|
||||
async nodeCreated(node, app) {
|
||||
let orig_dblClick = node.onDblClick;
|
||||
node.onDblClick = () => {
|
||||
orig_dblClick?.apply?.(this, arguments);
|
||||
if(node.inputs && node.outputs && node.inputs.length == 0 && node.outputs.length == 0)
|
||||
return;
|
||||
|
||||
console.log(arguments);
|
||||
let src_node = lookup_nearest_nodes(node);
|
||||
node_info_copy(src_node, node);
|
||||
}
|
||||
},
|
||||
|
||||
beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
addMenuHandler(nodeType, function (_, options) {
|
||||
options.push({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user