Skip to content

Commit cb19db9

Browse files
committed
Fix - VueUiDag - Place #free-node-label slot on the last svg layer
1 parent 38156b5 commit cb19db9

File tree

2 files changed

+48
-34
lines changed

2 files changed

+48
-34
lines changed

TestingArena/ArenaVueUiDag.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const configTheme = computed(() => ({
236236
<template #local>
237237
<LocalVueUiDag :dataset="dataset" :config="config" ref="local">
238238
<!-- <template #node-label="{ node }">
239-
{{ node.label }}
239+
TEST
240240
</template> -->
241241
<!-- <template #node="{ node }">
242242
<div style="width: 100%; height: 100%; border: 1px solid red; color: black;">
@@ -245,8 +245,8 @@ const configTheme = computed(() => ({
245245
</template> -->
246246
<!-- <template #tooltip-midpoint="{ edge }">
247247
{{ edge }}
248-
</template>
249-
<template #tooltip-node="{ node }">
248+
</template> -->
249+
<!-- <template #tooltip-node="{ node }">
250250
{{ node }}
251251
</template> -->
252252
<!-- <template #free-node-label="{ node, orientation }">

src/components/vue-ui-dag.vue

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,50 @@ defineExpose({
11671167
:style="{
11681168
cursor: FINAL_CONFIG.style.chart.nodes.tooltip.showOnClick ? 'pointer' : 'default'
11691169
}"
1170-
/>
1170+
/>
1171+
</template>
1172+
1173+
<!-- Full `node` slot to customize the node entirely using a div -->
1174+
<foreignObject
1175+
v-if="$slots.node"
1176+
:x="node.x - node.width / 2"
1177+
:y="node.y - node.height / 2"
1178+
:width="node.width"
1179+
:height="node.height"
1180+
>
1181+
<slot name="node" v-bind="{ node, orientation: direction }"/>
1182+
</foreignObject>
1183+
</g>
1184+
</g>
1185+
1186+
<!-- Edge arrows -->
1187+
<g class="vue-ui-dag-edges">
1188+
<path
1189+
v-for="edge in layoutData.edges"
1190+
:key="edge.id"
1191+
:d="edge.pathData"
1192+
fill="none"
1193+
stroke="transparent"
1194+
:stroke-width="FINAL_CONFIG.style.chart.edges.strokeWidth * ((edge.from === highlightedNodeId || edge.id === tooltipEdge?.id) ? 1.3 : 1)"
1195+
stroke-linecap="round"
1196+
stroke-linejoin="round"
1197+
:marker-end="layoutData.arrowShape === 'undirected'
1198+
? null
1199+
: `url(#${makeMarkerId(edge.original?.color || FINAL_CONFIG.style.chart.edges.stroke)})`"
1200+
style="pointer-events: none; transition: stroke-width 0.2s ease-in-out"
1201+
/>
1202+
</g>
1203+
1204+
<!-- Node labels (last layer to overlap edges when offset is applied) -->
1205+
<g class="vue-ui-dag-node-labels">
1206+
<g
1207+
v-for="node in layoutData.nodes"
1208+
:key="node.id"
1209+
@click.stop="FINAL_CONFIG.style.chart.nodes.tooltip.showOnClick && showNodeTooltip(node)"
1210+
@mouseenter="highlightedNodeId = node.id"
1211+
@mouseleave="highlightedNodeId = null"
1212+
>
1213+
<template v-if="!$slots['free-node-label']">
11711214
<!-- with `node-label` slot -->
11721215
<text
11731216
v-if="$slots['node-label']"
@@ -1186,7 +1229,7 @@ defineExpose({
11861229
<!-- default label, multiline when provided with /n -->
11871230
<text
11881231
data-cy-node-label
1189-
v-else-if="!$slots['free-node-label']"
1232+
v-else-if="!$slots['free-node-label'] && !$slots.node"
11901233
:x="node.x"
11911234
:y="node.y + FINAL_CONFIG.style.chart.nodes.labels.fontSize / 3"
11921235
text-anchor="middle"
@@ -1208,38 +1251,9 @@ defineExpose({
12081251
<g v-if="$slots['free-node-label']">
12091252
<slot name="free-node-label" v-bind="{ node, layoutData, orientation: direction }"/>
12101253
</g>
1211-
1212-
<!-- Full `node` slot to customize the node entirely using a div -->
1213-
<foreignObject
1214-
v-if="$slots.node"
1215-
:x="node.x - node.width / 2"
1216-
:y="node.y - node.height / 2"
1217-
:width="node.width"
1218-
:height="node.height"
1219-
>
1220-
<slot name="node" v-bind="{ node, orientation: direction }"/>
1221-
</foreignObject>
12221254
</g>
12231255
</g>
12241256
1225-
<!-- Edge arrows -->
1226-
<g class="vue-ui-dag-edges">
1227-
<path
1228-
v-for="edge in layoutData.edges"
1229-
:key="edge.id"
1230-
:d="edge.pathData"
1231-
fill="none"
1232-
stroke="transparent"
1233-
:stroke-width="FINAL_CONFIG.style.chart.edges.strokeWidth * ((edge.from === highlightedNodeId || edge.id === tooltipEdge?.id) ? 1.3 : 1)"
1234-
stroke-linecap="round"
1235-
stroke-linejoin="round"
1236-
:marker-end="layoutData.arrowShape === 'undirected'
1237-
? null
1238-
: `url(#${makeMarkerId(edge.original?.color || FINAL_CONFIG.style.chart.edges.stroke)})`"
1239-
style="pointer-events: none; transition: stroke-width 0.2s ease-in-out"
1240-
/>
1241-
</g>
1242-
12431257
<slot name="svg" :svg="{
12441258
drawingArea: panZoomViewBox,
12451259
data: layoutData,

0 commit comments

Comments
 (0)