LogicFlow icon indicating copy to clipboard operation
LogicFlow copied to clipboard

分组复制粘贴边相关问题修复

Open ZivvW opened this issue 8 months ago • 3 comments

修复问题

  1. 分组复制时内部的边丢失 chrome-capture-2025-5-9

  2. 边复制后因为 anchorId 未更新导致调整边(adjustEdgeStartAndEnd)时报错 chrome-capture-2025-5-13

改动说明

原先复制粘贴是用的 lf.addElements 。该方法用来添加元素,为了适配复制粘贴逻辑而添加了相关的处理如 nodeIdMap、distance(未使用)。

问题:其通过 nodeIdMap 处理了复制后边的 sourceNodeId 、targetNodeId,但未处理 sourceAnchorId、targetAnchorId。

添加 anchorId 相关逻辑时发现这些处理仅针对复制场景,共用同一个方法不太好,故拆分了原来的 addElements。 addElements 只用来做添加相关的,复制粘贴使用新方法 cloneElements。

ZivvW avatar May 13 '25 08:05 ZivvW

⚠️ No Changeset found

Latest commit: b775d596647f256b540ed6117b5ee0810d530f20

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

changeset-bot[bot] avatar May 13 '25 08:05 changeset-bot[bot]

巧了,刚好最近收到了个和这块逻辑相关的case: #2157 我理解可以合并一起考虑优化方案

DymoneLewis avatar May 21 '25 06:05 DymoneLewis

巧了,刚好最近收到了个和这块逻辑相关的case: #2157 我理解可以合并一起考虑优化方案

看了下 #2157 的问题。在引入 dynamic-group 插件后,有文字的 edge 会触发 dynamic-group 里重写的 addElements 的这段逻辑: https://github.com/didi/LogicFlow/blob/6bce368f3e10dcd430edfa3cb4ad1ac7f39f44cc/packages/extension/src/dynamic-group/index.ts#L550C1-L552C6 因为复制粘贴的快捷键那里已经做过位移了,所以这里会让 edge 额外移动 40

这个 PR 里统一了位移逻辑(移除了快捷键那的位移,统一由 LF 上的方法进行移动),应该是已经修复了这个问题。 chrome-capture-2025-5-21

ZivvW avatar May 21 '25 08:05 ZivvW