-----------时间略紧迫,随便记一下----------
ueditor.all.js文件下大概uNode.prototype(大概在8843行)下添加去除属性的方法
/**
* @description: 删除节点属性
* @param {*} name
* @return {*}
*/
removeAttr: function(node, name) {
if(name.indexOf(',') === -1) {
delete node.attrs[name]
} else {
var attrNameList = name.split(',')
attrNameList.forEach(item => {
delete node.attrs[item]
})
}
},
在引用的配置js中配置 默认纯文本粘贴模式打开
//粘贴只保留标签,去除标签所有属性
retainOnlyLabelPasted: true,
//getContent时,是否删除空的inlineElement节点(包括嵌套的情况)
autoClearEmptyNode : true,
//是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
pasteplain:true,
//纯文本粘贴模式下的过滤规则
filterTxtRules: (function () {
return {
// 直接删除及其字节点内容
'-': 'script style object iframe embed input select',
'p': function (node) {
node.tagName = 'p'
node.removeAttr(node, 'style')
},
'br': { $: {} },
'div': { '$': {} },
'li': { '$': {} },
'caption': function (node) {
node.tagName = 'p'
node.removeAttr(node, 'style')
},
'table': function (node) {
node.tagName = 'table'
node.setAttr('border', '1')
node.removeAttr(node, 'style')
},
'tbody': function (node) {
node.tagName = 'tbody'
node.removeAttr(node, 'style')
},
'th': function (node) {
node.tagName = 'th'
node.removeAttr(node, 'style')
},
'tr': function (node) {
node.tagName = 'tr'
node.removeAttr(node, 'style')
},
'td': function (node) {
node.tagName = 'td'
node.setAttr('rowspan', node.attrs.rowspan)
node.removeAttr(node, 'style')
},
'h1': function (node) {
node.tagName = 'h1'
node.removeAttr(node, 'style')
},
'h2': function (node) {
node.tagName = 'h2'
node.removeAttr(node, 'style')
},
'h3': function (node) {
node.tagName = 'h3'
node.removeAttr(node, 'style')
},
'h4': function (node) {
node.tagName = 'h4'
node.removeAttr(node, 'style')
},
'h5': function (node) {
node.tagName = 'h5'
node.removeAttr(node, 'style')
},
'h6': function (node) {
node.tagName = 'h6'
node.removeAttr(node, 'style')
},
'audio': function (node) {
node.tagName = 'audio'
},
'video': function (node) {
node.tagName = 'video'
},
'img': function (node) {
node.tagName = 'img'
},
'map': function (node) {
node.tagName = 'map'
},
'area': function (node) {
node.tagName = 'area'
},
'canvas': function (node) {
node.tagName = 'canvas'
},
'svg': function (node) {
node.tagName = 'svg'
}
}
}())