mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-01 19:51:54 +00:00
Merge pull request #154 from ilyabesk/replace_connection_improvements
Cheanges to allow ability to automatically create inputs if required.
This commit is contained in:
11
src/litegraph.d.ts
vendored
11
src/litegraph.d.ts
vendored
@@ -952,6 +952,17 @@ export declare class LGraphNode {
|
||||
slotIndex: number
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* Called just before connection (or disconnect - if input is linked).
|
||||
* A convenient place to switch to another input, or create new one.
|
||||
* This allow for ability to automatically add slots if needed
|
||||
* @param inputIndex
|
||||
* @return selected input slot index, can differ from parameter value
|
||||
*/
|
||||
onBeforeConnectInput?(
|
||||
inputIndex: number
|
||||
): number;
|
||||
|
||||
/** a connection changed (new one or removed) (LiteGraph.INPUT or LiteGraph.OUTPUT, slot, true if connected, link_info, input_info or output_info ) */
|
||||
onConnectionsChange(
|
||||
type: number,
|
||||
|
||||
@@ -3593,6 +3593,12 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
if (LiteGraph.isValidConnection(output.type, input.type)) {
|
||||
if (target_node.onBeforeConnectInput) {
|
||||
// This way node can choose another slot (if selected is occupied)
|
||||
target_slot = target_node.onBeforeConnectInput(target_slot);
|
||||
}
|
||||
|
||||
//if there is something already plugged there, disconnect
|
||||
if (target_node.inputs[target_slot].link != null) {
|
||||
target_node.disconnectInput(target_slot);
|
||||
@@ -3614,7 +3620,6 @@
|
||||
var input = target_node.inputs[target_slot];
|
||||
var link_info = null;
|
||||
|
||||
if (LiteGraph.isValidConnection(output.type, input.type)) {
|
||||
link_info = new LLink(
|
||||
++this.graph.last_link_id,
|
||||
input.type,
|
||||
|
||||
Reference in New Issue
Block a user