diff --git a/packages/vue-flow/src/components/Edges/EdgeText.vue b/packages/vue-flow/src/components/Edges/EdgeText.vue index 78ef5027..a8cf3feb 100644 --- a/packages/vue-flow/src/components/Edges/EdgeText.vue +++ b/packages/vue-flow/src/components/Edges/EdgeText.vue @@ -2,22 +2,21 @@ import type { EdgeTextProps } from '../../types/components' import type { Rect } from '../../types' -const props = withDefaults(defineProps(), { - labelStyle: () => ({}), - labelShowBg: true, - labelBgStyle: () => ({}), - labelBgPadding: () => [2, 4], - labelBgBorderRadius: 2, -}) +const { + x, + y, + label, + labelStyle = {}, + labelShowBg = true, + labelBgStyle = {}, + labelBgPadding = [2, 4], + labelBgBorderRadius = 2, +} = defineProps() -const edgeRef = templateRef('edge-text', null) +const el = templateRef('el', null) +const box = $(useElementBounding(el)) -let edgeRefBbox = $ref({ x: 0, y: 0, width: 0, height: 0 }) - -onMounted(() => { - edgeRefBbox = edgeRef.value.getBBox() -}) -const transform = computed(() => `translate(${props.x - edgeRefBbox.width / 2} ${props.y - edgeRefBbox.height / 2})`) +const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`)