feat: double hyphen to em dash (#395)

* feat: double hyphen to em dash

* chore: fix tests

---------

Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
Mathias Mogensen 2023-08-21 05:46:45 +02:00 • committed by GitHub
commit 2eb801e7f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -315,14 +315,24 @@ class MockIMEInput {
}
Future<void> replaceText(String text) async {
final selection = editorState.selection?.normalized;
if (selection == null || selection.isCollapsed) {
var selection = editorState.selection?.normalized;
if (selection == null) {
return;
}
final texts = editorState.getTextInSelection(selection).join('\n');
if (!selection.isSingle || !selection.isCollapsed) {
await editorState.deleteSelection(selection);
}
selection = editorState.selection?.normalized;
if (selection == null) {
return;
}
final oldText =
editorState.getNodeAtPath(selection.start.path)!.delta!.toPlainText();
await imeInput.apply([
TextEditingDeltaReplacement(
oldText: ' $texts',
oldText: ' $oldText',
replacementText: text,
replacedRange: TextSelection(
baseOffset: selection.startIndex + 1,