Report an issue
Class

CKEDITOR.htmlParser.filter

class

Filter is a configurable tool for transforming and filtering nodes. It is mainly used during data processing phase which is done not on real DOM nodes, but on their simplified form represented by CKEDITOR.htmlParser.node class and its subclasses.

var filter = new CKEDITOR.htmlParser.filter( {
    text: function( value ) {
        return '@' + value + '@';
    },
    elements: {
        p: function( element ) {
            element.attributes.foo = '1';
        }
    }
} );

var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<p>Foo<b>bar!</b></p>' ),
    writer = new CKEDITOR.htmlParser.basicWriter();
filter.applyTo( fragment );
fragment.writeHtml( writer );
writer.getHtml(); // '<p foo="1">@Foo@<b>@bar!@</b></p>'

Filtering

Properties

Methods

  • constructor( [ rules ] ) → filter

    Creates a filter class instance.

    Parameters

    [ rules ] : filterRulesDefinition

    Returns

    filter
  • addRules( rules, [ options ] )

    Add rules to this filter.

    Parameters

    rules : filterRulesDefinition

    Object containing filter rules.

    [ options ] : Object | Number

    Object containing rules' options or a priority (for a backward compatibility with CKEditor versions up to 4.2.x).

  • applyTo( node )

    Apply this filter to given node.

    Parameters

    node : node

    The node to be filtered.