-
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: add markdown divider encoder parser (#639)
- Loading branch information
1 parent
ca5b589
commit c8ba248
Showing
8 changed files
with
42 additions
and
10 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
13 changes: 13 additions & 0 deletions
13
lib/src/plugins/markdown/encoder/parser/divider_node_parser.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,13 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
|
||
class DividerNodeParser extends NodeParser { | ||
const DividerNodeParser(); | ||
|
||
@override | ||
String get id => DividerBlockKeys.type; | ||
|
||
@override | ||
String transform(Node node, DocumentMarkdownEncoder? encoder) { | ||
return '---\n'; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
export 'bulleted_list_node_parser.dart'; | ||
export 'code_block_node_parser.dart'; | ||
export 'divider_node_parser.dart'; | ||
export 'heading_node_parser.dart'; | ||
export 'image_node_parser.dart'; | ||
export 'node_parser.dart'; | ||
export 'quote_node_parser.dart'; | ||
export 'numbered_list_node_parser.dart'; | ||
export 'todo_list_node_parser.dart'; | ||
export 'text_node_parser.dart'; | ||
export 'code_block_node_parser.dart'; | ||
export 'quote_node_parser.dart'; | ||
export 'table_node_parser.dart'; | ||
export 'text_node_parser.dart'; | ||
export 'todo_list_node_parser.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
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 |
---|---|---|
|
@@ -98,4 +98,5 @@ const markdownDocumentEncoded = """# Heading 1 | |
## Heading 2 | ||
### Heading 3 | ||
--- | ||
"""; |
1 change: 0 additions & 1 deletion
1
test/plugins/markdown/encoder/document_markdown_encoder_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
20 changes: 20 additions & 0 deletions
20
test/plugins/markdown/encoder/parser/divider_node_parser_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,20 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() async { | ||
group('divider_node_parser.dart', () { | ||
test('parser divider node', () { | ||
final node = Node( | ||
type: DividerBlockKeys.type, | ||
); | ||
|
||
final result = const DividerNodeParser().transform(node, null); | ||
expect(result, '---\n'); | ||
}); | ||
|
||
test('DividerNodeParser id getter', () { | ||
const imageNodeParser = DividerNodeParser(); | ||
expect(imageNodeParser.id, 'divider'); | ||
}); | ||
}); | ||
} |
1 change: 0 additions & 1 deletion
1
test/plugins/markdown/encoder/parser/text_node_parser_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