How to define allowed tags in CKEditor?

前端 未结 6 1429
忘了有多久
忘了有多久 2020-12-08 01:01
  • Sometimes users copy and paste text from different sources to CKEditor, but I want to restrict what tags they can copy to CKEditor.

  • I only need to u

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 01:44

    There are some settings you can use. You define these settings editing the config.js file in the ckeditor's root directory. For example, if you want to be radical like me, you could put:

    config.forcePasteAsPlainText = true;
    

    If you want to restrict only certain tags exactly like you said, I found the setting bellow:

    config.removeFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd';
    

    The last will be done only when user execute the "remove format" command. More information: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.format_tags

    Considering all the time, I think that you already have found your answer, but others can be helped.

提交回复
热议问题