diff --git a/lib/src/widgets/raw_editor/raw_editor_actions.dart b/lib/src/widgets/raw_editor/raw_editor_actions.dart index 80774d20..e57dd228 100644 --- a/lib/src/widgets/raw_editor/raw_editor_actions.dart +++ b/lib/src/widgets/raw_editor/raw_editor_actions.dart @@ -577,3 +577,35 @@ class QuillEditorInsertEmbedIntent extends Intent { final Attribute type; } + +class QuillEditorUpdateCursorLocationAction + extends ContextAction { + QuillEditorUpdateCursorLocationAction(this.state); + + final QuillRawEditorState state; + + @override + Object? invoke(ScrollToDocumentBoundaryIntent intent, + [BuildContext? context]) { + if (intent.forward) { + return Actions.invoke( + context!, + UpdateSelectionIntent( + state.textEditingValue, + TextSelection.collapsed( + offset: state.controller.plainTextEditingValue.text.length, + ), + SelectionChangedCause.keyboard, + ), + ); + } + return Actions.invoke( + context!, + UpdateSelectionIntent( + state.textEditingValue, + const TextSelection.collapsed(offset: 0), + SelectionChangedCause.keyboard, + ), + ); + } +} diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index 6f146b8f..ccea2632 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -701,6 +701,18 @@ class QuillRawEditorState extends EditorState control: !isDesktopMacOS, meta: isDesktopMacOS, ): const OpenSearchIntent(), + + // Navigate to the start or end of the document + SingleActivator( + LogicalKeyboardKey.home, + control: !isDesktopMacOS, + meta: isDesktopMacOS, + ): const ScrollToDocumentBoundaryIntent(forward: false), + SingleActivator( + LogicalKeyboardKey.end, + control: !isDesktopMacOS, + meta: isDesktopMacOS, + ): const ScrollToDocumentBoundaryIntent(forward: true), }, { ...?widget.configurations.customShortcuts }), @@ -1674,7 +1686,8 @@ class QuillRawEditorState extends EditorState IndentSelectionIntent: _indentSelectionAction, QuillEditorApplyHeaderIntent: _applyHeaderAction, QuillEditorApplyCheckListIntent: _applyCheckListAction, - QuillEditorApplyLinkIntent: QuillEditorApplyLinkAction(this) + QuillEditorApplyLinkIntent: QuillEditorApplyLinkAction(this), + ScrollToDocumentBoundaryIntent: QuillEditorUpdateCursorLocationAction(this) }; @override