首页 > 其他 > 详细

ueditor1.4.3.1版本二次开发记录

时间:2015-10-10 11:54:03      阅读:783      评论:0      收藏:0      [点我收藏+]

最近项目需要拿ueditor做一些个性化功能,在此特意把修改的内容记录在这,一来方便自己知道改动过的地方,二来也是希望后来者如何需要做到类似的功能可以直接拿去用了。

1.去除复制粘贴内容中的图片、段落所包含的样式及类名

在ueditor.config.js中找到“filterTxtRules”配置,并修改为以下代码

 1 filterTxtRules : function(){
 2            function transP(node){
 3                node.tagName = ‘p‘;
 4                node.attrs=‘‘; //清空所有属性
 5                node.setStyle();               
 6            }
 7            return {
 8                //直接删除及其字节点内容
 9                ‘-‘ : ‘script style object iframe embed input select‘,
10                ‘p‘: function(node){
11                    node.attrs=‘‘; //清空粘贴内容中p元素所带的属性
12                },
13                ‘img‘:function(node){
14                 node.attrs[‘class‘]=‘‘;//清除class属性,此处不能使用node.attrs.class=‘‘,在ie8下报错,因为class是关键字
15                 node.attrs[‘style‘]=‘‘;//清除style属性
16                 node.setStyle();
17                },
18                ‘br‘:{‘$‘:{}},
19                ‘div‘:{‘$‘:{}},
20                ‘li‘:{‘$‘:{}},
21                ‘caption‘:transP,
22                ‘th‘:transP,
23                ‘tr‘:transP,
24                ‘h1‘:transP,‘h2‘:transP,‘h3‘:transP,‘h4‘:transP,‘h5‘:transP,‘h6‘:transP,
25                ‘td‘:function(node){
26                    //没有内容的td直接删掉
27                    var txt = !!node.innerText();
28                    if(txt){
29                        node.parentNode.insertAfter(UE.uNode.createText(‘    ‘),node);
30                    }
31                    node.parentNode.removeChild(node,node.innerText())
32                }
33            }
34         }()

 

ueditor1.4.3.1版本二次开发记录

原文:http://www.cnblogs.com/zhouzone/p/4866131.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!