美文网首页@IT·互联网
Kindeditor文本编辑器如何过滤HTML

Kindeditor文本编辑器如何过滤HTML

作者: 唯爱述虞谁 | 来源:发表于2017-05-04 13:39 被阅读101次

KindEditor.ready(function(K){

       editor = K.create('textarea[name="content"]',{

                  filterMode: true,//是否开启过滤模式  false:关闭过滤模式,

               //4.1版本以后默认是true,4.1版本以前的要加filterMode:true

       }

}

以及JS配置文件内,不在列表内的都被过滤掉了(下方的配置文件看个人需求),或可以采用js默认配置,在上方的js模块添加需要过滤的模块

htmlTags : {

font : ['id', 'class', 'color', 'size', 'face', '.background-color'],

span : ['id', 'class','.color', '.background-color', '.font-size', '.font-family', '.background',

             '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height'

           ],

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'

     ],

table: ['border','cellspacing','cellpadding','width','height','align','bordercolor',],

'td,th': ['id', 'class', 'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',],

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',

        ],

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']

}

注意!!Kindeditor编辑器过滤的标签为js配置文件htmlTags列表之外的标签!!!

相关文章

网友评论

    本文标题:Kindeditor文本编辑器如何过滤HTML

    本文链接:https://www.haomeiwen.com/subject/kvwrtxtx.html