TinyMCE valid elements: only allow specific CSS rules

与世无争的帅哥 提交于 2019-12-23 08:56:07

问题


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]

回答1:


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

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




回答2:


As far as i know, this is not possible with Version 3.3.9.3 . It might be available in Version 3.4 because the validation implementation will be changed (anounced by Mociecode).



来源:https://stackoverflow.com/questions/5165586/tinymce-valid-elements-only-allow-specific-css-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!