|
@@ -1,3 +1,5 @@
|
|
|
|
+import 'dart:math';
|
|
|
|
+
|
|
import 'package:example/plugin/debuggable_rich_text.dart';
|
|
import 'package:example/plugin/debuggable_rich_text.dart';
|
|
import 'package:flowy_editor/flowy_editor.dart';
|
|
import 'package:flowy_editor/flowy_editor.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
@@ -108,6 +110,30 @@ class _SelectedTextNodeWidgetState extends State<_SelectedTextNodeWidget>
|
|
return _renderParagraph.localToGlobal(offset);
|
|
return _renderParagraph.localToGlobal(offset);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @override
|
|
|
|
+ Offset getLeftOfOffset() {
|
|
|
|
+ final textSelection = _textSelection;
|
|
|
|
+ if (textSelection != null) {
|
|
|
|
+ final leftTextSelection = TextSelection.collapsed(
|
|
|
|
+ offset: max(0, textSelection.baseOffset - 1),
|
|
|
|
+ );
|
|
|
|
+ return getOffsetByTextSelection(leftTextSelection);
|
|
|
|
+ }
|
|
|
|
+ return Offset.zero;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ Offset getRightOfOffset() {
|
|
|
|
+ final textSelection = _textSelection;
|
|
|
|
+ if (textSelection != null) {
|
|
|
|
+ final leftTextSelection = TextSelection.collapsed(
|
|
|
|
+ offset: min(node.toRawString().length, textSelection.extentOffset + 1),
|
|
|
|
+ );
|
|
|
|
+ return getOffsetByTextSelection(leftTextSelection);
|
|
|
|
+ }
|
|
|
|
+ return Offset.zero;
|
|
|
|
+ }
|
|
|
|
+
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
Widget richText;
|
|
Widget richText;
|
|
@@ -117,6 +143,10 @@ class _SelectedTextNodeWidgetState extends State<_SelectedTextNodeWidget>
|
|
richText = RichText(key: _textKey, text: node.toTextSpan());
|
|
richText = RichText(key: _textKey, text: node.toTextSpan());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (node.children.isEmpty) {
|
|
|
|
+ return richText;
|
|
|
|
+ }
|
|
|
|
+
|
|
return Column(
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
children: [
|