diff --git a/.changeset/wet-rockets-drum.md b/.changeset/wet-rockets-drum.md new file mode 100644 index 0000000000..921744abbc --- /dev/null +++ b/.changeset/wet-rockets-drum.md @@ -0,0 +1,5 @@ +--- +"@udecode/plate-serializer-md": patch +--- + +Fix(deserialize md): support empty list item diff --git a/packages/serializer-md/src/deserializer/utils/deserializeMd.spec.tsx b/packages/serializer-md/src/deserializer/utils/deserializeMd.spec.tsx index 6224a9477c..4ca73e1963 100644 --- a/packages/serializer-md/src/deserializer/utils/deserializeMd.spec.tsx +++ b/packages/serializer-md/src/deserializer/utils/deserializeMd.spec.tsx @@ -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); + }); }); diff --git a/packages/serializer-md/src/remark-slate/remarkDefaultElementRules.ts b/packages/serializer-md/src/remark-slate/remarkDefaultElementRules.ts index 42ed259724..b5dd7e9817 100644 --- a/packages/serializer-md/src/remark-slate/remarkDefaultElementRules.ts +++ b/packages/serializer-md/src/remark-slate/remarkDefaultElementRules.ts @@ -68,7 +68,10 @@ export const remarkDefaultElementRules: RemarkElementRules = { type: getPluginType(options.editor, ELEMENT_PARAGRAPH), listStyleType, indent, - children: remarkTransformElementChildren(paragraph, options), + children: remarkTransformElementChildren( + paragraph || '', + options + ), }); subLists.forEach((subList) => {