insert line break instead of <p> in TinyMCE

Viewed 37189

I have initialised TinyMCE as follows. I want to force line breaks when user presses enter and not the paragraphs. I'm trying following, but not working. I'm using TinyMCE version 3_3_8.

tinyMCE.init({
        mode: "exact",
        theme: "advanced",
        elements: "textAreaId",
        cleanup: false,
        theme_advanced_toolbar_location: "",
        theme_advanced_buttons1: "",
        theme_advanced_buttons2: "",
        theme_advanced_buttons3: "",
        height: 200,
        width: 300,
    forced_root_block : false,
    force_br_newlines : true,
    force_p_newlines : false,
        oninit: InitPosition
    }); //init ends

I tried to define forced_root_block : "", but still it is not working.

What am I doing wrong?

9 Answers

TinyMCE On Mozilla Firefox adds <div> instead <br> or <p>.

I found the solution:

Open Mozilla Firefox and put in the address: about:config

Search the option and turn false: editor.use_div_for_default_newlines

in tinyMCE 5 I needed to add 1 extra parameter

tinymce.init({
    ...
    valid_elements: 'br',
    force_br_newlines : true,
    force_p_newlines : false,
    forced_root_block : ''
});

Just add

force_br_newlines : true,
force_p_newlines : false,
forced_root_block : false,

anywhere in tinymce.init

Related