Skip to content

Commit

Permalink
Merge pull request #2885 from FranciscoMoretti/main
Browse files Browse the repository at this point in the history
bugfix: Empty list item Md deserialization error
  • Loading branch information
zbeyens authored Jan 29, 2024
2 parents 3964565 + c09e55a commit 0d73c01
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wet-rockets-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-serializer-md": patch
---

Fix(deserialize md): support empty list item
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,29 @@ describe('deserializeMdIndentList', () => {

expect(deserializeMd(editor, input)).toEqual(output);
});

it('should deserialize an empty list item', () => {
const input = '* Line 1\n*';

const output = [
{
type: 'p',
listStyleType: 'disc',
indent: 1,
children: [
{
text: 'Line 1',
},
],
},
{
type: 'p',
listStyleType: 'disc',
indent: 1,
children: [],
},
];

expect(deserializeMd(editor, input)).toEqual(output);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export const remarkDefaultElementRules: RemarkElementRules<Value> = {
type: getPluginType(options.editor, ELEMENT_PARAGRAPH),
listStyleType,
indent,
children: remarkTransformElementChildren(paragraph, options),
children: remarkTransformElementChildren(
paragraph || '',
options
),
});

subLists.forEach((subList) => {
Expand Down

0 comments on commit 0d73c01

Please sign in to comment.