diff --git a/lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart b/lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart index 90fe0dede..958d2dbd3 100644 --- a/lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart +++ b/lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart @@ -53,6 +53,26 @@ Future onNonTextUpdate( ), ); } + } else if (PlatformExtension.isAndroid) { + // on some Android keyboards (e.g. Gboard), they use non-text update to update the selection when moving cursor + // by space bar. + // for the another keyboards (e.g. system keyboard), they will trigger the + // `onFloatingCursor` event instead. + AppFlowyEditorLog.input.debug('[Android] onNonTextUpdate: $nonTextUpdate'); + if (selection != null) { + editorState.updateSelectionWithReason( + Selection.collapsed( + Position( + path: selection.start.path, + offset: nonTextUpdate.selection.start, + ), + ), + ); + } + } else if (PlatformExtension.isIOS) { + // on iOS, the cursor movement will trigger the `onFloatingCursor` event. + // so we don't need to handle the non-text update here. + AppFlowyEditorLog.input.debug('[iOS] onNonTextUpdate: $nonTextUpdate'); } } diff --git a/lib/src/editor/editor_component/service/ime/non_delta_input_service.dart b/lib/src/editor/editor_component/service/ime/non_delta_input_service.dart index 3316ff3bb..256d714c8 100644 --- a/lib/src/editor/editor_component/service/ime/non_delta_input_service.dart +++ b/lib/src/editor/editor_component/service/ime/non_delta_input_service.dart @@ -106,6 +106,9 @@ class NonDeltaTextInputService extends TextInputService with TextInputClient { // on iOS, when using gesture to move cursor, this function will be called // which may cause the unneeded delta being applied // so we ignore the updateEditingValue event when the floating cursor is visible + AppFlowyEditorLog.editor.debug( + 'ignore updateEditingValue event when the floating cursor is visible', + ); return; }