clearCellKeepingEmptyFragment function

void clearCellKeepingEmptyFragment(
  1. FluentCell cell,
  2. Root root
)

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) {
  final childrenToRemove = cell.children.toList();
  for (final child in childrenToRemove) {
    removeNode(root, child);
  }

  final emptyParagraph = Paragraph();
  appendChild(cell, emptyParagraph);
}