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

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

Loading…
Cancel
Save