Proper TinyMCE Elements: Only allow specific CSS rules

The TinyMCE valid_elements property allows valid_elements to define a whitelist of valid HTML elements and their attributes. You can only allow paragraphs and links:

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

However, the style attribute is a problem. This is necessary for some things, such as alignment, but if you enable it, then it may contain all sorts of undesirable CSS rules. Is there a way to restrict its contents to allow certain rules, for example:

 a[href|style=text-align,font-size,color] 
+7
source share
2 answers

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

More and syntax: http://tinymce.moxiecode.com/forum/viewtopic.php?id=21554

+7
source

As far as I know, this is not possible in version 3.3.9.3. It may be available in version 3.4 because the verification implementation will be changed (declared by Mociecode).

+1
source

All Articles