Prevent Blank P tags in TinyMCE

I am coding a tinyMCE plug in that wraps a selection within a pair of HTML comment tags, as such:

 <p><!--comment name:--> the selection   <!--/comment name--></p>

or

 <!--comment name:-->
       <p>the selection</p>
        <p>the selection</p>
<!--/comment name-->

I have my code generally working., BUT… when wrapping comments around block tags additional blank P tags are added around the selection:

<p>&nbs;</p>
<!--comment name:-->
 <p>the selection</p>
 <p>the selection</p>
 <p>&nbs;</p>
<!--/comment name-->

It appears that using setContent() to insert text automatically opens the two full P tags at the beginning and the end of the inserted text as shown above.

I realize I could set :

forced_root_block : '',
force_br_newlines : false,
force_p_newlines : false

but that has the unfortunate side effect of NOT wrapping P tags around content when user types in content regularly. So… it’s an all or nothing behavior :frowning:

Is there away to insert content ( HTML comments) as described in the top of this post w/o tinyMCE adding the tag around that SPECIFIC insert?

as always, thanks all for any all all advice. :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.