in TinyMCE
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 ve
I faced the same situation with TinyMCE 4. All my "Enter" (keyboard) resulted in a new <p> </p>
injected.
I didn't want to use forced_root_block : false so I figured something out in the tinymce.init
function (each empty paragraph will be cleaned directly):
setup : function(editor) {
editor.on('PostProcess', function(ed) {
// we are cleaning empty paragraphs
ed.content = ed.content.replace(/(<p> <\/p>)/gi,'<br />');
});
}
https://www.tinymce.com/docs/configure/integration-and-setup/#setup https://www.tinymce.com/docs/api/class/tinymce.editor/#postprocess
Insert in theme functions.php the following code:
add_filter( 'tiny_mce_before_init', 'my_switch_tinymce_p_br' );
function my_switch_tinymce_p_br( $settings ) {
$settings['forced_root_block'] = 'br';
return $settings;
}
Instead try:
force_p_newlines : false,
force_br_newlines : true,
convert_newlines_to_brs : false,
remove_linebreaks : true,
What worked for me was:
tinymce.init({
...
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : ''
});
Each linebreak is producing br tag with these settings.
SOURCE: http://www.tinymce.com/wiki.php/Configuration3x:force_br_newlines
The "forced_root_block : false" option works fine for TinyMCE 4.0.
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