diff --git a/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart b/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart index 1f321e937a..bafe106f27 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/document/node_iterator.dart @@ -43,7 +43,7 @@ class NodeIterator implements Iterator { if (nextOfParent == null) { _currentNode = null; } else { - _currentNode = _findLeadingChild(node); + _currentNode = _findLeadingChild(nextOfParent); } } diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart index 065ae8b595..5c02955d7b 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/render/rich_text/checkbox_text.dart @@ -110,11 +110,17 @@ class _CheckboxNodeWidgetState extends State .map( (child) => widget.editorState.service.renderPluginService .buildPluginWidget( - NodeWidgetContext( - context: context, - node: child, - editorState: widget.editorState, - ), + child is TextNode + ? NodeWidgetContext( + context: context, + node: child, + editorState: widget.editorState, + ) + : NodeWidgetContext( + context: context, + node: child, + editorState: widget.editorState, + ), ), ) .toList(), diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart index 95c158f3ee..a1506bf140 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/service/selection_service.dart @@ -527,6 +527,7 @@ class _FlowySelectionState extends State /// currently only single-level nesting is supported // find the first node's rect.bottom <= offset.dy Node _lowerBound(List sortedNodes, Offset offset, int start, int end) { + assert(start >= 0 && end < sortedNodes.length); var min = start; var max = end; while (min <= max) { @@ -537,7 +538,12 @@ class _FlowySelectionState extends State max = mid - 1; } } - return sortedNodes[min]; + final node = sortedNodes[min]; + if (node.children.isNotEmpty && node.children.first.rect.top <= offset.dy) { + final children = node.children.toList(growable: false); + return _lowerBound(children, offset, 0, children.length - 1); + } + return node; } /// TODO: Supports multi-level nesting, @@ -549,6 +555,7 @@ class _FlowySelectionState extends State int start, int end, ) { + assert(start >= 0 && end < sortedNodes.length); var min = start; var max = end; while (min <= max) { @@ -559,7 +566,12 @@ class _FlowySelectionState extends State max = mid - 1; } } - return sortedNodes[max]; + final node = sortedNodes[max]; + if (node.children.isNotEmpty && node.children.first.rect.top <= offset.dy) { + final children = node.children.toList(growable: false); + return _lowerBound(children, offset, 0, children.length - 1); + } + return node; } }