Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

jquery - tinymce remove text spaces and line breaks

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"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...