From c7be3a31a1cdbff025d49c36dd6f0064799171c2 Mon Sep 17 00:00:00 2001 From: Andy Trand Date: Tue, 22 Feb 2022 18:15:00 +0200 Subject: [PATCH] added selection change callback (#683) --- lib/src/widgets/controller.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/widgets/controller.dart b/lib/src/widgets/controller.dart index 16506c10..f9447c0e 100644 --- a/lib/src/widgets/controller.dart +++ b/lib/src/widgets/controller.dart @@ -23,6 +23,7 @@ class QuillController extends ChangeNotifier { this.onReplaceText, this.onDelete, this.onSelectionCompleted, + this.onSelectionChanged, }) : _selection = selection, _keepStyleOnNewLine = keepStyleOnNewLine; @@ -52,6 +53,7 @@ class QuillController extends ChangeNotifier { DeleteCallback? onDelete; void Function()? onSelectionCompleted; + void Function(TextSelection textSelection)? onSelectionChanged; /// Store any styles attribute that got toggled by the tap of a button /// and that has not been applied yet. @@ -328,6 +330,7 @@ class QuillController extends ChangeNotifier { baseOffset: math.min(selection.baseOffset, end), extentOffset: math.min(selection.extentOffset, end)); toggledStyle = Style(); + onSelectionChanged?.call(textSelection); } /// Given offset, find its leaf node in document