Bläddra i källkod

fix: #811 The height of selection areas in same line is not same.

Lucas.Xu 2 år sedan
förälder
incheckning
fe2790fb68

+ 2 - 0
frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/flowy_rich_text.dart

@@ -174,6 +174,8 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {
     final textSpan = _textSpan;
     return RichText(
       key: _textKey,
+      textHeightBehavior: const TextHeightBehavior(
+          applyHeightToFirstAscent: false, applyHeightToLastDescent: false),
       text: widget.textSpanDecorator != null
           ? widget.textSpanDecorator!(textSpan)
           : textSpan,

+ 1 - 11
frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/rich_text_style.dart

@@ -192,17 +192,7 @@ class RichTextStyle {
   TextSpan toTextSpan() => _toTextSpan(height);
 
   double get topPadding {
-    if (height == 1.0) {
-      return 0;
-    }
-    // TODO: Need to be optimized.
-    final painter =
-        TextPainter(text: _toTextSpan(height), textDirection: TextDirection.ltr)
-          ..layout();
-    final basePainter =
-        TextPainter(text: _toTextSpan(null), textDirection: TextDirection.ltr)
-          ..layout();
-    return painter.height - basePainter.height;
+    return 0;
   }
 
   TextSpan _toTextSpan(double? height) {