网上资料少得可怜,蒙着做完记录一下。
第一步:下面是逻辑处理代码(网上抄的),这个代码是放在项目路径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