diff --git a/lib/src/editor/editor_component/service/editor.dart b/lib/src/editor/editor_component/service/editor.dart index d54a5b3a0..cacfcb2d3 100644 --- a/lib/src/editor/editor_component/service/editor.dart +++ b/lib/src/editor/editor_component/service/editor.dart @@ -17,7 +17,7 @@ KeepEditorFocusNotifier keepEditorFocusNotifier = KeepEditorFocusNotifier(); /// The default value of the auto scroll edge offset on mobile /// The editor will scroll when the cursor is close to the edge of the screen -double appFlowyEditorAutoScrollEdgeOffset = 220.0; +const double appFlowyEditorAutoScrollEdgeOffset = 220.0; class AppFlowyEditor extends StatefulWidget { AppFlowyEditor({ @@ -45,6 +45,7 @@ class AppFlowyEditor extends StatefulWidget { this.disableKeyboardService = false, this.disableScrollService = false, this.disableAutoScroll = false, + this.autoScrollEdgeOffset = appFlowyEditorAutoScrollEdgeOffset, }) : blockComponentBuilders = blockComponentBuilders ?? standardBlockComponentBuilderMap, characterShortcutEvents = @@ -216,6 +217,10 @@ class AppFlowyEditor extends StatefulWidget { /// final bool disableAutoScroll; + /// The edge offset of the auto scroll. + /// + final double autoScrollEdgeOffset; + @override State createState() => _AppFlowyEditorState(); } @@ -362,6 +367,7 @@ class _AppFlowyEditorState extends State { editorState.enableAutoComplete = widget.enableAutoComplete; editorState.autoCompleteTextProvider = widget.autoCompleteTextProvider; editorState.disableAutoScroll = widget.disableAutoScroll; + editorState.autoScrollEdgeOffset = widget.autoScrollEdgeOffset; } BlockComponentRendererService get _renderer => BlockComponentRenderer( diff --git a/lib/src/editor/editor_component/service/scroll_service_widget.dart b/lib/src/editor/editor_component/service/scroll_service_widget.dart index 7f3664066..bb95004f7 100644 --- a/lib/src/editor/editor_component/service/scroll_service_widget.dart +++ b/lib/src/editor/editor_component/service/scroll_service_widget.dart @@ -108,7 +108,7 @@ class _ScrollServiceWidgetState extends State return Future.delayed(duration, () { startAutoScroll( endTouchPoint, - edgeOffset: appFlowyEditorAutoScrollEdgeOffset, + edgeOffset: editorState.autoScrollEdgeOffset, duration: Duration.zero, ); }); diff --git a/lib/src/editor_state.dart b/lib/src/editor_state.dart index b484e3b0c..8c24e5bbb 100644 --- a/lib/src/editor_state.dart +++ b/lib/src/editor_state.dart @@ -99,6 +99,9 @@ class EditorState { /// Whether the editor should disable auto scroll. bool disableAutoScroll = false; + /// The edge offset of the auto scroll. + double autoScrollEdgeOffset = appFlowyEditorAutoScrollEdgeOffset; + /// The style of the editor. late EditorStyle editorStyle;