ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
8.71k stars 3.62k forks source link

Markdown plugin - no way to prevent output trimming #15975

Open kstinson14 opened 4 months ago

kstinson14 commented 4 months ago

📝 Provide detailed reproduction steps (if any)

Apologies if this should be a feature request instead of a bug - I wasn't sure if this was expected behavior or not.

It seems that the trim option for the getData method does not work for editors using the Markdown plugin. Opting out of trimming the output still does not respect spaces / newlines in otherwise empty output.

JSFiddle: https://jsfiddle.net/kstinson/egnLhsrz/ Each editor outputs its getData result in the console. You can see the HTML whitespace editor outputs content when only spaces/ newlines are present in the editor, but the Markdown whitespace editor does not.

✔️ Expected result

I would expect this option to work in the Markdown editor

❌ Actual result

The output is still trimmed

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

Witoso commented 4 months ago

Hi, thanks for the request. 

does not respect spaces / newlines in otherwise empty output.

Hmm, I think it might be related to the behavior of Markdown itself, we most likely return proper HTML but Markdown has its logic of content and white spaces, and the processor skips them anyway, see more in: https://github.com/ckeditor/ckeditor5/issues/14038#issuecomment-1539609348

A workaround could be to configure keepHtml with br for example or the registerRawContentMatcher.