TinyMCE wraps my text in <p>. </p> Can I avoid this?
I am using TinyMCE ( http://tinymce.moxiecode.com/ ) on a .NET page. Whenever I load text
myTMCE.value=mycontent; I see that my text is wrapped in <p></p> . This is undesirable for me, so I try to avoid it. Try to initialize to
<script> tinyMCE.init({ force_p_newlines: true }) </script> does not work. Any ideas? Thanks in advance, m.
You can remove the <p> tags after the fact using .NET, or alternatively just use the plain <textarea> data entry field if that matches what you are trying to do.
You need to do this:
<script> tinyMCE.init({ forced_root_block: false, //some other options here }) </script> By default, TinyMCE is installed as the root block. By setting this property to false, you will remove any wrapper for the text. Below is the text from the TinyMCE documentation:
This option allows you to make sure that any non-blocking elements or text nodes are wrapped in block elements. For example , something will lead to a conclusion, for example:
something
This option is enabled by default on 3.0a1.
If you set this parameter to false, it will never generate P tags as you type or will automatically produce BR elements, and Shift + Enter will create P.
Note that not using P elements as the root block can seriously damage the editorβs functionality.
http://www.tinymce.com/wiki.php/Configuration:forced_root_block
See this thread and the answer on the TinyMCE forum. force_p_newline is just a gecko option (i.e. FF).
TinyMCE adds a whole load of tags to the text - its design goal is to create a valid html from arbitrary input (including html input). If you need control over the generated html code, you better use a different editor.