cleanupEmptyInlineParents function
Removes empty Links and other inline wrappers that no longer contain any text fragments after a deletion.
Implementation
void cleanupEmptyInlineParents(Root root, FNode? node, {FluentDocument? document}) {
if (node == null) return;
if (node is Link && node.getChildren().isEmpty) {
final parent = document != null
? findParentCached(document, node)
: findParent(root, node);
removeNode(root, node);
if (parent != null) cleanupEmptyInlineParents(root, parent, document: document);
}
}