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

This commit is contained in:
Lucas.Xu 2022-08-11 11:49:54 +08:00
parent 9b00a25004
commit fe2790fb68
2 changed files with 3 additions and 11 deletions

View File

@ -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,

View File

@ -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) {