tinymce.dom.Serializer

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

Constructors

name summary defined by
Serializer() Constructs a new DOM serializer class. tinymce.dom.Serializer

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 ones it has finished parsing the document. tinymce.dom.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 ones it has finished parsing the document. tinymce.dom.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 Wiki for more details on this format. tinymce.dom.Serializer
addTempAttr() Adds a temporary internal attribute these attributes will get removed on undo and when getting contents out of the editor. tinymce.dom.Serializer
serialize() Serializes the specified browser DOM node into a HTML string. tinymce.dom.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 Wiki for more details on this format. tinymce.dom.Serializer

Constructors

Serializer

public constructor function Serializer(settings:Object, editor:tinymce.Editor)

Constructs a new DOM serializer class.

Parameters

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 ones 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

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 ones 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

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 Wiki for more details on this format.

Parameters

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

serialize

serialize(node:DOMNode, args:Object)

Serializes the specified browser DOM node into a HTML string.

Parameters

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 Wiki for more details on this format.

Parameters

Can't find what you're looking for? Let us know.

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.