Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE valid elements: only allow specific CSS rules

TinyMCE's valid_elements property lets you define a whitelist of valid HTML elements and their attributes. You can allow only paragraphs and links with this:

tinyMCE.init({
    valid_elements: 'p,a[href]'
});

However, the style attribute is a bit of a problem. It's needed for certain things like aligning, but if you allow it then it could contain all sorts of undesirable CSS rules. Is there any way to restrict its contents to only allow certain rules, something like this:

a[href|style=text-align,font-size,color]
like image 841
Marcus Downing Avatar asked Mar 02 '11 09:03

Marcus Downing


People also ask

How do you override TinyMCE CSS?

You can bring the toolbar down using toolbar_location: "bottom" . Regarding CSS, you can override the default CSS with your own styles using content_css . For example: content_css: "/mycontent.

How do you make TinyMCE editor readonly?

</p></textarea> <br><br> <label class="container">Editable ("design") mode <input type="checkbox" checked onclick="toggleEditorMode(this. checked); return true;"> <span class="checkmark"></span> </label> <br> Use the checkbox to toggle between the "design" and "readonly" modes.


1 Answers

There you go, there is an undocumented option called "valid_styles".

More & Syntax: http://tinymce.moxiecode.com/forum/viewtopic.php?id=21554

like image 182
leomelzer Avatar answered Sep 18 '22 00:09

leomelzer