fix: enter after emoji will create a softbreak on mobile (#1010)
* fix: enter after emoji will create a softbreak * test: enter after emoji will create a softbreak
This commit is contained in:
parent
cfb8b1b6eb
commit
9f6a29968e
2 changed files with 36 additions and 0 deletions
|
|
@ -5,6 +5,11 @@ Future<bool> executeCharacterShortcutEvent(
|
|||
String? character,
|
||||
List<CharacterShortcutEvent> characterShortcutEvents,
|
||||
) async {
|
||||
// if the character is a space + enter, we should execute the enter event
|
||||
if (character == ' \n') {
|
||||
character = '\n';
|
||||
}
|
||||
|
||||
if (character?.length != 1) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:appflowy_editor/src/editor/editor_component/service/ime/delta_input_impl.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('character shortcut on insert', () {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('call', () async {
|
||||
final editorState = EditorState.blank();
|
||||
editorState.selection = Selection.collapsed(
|
||||
Position(path: [0]),
|
||||
);
|
||||
await onInsert(
|
||||
const TextEditingDeltaInsertion(
|
||||
textInserted: ' \n',
|
||||
composing: TextRange.empty,
|
||||
oldText: '',
|
||||
selection: TextSelection.collapsed(offset: 0),
|
||||
insertionOffset: 0,
|
||||
),
|
||||
editorState,
|
||||
[insertNewLine],
|
||||
);
|
||||
final nodes = editorState.document.root.children;
|
||||
expect(nodes.length, 2);
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue