Jump to content

Get TinyMCE to preserve linebreaks


larrybotha
 Share

Recommended Posts

Hey guys,

Struggling with some formatting in TinyMCE. What I'm looking for is WordPress' wysiwyg behaviour where a user can add as many linebreaks between paragraphs as they wish, and a nbsp is used for each line-break.

i.e.

lorem ipsum dolor sit amet

<enter>

<enter>

<enter>

morus lorem ipsumus

yields

<p>lorem ipsum dolor site amet</p>
<p> </p>
<p> </p>
<p>morus lorem ipsumus</p>
 

Currently, TinyMCE strips all white space. nbsp can be added manually, but I don't want our clients to have to worry about how or when to use it, or which areas of content to be careful about editing.

I've looked at a number of options to set for TinyMCE, but their documentation is pretty cryptic, and none of the options I've tried have given me the result I'm looking for.

Any help is appreciated!

Link to comment
Share on other sites

If you go to Admin>Setup>Fields and then edit the field with the tinymce Inpufield Type, there is a tab called "Input". On there you have the TinyMCE advanced configuration options. In the valid elements part replace "-p" with "#p". This will allow empty p tags. This should also pad the empty paragraph with a non-breaking space but for some reason TinyMCE seems to replace them with a regular whitespace.

some more info here: http://processwire.com/talk/topic/4204-stop-tinymce-from-removing-entities/

and here http://www.tinymce.com/wiki.php/configuration:valid_elements

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...