tinymce.html.DomParser
This class parses HTML code into a DOM like structure of nodes it will remove redundant whitespace and make sure that the node tree is valid according to the specified schema. So for example: <p>a<p>b</p>c</p>
will become <p>a</p><p>b</p><p>c</p>
.
Examples
const parser = tinymce.html.DomParser({ validate: true }, schema);
const rootNode = parser.parse('<h1>content</h1>');
Summary
Methods
Name | Summary | Defined by |
---|---|---|
Adds an attribute filter function to the parser, the parser will collect nodes that has the specified attributes and then execute the callback once it has finished parsing the document. |
||
Adds a node filter function to the parser, the parser will collect the specified nodes by name and then execute the callback once it has finished parsing the document. |
||
Parses the specified HTML string into a DOM like node tree and returns the result. |
||
Removes an attribute filter function or removes all filter functions from the parser for the attribute names provided. |
||
Removes a node filter function or removes all filter functions from the parser for the node names provided. |
Methods
addAttributeFilter()
addAttributeFilter(name: String, callback: Function)
Adds an attribute filter function to the parser, the parser will collect nodes that has the specified attributes and then execute the callback once it has finished parsing the document.
addNodeFilter()
addNodeFilter(name: String, callback: Function)
Adds a node filter function to the parser, the parser will collect the specified nodes by name and then execute the callback once it has finished parsing the document.
parse()
parse(html: String, args: Object): tinymce.html.Node
Parses the specified HTML string into a DOM like node tree and returns the result.
removeAttributeFilter()
removeAttributeFilter(name: String, callback: Function)
Removes an attribute filter function or removes all filter functions from the parser for the attribute names provided.
removeNodeFilter()
removeNodeFilter(name: String, callback: Function)
Removes a node filter function or removes all filter functions from the parser for the node names provided.