|
1 | 1 | import { generateUUID, getArrowPoints, getObjById, getOffsetLT, setAttributes } from './utils/index' |
2 | 2 | import LinkDragMoveHelper from './utils/LinkDragMoveHelper' |
3 | | -import { createSvgGroup, editSvgText, svgNS } from './utils/svg' |
| 3 | +import { createSvgGroup, createSvgText, editSvgText, svgNS } from './utils/svg' |
4 | 4 | import type { CustomSvg, Topic } from './types/dom' |
5 | 5 | import type { MindElixirInstance, Uid } from './index' |
6 | 6 |
|
@@ -243,19 +243,6 @@ function calcP(data: DivData) { |
243 | 243 | } |
244 | 244 | } |
245 | 245 |
|
246 | | -const createText = function (string: string, x: number, y: number, color?: string) { |
247 | | - const text = document.createElementNS(svgNS, 'text') |
248 | | - setAttributes(text, { |
249 | | - 'text-anchor': 'middle', |
250 | | - x: x + '', |
251 | | - y: y + '', |
252 | | - fill: color || 'rgb(235, 95, 82)', |
253 | | - }) |
254 | | - text.dataset.type = 'custom-link' |
255 | | - text.innerHTML = string |
256 | | - return text |
257 | | -} |
258 | | - |
259 | 246 | /** |
260 | 247 | * FYI |
261 | 248 | * p1: start point |
@@ -291,7 +278,11 @@ const drawArrow = function (mei: MindElixirInstance, from: Topic, to: Topic, obj |
291 | 278 | // Use extracted common function to calculate midpoint |
292 | 279 | const { x: halfx, y: halfy } = calcBezierMidPoint(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) |
293 | 280 | const labelColor = obj.style?.labelColor |
294 | | - const label = createText(obj.label, halfx, halfy, labelColor) |
| 281 | + const label = createSvgText(obj.label, halfx, halfy, { |
| 282 | + anchor: 'middle', |
| 283 | + color: labelColor, |
| 284 | + dataType: 'custom-link', |
| 285 | + }) |
295 | 286 | newSvgGroup.appendChild(label) |
296 | 287 | newSvgGroup.label = label |
297 | 288 |
|
|
0 commit comments