Skip to content

ckeditor5-elements / validateElementSchema

Function: validateElementSchema() ​

ts
function validateElementSchema(input, __namedParameters?): ElementSchemaIssue[];

Checks an element schema, so that it is not contradictory, and returns the problems. An empty array means that the schema is valid.

The schema is rejected when it:

  • is not of the shape ElementSchemaDefinition: an object of elements, by name; has keys that are not part of it (typos are problems), or has values of the wrong type;
  • declares an element with an unknown type, or an empty element with allowChildren;
  • has attribute names that are not valid, or that differ only in case (HTML attribute names are not case sensitive), or a tag or an editingTag that is not the name of a tag, or the tag of another element;
  • refers to elements that do not exist (a name that is neither declared in the schema, nor in external), or lists the same name twice;
  • allows what its type cannot hold: text or an inline element in a container or in the root, a block-level (not inline) element in a block, or anything in an empty element, whichever side says it: allowChildren of the parent, or allowIn of the child;
  • makes verbatim what is not a block-level block, or a list of what is not a block-level container; names a list item that is not a block-level container of the schema, or gives it allowIn (its places are its lists); gives a list allowChildren, or allows another element in a list, which holds only its items.

isInline is about the position and the layout of an element, so it is valid for every type: an inline element is laid out in a line with its siblings. Inline elements are allowed only in blocks, which can hold several of them, e.g. inline containers, or inline images between text.

It does not need an editor. The editor of ElementSchema runs it with the elements of the other plugins as external.

Parameters ​

ParameterType
inputunknown
__namedParameters?ValidateElementSchemaOptions

Returns ​

ElementSchemaIssue[]