SCEditor icon indicating copy to clipboard operation
SCEditor copied to clipboard

validChildren vs allowedChildren

Open abetis opened this issue 6 years ago • 5 comments

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.

abetis avatar Apr 17 '18 12:04 abetis

That is HTML5 spec data. It is so SCE can know, by the spec rules, which tags are allowed as descendants of other tags.

brunoais avatar Apr 17 '18 14:04 brunoais

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/

abetis avatar Apr 17 '18 15:04 abetis

allowedChildren tells what the BBCode allows. The validChildren tells what the HTML5 spec allows

brunoais avatar Apr 17 '18 15:04 brunoais

Well... The name is not that clear about it.

abetis avatar Apr 17 '18 16:04 abetis

Agreed

brunoais avatar Apr 17 '18 17:04 brunoais