-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
复制粘贴插件——自定义粘贴节点id #3736
Comments
Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. |
自定义粘贴节点会涉及到以下内容变更:
|
目前使用插件,复制选中内容(包括节点和边)后获取粘贴板中的元素没有边,但实际粘贴效果显示会出现边。粘贴时需要获取边,来更新节点连接关系,目前没有办法实现。 |
@ShirlyKong 粘贴板中是可以获取到边的,如果没有获取的话,提供一个可以复现的 demo 看下。 |
感谢回答,已找到问题原因。 通过graph.getCellsInClipboard()获取元素确实包括了边,之前是直接通过graph.getSelectedCells()获取的待粘贴元素是不包含edge的,而且框选中也确实不会选中边即使设置了showEdgeSelectionBox: true。 |
可以考虑这么搞,监听 node:added 事件,检测到新添加节点的时候检查这个节点的id,如果id的格式不是你要的(那就是x6自动生成的),那么就调用undo撤销这个复制的节点,复制这个节点数据并且设置id为你自己的id生成方式,然后graph.addNode添加你自己这个新的node数据 |
嗯嗯。也可以监听node:added后直接调用updateCellId去更新ID😋 |
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. |
功能描述
场景中需要对节点的id进行定制,如节点id为 base_123 ,不包含 -
希望在粘贴节点的时候可以自定义节点id,从而进行分类或满足节点id要求,如粘贴的节点id为base_456
期望解决方案
graph.paste({
id: 'base_456'
offset: {
dx: 200,
dy: 0,
},
});
The text was updated successfully, but these errors were encountered: