From fe2790fb684526ae121b9cacf2fd90c2375fc2d6 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Thu, 11 Aug 2022 11:49:54 +0800 Subject: [PATCH] fix: #811 The height of selection areas in same line is not same. --- .../lib/src/render/rich_text/flowy_rich_text.dart | 2 ++ .../lib/src/render/rich_text/rich_text_style.dart | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/flowy_rich_text.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/flowy_rich_text.dart index 01949aa99c..bdfae73d66 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/flowy_rich_text.dart +++ b/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/flowy_rich_text.dart @@ -174,6 +174,8 @@ class _FlowyRichTextState extends State with Selectable { final textSpan = _textSpan; return RichText( key: _textKey, + textHeightBehavior: const TextHeightBehavior( + applyHeightToFirstAscent: false, applyHeightToLastDescent: false), text: widget.textSpanDecorator != null ? widget.textSpanDecorator!(textSpan) : textSpan, diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/rich_text_style.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/rich_text_style.dart index c924709948..4ac2adc39f 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/src/render/rich_text/rich_text_style.dart +++ b/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) {