-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support formatting greater hyphen to single arrow (#665)
* feat: support formatting greater hyphen to single arrow * refactor: renamed test group description * refactor: formatted code file using dart formatter * refactor: removes GreaterHyphen shortcut event from standard shortcuts * fix: enable formatGreaterHyphen shortcut in test mode --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
- Loading branch information
1 parent
3feff00
commit dccd4e8
Showing
4 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ew/editor_component/service/shortcuts/character_shortcuts/format_greater_hyphen_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../../../infra/testable_editor.dart'; | ||
|
||
const _hyphen = '-'; | ||
const _greater = '>'; | ||
const _singleArrow = '→'; | ||
|
||
void main() async { | ||
group('format_arrow_character.dart', () { | ||
testWidgets('hyphen + greater to single arrow', (tester) async { | ||
final editor = tester.editor..addEmptyParagraph(); | ||
await editor.startTesting(); | ||
|
||
await editor.updateSelection(Selection.collapsed(Position(path: [0]))); | ||
|
||
await editor.ime.typeText(_hyphen); | ||
await editor.ime.typeText(_greater); | ||
|
||
final delta = editor.nodeAtPath([0])!.delta!; | ||
expect(delta.length, 1); | ||
expect(delta.toPlainText(), _singleArrow); | ||
|
||
await editor.dispose(); | ||
}); | ||
|
||
testWidgets('hyphen + greater to single arrow with selection', | ||
(tester) async { | ||
const welcome = 'Welcome'; | ||
const initialText = '$_hyphen$welcome'; | ||
|
||
final editor = tester.editor..addParagraph(initialText: initialText); | ||
await editor.startTesting(); | ||
|
||
await editor.updateSelection( | ||
Selection.single( | ||
path: [0], | ||
startOffset: 1, | ||
endOffset: initialText.length, | ||
), | ||
); | ||
|
||
await editor.ime.typeText(_greater); | ||
|
||
final delta = editor.nodeAtPath([0])!.delta!; | ||
expect(delta.length, 1); | ||
expect(delta.toPlainText(), _singleArrow); | ||
|
||
await editor.dispose(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters