clearCellKeepingEmptyFragment function
Empties a cell by removing all children except an empty Paragraph. Maintains the table structure preserving at least one empty paragraph to allow the cursor to be positioned in the cell.
Implementation
void clearCellKeepingEmptyFragment(FluentCell cell, Root root) {
// Remove all existing children
final childrenToRemove = cell.children.toList();
for (final child in childrenToRemove) {
removeNode(root, child);
}
// Add an empty Paragraph to keep the cell "alive"
final emptyParagraph = Paragraph();
appendChild(cell, emptyParagraph);
}