fix: slash not recogized on mobile (#1096)

This commit is contained in:
Morn 2025-04-16 16:04:20 +08:00 • committed by GitHub
commit 680222f503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/editor/editor_component/service/ime/character_shortcut_event_helper.dart'; import 'package:appflowy_editor/src/editor/editor_component/service/ime/character_shortcut_event_helper.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:universal_platform/universal_platform.dart';
Future<void> onInsert( Future<void> onInsert(
TextEditingDeltaInsertion insertion, TextEditingDeltaInsertion insertion,
@ -12,10 +13,15 @@ Future<void> onInsert(
final textInserted = insertion.textInserted; final textInserted = insertion.textInserted;
/// On mobile devices, the "/" is context-sensitive,which means it can't be
/// recognized as a standalone character. This requires special handling.
final isMobileSlash =
UniversalPlatform.isMobile && insertion.textInserted == '/';
// In France, the backtick key is used to toggle a character style. // In France, the backtick key is used to toggle a character style.
// We should prevent the execution of character shortcut events when the // We should prevent the execution of character shortcut events when the
// composing range is not collapsed. // composing range is not collapsed.
if (insertion.composing.isCollapsed) { if (insertion.composing.isCollapsed || isMobileSlash) {
// execute character shortcut events // execute character shortcut events
final execution = await executeCharacterShortcutEvent( final execution = await executeCharacterShortcutEvent(
editorState, editorState,