executeHandleEnter function
Handles the ENTER key.
- Paragraphs: creates a new paragraph below or splits content if in the middle
- Cells: creates a new fragment with line break or new row if at the end
- Lists: creates a new list item
Implementation
bool executeHandleEnter(FluentDocument document) {
if (document.registry.dispatchEnter(document)) return true;
final cursor = document.cursor;
if (!cursor.isCollapsed) {
executeHandleReplaceSelection('', document);
}
final container = document.findLogicalContainerCached(cursor.anchorId);
if (container == null) return false;
if (container is Link) {
return _handleLinkEnter(document, container);
}
if (container is Paragraph) {
final ancestorItem = findAncestorCached<ListItem>(document, container);
if (ancestorItem != null) {
return _handleListEnter(document, ancestorItem, container);
}
final ancestorCell = findAncestorCached<FluentCell>(document, container);
if (ancestorCell != null) {
return _handleCellEnter(document, ancestorCell);
}
}
return _handleParagraphEnter(document, container);
}