tinymce.html.Schema
Schema validator class.
Examples
if (tinymce.activeEditor.schema.isValidChild('p', 'span')) {
alert('span is valid child of p.');
}
if (tinymce.activeEditor.schema.getElementRule('p')) {
alert('P is a valid element.');
}
Summary
Methods
Name | Summary | Defined by |
---|---|---|
Adds custom non-HTML elements to the schema. For more information about adding custom elements see: custom_elements |
||
Parses a valid children string and adds them to the schema structure. The valid children
format is for example |
||
Parses a valid elements string and adds it to the schema. The valid elements
format is for example |
||
Returns a map with block elements. |
||
Returns a map with boolean attributes. |
||
Returns an map object of all custom elements. |
||
Returns true/false if the specified element is valid or not according to the schema. |
||
Name/value map object with valid styles for each element. |
||
Returns a map with elements that the caret should be moved in front of after enter is pressed. |
||
Returns a map with elements that should be treated as contents regardless if it has text
content in them or not. For example: |
||
Returns a map with self closing tags. For example: |
||
Returns a map with special elements. These are elements that needs to be parsed in a special way such as script, style, textarea etc. The map object values are regexps used to find the end of the element. |
||
Returns a map with text block elements. For example: |
||
Returns a map of inline text format nodes. For example: |
||
Returns a map with elements that should be treated as transparent. |
||
Name/value map object with valid classes for each element. |
||
Name/value map object with valid styles for each element. |
||
Returns a map with void elements. For example: |
||
Returns a map with elements where white space is to be preserved. For example: |
||
Returns true/false if the specified element name and optional attribute is valid according to the schema. |
||
Returns true/false if the specified element and it’s child is valid or not according to the schema. |
||
Parses a valid elements string and sets it to the schema. The valid elements
format is for example |
Methods
addCustomElements()
addCustomElements(custom_elements: String | Object)
Adds custom non-HTML elements to the schema. For more information about adding custom elements see: custom_elements
addValidChildren()
addValidChildren(valid_children: String)
Parses a valid children string and adds them to the schema structure. The valid children
format is for example element[child1|child2]
.
addValidElements()
addValidElements(valid_elements: String)
Parses a valid elements string and adds it to the schema. The valid elements
format is for example element[attr=default|otherattr]
.
Existing rules will be replaced with the ones specified, so this extends the schema.
getElementRule()
getElementRule(name: String): Object
Returns true/false if the specified element is valid or not according to the schema.
getMoveCaretBeforeOnEnterElements()
getMoveCaretBeforeOnEnterElements(): Object
Returns a map with elements that the caret should be moved in front of after enter is pressed.
getNonEmptyElements()
getNonEmptyElements(): Object
Returns a map with elements that should be treated as contents regardless if it has text
content in them or not. For example: <td>
, <video>
or <img>
.
getSelfClosingElements()
getSelfClosingElements(): Object
Returns a map with self closing tags. For example: <li>
.
getSpecialElements()
getSpecialElements(): Object
Returns a map with special elements. These are elements that needs to be parsed in a special way such as script, style, textarea etc. The map object values are regexps used to find the end of the element.
getTextBlockElements()
getTextBlockElements(): Object
Returns a map with text block elements. For example: <p>
, <h1>
to <h6>
, <div>
or <address>
.
getTextInlineElements()
getTextInlineElements(): Object
Returns a map of inline text format nodes. For example: <strong>
, <span>
or <ins>
.
getTransparentElements()
getTransparentElements(): Object
Returns a map with elements that should be treated as transparent.
getVoidElements()
getVoidElements(): Object
Returns a map with void elements. For example: <br>
or <img>
.
getWhitespaceElements()
getWhitespaceElements(): Object
Returns a map with elements where white space is to be preserved. For example: <pre>
or <script>
.
isValid()
isValid(name: String, attr: String): Boolean
Returns true/false if the specified element name and optional attribute is valid according to the schema.
isValidChild()
isValidChild(name: String, child: String): Boolean
Returns true/false if the specified element and it’s child is valid or not according to the schema.