CKEditor - remove script tag with data processor

故事扮演 提交于 2019-12-04 11:40:00

You can use this :

CKEDITOR.replace('editor1', {
   on: {
      pluginsLoaded: function(event) {
         event.editor.dataProcessor.dataFilter.addRules({
            elements: {
               script: function(element) {
                  return false;
               }
            }
         });
      }
   }
});

If you are using CKEditor 4.1 or above, you may use Advanced Content Filter to allow the content you want.

If you are using CKEditor 4.4 or above, there is an easier way. You can use Disallowed Content to filter content you don't like .

 config.disallowedContent = 'script';

As I'm having CKEditor 4, I did the next

CKEDITOR.instances.editor1.config.protectedSource.push( /{.*\".*}/g );

It will ignore quotes in smarty curly brackets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!