Upgrade to 2.0.3

pull/400/head
Xin Yao 4 years ago
parent 2b572ca409
commit 2009a0d1ef
  1. 3
      CHANGELOG.md
  2. 29
      lib/src/widgets/cursor.dart
  3. 6
      lib/src/widgets/text_line.dart
  4. 2
      pubspec.yaml

@ -1,3 +1,6 @@
## [2.0.3]
* Fix cursor when line contains image.
## [2.0.2] ## [2.0.2]
* Address KeyboardListener class name conflict. * Address KeyboardListener class name conflict.

@ -245,24 +245,21 @@ class CursorPainter {
/// Paints cursor on [canvas] at specified [position]. /// Paints cursor on [canvas] at specified [position].
/// [offset] is global top left (x, y) of text line /// [offset] is global top left (x, y) of text line
/// [position] is relative (x) in text line /// [position] is relative (x) in text line
void paint(Canvas canvas, Offset offset, TextPosition position, bool lineHasEmbed) { void paint(
var caretOffset = Canvas canvas, Offset offset, TextPosition position, bool lineHasEmbed) {
editable!.getOffsetForCaret(position, prototype) + offset; // relative (x, y) to global offset
if (lineHasEmbed) { var relativeCaretOffset = editable!.getOffsetForCaret(position, prototype);
// relative (x, y) to global offset if (lineHasEmbed && relativeCaretOffset == Offset.zero) {
var relativeCaretOffset = editable!.getOffsetForCaret(position, prototype); relativeCaretOffset = editable!.getOffsetForCaret(
if (relativeCaretOffset == Offset.zero) { TextPosition(
relativeCaretOffset = editable!.getOffsetForCaret( offset: position.offset - 1, affinity: position.affinity),
TextPosition( prototype);
offset: position.offset - 1, affinity: position.affinity), // Hardcoded 6 as estimate of the width of a character
prototype); relativeCaretOffset =
// Hardcoded 6 as estimate of the width of a character Offset(relativeCaretOffset.dx + 6, relativeCaretOffset.dy);
relativeCaretOffset =
Offset(relativeCaretOffset.dx + 6, relativeCaretOffset.dy);
}
caretOffset = relativeCaretOffset + offset;
} }
final caretOffset = relativeCaretOffset + offset;
var caretRect = prototype.shift(caretOffset); var caretRect = prototype.shift(caretOffset);
if (style.offset != null) { if (style.offset != null) {
caretRect = caretRect.shift(style.offset!); caretRect = caretRect.shift(style.offset!);

@ -847,12 +847,14 @@ class RenderEditableTextLine extends RenderEditableBox {
} }
} }
void _paintCursor(PaintingContext context, Offset effectiveOffset, bool lineHasEmbed) { void _paintCursor(
PaintingContext context, Offset effectiveOffset, bool lineHasEmbed) {
final position = TextPosition( final position = TextPosition(
offset: textSelection.extentOffset - line.documentOffset, offset: textSelection.extentOffset - line.documentOffset,
affinity: textSelection.base.affinity, affinity: textSelection.base.affinity,
); );
_cursorPainter.paint(context.canvas, effectiveOffset, position, lineHasEmbed); _cursorPainter.paint(
context.canvas, effectiveOffset, position, lineHasEmbed);
} }
@override @override

@ -1,6 +1,6 @@
name: flutter_quill name: flutter_quill
description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us) description: A rich text editor supporting mobile and web (Demo App @ bulletjournal.us)
version: 2.0.2 version: 2.0.3
#author: bulletjournal #author: bulletjournal
homepage: https://bulletjournal.us/home/index.html homepage: https://bulletjournal.us/home/index.html
repository: https://github.com/singerdmx/flutter-quill repository: https://github.com/singerdmx/flutter-quill

Loading…
Cancel
Save