ue怎么转换html格式,富文本编辑器生成的HTML标签,如何读取

ffd6ac8b64ae3ad2c6d02f2b36d5143f.png

aichipu

新兵答主

07-22

TA获得超过6599个赞

根据现象,Editor是把,标签滤掉了,这个时Editor为了保护专门滤掉的,需要手动配置才可以:

不知道你的是什么版本,这个配置和Editor的版本有关,请先在ueditor.config.js中搜索whiteList,

如有有,证明你这个版本是老版本,这样打开注释并设置如下:

serialize : {

//黑名单,编辑器会过滤掉以下标签

blackList:{style:1, link:1,object:1, input:1, meta:1},

//白名单,编辑器会根据此配置保留对应标签下的对应标签或者属性

whiteList:{

''p'': {''br'':1,''BR'':1},

''br'':{''$'':{}},

''div'':{''br'':1,''BR'':1,''$'':{''id'':1,''style'':1}} ,

''html'':{$:{}},

''body'':{$:{}}

}

}

如果没有搜到whiteList,那证明是新版本,那么搜索filterTxtRules,打卡注释并设置如下:

''filterTxtRules'' : function(){

function transP(node){

node.tagName = ''p'';

node.setStyle();

}

return {

//直接删除及其字节点内容

''-'' : ''script style object iframe embed input select'',

''p'': {$:{}},

''br'':{$:{}},

''div'':{''$'':{}},

''li'':{''$'':{}},

''caption'':transP,

''th'':transP,

''tr'':transP,

''h1'':transP,''h2'':transP,''h3'':transP,''h4'':transP,''h5'':transP,''h6'':transP,

''td'':function(node){

//没有内容的td直接删掉

var txt = !!node.innerText();

if(txt){

node.parentNode.insertAfter(UE.uNode.createText('' ''),node);

}

node.parentNode.removeChild(node,node.innerText())

}

}

}()

你试试看。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值