I tried to remove the links, first. And then, the elements, as below:
var links = graph.getLinks();
for(i = 0; i < links.length; i++) {
links[i].remove();
}
var elements = graph.getElements();
for(i = 0 ; i < elements.length ; i++) {
elements[i].remove();
}
the links get deleted and then in the second loop some elements also get deleted.
The elements that are connected/linked with other elements fail to delete.
I have also tried to delete the dependent elements first by looping the element from revers order, as below:
var elements = graph.getElements();
for(i = elements.length -1 ; i >= 0; i--) {
elements[i].remove();
}
But this also fails to delete the parent element.(even though the links and dependent elements are already deleted)
And the error message is same as ever : "TypeError: Cannot read property 'unembed' of undefined"
Thanks with best Regards,
Puneet.