Skip to content

ckeditor5-elements / compileElementSchema

Function: compileElementSchema() ​

ts
function compileElementSchema(definition): CompiledElementSchema;

Translates a valid element schema (see parseElementSchema) to the definitions of CKEditor's schema. Each type is made like a generic item of CKEditor:

  • container: like $container: allowed in the root and in containers; holds what is allowed in a container: blocks, containers and block objects, not text.
  • block: like $block: a block, allowed in the root and in containers; holds text and inline objects.
  • empty and not inline: like $blockObject: an object, allowed where blocks are.
  • empty and inline: like $inlineObject: an object, allowed where text is, with the attributes of text.
  • block and inline: an inline element that holds text and inline elements, allowed where text is, with the attributes of text: like $text, but an element, so it can have attributes of its own.
  • container and inline: a container laid out in a line, e.g. with others in a block: allowed where text is, like every inline element, and holds the same as a container: blocks, not text.

isInline is about the layout and the position of an element, so it is set for every type, and CKEditor's features and the converters can use it.

allowAttributes is passed as it is. allowIn replaces the default places of the type. allowChildren adds to what the type holds, as in CKEditor.

A list (listItem) holds only its items, not what a container holds, and an item is allowed only in its lists. A verbatim block is a block: its whitespace is kept by its converters and its typing, not by the schema.

Parameters ​

ParameterType
definitionElementSchemaDefinition

Returns ​

CompiledElementSchema