How to define allowed tags in CKEditor?

前端 未结 6 1434
忘了有多久
忘了有多久 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条回答
  •  萌比男神i
    2020-12-08 01:59

    I just did this to make sure nobody could put an tag in the editor. It could probably be extended to other tags:

                CKEDITOR.on('instanceReady', function(ev)
                {
                    var editor = ev.editor;
                    var dataProcessor = editor.dataProcessor;
                    var htmlFilter = dataProcessor && dataProcessor.htmlFilter;
                    htmlFilter.addRules(
                    {
                        elements : 
                        {
                            input: function(element)
                            {
                                return false;
                            },
                        }
                    });
                });
    

提交回复
热议问题