From 0f51f6f93661913ce551a6987a28d88ebd38c984 Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Fri, 29 Sep 2023 10:00:14 +0300 Subject: [PATCH] fix: make it easier to enter when last child is a table/image Insert an empty paragraph below. --- src/importMarkdownToLexical.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/importMarkdownToLexical.ts b/src/importMarkdownToLexical.ts index 9072553b..d76ba017 100644 --- a/src/importMarkdownToLexical.ts +++ b/src/importMarkdownToLexical.ts @@ -112,6 +112,11 @@ export function importMarkdownToLexical({ root, markdown, visitors, syntaxExtens mdastRoot.children.push({ type: 'paragraph', children: [] }) } + // leave empty paragraph, so that the user can start typing + if (mdastRoot.children.at(-1)?.type !== 'paragraph') { + mdastRoot.children.push({ type: 'paragraph', children: [] }) + } + importMdastTreeToLexical({ root, mdastRoot, visitors }) }