forked from AppFlowy-IO/appflowy-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize Enter operation (AppFlowy-IO#673)
* outdentCommand is called when the node path is greater than 1 * feat:add test * feat:update test
- Loading branch information
1 parent
a856888
commit b7c381e
Showing
3 changed files
with
85 additions
and
4 deletions.
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
77 changes: 77 additions & 0 deletions
77
test/editor/block_component/base_component/insert_newline_in_type_command_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,77 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('InsertNewlineInTypeCommand tests', () { | ||
test('bulleted list', () async { | ||
final bulletedNode = bulletedListNode( | ||
text: 'bulleted list 1', | ||
children: [ | ||
bulletedListNode(text: '1'), | ||
bulletedListNode(text: ''), | ||
], | ||
); | ||
final document = Document.blank()..insert([0], [bulletedNode]); | ||
|
||
final editorState = EditorState(document: document); | ||
|
||
editorState.selection = Selection.collapsed(Position(path: [0, 1])); | ||
|
||
insertNewLineAfterBulletedList.execute(editorState); | ||
Node? node1 = editorState.getNodeAtPath([1]); | ||
expect(node1?.type, BulletedListBlockKeys.type); | ||
|
||
insertNewLineAfterBulletedList.execute(editorState); | ||
Node? node2 = editorState.getNodeAtPath([1]); | ||
|
||
expect(node2?.type, ParagraphBlockKeys.type); | ||
}); | ||
|
||
test('todo list', () async { | ||
final todoListNodes = todoListNode( | ||
checked: false, | ||
children: [ | ||
todoListNode(checked: false), | ||
todoListNode(checked: false), | ||
], | ||
); | ||
final document = Document.blank()..insert([0], [todoListNodes]); | ||
|
||
final editorState = EditorState(document: document); | ||
|
||
editorState.selection = Selection.collapsed(Position(path: [0, 1])); | ||
|
||
insertNewLineAfterTodoList.execute(editorState); | ||
Node? node1 = editorState.getNodeAtPath([1]); | ||
expect(node1?.type, TodoListBlockKeys.type); | ||
|
||
insertNewLineAfterTodoList.execute(editorState); | ||
Node? node2 = editorState.getNodeAtPath([1]); | ||
|
||
expect(node2?.type, ParagraphBlockKeys.type); | ||
}); | ||
|
||
test('numbered list', () async { | ||
final numberedListNodes = numberedListNode( | ||
children: [ | ||
numberedListNode(), | ||
numberedListNode(), | ||
], | ||
); | ||
final document = Document.blank()..insert([0], [numberedListNodes]); | ||
|
||
final editorState = EditorState(document: document); | ||
|
||
editorState.selection = Selection.collapsed(Position(path: [0, 1])); | ||
|
||
insertNewLineAfterNumberedList.execute(editorState); | ||
Node? node1 = editorState.getNodeAtPath([1]); | ||
expect(node1?.type, NumberedListBlockKeys.type); | ||
|
||
insertNewLineAfterNumberedList.execute(editorState); | ||
Node? node2 = editorState.getNodeAtPath([1]); | ||
|
||
expect(node2?.type, ParagraphBlockKeys.type); | ||
}); | ||
}); | ||
} |
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