Q:

TinyMce : Customizing new lines

Is there any way to put one span inside p tag(root element of tiny mce)?
I mean each new line should be 
<p><span></span></p>

Any idea to achieve this?
My workarounds are these..

I tested forced_root_block: 'p,span' but it wont worked.
In each key press i tried to replace <p> with <p><span> and </p> with </span></p> but that is not reflecting in editor and i am sure the replace logic works perfectly because i printed in console that shows the expected output(<p><span>{{my input}}</span></p>).

A:

Yes, use this directive inside your tinymce.init({});
setup: function(editor) {
    editor.on('PostProcess', function(ed) {
        ed.content = ed.content.replace(/(<p>)/gi,'<p><span>').replace(/(<\/p>)/gi,'<\/span><\/p>');
    });
}

This will replace automatically all your <p></p> tags with <p><span></span></p>
Look: i'm using the PostProcess event http://www.tinymce.com/wiki.php/api4:event.tinymce.Editor.PostProcess
With a little bit of imagination you can customize that event a little bit more. Here you can see a full working example: http://jsfiddle.net/csedoardo/bbfg7x3z/

