分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

百度编辑器不能插入html标签解决方法

发布时间:2023-09-06 01:12责任编辑:熊小新关键词:暂无标签

在ueditor.all.js文件中找到此方法:

me.addInputRule(function (root) { ???????var allowDivTransToP = this.options.allowDivTransToP; ???????var val; ???????function tdParent(node){ ???????????while(node && node.type == ‘element‘){ ???????????????if(node.tagName == ‘td‘){ ???????????????????return true; ???????????????} ???????????????node = node.parentNode; ???????????} ???????????return false; ???????}// ????????case ‘style‘:// ???????????????????case ‘script‘:// ???????????????????????node.setAttr({// ???????????????????????????cdata_tag: node.tagName,// ???????????????????????????cdata_data: (node.innerHTML() || ‘‘),// ???????????????????????????‘_ue_custom_node_‘:‘true‘// ???????????????????????});// ???????????????????????node.tagName = ‘div‘;// ???????????????????????node.innerHTML(‘‘);// ???????????????????????break; ???????// ???????????????????????var cssStyle = node.getAttr(‘style‘);// ???????????????????????if (cssStyle) {// ???????????????????????????cssStyle = cssStyle.replace(/(margin|padding)[^;]+/g, ‘‘);// ???????????????????????????node.setAttr(‘style‘, cssStyle)//// ???????????????????????} ???????????????????????//p标签不允许嵌套// ???????????????????????utils.each(node.children,function(n){// ???????????????????????????if(n.type == ‘element‘ && n.tagName == ‘p‘){// ???????????????????????????????var next = n.nextSibling();// ???????????????????????????????node.parentNode.insertAfter(n,node);// ???????????????????????????????var last = n;// ???????????????????????????????while(next){// ???????????????????????????????????var tmp = next.nextSibling();// ???????????????????????????????????node.parentNode.insertAfter(next,last);// ???????????????????????????????????last = next;// ???????????????????????????????????next = tmp;// ???????????????????????????????}// ???????????????????????????????return false;// ???????????????????????????}// ???????????????????????});}) ???

 将这些对标签处理的逻辑都注释掉,当然后面还有别的标签,大家自己根据自己的需求看是否需要注释。

还有一点需要说明,div标签会自动变成p标签,这里的设置可以在ueditor.config.js文件中找到配置项

搜索allowDivTransToP配置项,将此项改为false,就不会把div改成p了。

百度编辑器不能插入html标签解决方法

原文地址:http://www.cnblogs.com/sxf2017/p/7568689.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved