5099 Posts in 1519 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1368 Views |
-
Remove <p> tags - TinyMCE HTMLeditor

17 February 2012 at 7:26pm Last edited: 17 February 2012 8:37pm
I'm posting the solution Ive found to successfully removing the p tags from the TinyMCE editor considering the grief it has given me, it might be useful to someone else.
I understand there are people who believe the p tags are necessary, but I much prefer <br /> tags and think they provide much for cleaner code.
There's also a css 'solution'.
p{
margin:0px;
padding:0px;
}But my preferred solution below.
CustomLeftAndMainDecorator.php
<?php
class CustomLeftAndMainDecorator extends LeftAndMainDecorator{
function init(){
$htmlEditorConfig = HtmlEditorConfig::get('cms');
$htmlEditorConfig->setOption('forced_root_block','');
$htmlEditorConfig->setOption('force_br_newlines',true);
$htmlEditorConfig->setOption('force_p_newlines',false);
$htmlEditorConfig->setOption('convert_newlines_to_brs',false);
$htmlEditorConfig->setOption('invalid_elements','p');
$htmlEditorConfig->setOption('paste_auto_cleanup_on_past',true);
$htmlEditorConfig->setOption('paste_remove_styles',true);
$htmlEditorConfig->setOption('paste_remove_styles_if_webkit',true);
$htmlEditorConfig->setOption('paste_strip_class_attributes',true);
}
}Add to mysite/_config.php
Object::add_extension("LeftAndMain", "CustomLeftAndMainDecorator");
-
Re: Remove <p> tags - TinyMCE HTMLeditor

18 February 2012 at 12:58am Last edited: 18 February 2012 12:59am
On windows you can do <shift><enter> to create a <br /> instead of a new <p>. giving you the best of both worlds. Works on mac too I think
| 1368 Views | ||
|
Page:
1
|
Go to Top |

