From 62d323f98e27424894c26ffa42c35e2493c2427a Mon Sep 17 00:00:00 2001 From: Francisco Moretti Date: Sat, 20 Jan 2024 09:22:32 +0000 Subject: [PATCH 1/2] bugfix: Empty list item deserialization error --- .../deserializer/utils/deserializeMd.spec.tsx | 25 +++++++++++++++++++ .../remark-slate/remarkDefaultElementRules.ts | 5 +++- 2 files changed, 29 insertions(+), 1 deletion(-) 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) => { From c09e55a9dcbc0c8f7b13d00b3231ca2082ce51f1 Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Sat, 20 Jan 2024 15:53:14 +0100 Subject: [PATCH 2/2] Create wet-rockets-drum.md --- .changeset/wet-rockets-drum.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wet-rockets-drum.md 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