Skip to content

Commit 58a5c1a

Browse files
committed
test
1 parent a1a63d3 commit 58a5c1a

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

packages/markdown/src/lib/deserializer/utils/deserializeMd.spec.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,34 @@ describe('deserializeMd', () => {
376376

377377
expect(deserializeMd(editor, input)).toEqual(output);
378378
});
379+
380+
it('should not trim the end of the first line', () => {
381+
const input = 'There is a space at the end of this line. \n\nLine 2';
382+
383+
const output = (
384+
<fragment>
385+
<hp>There is a space at the end of this line. </hp>
386+
<hp>Line 2</hp>
387+
</fragment>
388+
);
389+
390+
expect(deserializeMd(editor, input)).toEqual(output);
391+
});
392+
393+
it('should preserve \n\n as a new paragraph.', () => {
394+
const input = 'Line 1\n\n';
395+
396+
const output = (
397+
<fragment>
398+
<hp>Line 1</hp>
399+
<hp>
400+
<htext />
401+
</hp>
402+
</fragment>
403+
);
404+
405+
expect(deserializeMd(editor, input)).toEqual(output);
406+
});
379407
});
380408

381409
describe('deserializeMd table', () => {

packages/markdown/src/lib/deserializer/utils/deserializeMd.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ export const deserializeMd = (
5555
if (memoize) {
5656
return parseMarkdownBlocks(data, parser).flatMap((token) => {
5757
if (token.type === 'space') {
58-
return {
59-
...editor.api.create.block(),
60-
_memo: token.raw,
61-
};
58+
return tree.processSync(token.raw).result;
6259
}
6360

6461
// TODO: split list items

0 commit comments

Comments
 (0)