antvis / X6

🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
https://x6.antv.antgroup.com
MIT License
5.79k stars 1.71k forks source link

复制粘贴父节点,父节点的children只有一个 #3876

Open blank-peas opened 1 year ago

blank-peas commented 1 year ago

Describe the bug

如下图可看:两个子节点的parentID都指向一个父id,但是父节点的children数组只有一个节点

image

Your Example Website or App

内部系统

Steps to Reproduce the Bug or Issue

// 复制
graph.bindKey(['ctrl+c', 'command+c'], () => {
  const cells = graph.getSelectedCells();
  if (cells.length) {
    for (let i = 0; i < cells.length; i++) {
      const parentId = cells[i].parent?.id;
      if (parentId && parentId !== 'wrapper-node') {
        const parent = graph.getCellById(parentId);
        cells.push(parent);
      }
    }
    graph.copy(cells, {
      deep: true,
    });
  }
  return false;
});

graph.bindKey(['ctrl+v', 'command+v'], () => {
  if (!graph.isClipboardEmpty()) {
    const cells = graph.paste({ offset: 32 });
    graph.cleanSelection();
    graph.select(cells);
  }
  return false;
});

Expected behavior

期待复制父节点后,对应的children数组可以全部对应

Screenshots or Videos

No response

Platform

Additional context

No response

x6-bot[bot] commented 1 year ago

👋 @blank-peas

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

qiufeihong2018 commented 1 year ago

@blank-peas 有没有可以复现的demo?