CkEditor敏感词过滤高亮提示方法【详细】

网上资料少得可怜,蒙着做完记录一下。
第一步:下面是逻辑处理代码(网上抄的),这个代码是放在项目路径ckeditor/plugins/sensitivewordshighlight/plugin.js中,这是以插件形式导入,目录没有就需要自己新建,这是参考的官方文档的插件目录结构说明。

CKEDITOR.plugins.add('sensitivewordshighlight', {
   

    init: function (editor) {
   
        /*
        *      取消所有高亮
        */
        editor.CancleSensitiveWordsHighlight=function () {
   
            var regstrEpswh = '<span class="ep_ckeditor_sensitivewords" style="background-color:[^<>:]+[;]*">([^<>]+)<\/span>';
            var htmlEpswh = this.getData();
            htmlEpswh = htmlEpswh.replace(eval("/" + regstrEpswh + "/ig"), "$1");
            if (this.document != null)
                this.document.getBody().setHtml(htmlEpswh);
            return htmlEpswh;
        }
        /*
        *    words 敏感词
        *    igChar 敏感词中忽略的特殊字符
        *    color 高亮底色
        */
        editor.SensitiveWordsHighlight = function 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值