Skip to content
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: added support for custom parser for markdown to document #403

Merged
merged 6 commits into from
Aug 25, 2023

Conversation

Mukund-Tandon
Copy link
Contributor

fixes: #401

@LucasXu0
Copy link
Collaborator

@Mukund-Tandon Please format the code

@Mukund-Tandon
Copy link
Contributor Author

@Mukund-Tandon Please format the code

Ok,I am also writing test for it

@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

Merging #403 (5a08ee9) into main (56474e8) will decrease coverage by 0.16%.
Report is 14 commits behind head on main.
The diff coverage is 89.28%.

@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
- Coverage   80.75%   80.60%   -0.16%     
==========================================
  Files         252      254       +2     
  Lines       10258    10393     +135     
==========================================
+ Hits         8284     8377      +93     
- Misses       1974     2016      +42     
Files Changed Coverage Δ
...ns/markdown/decoder/document_markdown_decoder.dart 93.57% <82.35%> (-1.32%) ⬇️
...ugins/markdown/decoder/delta_markdown_decoder.dart 100.00% <100.00%> (ø)
lib/src/plugins/markdown/document_markdown.dart 100.00% <100.00%> (ø)

... and 21 files with indirect coverage changes

@Mukund-Tandon Mukund-Tandon marked this pull request as ready for review August 24, 2023 00:55
Comment on lines 64 to 68
for (final key in element.attributes.keys) {
if (element.attributes[key] != null) {
_attributes[key] = jsonDecode(element.attributes[key]!);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (final key in element.attributes.keys) {
if (element.attributes[key] != null) {
_attributes[key] = jsonDecode(element.attributes[key]!);
}
}
element.attributes.forEach((key, value) {
_attributes[key] = jsonDecode(value);
});

@@ -72,6 +82,10 @@ class DeltaMarkdownDecoder extends Converter<String, Delta>
_attributes.remove(BuiltInAttributeKey.href);
} else if (element.tag == 'u') {
_attributes.remove(BuiltInAttributeKey.underline);
} else {
for (var key in element.attributes.keys) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (var key in element.attributes.keys) {
for (final key in element.attributes.keys) {

Comment on lines 37 to 38
document
.insert([i], [_convertLineToNode(lines[i], customInlineSyntaxes)]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
document
.insert([i], [_convertLineToNode(lines[i], customInlineSyntaxes)]);
document.insert(
[i],
[_convertLineToNode(lines[i], customInlineSyntaxes)],
);

Comment on lines 66 to 67
document
.insert([i], [_convertLineToNode(lines[i], customInlineSyntaxes)]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
document
.insert([i], [_convertLineToNode(lines[i], customInlineSyntaxes)]);
document.insert(
[i],
[_convertLineToNode(lines[i], customInlineSyntaxes)],
);

Comment on lines 79 to 87
final decoder =
DeltaMarkdownDecoder(customInlineSyntaxes: customInlineSyntaxes);
for (final parser in customNodeParsers) {
final Node? node = parser.transform(line);

if (node != null) {
return node;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final decoder =
DeltaMarkdownDecoder(customInlineSyntaxes: customInlineSyntaxes);
for (final parser in customNodeParsers) {
final Node? node = parser.transform(line);
if (node != null) {
return node;
}
}
final decoder = DeltaMarkdownDecoder(
customInlineSyntaxes: customInlineSyntaxes,
);
for (final parser in customNodeParsers) {
final node = parser.transform(line);
if (node != null) {
return node;
}
}

@LucasXu0
Copy link
Collaborator

@Mukund-Tandon I refactored some codes. The suggestions are just for your reference, don't commit them.

@Mukund-Tandon
Copy link
Contributor Author

@Mukund-Tandon I refactored some codes. The suggestions are just for your reference, don't commit them.

Ok 👍

@LucasXu0 LucasXu0 merged commit 687af49 into AppFlowy-IO:main Aug 25, 2023
9 of 10 checks passed
q200892907 added a commit to q200892907/appflowy-editor that referenced this pull request Aug 28, 2023
* main: (48 commits)
  chore: comment suggesting use of deprecated method (AppFlowy-IO#417)
  fix: replace matches on the same node (AppFlowy-IO#418)
  fix: rect of the divider block is incorrect (AppFlowy-IO#415)
  chore: bump version 1.2.4 (AppFlowy-IO#414)
  feat: migrate copy paste command from AppFlowy (AppFlowy-IO#413)
  feat: added support for custom parser for markdown to document (AppFlowy-IO#403)
  feat: improve CJK IME support
  feat: add support for context menu items to the editor
  fix: refactor _onSelectionChange method to update _showPlaceholder state more efficiently
  fix: typo (AppFlowy-IO#408)
  Fix selected nodes (AppFlowy-IO#407)
  fix: miss the nested node when copying (AppFlowy-IO#406)
  feat: skip whitespace between words while navigating with CTRL+ARROW keys (AppFlowy-IO#363)
  feat: double hyphen to em dash (AppFlowy-IO#395)
  fix: add variable to hold editor selection for colour menu (AppFlowy-IO#400)
  test: open link command
  refactor: show link command test
  refactor: show link menu command
  feat: open link command
  fix: placeholder on paragraph when selected (AppFlowy-IO#390)
  ...
zoli added a commit to zoli/appflowy-editor that referenced this pull request Aug 28, 2023
…-state-update-node

* fix/previous-node-text-direction-null:
  feat: default text direction property (AppFlowy-IO#402)
  fix: fixed the cursor not moving to next line after inserting divider (AppFlowy-IO#371)
  chore: update theme colors for editor
  feat: refactor floating toolbar positioning logic
  fix: update resizable image width calculation with minimum width constraint
  chore: comment suggesting use of deprecated method (AppFlowy-IO#417)
  fix: replace matches on the same node (AppFlowy-IO#418)
  fix: rect of the divider block is incorrect (AppFlowy-IO#415)
  chore: bump version 1.2.4 (AppFlowy-IO#414)
  feat: migrate copy paste command from AppFlowy (AppFlowy-IO#413)
  feat: added support for custom parser for markdown to document (AppFlowy-IO#403)
  feat: improve CJK IME support
  feat: add support for context menu items to the editor
  fix: refactor _onSelectionChange method to update _showPlaceholder state more efficiently
  fix: typo (AppFlowy-IO#408)
  Fix selected nodes (AppFlowy-IO#407)
  fix: miss the nested node when copying (AppFlowy-IO#406)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Add Support for custom Parsers in mardownTODocument Function
2 participants