From a20c63ec33e85911654ecbf2cf6778c332c422ce Mon Sep 17 00:00:00 2001 From: chengweiw Date: Mon, 13 Oct 2025 11:31:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E6=96=87=E6=9C=AC=E4=BD=8D=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E8=B7=9F=E6=96=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/layout/custom/index.tsx | 3 --- .../src/pages/layout/default/index.tsx | 3 --- packages/layout/src/dagre.ts | 17 ++++++----------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/examples/feature-examples/src/pages/layout/custom/index.tsx b/examples/feature-examples/src/pages/layout/custom/index.tsx index f2868b764..433903762 100644 --- a/examples/feature-examples/src/pages/layout/custom/index.tsx +++ b/examples/feature-examples/src/pages/layout/custom/index.tsx @@ -31,9 +31,6 @@ const config: Partial = { stopScrollGraph: false, stopZoomGraph: false, stopMoveGraph: true, - textEdit: false, - nodeTextEdit: false, - edgeTextEdit: false, keyboard: { enabled: true, }, diff --git a/examples/feature-examples/src/pages/layout/default/index.tsx b/examples/feature-examples/src/pages/layout/default/index.tsx index 953dacca3..daa34af47 100644 --- a/examples/feature-examples/src/pages/layout/default/index.tsx +++ b/examples/feature-examples/src/pages/layout/default/index.tsx @@ -31,9 +31,6 @@ const config: Partial = { stopScrollGraph: false, stopZoomGraph: false, stopMoveGraph: true, - textEdit: false, - nodeTextEdit: false, - edgeTextEdit: false, keyboard: { enabled: true, }, diff --git a/packages/layout/src/dagre.ts b/packages/layout/src/dagre.ts index abc093d1b..c2deaa947 100644 --- a/packages/layout/src/dagre.ts +++ b/packages/layout/src/dagre.ts @@ -153,6 +153,9 @@ export class Dagre { delete lfEdge.pointsList delete lfEdge.startPoint delete lfEdge.endPoint + if (lfEdge.text && lfEdge.text.value) { + lfEdge.text = lfEdge.text.value + } } else { // 默认锚点,重新计算路径以及边的起点和终点(节点默认锚点为上下左右) delete lfEdge.pointsList @@ -173,17 +176,9 @@ export class Dagre { const last = lfEdge.pointsList[lfEdge.pointsList.length - 1] lfEdge.startPoint = { x: first.x, y: first.y } lfEdge.endPoint = { x: last.x, y: last.y } - - // 调整边标签位置 - if (lfEdge.text && lfEdge.text.value) { - lfEdge.text = { - x: last.x - this.getBytesLength(lfEdge.text.value) * 6 - 10, - y: last.y, - value: lfEdge.text.value, - } - } - } else if (lfEdge.text && lfEdge.text.value) { - // 没有自定义路径时保留文本内容 + } + if (lfEdge.text && lfEdge.text.value) { + // 保留文本内容 lfEdge.text = lfEdge.text.value } }