Report an issue
Class

CKEDITOR.filter

classsince 4.1.0

Highly configurable class which implements input data filtering mechanisms and core functions used for the activation of editor features.

A filter instance is always available under the CKEDITOR.editor.filter property and is used by the editor in its core features like filtering input data, applying data transformations, validating whether a feature may be enabled for the current setup. It may be configured in two ways:

In both cases additional allowed content rules may be added by setting the CKEDITOR.config.extraAllowedContent configuration option.

Note: Filter rules will be extended with the following elements depending on the CKEDITOR.config.enterMode and CKEDITOR.config.shiftEnterMode settings:

Read more about Advanced Content Filter in guides.

A filter may also be used as a standalone instance by passing CKEDITOR.filter.allowedContentRules instead of CKEDITOR.editor to the constructor:

var filter = new CKEDITOR.filter( 'b' );

filter.check( 'b' ); // -> true
filter.check( 'i' ); // -> false
filter.allow( 'i' );
filter.check( 'i' ); // -> true

If the filter is only used by a single editor instance, you should pass the editor instance alongside with the rules. Passing the editor as the first parameter binds it with the filter so the filter can be removed with the CKEDITOR.editor.destroy method to prevent memory leaks.

// In both cases the filter will be removed during the CKEDITOR.editor.destroy function execution.
var filter1 = new CKEDITOR.filter( editor );
var filter2 = new CKEDITOR.filter( editor, 'b' );

Filtering

Properties

Static properties

Methods