i wanna delete a node below the node i clicked where the scenario will be like the node will have two handle in the bottom of true and false where the true has separate nodes below it and the false also the same. if i click the node and say true handle means only the node and its child in true handle nodes must be deleted with edges but the false node child must be connected to the selected nodes parent node.
const onDeleteSave = () => {
const targetNode = flow.use.rfInstance!.getNode(nodeProps.id)!;
const edges = getConnectedEdges(
[targetNode],
flow.use.rfInstance!.getEdges(),
);
const sourceEdge = edges.find(e => e.target === nodeProps.id);
let path_id: string | [string, string] = '';
if (data?.settings) {
path_id = flow.use.toolBox!.getBinaryPathId(whichPath, data) as any;
}
const nodesInPath = (path: string | string[]) => {
return flow.use
.rfInstance!.getNodes()
.filter(n => {
if ('path_id' in n.data || 'routeId' in n.data) {
switch (typeof path) {
case 'string': {
if (n.data.path_id === path || n.data.routeId === path) {
return n;
}
break;
}
case 'object': {
if (
path.includes(n.data.path_id) ||
path.includes(n.data.routeId)
) {
return n;
}
break;
}
}
}
})
.map(n => n.id);
};
const whichNodeToConnect = nodesInPath(
flow.use.toolBox!.getBinaryPathId(
whichPath === 'true_path' ? 'false_path' : 'true_path',
data,
),
);
let nodeToConnect = {};
if (whichPath === 'both_path') {
nodeToConnect = whichNodeToConnect[whichNodeToConnect.length];
} else {
nodeToConnect = whichNodeToConnect[0]!;
}
const edgesToDeleteId = flow.use.toolBox!.getBinaryPathId(whichPath, data);
const edgesToDelete = flow.use.rfInstance
?.getEdges()
.filter(
e =>
edgesToDeleteId.includes(e.source) ||
edgesToDeleteId.includes(e.target),
);
flow.use.actions!.deleteAction({
data,
flow,
nextEdge: nodeToConnect as any,
nodeId: nodeProps.id,
flowId: param.id!,
type: 'binary',
nodeIds: nodesInPath(path_id)!,
path: whichPath,
});
};