From ab004b875500d5892609c696029f4c4da5d448a6 Mon Sep 17 00:00:00 2001 From: Huan Du Date: Wed, 24 Jul 2024 23:09:06 +0800 Subject: [PATCH] feat: add callback to handle performAction (#2061) --- lib/src/editor/config/editor_configurations.dart | 6 ++++++ lib/src/editor/editor.dart | 1 + .../editor/raw_editor/config/raw_editor_configurations.dart | 4 ++++ .../raw_editor_state_text_input_client_mixin.dart | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/src/editor/config/editor_configurations.dart b/lib/src/editor/config/editor_configurations.dart index 80b4811e..421fcc43 100644 --- a/lib/src/editor/config/editor_configurations.dart +++ b/lib/src/editor/config/editor_configurations.dart @@ -81,6 +81,7 @@ class QuillEditorConfigurations extends Equatable { this.onScribbleActivated, this.scribbleAreaInsets, this.readOnlyMouseCursor = SystemMouseCursors.text, + this.onPerformAction, }); final QuillSharedConfigurations sharedConfigurations; @@ -374,6 +375,9 @@ class QuillEditorConfigurations extends Equatable { /// Optional insets for the scribble area. final EdgeInsets? scribbleAreaInsets; + /// Called when a text input action is performed. + final void Function(TextInputAction action)? onPerformAction; + @override List get props => [ placeholder, @@ -437,6 +441,7 @@ class QuillEditorConfigurations extends Equatable { bool? enableScribble, void Function()? onScribbleActivated, EdgeInsets? scribbleAreaInsets, + void Function(TextInputAction action)? onPerformAction, }) { return QuillEditorConfigurations( sharedConfigurations: sharedConfigurations ?? this.sharedConfigurations, @@ -503,6 +508,7 @@ class QuillEditorConfigurations extends Equatable { enableScribble: enableScribble ?? this.enableScribble, onScribbleActivated: onScribbleActivated ?? this.onScribbleActivated, scribbleAreaInsets: scribbleAreaInsets ?? this.scribbleAreaInsets, + onPerformAction: onPerformAction ?? this.onPerformAction, ); } } diff --git a/lib/src/editor/editor.dart b/lib/src/editor/editor.dart index 271a6d55..104f7172 100644 --- a/lib/src/editor/editor.dart +++ b/lib/src/editor/editor.dart @@ -300,6 +300,7 @@ class QuillEditorState extends State readOnlyMouseCursor: configurations.readOnlyMouseCursor, magnifierConfiguration: configurations.magnifierConfiguration, textInputAction: configurations.textInputAction, + onPerformAction: configurations.onPerformAction, ), ), ), diff --git a/lib/src/editor/raw_editor/config/raw_editor_configurations.dart b/lib/src/editor/raw_editor/config/raw_editor_configurations.dart index 46dad31b..dedd3fb3 100644 --- a/lib/src/editor/raw_editor/config/raw_editor_configurations.dart +++ b/lib/src/editor/raw_editor/config/raw_editor_configurations.dart @@ -89,6 +89,7 @@ class QuillRawEditorConfigurations extends Equatable { this.scribbleAreaInsets, this.readOnlyMouseCursor = SystemMouseCursors.text, this.magnifierConfiguration, + this.onPerformAction, }); /// Controls the document being edited. @@ -341,6 +342,9 @@ class QuillRawEditorConfigurations extends Equatable { final TextMagnifierConfiguration? magnifierConfiguration; + /// Called when a text input action is performed. + final void Function(TextInputAction action)? onPerformAction; + @override List get props => [ readOnly, diff --git a/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart b/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart index 5eb38892..7aacc28f 100644 --- a/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart +++ b/lib/src/editor/raw_editor/raw_editor_state_text_input_client_mixin.dart @@ -212,7 +212,7 @@ mixin RawEditorStateTextInputClientMixin on EditorState @override void performAction(TextInputAction action) { - // no-op + widget.configurations.onPerformAction?.call(action); } @override