TinyMCE有效元素:只允许特定的CSS规则 [英] TinyMCE valid elements: only allow specific CSS rules

查看:963
本文介绍了TinyMCE有效元素:只允许特定的CSS规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TinyMCE的 valid_elements 属性可让您定义有效HTML元素及其属性的白名单。您只能以下列方式允许段落和连结:

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]'
});

但是, style 的问题。它需要某些事情,如对齐,但如果你允许它,那么它可能包含各种不良的CSS规则。有任何方法来限制其内容只允许某些规则,像这样:

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]


推荐答案

,有一个未记录的选项称为valid_styles。

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

更多&语法: http://tinymce.moxiecode.com/forum/viewtopic.php?id=21554

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

这篇关于TinyMCE有效元素:只允许特定的CSS规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆