tinymce.dom.Serializer

This class is used to serialize DOM trees into a string. Consult the TinyMCE API Documentation for more details and examples on how to use this class.

Summary

Methods

Name Summary Defined by

addAttributeFilter()

Adds a attribute filter function to the parser used by the serializer, the parser will collect nodes that has the specified attributes and then execute the callback once it has finished parsing the document.

Serializer

addNodeFilter()

Adds a node filter function to the parser used by the serializer, the parser will collect the specified nodes by name and then execute the callback once it has finished parsing the document.

Serializer

addRules()

Adds valid elements rules to the serializers schema instance this enables you to specify things like what elements should be outputted and what attributes specific elements might have. Consult the TinyMCE Documentation for more details on this format.

Serializer

addTempAttr()

Adds a temporary internal attribute these attributes will get removed on undo and when getting contents out of the editor.

Serializer

getTempAttrs()

Returns an array of all added temp attrs names.

Serializer

serialize()

Serializes the specified browser DOM node into a HTML string.

Serializer

setRules()

Sets the valid elements rules to the serializers schema instance this enables you to specify things like what elements should be outputted and what attributes specific elements might have. Consult the TinyMCE Documentation for more details on this format.

Serializer

Methods

addAttributeFilter()

addAttributeFilter(callback: function)

Adds a attribute filter function to the parser used by the serializer, the parser will collect nodes that has the specified attributes and then execute the callback once it has finished parsing the document.

Examples

parser.addAttributeFilter('src,href', function(nodes, name) {
 for (var i = 0; i < nodes.length; i++) {
  console.log(nodes[i].name);
 }
});

Parameters

  • callback (function) - Callback function to execute once it has collected nodes.


addNodeFilter()

addNodeFilter(callback: function)

Adds a node filter function to the parser used by the serializer, the parser will collect the specified nodes by name and then execute the callback once it has finished parsing the document.

Examples

parser.addNodeFilter('p,h1', function(nodes, name) {
 for (var i = 0; i < nodes.length; i++) {
  console.log(nodes[i].name);
 }
});

Parameters

  • callback (function) - Callback function to execute once it has collected nodes.


addRules()

addRules(rules: String)

Adds valid elements rules to the serializers schema instance this enables you to specify things like what elements should be outputted and what attributes specific elements might have. Consult the TinyMCE Documentation for more details on this format.

Parameters

  • rules (String) - Valid elements rules string to add to schema.


addTempAttr()

addTempAttr(name: String)

Adds a temporary internal attribute these attributes will get removed on undo and when getting contents out of the editor.

Parameters

  • name (String) - string


getTempAttrs()

getTempAttrs(): String[]

Returns an array of all added temp attrs names.

Return value

  • String[] - Array with attribute names.


serialize()

serialize(node: DOMNode, args: Object)

Serializes the specified browser DOM node into a HTML string.

Parameters

  • node (DOMNode) - DOM node to serialize.

  • args (Object) - Arguments option that gets passed to event handlers.


setRules()

setRules(rules: String)

Sets the valid elements rules to the serializers schema instance this enables you to specify things like what elements should be outputted and what attributes specific elements might have. Consult the TinyMCE Documentation for more details on this format.

Parameters

  • rules (String) - Valid elements rules string.