diff --git a/lib/src/editor/editor_component/service/scroll/auto_scrollable_widget.dart b/lib/src/editor/editor_component/service/scroll/auto_scrollable_widget.dart index 2f3725734..5d9d52cdd 100644 --- a/lib/src/editor/editor_component/service/scroll/auto_scrollable_widget.dart +++ b/lib/src/editor/editor_component/service/scroll/auto_scrollable_widget.dart @@ -1,3 +1,4 @@ +import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/src/editor/editor_component/service/scroll/auto_scroller.dart'; import 'package:flutter/material.dart'; @@ -49,9 +50,9 @@ class _AutoScrollableWidgetState extends State { void _initAutoScroller() { _autoScroller = AutoScroller( _scrollableState, - velocityScalar: 15, + velocityScalar: PlatformExtension.isDesktopOrWeb ? 15 : 100, onScrollViewScrolled: () { - _autoScroller.continueToAutoScroll(); + // _autoScroller.continueToAutoScroll(); }, ); } 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 c5ee5e0dc..85e6d5a3b 100644 --- a/lib/src/editor/editor_component/service/scroll_service_widget.dart +++ b/lib/src/editor/editor_component/service/scroll_service_widget.dart @@ -109,14 +109,22 @@ class _ScrollServiceWidgetState extends State editorState.selectionUpdateReason == SelectionUpdateReason.selectAll) { return; } - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { final selectionRect = editorState.selectionRects(); if (selectionRect.isEmpty) { return; } final endTouchPoint = selectionRect.last.centerRight; if (selection.isCollapsed) { - startAutoScroll(endTouchPoint, edgeOffset: 50); + if (PlatformExtension.isMobile) { + // soft keyboard + // workaround: wait for the soft keyboard to show up + Future.delayed(const Duration(milliseconds: 300), () { + startAutoScroll(endTouchPoint, edgeOffset: 50); + }); + } else { + startAutoScroll(endTouchPoint, edgeOffset: 50); + } } else { startAutoScroll(endTouchPoint); } diff --git a/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart b/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart index 46e2692a6..77d840b46 100644 --- a/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart +++ b/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart @@ -61,6 +61,7 @@ class _MobileSelectionServiceWidgetState /// Pan Offset? _panStartOffset; double? _panStartScrollDy; + Selection? _panStartSelection; MobileSelectionDragMode dragMode = MobileSelectionDragMode.none; @@ -274,6 +275,7 @@ class _MobileSelectionServiceWidgetState final position = details.globalPosition; final selection = editorState.selection; + _panStartSelection = selection; if (selection == null) { dragMode = MobileSelectionDragMode.none; } else if (selection.isCollapsed && @@ -322,7 +324,10 @@ class _MobileSelectionServiceWidgetState if (end != null) { if (dragMode == MobileSelectionDragMode.leftSelectionHandler) { updateSelection( - selection.copyWith(start: end), + selection.copyWith( + end: end, + start: _panStartSelection?.normalized.end, + ), ); } else if (dragMode == MobileSelectionDragMode.rightSelectionHandler) { updateSelection(