2

I have initialised tinyMCE like so:

        $('#description').tinymce({
        // Location of TinyMCE script
        script_url : 'tinymce/jscripts/tiny_mce/tiny_mce.js',
        // General options
        width : "830",
        height: "300",
        theme : "advanced",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_toolbar_location : "top",
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,bullist,numlist,",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        force_br_newlines : true,
        force_p_newlines : false,
        gecko_spellcheck : true,  
        forced_root_block : '', // Needed for 3.x

        plugins : "paste"


    });

i have textarea with some text.when i run it,it removes all spaces and line breaks and display text in one line here is my text

"Brand new!!!

Huge size of 3 bedroom apartment located in Dubai Marina Orra tower for rent

Situated on high floor, overlooking a gorgeous view of Marina"

2 Answers2

3

You can manage it by adding another argument remove_linebreaks

$('#description').tinymce({
// Location of TinyMCE script
    script_url : 'tinymce/jscripts/tiny_mce/tiny_mce.js',
    // General options
    width : "830",
    height: "300",
    theme : "advanced",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_toolbar_location : "top",
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,bullist,numlist,",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_buttons4 : "",
    force_br_newlines : true,
    force_p_newlines : false,
    gecko_spellcheck : true,  
    forced_root_block : '', // Needed for 3.x

    remove_linebreaks : false,

    plugins : "paste"});

But this depend on the tinyMCE version you are using. Because in the below site they say the attribute is not available in some version. http://www.tinymce.com/wiki.php/Configuration3x:remove_linebreaks

Eonasdan
  • 7,563
  • 8
  • 55
  • 82
Supriti Panda
  • 1,281
  • 1
  • 11
  • 12
  • 1
    Answer from **Supriti Panda** works for version 3. For TinyMCE 4+ I posted answer here: http://stackoverflow.com/questions/23501867/tinymce-line-breaks-get-stripped-off-in-firefox-while-using-getcontentformat – Jehy Jul 14 '15 at 12:26
  • I am using django-tinymce https://github.com/aljosa/django-tinymce, it use tinymce 3.5.11. but by adding 'remove_linebreaks' : False, do not help with keeping line breaks in the text. – GoTop May 02 '19 at 05:14
0

In case anyone comes across this in the future, we were having issues with linebreaks being stripped and tried just about every suggestion we could find, with no luck.

I came across this solution here: http://community.tinymce.com/forum/viewtopic.php?id=5636, and it did the trick perfectly.

Add the following two lines two the tinyMCE.init() function, by default they seem to be set to false.

force_p_newlines : true,
force_br_newlines : true
codestr
  • 193
  • 12
  • link is broken. – Duck Aug 30 '20 at 07:27
  • Looks like they moved their forums to https://community.tiny.cloud/, I'm not sure if they migrated the old questions or not, but I'm sure info on this issue can still be found there. – codestr Sep 02 '20 at 17:02