Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ZivvW
Copy link
Contributor

@ZivvW ZivvW commented May 13, 2025

修复问题

  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。

Copy link

changeset-bot bot commented May 13, 2025

⚠️ No Changeset found

Latest commit: b775d59

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

@DymoneLewis
Copy link
Collaborator

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

@DymoneLewis DymoneLewis requested a review from boyongjiong May 21, 2025 06:24
@ZivvW
Copy link
Contributor Author

ZivvW commented May 21, 2025

巧了,刚好最近收到了个和这块逻辑相关的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

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.

2 participants