From 7258ed9ea7d09af02513b8abd0bf0f3f19f2f30e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Fri, 22 Nov 2024 16:51:56 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=A4=84=E7=90=86=E8=8A=82=E7=82=B9=E8=BF=9E?= =?UTF-8?q?=E7=BA=BF=E5=85=83=E7=B4=A0=E7=9A=84=E5=AE=9E=E4=BE=8B=E5=8C=96?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/constants/defaultOptions.js | 2 ++ simple-mind-map/src/core/render/node/Style.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 028201ed..3fd7be06 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -263,6 +263,8 @@ export const defaultOpt = { minNodeTextModifyWidth: 20, // 同minNodeTextModifyWidth,最大值,传-1代表不限制 maxNodeTextModifyWidth: -1, + // 自定义处理节点的连线方法,可以传递一个函数,函数接收三个参数:node(节点实例)、line(节点的某条连线,@svgjs库的path对象), { width, color, dasharray },dasharray(该条连线的虚线样式,为none代表实线),你可以修改line对象来达到修改节点连线样式的效果,比如增加流动效果 + customHandleLine: null, // 【Select插件】 // 多选节点时鼠标移动到边缘时的画布移动偏移量 diff --git a/simple-mind-map/src/core/render/node/Style.js b/simple-mind-map/src/core/render/node/Style.js index 8fc9d70d..ecd3d89d 100644 --- a/simple-mind-map/src/core/render/node/Style.js +++ b/simple-mind-map/src/core/render/node/Style.js @@ -278,6 +278,10 @@ class Style { // 连线 line(line, { width, color, dasharray } = {}, enableMarker, childNode) { + const { customHandleLine } = this.ctx.mindMap.opt + if (typeof customHandleLine === 'function') { + customHandleLine(this.ctx, line, { width, color, dasharray }) + } line.stroke({ color, dasharray, width }).fill({ color: 'none' }) // 可以显示箭头 if (enableMarker) {