Question

I am using TinyMCE (http://tinymce.moxiecode.com/) in a .NET page. Whenever I load a text

myTMCE.value=mycontent;

I can see that my text gets wrapped in <p></p>. This is not desirable for me, so I am trying to avoid it. Trying to initialize in

        <script>
            tinyMCE.init({
                force_p_newlines: true
            })

        </script>

did not work. Any idea? Thanks in advance, m.

Was it helpful?

Solution

You could strip <p> tags after the fact using .NET, or alternatively, just use a plain <textarea> field for data entry if that suits what you're trying to do.

OTHER TIPS

You need to to do this :

<script>
    tinyMCE.init({
        forced_root_block: false,
        //some other options here
    })
</script>

By default TinyMCE sets as a root block. By setting this property to false you remove any wrapper for the text. The below text is from TinyMCE documentation:

This option enables you to make sure that any non block elements or text nodes are wrapped in block elements. For example something will result in output like:

something

This option is enabled by default as of 3.0a1.

If you set this option to false it will never produce P tags on enter or automatically it will instead produce BR elements and Shift+Enter will produce a P.

Note that not using P elements as root block can severely cripple the functionality of the editor.

http://www.tinymce.com/wiki.php/Configuration:forced_root_block

See this thread and the answer in TinyMCE forum. force_p_newline is a gecko only option (ie FF).

TinyMCE adds a whole load of tags to the text - its design goal is to create valid html from arbitrary input (including html input). If you want control over the generated html code, you're better off using another editor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top