Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: the height of the selection rects in same line is not same
Lucas.Xu9b00a25004ea
diff --git a/frontend/app_flowy/packages/flowy_editor/example/lib/main.dart b/frontend/app_flowy/packages/flowy_editor/example/lib/main.dartindex 5db7288c76..19c732f6a0 100644--- a/frontend/app_flowy/packages/flowy_editor/example/lib/main.dart+++ b/frontend/app_flowy/packages/flowy_editor/example/lib/main.dart@@ -21,7 +21,6 @@ class MyApp extends StatelessWidget {@overrideWidget build(BuildContext context) {return MaterialApp(- title: 'Flutter Demo',theme: ThemeData(// This is the theme of your application.//@@ -64,11 +63,6 @@ class _MyHomePageState extends State<MyHomePage> {@overrideWidget build(BuildContext context) {return Scaffold(- appBar: AppBar(- // Here we take the value from the MyHomePage object that was created by- // the App.build method, and use it to set our appbar title.- title: Text(widget.title),- ),body: _buildBody(),floatingActionButton: _buildExpandableFab(),);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.dartindex fb0009ad73..01949aa99c 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@@ -1,3 +1,5 @@+import 'dart:ui';+import 'package:flutter/material.dart';import 'package:flutter/rendering.dart';@@ -17,7 +19,7 @@ class FlowyRichText extends StatefulWidget {const FlowyRichText({Key? key,this.cursorHeight,- this.cursorWidth = 2.0,+ this.cursorWidth = 1.0,this.textSpanDecorator,this.placeholderText = ' ',this.placeholderTextSpanDecorator,@@ -41,7 +43,8 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {final _textKey = GlobalKey();final _placeholderTextKey = GlobalKey();- final lineHeight = 1.5;+ final _lineHeight = 1.5;+ double? _cursorHeight;RenderParagraph get _renderParagraph =>_textKey.currentContext?.findRenderObject() as RenderParagraph;@@ -54,6 +57,13 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {return _buildRichText(context);}+ @override+ void didUpdateWidget(covariant FlowyRichText oldWidget) {+ super.didUpdateWidget(oldWidget);++ _cursorHeight = null;+ }+@overridePosition start() => Position(path: widget.textNode.path, offset: 0);@@ -66,7 +76,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {final textPosition = TextPosition(offset: position.offset);final cursorOffset =_renderParagraph.getOffsetForCaret(textPosition, Rect.zero);- final cursorHeight = widget.cursorHeight ??+ _cursorHeight ??= widget.cursorHeight ??_renderParagraph.getFullHeightForCaret(textPosition) ??_placeholderRenderParagraph.getFullHeightForCaret(textPosition) ??18.0; // default height@@ -74,7 +84,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {cursorOffset.dx - (widget.cursorWidth / 2),cursorOffset.dy,widget.cursorWidth,- cursorHeight,+ _cursorHeight!,);}@@ -105,7 +115,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {extentOffset: selection.end.offset,);return _renderParagraph- .getBoxesForSelection(textSelection)+ .getBoxesForSelection(textSelection, boxHeightStyle: BoxHeightStyle.max).map((box) => box.toRect()).toList();}@@ -147,7 +157,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {? Colors.transparent: Colors.grey,fontSize: baseFontSize,- height: lineHeight,+ height: _lineHeight,),),],@@ -203,7 +213,7 @@ class _FlowyRichTextState extends State<FlowyRichText> with Selectable {.map((insert) => RichTextStyle(attributes: insert.attributes ?? {},text: insert.content,- height: lineHeight,+ height: _lineHeight,).toTextSpan()).toList(growable: false),);