tinymce remove text spaces and line breaks

13,372

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

Share:
13,372
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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"

  • Jehy
    Jehy almost 9 years
    Answer from Supriti Panda works for version 3. For TinyMCE 4+ I posted answer here: stackoverflow.com/questions/23501867/…
  • GoTop
    GoTop about 5 years
    I am using django-tinymce 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.
  • Duck
    Duck over 3 years
    link is broken.
  • codestr
    codestr over 3 years
    Looks like they moved their forums to 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.