feat(edges): Add source/target nodes to graph edges

# What's changed?

* Bind source and target nodes to graph edges for convenience
This commit is contained in:
Braks
2022-04-21 10:47:53 +02:00
parent e3270d5f94
commit a19474c341
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -249,6 +249,8 @@ export default (state: State, getters: ComputedGetters): Actions => {
...state.defaultEdgeOptions, ...state.defaultEdgeOptions,
...storedEdge, ...storedEdge,
}), }),
sourceNode,
targetNode,
}) })
return res return res
@@ -287,6 +289,8 @@ export default (state: State, getters: ComputedGetters): Actions => {
state.edges.push({ state.edges.push({
...state.defaultEdgeOptions, ...state.defaultEdgeOptions,
...edge, ...edge,
sourceNode,
targetNode,
}) })
} }
}) })
+2
View File
@@ -97,6 +97,8 @@ export interface EdgePositions {
export type GraphEdge<Data = ElementData> = Edge<Data> & { export type GraphEdge<Data = ElementData> = Edge<Data> & {
selected?: boolean selected?: boolean
z?: number z?: number
sourceNode: GraphNode
targetNode: GraphNode
} & EdgePositions } & EdgePositions
/** these props are passed to edge components */ /** these props are passed to edge components */