CKEDITOR.htmlParser.filter
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
-
attributeNameRules : filterRulesGroup
readonly
Rules for attribute names.
-
attributesRules : Object
readonly
Hash of attributeName => rules for attributes.
Defaults to
{}
-
commentRules : filterRulesGroup
readonly
Rules for comment nodes.
-
elementNameRules : filterRulesGroup
readonly
Rules for element names.
-
elementsRules : Object
readonly
Hash of elementName => rules for elements.
Defaults to
{}
-
id : Number
readonly
ID of filter instance, which is used to mark elements to which this filter has been already applied.
-
rootRules : filterRulesGroup
readonly
Rules for a root node.
-
textRules : filterRulesGroup
readonly
Rules for text nodes.
Methods
-
constructor( [ rules ] ) → filter
Creates a filter class instance.
-
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).
Properties[ priority ] : Number
The priority of a rule.
Defaults to
10
[ applyToAll ] : Boolean
Whether to apply rule to non-editable elements and their descendants too.
Defaults to
false
-
applyTo( node )
Apply this filter to given node.
Parameters
node : node
The node to be filtered.