GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

How to enter and save an empty line or paragraph #502

Open cyclaero opened 6 years ago

cyclaero commented 6 years ago

I cannot seem to save an (almost) empty line or paragraph to a document <p>&nbsp;</p> would be removed on save <p>&#8194;</p> would be removed on save <p>The actual text.<br>&nbsp;</p> removes the line break and the space.

The only kind of working empty line which would not be removed on save that I found is: <p><span hidden>.</span>/p>

What is the supported way to add and save empty lines or paragraphs?

I am working with the lates ContentTools from the present GitHub repeository.

anthonyjb commented 6 years ago

Hi @cyclaero - So CT by default wont hold on to empty paragraphs it strips them. But there are possible workarounds.

  1. Set the ContentEdit.TRIM_WHITESPACE flag to false, this should allow your paragraphs to contain a simple &nbsp; or a no width space &#8203;
  2. There's a more complete workaround documented here that you might consider: https://github.com/GetmeUK/ContentTools/issues/298
cyclaero commented 6 years ago

Setting ContentEdit.TRIM_WHITESPACE to false serves for my present needs, since with this in place, upon save of <p>The actual text.<br>&nbsp;</p> the line break and &nbsp; or &#8203; are not removed. <p>&nbsp;</p> still doesn't work, though.

ghost commented 5 years ago

Some of my clients reported the problem to not be able to insert spaces between paragraphs like they want.

I can understand that contenttools would automatically remove empty paragraphs cause it's not semantically correct. But it should respect line break <br /> when customer do a shift + enter