CKEditor 4 Documentation

CKEDITOR.htmlParser.filter

Files

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>'
Defined By

Properties

Rules for attribute names.

Rules for attribute names.

CKEDITOR.htmlParser.filter
view source
: Objectreadonly
Hash of attributeName => rules for attributes. ...

Hash of attributeName => rules for attributes.

Defaults to: {}

Rules for comment nodes.

Rules for comment nodes.

Rules for element names.

Rules for element names.

CKEDITOR.htmlParser.filter
view source
: Objectreadonly
Hash of elementName => rules for elements. ...

Hash of elementName => rules for elements.

Defaults to: {}

CKEDITOR.htmlParser.filter
view source
: Numberreadonly

ID of filter instance, which is used to mark elements to which this filter has been already applied.

ID of filter instance, which is used to mark elements to which this filter has been already applied.

Rules for a root node.

Rules for a root node.

Rules for text nodes.

Rules for text nodes.

Defined By

Methods

CKEDITOR.htmlParser.filter
view source
new( [rules] ) : CKEDITOR.htmlParser.filter
Creates a filter class instance. ...

Creates a filter class instance.

Parameters

Returns

CKEDITOR.htmlParser.filter
view source
( rules, [options] )
Add rules to this filter. ...

Add rules to this filter.

Parameters

  • rules : CKEDITOR.htmlParser.filterRulesDefinition

    Object containing filter rules.

  • options : Object/Number (optional)

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

    • priority : Number (optional)

      The priority of a rule.

      Defaults to: 10

    • applyToAll : Boolean (optional)

      Whether to apply rule to non-editable elements and their descendants too.

      Defaults to: false

CKEDITOR.htmlParser.filter
view source
( node )
Apply this filter to given node. ...

Apply this filter to given node.

Parameters