LogicFlow icon indicating copy to clipboard operation
LogicFlow copied to clipboard

[Feature]: 如何在贝塞尔曲线上的中间位置增加元素

Open AllenTank opened this issue 2 years ago • 1 comments

背景&目的

有需求需要在连线的中间位置增加一个button,用于删除连线

AllenTank avatar Aug 23 '24 08:08 AllenTank

🤔目前贝塞尔曲线在视图层是一条svg path画出来的曲线,所以目前只能在svg上层加按钮 大概思路是这样: 监听edge:click事件 -> 从触发返回的data数据里取出id -> lf.getModelById(id).textPosition 获取文本位置(一般贝塞尔曲线的文本也是放在中间)-> 加button(这里的实现有两个选择:

  1. 业务组件中实现 1.1 获取画布DOM的位置(x1, y1) 1.2 调用lf.graphModel.transformModel.CanvasPointToHtmlPoint([textPosition.x, textPosition.y])计算当前边中心相对画布DOM的偏移位置(x2, y2) 1.3 (x1, y1) (x2, y2)相加获得 边中心在屏幕上的位置(x3, y3) 1.4 在(x3, y3)这个点上增加按钮
  2. 自定义插件实现:可以参考官网自定义插件实现https://site.logic-flow.cn/tutorial/extension/custom

DymoneLewis avatar Sep 11 '24 03:09 DymoneLewis