diff --git a/lib/src/widgets/raw_editor/raw_editor_actions.dart b/lib/src/widgets/raw_editor/raw_editor_actions.dart index 63ee48d6..a343f03f 100644 --- a/lib/src/widgets/raw_editor/raw_editor_actions.dart +++ b/lib/src/widgets/raw_editor/raw_editor_actions.dart @@ -580,3 +580,29 @@ class QuillEditorInsertEmbedIntent extends Intent { final Attribute type; } + +class NavigateToDocumentBoundaryAction + extends ContextAction { + NavigateToDocumentBoundaryAction(this.state); + + final QuillRawEditorState state; + + @override + Object? invoke( + ScrollToDocumentBoundaryIntent intent, [ + BuildContext? context, + ]) { + return Actions.invoke( + context!, + UpdateSelectionIntent( + state.textEditingValue, + intent.forward + ? TextSelection.collapsed( + offset: state.controller.plainTextEditingValue.text.length, + ) + : 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..1f2b7ff4 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: NavigateToDocumentBoundaryAction(this) }; @override