Skip to content
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

node/edge clone的时候 如何使用自定义id? #3011

Closed
cuidong626 opened this issue Dec 7, 2022 · 8 comments
Closed

node/edge clone的时候 如何使用自定义id? #3011

cuidong626 opened this issue Dec 7, 2022 · 8 comments
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions

Comments

@cuidong626
Copy link
Contributor

功能描述

cell 构造函数会判断id是开发配置还是采用uuid,但是调用 clone 方法的时候就没办法自定义了。
希望提供一个机制,可以自己根据业务规则创建 id
image
image

期望解决方案

node/edge 使用 clone 方法的时候 可以自定义的 id
希望提供一个机制,可以自己根据业务规则创建id

@NewByVector
Copy link
Contributor

这个的场景是什么呢?

@NewByVector NewByVector added the type: discussion 讨论 Usage questions, guidance, and other discussions label Dec 7, 2022
@cuidong626
Copy link
Contributor Author

这个的场景是什么呢?

复制节点的时候,我看会调用clone方法

@NewByVector
Copy link
Contributor

如果是复制粘贴场景,提供一个思路:可以在粘贴后使用 graph.updateCellId 方法来修改节点的 ID。

@cuidong626
Copy link
Contributor Author

如果是复制粘贴场景,提供一个思路:可以在粘贴后使用 graph.updateCellId 方法来修改节点的 ID。

那我是不是可以直接监听cell:added 事件对这个Id的进行修改?

@NewByVector
Copy link
Contributor

@cuidong626 还是推荐粘贴方法执行后更新节点 id,因为与很多原因导致 cell:added 事件。

@cuidong626
Copy link
Contributor Author

我还是希望能提供一个机制,用于自己生成id,或者可不可以在cell里面写一个生成Id的方法,开发者通过原型链重写?就像 generatePortId这个方法一样

@NewByVector
Copy link
Contributor

@cuidong626 外部自定义 id 非常容易导致错误,比如 id 重复、id 匹配不上等。

@x6-bot
Copy link
Contributor

x6-bot bot commented Dec 9, 2023

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: discussion 讨论 Usage questions, guidance, and other discussions
Projects
None yet
Development

No branches or pull requests

2 participants