feat(editor): Add ability to extract sub-workflows to canvas context menu (#15538)

This commit is contained in:
Charlie Kolb
2025-06-02 12:17:27 +02:00
committed by GitHub
parent 096806af15
commit 5985df6e51
23 changed files with 2070 additions and 373 deletions

View File

@@ -927,4 +927,38 @@ export class Workflow {
return this.__getStartNode(Object.keys(this.nodes));
}
getConnectionsBetweenNodes(
sources: string[],
targets: string[],
): Array<[IConnection, IConnection]> {
const result: Array<[IConnection, IConnection]> = [];
for (const source of sources) {
for (const type of Object.keys(this.connectionsBySourceNode[source] ?? {})) {
for (const sourceIndex of Object.keys(this.connectionsBySourceNode[source][type])) {
for (const connectionIndex of Object.keys(
this.connectionsBySourceNode[source][type][parseInt(sourceIndex, 10)] ?? [],
)) {
const targetConnectionData =
this.connectionsBySourceNode[source][type][parseInt(sourceIndex, 10)]?.[
parseInt(connectionIndex, 10)
];
if (targetConnectionData && targets.includes(targetConnectionData?.node)) {
result.push([
{
node: source,
index: parseInt(sourceIndex, 10),
type: type as NodeConnectionType,
},
targetConnectionData,
]);
}
}
}
}
}
return result;
}
}