@ -533,39 +533,36 @@ export const useWorkflowStore = create<WorkflowStore>((set, get) => ({
} ,
} ,
onConnect : ( connection : Connection , edgeDataOverrides? : Record < string , unknown > ) = > {
onConnect : ( connection : Connection , edgeDataOverrides? : Record < string , unknown > ) = > {
set ( ( state ) = > ( {
set ( ( state ) = > {
edges : addEdge (
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
( ( ) = > {
const newEdge = {
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
. . . connection ,
return {
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
. . . connection ,
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
} ;
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
// Cast needed: React Flow's Edge<T> types data as T | undefined, but addEdge expects data to be defined
} ;
return {
} ) ( ) ,
edges : addEdge ( newEdge , state . edges as never ) as WorkflowEdge [ ] ,
state . edges
hasUnsavedChanges : true ,
) ,
} ;
hasUnsavedChanges : true ,
} ) ;
} ) ) ;
get ( ) . incrementManualChangeCount ( ) ;
get ( ) . incrementManualChangeCount ( ) ;
} ,
} ,
addEdgeWithType : ( connection : Connection , edgeType : string , edgeDataOverrides? : Record < string , unknown > ) = > {
addEdgeWithType : ( connection : Connection , edgeType : string , edgeDataOverrides? : Record < string , unknown > ) = > {
set ( ( state ) = > ( {
set ( ( state ) = > {
edges : addEdge (
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
( ( ) = > {
const newEdge = {
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
. . . connection ,
return {
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
. . . connection ,
type : edgeType ,
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
type : edgeType ,
} ;
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
return {
} ;
edges : addEdge ( newEdge , state . edges as never ) as WorkflowEdge [ ] ,
} ) ( ) ,
hasUnsavedChanges : true ,
state . edges
} ;
) ,
} ) ;
hasUnsavedChanges : true ,
} ) ) ;
} ,
} ,
removeEdge : ( edgeId : string ) = > {
removeEdge : ( edgeId : string ) = > {