refactor(edges)!: use markerEnd and markerStart

* remove markerEndId

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent d54c981aad
commit a7bacb754a
4 changed files with 24 additions and 16 deletions
+8 -7
View File
@@ -1,8 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { CSSProperties } from 'vue'
import { Position } from '../../types/flow' import { Position } from '../../types/flow'
import type { EdgeProps } from '../../types/edge' import type { EdgeProps } from '../../types/edge'
import { getCenter, getMarkerEnd, getBezierPath } from './utils' import { getCenter, getBezierPath } from './utils'
import EdgeText from './EdgeText.vue' import EdgeText from './EdgeText.vue'
const props = withDefaults(defineProps<EdgeProps>(), { const props = withDefaults(defineProps<EdgeProps>(), {
@@ -26,10 +25,6 @@ const path = computed(() => {
}) })
else return '' else return ''
}) })
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
const attrs = useAttrs() as Record<'style', CSSProperties>
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
@@ -38,7 +33,13 @@ export default {
} }
</script> </script>
<template> <template>
<path class="vue-flow__edge-path" :style="attrs.style" :d="path" :marker-end="markerEnd" /> <path
class="vue-flow__edge-path"
:style="props.style"
:d="path"
:marker-end="props.markerEnd"
:marker-start="props.markerStart"
/>
<slot :x="centered[0]" :y="centered[1]" v-bind="props"> <slot :x="centered[0]" :y="centered[1]" v-bind="props">
<EdgeText <EdgeText
v-if="props.label" v-if="props.label"
+8 -4
View File
@@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Position } from '../../types' import { Position } from '../../types'
import type { SmoothStepEdgeProps } from '../../types/edge' import type { SmoothStepEdgeProps } from '../../types/edge'
import { getCenter, getMarkerEnd, getSmoothStepPath } from './utils' import { getCenter, getSmoothStepPath } from './utils'
import EdgeText from './EdgeText.vue' import EdgeText from './EdgeText.vue'
const props = withDefaults(defineProps<SmoothStepEdgeProps>(), { const props = withDefaults(defineProps<SmoothStepEdgeProps>(), {
@@ -27,8 +27,6 @@ const path = computed(() => {
}) })
else return '' else return ''
}) })
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
@@ -37,7 +35,13 @@ export default {
} }
</script> </script>
<template> <template>
<path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" /> <path
class="vue-flow__edge-path"
:style="props.style"
:d="path"
:marker-end="props.markerEnd"
:marker-start="props.markerStart"
/>
<slot :x="centered[0]" :y="centered[1]" v-bind="props"> <slot :x="centered[0]" :y="centered[1]" v-bind="props">
<EdgeText <EdgeText
v-if="props.label" v-if="props.label"
+8 -4
View File
@@ -2,7 +2,7 @@
import { Position } from '../../types' import { Position } from '../../types'
import type { EdgeProps } from '../../types/edge' import type { EdgeProps } from '../../types/edge'
import EdgeText from './EdgeText.vue' import EdgeText from './EdgeText.vue'
import { getMarkerEnd, getBezierPath } from './utils' import { getBezierPath } from './utils'
const props = withDefaults(defineProps<EdgeProps>(), { const props = withDefaults(defineProps<EdgeProps>(), {
selected: false, selected: false,
@@ -30,8 +30,6 @@ const path = computed(() => {
}) })
else return '' else return ''
}) })
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
@@ -40,7 +38,13 @@ export default {
} }
</script> </script>
<template> <template>
<path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" /> <path
class="vue-flow__edge-path"
:style="props.style"
:d="path"
:marker-end="props.markerEnd"
:marker-start="props.markerStart"
/>
<slot :x="centerX" :y="centerY" v-bind="props"> <slot :x="centerX" :y="centerY" v-bind="props">
<EdgeText <EdgeText
v-if="props.label" v-if="props.label"
-1
View File
@@ -70,7 +70,6 @@ export interface EdgeProps<Data = any> {
selected?: boolean selected?: boolean
sourcePosition: Position sourcePosition: Position
targetPosition: Position targetPosition: Position
markerEndId?: string
sourceHandleId?: string sourceHandleId?: string
targetHandleId?: string targetHandleId?: string
source: string source: string