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

[Bug Report]: 官网自定义节点demo的节点只能复制一次 #1791

Closed
DymoneLewis opened this issue Aug 20, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@DymoneLewis
Copy link
Collaborator

DymoneLewis commented Aug 20, 2024

发生了什么?

第一个节点复制以后,再去选中第二个节点复制,就复制不了
{B464B1B8-019F-8ECB-D6DD-E7CE888B4F80}

————————————2024.12.11 更新——————————————————
验证了一下,感觉是操作问题,如果没选中节点就复制粘贴的话确实就复制不了了

logicflow/core版本

1.2.28

logicflow/extension版本

1.2.28

logicflow/engine版本

No response

浏览器&环境

Chrome

@DymoneLewis DymoneLewis added the bug Something isn't working label Aug 20, 2024
@DymoneLewis DymoneLewis self-assigned this Aug 20, 2024
@Ari1c
Copy link

Ari1c commented Dec 5, 2024

@boyongjiong 问一下有没有类似 node 的复制方法,背景是我在编排 html 节点的时候里面可以设置全局变量,我想在用户复制的时候把复制 node 的全局变量也复制一份,这个有办法吗,有没有类似 lf.on("node:xxx(复制)", (node) => {}) 的方法

@DymoneLewis
Copy link
Collaborator Author

@boyongjiong 问一下有没有类似 node 的复制方法,背景是我在编排 html 节点的时候里面可以设置全局变量,我想在用户复制的时候把复制 node 的全局变量也复制一份,这个有办法吗,有没有类似 lf.on("node:xxx(复制)", (node) => {}) 的方法

🤔如果想要实现这样的效果,不用加"node:xxx(复制)"事件也能实现吧,因为cloneNode的逻辑其实就是这样

const targetNode = this.getNodeModelById(nodeId) // 根据ID找到对应的nodeModel
const data = targetNode?.getData() // 获取节点数据,里面会包括当前节点的id、坐标、文本、properties信息
if (data) {
data.x += 30 // 设置新节点的坐标位移以错开两个节点
data.y += 30
data.id = ''
if (typeof data.text === 'object' && data.text !== null) { // 如果有文本的话也更新一下文本年代坐标
  data.text.x += 30
  data.text.y += 30
}
const nodeModel = this.addNode(data) // 根据上面的数据创建新节点

所以如果要复制的话可以在执行cloneNode之前把当前节点的数据和全局变量存下来再复制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants