BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Empty paragraphs are being removed

Open nchanged opened this issue 1 year ago • 4 comments

Describe the bug Empty paragraphs are being removed, Which is sometimes crucial for the formatting of the text.

To Reproduce

Load the following content

<p class="bn-inline-content">asdfasdf</p><p class="bn-inline-content">asd</p><p class="bn-inline-content">f</p><p class="bn-inline-content">asdf</p><p class="bn-inline-content"></p><p class="bn-inline-content"></p><p class="bn-inline-content"></p><p class="bn-inline-content"></p><p class="bn-inline-content"></p><p class="bn-inline-content"></p><p class="bn-inline-content"></p><p class="bn-inline-content"></p>

Will result in not preserving the empty lines

Is there a hidden option or something? Thanks!

nchanged avatar Aug 05 '24 10:08 nchanged

Did you try by adding like a blank space? I know it is not the optimal solution but it might be a workaround

aespinoza96 avatar Aug 06 '24 21:08 aespinoza96

that doesn't sound a look a good idea. The formatting will be inconsistent when loading new docs, or if the user just inserts a new line 2 times.

nchanged avatar Aug 14 '24 13:08 nchanged

Found a workaround using turndown lib :

const turndownService = new TurndownService({
  blankReplacement: () => {
    return '&nbsp;';
  },
});
const html = await editor.blocksToFullHTML(editor.document);
const markdown = turndownService.turndown(html);

meteorSD avatar Oct 26 '24 14:10 meteorSD

@meteorSD do you have a more complete example. I'm not sure I understand how to use the lib for this use case.

Ideally i want BlockNote to take markdown as input, and mardown as output (in the onChange handler).

Would be great if you could help out here 🙏

elitan avatar Jan 09 '25 19:01 elitan

problem still persists

dh4bu avatar Jun 12 '25 14:06 dh4bu