From 1578d404eee5b25fb2d14a391ae0242c767f8eab Mon Sep 17 00:00:00 2001 From: bcakmakoglu <78412429+bcakmakoglu@users.noreply.github.com> Date: Sun, 26 Jun 2022 17:11:06 +0200 Subject: [PATCH] feat(edges): add `connectionLineOptions` prop # What's changed? * allow defining markers on connection lines * deprecate `connectionLineType` * deprecate `connectionLineStyle` --- .../ConnectionLine/ConnectionLine.vue | 18 +++++++-- .../container/EdgeRenderer/EdgeRenderer.vue | 3 +- .../src/container/EdgeRenderer/Marker.vue | 2 +- .../EdgeRenderer/MarkerDefinitions.vue | 37 ++++++++++--------- packages/vue-flow/src/store/state.ts | 4 ++ packages/vue-flow/src/types/connection.ts | 14 ++++++- packages/vue-flow/src/types/flow.ts | 5 ++- packages/vue-flow/src/types/store.ts | 5 ++- 8 files changed, 61 insertions(+), 27 deletions(-) diff --git a/packages/vue-flow/src/components/ConnectionLine/ConnectionLine.vue b/packages/vue-flow/src/components/ConnectionLine/ConnectionLine.vue index c72872ed..a71d71d8 100644 --- a/packages/vue-flow/src/components/ConnectionLine/ConnectionLine.vue +++ b/packages/vue-flow/src/components/ConnectionLine/ConnectionLine.vue @@ -4,6 +4,7 @@ import type { GraphNode, HandleElement, HandleType } from '../../types' import { ConnectionLineType, Position } from '../../types' import { useVueFlow } from '../../composables' import { Slots } from '../../context' +import { getMarkerId } from '../../utils' const { sourceNode } = defineProps<{ sourceNode: GraphNode @@ -17,6 +18,7 @@ const { connectionLineType, connectionLineStyle, connectionNodeId, + connectionLineOptions, viewport, } = $(useVueFlow()) @@ -44,7 +46,7 @@ const targetY = $computed(() => (connectionPosition.y - viewport.y) / viewport.z const dAttr = computed(() => { let path = `M${sourceX},${sourceY} ${targetX},${targetY}` - switch (connectionLineType) { + switch (connectionLineType || connectionLineOptions.type) { case ConnectionLineType.Bezier: path = getBezierPath({ sourceX, @@ -99,13 +101,21 @@ export default { targetX, targetY, targetPosition, - connectionLineType, - connectionLineStyle, nodes: getNodes, sourceNode, sourceHandle, + markerEnd: `url(#${getMarkerId(connectionLineOptions.markerEnd)})`, + markerStart: `url(#${getMarkerId(connectionLineOptions.markerStart)})`, }" /> - + diff --git a/packages/vue-flow/src/container/EdgeRenderer/EdgeRenderer.vue b/packages/vue-flow/src/container/EdgeRenderer/EdgeRenderer.vue index d680a9de..af621809 100644 --- a/packages/vue-flow/src/container/EdgeRenderer/EdgeRenderer.vue +++ b/packages/vue-flow/src/container/EdgeRenderer/EdgeRenderer.vue @@ -18,7 +18,6 @@ const { connectionNodeId, nodesConnectable, connectionHandleType, - defaultMarkerColor, edgesUpdatable, elementsSelectable, getSelectedNodes, @@ -181,7 +180,7 @@ export default {