Create a predicate based input filter for an editor instance with editor.filters.predicate.addInput().
The predicate based input filter modifies content added to the editor with: textboxio.replace(), editor.content.set(), editor.content.insertHtmlAtCursor().
Example
editor.filters.predicate.addInput(matchingFn, callback)
// A matching function identifying elements that are HTML comments and then returning those elements
var comments = function(element) {
return element.nodeType == 8 || element.nodeName == '#comment';
};
// Create an in filter identifying comments, supplying the matching function highlights the comment text in a red span and then removes the original comment
editor.filters.predicate.addInput(comments, function(elements) {
$(elements).each(function(index, element){
var textContent = $(element)[0].textContent;
$(element).after('<span style="background-color:red;">' + textContent + '</span>');
$(element).remove();
});
});
Parameters
matchingFn | Function | Specify a named function that returns the elements you wish to pass to the callback function. |
callback | Function | A function to process the array of matched elements. |
Returns
No return value.