Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE: How to prevent <br>-TAG in list-element

I have an tinyMCE and I have to set the option "force_br_newlines: true", because when I don't do it, and I'm pushing "Enter" for example two times and look in the source-code, there is only one <br>.

But when I set the option on TRUE, I have a problem with my unsorted list. When the loaded text comes from my databse to the tinyMCE, it makes out of

<ul><li> MY TEXT </li><li> MY TEXT 2 </li><ul>

this-->

<ul><br /><li> MY TEXT </li><br /><li> MY TEXT 2 </li><br /><ul>

Is there a possibility to prevent this??? I dont want to have the <br /> in it! THANK YOU VERY MUCH FOR YOUR HELP!!!!!

like image 560
Zwen2012 Avatar asked Oct 30 '14 07:10

Zwen2012


1 Answers

BR elements should only be used when you really have to (mostly never). Also as of 3.x the forced_root_block option is enabled by default so if you really want to disable paragraphs disable that one as well.

So add

tinyMCE.init({
        ...
        force_br_newlines : true,
        force_p_newlines : false,
        forced_root_block : '' // Needed for 3.x
});

BTW TinyMCE's official page suggests not to use BR elements for linebreaks.

like image 87
Chankey Pathak Avatar answered Oct 06 '22 00:10

Chankey Pathak