Skip to content

Commit

Permalink
feat: support keyboard gesture on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Sep 29, 2024
1 parent 6da7b4e commit e50e6b9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ Future<void> onNonTextUpdate(
),
);
}
} else if (PlatformExtension.isAndroid) {

Check warning on line 56 in lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart#L56

Added line #L56 was not covered by tests
// 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');

Check warning on line 61 in lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart#L61

Added line #L61 was not covered by tests
if (selection != null) {
editorState.updateSelectionWithReason(
Selection.collapsed(
Position(
path: selection.start.path,
offset: nonTextUpdate.selection.start,

Check warning on line 67 in lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart#L63-L67

Added lines #L63 - L67 were not covered by tests
),
),
);
}
} else if (PlatformExtension.isIOS) {

Check warning on line 72 in lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart#L72

Added line #L72 was not covered by tests
// 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');

Check warning on line 75 in lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/ime/delta_input_on_non_text_update_impl.dart#L75

Added line #L75 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(

Check warning on line 109 in lib/src/editor/editor_component/service/ime/non_delta_input_service.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/editor/editor_component/service/ime/non_delta_input_service.dart#L109

Added line #L109 was not covered by tests
'ignore updateEditingValue event when the floating cursor is visible',
);
return;
}

Expand Down

0 comments on commit e50e6b9

Please sign in to comment.