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:
parent
1f2668c18a
commit
2eb801e7f5
1 changed files with 160 additions and 6 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue