在使用kindeditor文本编辑器时遇到的问题,客户直接从Excel里粘贴文本内容到文本编辑器中(能不能再懒一些),然后不调整粘贴内容直接就保存(你敢不敢再懒一些)!对于这种很无语的行径,我只能对他大吼一声,我做一个标签过滤吧,这样你粘贴就不会出现问题了(怂?谁惹得起客户)。

过滤方法也简单:

KindEditor.ready(function (K) {
editor = K.create('textarea[name="content"]', {
filterMode: true,//是否开启过滤模式
});
});

默认filterMode是关闭状态,首先把filterMode设置为true,然后增加htmlTags,指定要保留的HTML标记和属性。哈希数组的key为HTML标签名,value为HTML属性数组,"."开始的属性表示style属性。数据类型:Object

KindEditor.ready(function (K) {
editor = K.create('textarea[name="content"]', {
filterMode: true,//是否开启过滤模式
htmlTags : {
font : ['id', 'class', 'color', 'size', 'face', '.background-color'],
div : [
'id', 'class', 'align', '.border', '.margin', '.padding', '.text-align', '.color',
'.background-color', '.font-size', '.font-family', '.font-weight', '.background',
'.font-style', '.text-decoration', '.vertical-align', '.margin-left'
],
a : ['id', 'class', 'href', 'target', 'name'],
embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
img : ['id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
'.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
],
pre : ['id', 'class'],
hr : ['id', 'class', '.page-break-after'],
'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : ['id', 'class'],
iframe : ['id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height']
}
});
});

最新文章

  1. redhat7 修改hostname
  2. 一鼓作气 博客--第三篇 note3
  3. 查看修改Linux时区和时间
  4. JQ第一天
  5. 分享我常用的一些JS验证和函数
  6. Max retries exceeded with url
  7. JDBC链接
  8. 【狼】unity3d collision获取碰撞的点的位置
  9. 解决的方法:warning: Clock skew detected. Your build may be incomplete.
  10. python tornado nginx deployment tornado 的部署在linux Nginx服务器
  11. gmic全球移动互联网大会 全球九站已开启!
  12. 「CSS3 」3D效果 & 透视
  13. js原生API妙用(一)
  14. RadioButton与监听
  15. MySQL数据库学习笔记----MySQL多表查询之外键、表连接、子查询、索引
  16. 十、Python练习----基础搭建飞机大战
  17. Oracle 自定义函数、存储过程
  18. selenium + python + nwjs
  19. AT2046 Namori 图论
  20. C# 在WPF中使用Exceptionless异常日志框架

热门文章

  1. IIS基本介绍
  2. DotNetBar for Windows Forms 14.0.0.3_冰河之刃重打包版原创发布
  3. Boost总结汇总
  4. Selenium-等待
  5. 关于Android 7.0更新后调用系统相机及电筒问题
  6. linux系统中ls命令的用法
  7. PHP XDebug Sublime Text 单步调试
  8. Win10版《芒果TV》全平台直播第89届奥斯卡颁奖典礼,特设第二演播室带来一手资讯
  9. Win10《芒果TV》商店版更新v3.2.3:新增应用内意见反馈、播放重试、透明磁贴
  10. Win10的UWP之进度条