在使用ueditor编辑器中,想保存style标签的样式须要对js配置文件进行修改。官方为了安全考虑,默认会将style标签转为DIV标签,致使样式不能显示出对应的效果。html
基于1.4.3版本修改以下node
1.找到ueditor.config.js文件安全
// 将下面3个参数值改成false // xss 过滤是否开启,inserthtml等操做 ,xssFilterRules: false //input xss过滤 ,inputXssFilter: false //output xss过滤 ,outputXssFilter: false
2.肯定页面引入的是 ueditor.all.min.js 仍是 ueditor.all.js ,并修改:xss
// 找到allowDivTransToP参数,这个参数会将DIV标签转为P标签,设置为false
me.setOpt(
{
'allowDivTransToP':false,
'disabledTableInTable':true
}
);
// 找到addInputRule方法,并将switch case 中的case style:删除 me.addInputRule(function (root) { ... //进行默认的处理 root.traversal(function (node) { if (node.type == 'element') { ... switch (node.tagName) { case 'style': // 删除这项 case 'script': .... } } } })
3. 刷新文件,从新设置便可编辑器