Creates an instance of the context.
The last item (the lowest node).
The number of items.
Iterable interface.
Iterates over all context items.
Checks whether the context ends with the given nodes.
const ctx = new ModelSchemaContext( [ rootElement, paragraphElement, textNode ] );
ctx.endsWith( '$text' ); // -> true
ctx.endsWith( 'paragraph $text' ); // -> true
ctx.endsWith( '$root' ); // -> false
ctx.endsWith( 'paragraph' ); // -> false
Returns the names of items.
Returns a new schema context instance with an additional item.
Item can be added as:
const context = new ModelSchemaContext( [ '$root' ] );
// An element.
const fooElement = writer.createElement( 'fooElement' );
const newContext = context.push( fooElement ); // [ '$root', 'fooElement' ]
// A text node.
const text = writer.createText( 'foobar' );
const newContext = context.push( text ); // [ '$root', '$text' ]
// A string (element name).
const newContext = context.push( 'barElement' ); // [ '$root', 'barElement' ]
Note module:engine/model/node~ModelNode that is already in the model tree will be added as the only item (without ancestors).
An item that will be added to the current context.
A new schema context instance with an additional item.
Checks whether the context starts with the given nodes.
const ctx = new ModelSchemaContext( [ rootElement, paragraphElement, textNode ] );
ctx.endsWith( '$root' ); // -> true
ctx.endsWith( '$root paragraph' ); // -> true
ctx.endsWith( '$text' ); // -> false
ctx.endsWith( 'paragraph' ); // -> false
Returns a new schema context that is based on this context but has the last item removed.
const ctxParagraph = new ModelSchemaContext( [ '$root', 'blockQuote', 'paragraph' ] );
const ctxBlockQuote = ctxParagraph.trimLast(); // Items in `ctxBlockQuote` are: `$root` an `blockQuote`.
const ctxRoot = ctxBlockQuote.trimLast(); // Items in `ctxRoot` are: `$root`.
A new reduced schema context instance.
A schema context – a list of ancestors of a given position in the document.
Considering such position:
The context of this position is its module:engine/model/position~ModelPosition#getAncestors lists of ancestors:
Contexts are used in the module:engine/model/schema~ModelSchema#event:checkChild
Schema#checkChildand module:engine/model/schema~ModelSchema#event:checkAttributeSchema#checkAttributeevents as a definition of a place in the document where the check occurs. The context instances are created based on the first arguments of the module:engine/model/schema~ModelSchema#checkChildSchema#checkChild()and module:engine/model/schema~ModelSchema#checkAttributeSchema#checkAttribute()methods so when using these methods you need to use module:engine/model/schema~ModelSchemaContextDefinitions.