Skip to content

Commit 67634fd

Browse files
committed
feat(connection): Extend connection line props for more advanced usage
Signed-off-by: Braks <[email protected]>
1 parent 3453127 commit 67634fd

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/components/ConnectionLine/ConnectionLine.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ConnectionMode,
1212
VFInternals,
1313
Transform,
14+
GraphNode,
1415
} from '../../types'
1516
1617
interface ConnectionLineProps {
@@ -22,6 +23,7 @@ interface ConnectionLineProps {
2223
connectionHandleType?: HandleType
2324
connectionPosition?: XYPosition
2425
connectionMode: ConnectionMode
26+
nodes: GraphNode[]
2527
transform: Transform
2628
}
2729
@@ -31,6 +33,7 @@ const props = withDefaults(defineProps<ConnectionLineProps>(), {
3133
connectionPosition: () => ({ x: 0, y: 0 }),
3234
})
3335
36+
const sourceNode = props.nodes.find((n) => n.id === props.connectionNodeId)
3437
const sourceHandle =
3538
props.connectionHandleId && props.connectionHandleType
3639
? props.vf.handleBounds[props.connectionHandleType]?.find((d: HandleElement) => d.id === props.connectionHandleId)
@@ -101,6 +104,9 @@ export default {
101104
targetPosition,
102105
connectionLineType: props.connectionLineType,
103106
connectionLineStyle: props.connectionLineStyle,
107+
nodes: props.nodes,
108+
sourceNode,
109+
sourceHandle,
104110
}"
105111
>
106112
<path :d="dAttr" class="vue-flow__connection-path" :style="props.connectionLineStyle" />

src/container/EdgeRenderer/EdgeRenderer.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default {
112112
:connection-handle-type="props.connectionHandleType"
113113
:connection-position="props.connectionPosition"
114114
:connection-mode="props.connectionMode"
115+
:nodes="props.nodes"
115116
:transform="props.transform"
116117
>
117118
<template #default="customConnectionLineProps">

src/types/components.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CSSProperties } from 'vue'
22
import { BackgroundVariant, Dimensions, ElementId, FitViewParams, Position, XYPosition } from './flow'
3-
import { Connection } from './connection'
4-
import { Node } from './node'
3+
import { Connection, ConnectionLineType } from './connection'
4+
import { GraphNode, Node } from './node'
55

66
export type HandleType = 'source' | 'target'
77

@@ -33,7 +33,7 @@ export interface ControlEvents {
3333
(event: 'interaction-change', active: boolean): void
3434
}
3535

36-
export type StringFunc = (node: Node) => string
36+
export type StringFunc = (node: Node | GraphNode) => string
3737
export type ShapeRendering = 'inherit' | 'auto' | 'geometricPrecision' | 'optimizeSpeed' | 'crispEdges' | undefined
3838

3939
export interface MiniMapProps {
@@ -72,3 +72,17 @@ export interface EdgeTextProps {
7272
labelBgPadding?: [number, number]
7373
labelBgBorderRadius?: number
7474
}
75+
76+
interface CustomConnectionLineProps {
77+
sourceX: number
78+
sourceY: number
79+
sourcePosition: Position
80+
targetX: number
81+
targetY: number
82+
targetPosition: Position
83+
connectionLineType: ConnectionLineType
84+
connectionLineStyle: CSSProperties
85+
nodes: GraphNode[]
86+
sourceNode: GraphNode
87+
sourceHandle: HandleElement
88+
}

0 commit comments

Comments
 (0)