Skip to content

Conversation

@z-pangolin
Copy link
Collaborator

@z-pangolin z-pangolin commented Dec 8, 2025

  1. fix:目前将连线拖动到节点释放后会连接最近的锚点,如何禁用此功能 #810
    解决方案: 提供anchorOnlyConnectValidate配置,默认值为false。当设置为true时,禁用拖动锚点到节点中会不断触发校验规则的现象,变成只有拖动到锚点附近时才会触发校验规则。具体使用如下
    lf.updateEditConfig({ anchorOnlyConnectValidate: true }) // 默认值为false

  2. fix:[Feature] 在手动连接2个节点,在目标节点上释放时,需要能让业务代码有机会来决定连接到哪个锚点 #791
    解决方案: 支持用户自定义锚点连接指向,也提供了setTargetAnchorId方法支持用户直接使用。当两者同时存在时优先使用传入的自定义函数实现锚点连接指向。两个方法的具体使用如下:

    • 调用setTargetAnchorId方法设置连接锚点,第一个参数是想改变锚点连接指向的节点,第二个参数是你想要指向锚点的id,当不传递第二个参数时,则代表着删除nodeid设置的对应连接锚点,恢复默认行为

      //设置连接锚点(nodeId -> anchorId)
      BaseEdgeModel.setTargetAnchorId(nodeId,'AnchorId')
      
      //取消设置,恢复默认行为
      BaseEdgeModel.setTargetAnchorId(nodeId)
      
    • 自定义锚点指向,在节点上添加customTargetAnchor方法,用户没有传递时,则默认连接最近的锚点

      const node = lf.graphModel.getNodeModelById(nodeId) //获取目标节点
      
      //不依赖锚点id,永远连接最左侧锚点
      node.customTargetAnchor = (position, nodeModel) => {
        const anchors = nodeModel.getAnchorsByOffset()
        let idx = 0
        for (let i = 1; i < anchors.length; i++) {
          if (anchors[i].x < anchors[idx].x) idx = i
        }
        return { index: idx, anchor: anchors[idx] }
      }
      
  3. [Bug report]自动插入节点功能,使用addEdge绘制的连线上无法触发自动插入节点功能 #723
    解决方案: 当插入节点时,允许一定误差,节点锚点没有严格对齐连线也可以插入进连线里,并且会连接到最近的锚点

@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

⚠️ No Changeset found

Latest commit: f98bb5d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant