-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add markdown divider encoder parser #639
Merged
LucasXu0
merged 4 commits into
AppFlowy-IO:main
from
hamishjohnson:feat/add-markdown-divider-encoder-parser
Jan 8, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5e985ce
feat: add markdown divider encoder parser
hamishjohnson 6afb1ed
rm image import from document_markdown.dart
hamishjohnson 32a823a
fix(document_markdown_test): markdownDocumentEncoded to include divider
hamishjohnson 5d00fd4
fix: remove code related to children
hamishjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 18 additions & 0 deletions
18
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,18 @@ | ||
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) { | ||
final children = encoder?.convertNodes(node.children); | ||
String markdown = '---\n'; | ||
if (children != null && children.isNotEmpty) { | ||
markdown += children; | ||
} | ||
return markdown; | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The children of the divider node must be empty.