fix: paste edges between components selected even if edges are not selected (#8497)
* Added pasting the edges between components selected as well * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
892ffe6bd9
commit
a913adc39f
1 changed files with 15 additions and 0 deletions
|
|
@ -385,6 +385,21 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
track("Component Connection Deleted", { edgeId });
|
||||
},
|
||||
paste: (selection, position) => {
|
||||
// Collect IDs of nodes in the selection
|
||||
const selectedNodeIds = new Set(selection.nodes.map((node) => node.id));
|
||||
// Find existing edges in the flow that connect nodes within the selection
|
||||
const existingEdgesToCopy = get().edges.filter((edge) => {
|
||||
return (
|
||||
selectedNodeIds.has(edge.source) &&
|
||||
selectedNodeIds.has(edge.target) &&
|
||||
!selection.edges.some((selEdge) => selEdge.id === edge.id)
|
||||
);
|
||||
});
|
||||
// Add these edges to the selection's edges
|
||||
if (existingEdgesToCopy.length > 0) {
|
||||
selection.edges = selection.edges.concat(existingEdgesToCopy);
|
||||
}
|
||||
|
||||
if (
|
||||
selection.nodes.some((node) => node.data.type === "ChatInput") &&
|
||||
checkChatInput(get().nodes)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue