TinyMCE produce P elements on enter/return instead of BR elements?
Here are a few reasons why BR elements and the force_br_newlines aren't enabled by default and why forced_root_block is.
- Paragraphs were invented for a reason. Try modifying paragraph margins using CSS without using paragraph tags and you see what we mean.
- The IE WYSIWYG environment is built on handling paragraphs when it comes to alignment/list management and much more. TinyMCE and other editors will start producing lots of strange results if you enable force_br_newlines.
- The space between the paragraphs can be removed using a simple CSS trick like this. p {margin:0; padding: 0;}. This is not possible with BR elements, since the whole line is not wrapped in a container. So P elements gives you the flexibility to choose.
- If you really must have BR instead of paragraph elements for some reason – for example to interface with Flash or send e-mail messages –, then simply post process them away by replacing <p with <span and </p> with </span><br />, which takes care of P tags with class or style attributes. The same process but from BR tags to P tags can not be done since you don't have a reference for the start element.
- Paragraphs make more semantically correct XHTML markup, and we are trying to make an XHTML editor, not an old HTML editor.
- Paragraphs are mostly more valid containers for text in a W3C strict environment since plain text nodes are not allowed in all containers.
- BR elements can still be produced if you really need one at a specific place for some reason using Shift+Enter/Return this is exactly the same behavior popular Word processors have. Check this video.
- We have never seen one single valid reason why paragraphs must not be used unless it's for e-mail software or for integration with Flash, and both cases can and should be solved with post processing if you want the user to be able to modify the contents again with TinyMCE. If you have a good reason please drop us a e-mail describing it and I will put it on my exceptions list.
So if you really really must use BR elements for some odd reason then set this in your init code:
tinyMCE.init({
forced_root_block : false,
force_br_newlines : true,
force_p_newlines : false
});
- Since all too many people prefer to have "single spacing", why not set the default behaviour to "margin: 0px;padding: 0px;" and have two consecutive lines (created by pressing "Enter" twice) be turned to proper paragraph with padding-margin?
- I am too noob to understand how I can make this the default behaviour when using TinyMCE in my website. Would it be possible to create a detailed guide on how to add this functionality to TinyMCE?
- I can add the 0 margin, padding when writing text within TinyMCE, but how could I get this embedded in a text pasted into the editor, so that it would be the default when creating/writing a new document AND when pasting a document?
I beg for your understanding. Thanks in advance.