Recursive ID updating implemented on nodes
This commit is contained in:
parent
dbc3eaa673
commit
46c538c4a7
1 changed files with 21 additions and 4 deletions
|
|
@ -427,6 +427,26 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
let newId = getNodeId(node.data.type);
|
let newId = getNodeId(node.data.type);
|
||||||
idsMap[node.id] = newId;
|
idsMap[node.id] = newId;
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
..._.cloneDeep(node.data),
|
||||||
|
id: newId,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (data.node?.flow) {
|
||||||
|
let internNodes = [];
|
||||||
|
data.node.flow.data!.nodes.map((node) => {
|
||||||
|
internNodes = updateNodeId(
|
||||||
|
node,
|
||||||
|
idsMap,
|
||||||
|
internNodes,
|
||||||
|
insidePosition,
|
||||||
|
minimumX,
|
||||||
|
minimumY
|
||||||
|
);
|
||||||
|
});
|
||||||
|
data.node.flow.data!.nodes = internNodes;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a new node object
|
// Create a new node object
|
||||||
const newNode: NodeType = {
|
const newNode: NodeType = {
|
||||||
id: newId,
|
id: newId,
|
||||||
|
|
@ -435,10 +455,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
x: insidePosition.x + node.position!.x - minimumX,
|
x: insidePosition.x + node.position!.x - minimumX,
|
||||||
y: insidePosition.y + node.position!.y - minimumY,
|
y: insidePosition.y + node.position!.y - minimumY,
|
||||||
},
|
},
|
||||||
data: {
|
data,
|
||||||
..._.cloneDeep(node.data),
|
|
||||||
id: newId,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add the new node to the list of nodes in state
|
// Add the new node to the list of nodes in state
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue