Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor strip/filter HTML comments?

Tags:

ckeditor

I see a lot about this smart Advanced Content Filter, but it's too smart, it handles HTML elements and doesn't let me do custom filtering. I can't figure out how to strip all inserted HTML comments.

like image 976
Farzher Avatar asked Feb 19 '26 12:02

Farzher


1 Answers

Advanced Content Filter does not touch comments. It only filters HTML elements, nothing more.

If you want to strip all comments, then using dataProcessor's filters will be the best choice.

For example to filter them out on input:

CKEDITOR.replace( 'editor1', {
    on: {
        pluginsLoaded: function( evt ) {
            evt.editor.dataProcessor.dataFilter.addRules( {
                comment: function() {
                    return false;
                }
            } );
        }
    }
} );
like image 121
Reinmar Avatar answered Feb 21 '26 00:02

Reinmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!