Selection completion customizable via callback

pull/576/head
frmatthew 3 years ago
parent 8d93bb821b
commit 3f1101e48b
  1. 7
      lib/src/widgets/controller.dart
  2. 2
      lib/src/widgets/raw_editor.dart

@ -20,6 +20,7 @@ class QuillController extends ChangeNotifier {
bool keepStyleOnNewLine = false,
this.onReplaceText,
this.onDelete,
this.onSelectionCompleted,
}) : _selection = selection,
_keepStyleOnNewLine = keepStyleOnNewLine;
@ -48,6 +49,8 @@ class QuillController extends ChangeNotifier {
/// Custom delete handler
DeleteCallback? onDelete;
void Function()? onSelectionCompleted;
/// Store any styles attribute that got toggled by the tap of a button
/// and that has not been applied yet.
/// It gets reset after each format action within the [document].
@ -242,10 +245,6 @@ class QuillController extends ChangeNotifier {
notifyListeners();
}
// callback sub classes can override to implement actions when a selection is
// completed.
void selectionCompleted() {}
void compose(Delta delta, TextSelection textSelection, ChangeSource source) {
if (delta.isNotEmpty) {
document.compose(delta, source);

@ -377,7 +377,7 @@ class RawEditorState extends EditorState
}
void _handleSelectionCompleted() {
widget.controller.selectionCompleted();
widget.controller.onSelectionCompleted?.call();
}
/// Updates the checkbox positioned at [offset] in document

Loading…
Cancel
Save