SCEditor
SCEditor copied to clipboard
validChildren vs allowedChildren
Why do we need the separate validChildred
list?
/**
* Allowed children of specific HTML tags. Empty array if no
* children other than text nodes are allowed
* @private
*/
var validChildren = {
ul: ['li', 'ol', 'ul'],
ol: ['li', 'ol', 'ul'],
table: ['tr'],
tr: ['td', 'th'],
code: ['br', 'p', 'div']
};
if we already have the allowedChildren
in the format handlers?
If validChildren
is needed, there is no access to that list for plugins.
That is HTML5 spec data. It is so SCE can know, by the spec rules, which tags are allowed as descendants of other tags.
I'm saying that this information is duplicated. If it's a tag property, it should be specified in the tag itself and not as a separate list.
According to the documentation, the allowedChildren
does exactly that you described:
allowedChildren
allowedChildren Array or null Defaults to null
If null/undefined then all children will be allowed. If it’s an array only the tags specified will be allowed. To allow plain text use # as the tag name.
To only allow plain text: allowedChildren: ['#']
To only allow bold and italic as children: allowedChildren: ['b', 'i'] https://www.sceditor.com/documentation/custom-bbcodes/
allowedChildren
tells what the BBCode allows. The validChildren
tells what the HTML5 spec allows
Well... The name is not that clear about it.
Agreed