# ModelSchema

class

The model's schema. It defines the allowed and disallowed structures of nodes as well as nodes' attributes. The schema is usually defined by the features and based on them, the editing framework and features make decisions on how to change and process the model.

The instance of schema is available in [`editor.model.schema`](module_engine_model_model-Model.md#member-schema).

Read more about the schema in:

* The [schema section](../framework/architecture/editing-engine.md#schema) of the [Introduction to the Editing engine architecture](../framework/architecture/editing-engine.md) guide.
* The [Schema deep-dive](../framework/deep-dive/schema.md) guide.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L45)

<a id="properties">

## Properties

<a id="member-_attributeProperties">

### `_attributeProperties: Record<string, ModelAttributeProperties>` _(private)_

A dictionary containing attribute properties.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L51)

<a id="member-_compiledDefinitions">

### `_compiledDefinitions?: Record<string, ModelSchemaCompiledItemDefinition> | null` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L75)

<a id="member-_customAttributeChecks">

### `_customAttributeChecks: Map<string | symbol, Array<ModelSchemaAttributeCheckCallback>>` _(private)_

Stores additional callbacks registered for attribute names, which are evaluated when [`checkAttribute`](#function-checkAttribute) is called.

Keys are schema attribute names for which the callbacks are registered. Values are arrays with the callbacks.

Some checks are added under [`_genericCheckSymbol`](#member-_genericCheckSymbol) key, these are evaluated for every [`checkAttribute`](#function-checkAttribute) call.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L71)

<a id="member-_customChildChecks">

### `_customChildChecks: Map<string | symbol, Array<ModelSchemaChildCheckCallback>>` _(private)_

Stores additional callbacks registered for schema items, which are evaluated when [`checkChild`](#function-checkChild) is called.

Keys are schema item names for which the callbacks are registered. Values are arrays with the callbacks.

Some checks are added under [`_genericCheckSymbol`](#member-_genericCheckSymbol) key, these are evaluated for every [`checkChild`](#function-checkChild) call.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L61)

<a id="member-_genericCheckSymbol">

### `_genericCheckSymbol: symbol` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L73)

<a id="member-_sourceDefinitions">

### `_sourceDefinitions: Record<string, Array<ModelSchemaItemDefinition>>` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L46)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor()`

Creates a schema instance.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L80)

<a id="function-addAttributeCheck">

### `addAttributeCheck( callback, attributeName? ) → void`

Allows registering a callback to the [`checkAttribute`](#function-checkAttribute) method calls.

Callbacks allow you to implement rules which are not otherwise possible to achieve by using the declarative API of [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md).

Note that callback checks have bigger priority than declarative rules checks and may overwrite them.

For example, by using this method you can disallow setting attributes on nodes in specific contexts:

```typescript
// Disallow setting `bold` on text inside `heading1` element:
schema.addAttributeCheck( context => {
	if ( context.endsWith( 'heading1 $text' ) ) {
		return false;
	}
}, 'bold' );
```

You can skip the optional `attributeName` parameter to evaluate the callback for every `checkAttribute()` call.

```typescript
// Disallow formatting attributes on text inside custom `myTitle` element:
schema.addAttributeCheck( ( context, attributeName ) => {
	if ( context.endsWith( 'myTitle $text' ) && schema.getAttributeProperties( attributeName ).isFormatting ) {
		return false;
	}
} );
```

Please note that the generic callbacks may affect the editor performance and should be avoided if possible.

When one of the callbacks makes a decision (returns `true` or `false`) the processing is finished and other callbacks are not fired. Callbacks are fired in the order they were added, however generic callbacks are fired before callbacks added for a specified item.

You can also use [event-checkAttribute](#event-checkAttribute) event, if you need even better control. The result from the example above could also be achieved with following event callback:

```typescript
schema.on( 'checkAttribute', ( evt, args ) => {
	const context = args[ 0 ];
	const attributeName = args[ 1 ];

	if ( context.endsWith( 'myTitle $text' ) && schema.getAttributeProperties( attributeName ).isFormatting ) {
		// Prevent next listeners from being called.
		evt.stop();
		// Set the `checkAttribute()` return value.
		evt.return = false;
	}
}, { priority: 'high' } );
```

Note that the callback checks and declarative rules checks are processed on `normal` priority.

Adding callbacks this way can also negatively impact editor performance.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L674)

#### Parameters

* `callback: ModelSchemaAttributeCheckCallback`

  The callback to be called. It is called with two parameters: [`context`](module_engine_model_schema-ModelSchemaContext.md) and attribute name. The callback may return `true` or `false`, to override `checkAttribute()`'s return value. If it does not return a boolean value, the default algorithm (or other callbacks) will define `checkAttribute()`'s return value.

* `attributeName?: string`

  Name of the attribute for which the callback is registered. If specified, the callback will be run only for `checkAttribute()` calls with matching `attributeName`. Otherwise, the callback will run for every `checkAttribute()` call.

#### Returns

* `void`

<a id="function-addChildCheck">

### `addChildCheck( callback, itemName? ) → void`

Allows registering a callback to the [`checkChild`](#function-checkChild) method calls.

Callbacks allow you to implement rules which are not otherwise possible to achieve by using the declarative API of [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md).

Note that callback checks have bigger priority than declarative rules checks and may overwrite them.

For example, by using this method you can disallow elements in specific contexts:

```typescript
// Disallow `heading1` inside a `blockQuote` that is inside a table.
schema.addChildCheck( ( context, childDefinition ) => {
	if ( context.endsWith( 'tableCell blockQuote' ) ) {
		return false;
	}
}, 'heading1' );
```

You can skip the optional `itemName` parameter to evaluate the callback for every `checkChild()` call.

```typescript
// Inside specific custom element, allow only children, which allows for a specific attribute.
schema.addChildCheck( ( context, childDefinition ) => {
	if ( context.endsWith( 'myElement' ) ) {
		return childDefinition.allowAttributes.includes( 'myAttribute' );
	}
} );
```

Please note that the generic callbacks may affect the editor performance and should be avoided if possible.

When one of the callbacks makes a decision (returns `true` or `false`) the processing is finished and other callbacks are not fired. Callbacks are fired in the order they were added, however generic callbacks are fired before callbacks added for a specified item.

You can also use `checkChild` event, if you need even better control. The result from the example above could also be achieved with following event callback:

```typescript
schema.on( 'checkChild', ( evt, args ) => {
	const context = args[ 0 ];
	const childDefinition = args[ 1 ];

	if ( context.endsWith( 'myElement' ) ) {
		// Prevent next listeners from being called.
		evt.stop();
		// Set the `checkChild()` return value.
		evt.return = childDefinition.allowAttributes.includes( 'myAttribute' );
	}
}, { priority: 'high' } );
```

Note that the callback checks and declarative rules checks are processed on `normal` priority.

Adding callbacks this way can also negatively impact editor performance.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L602)

#### Parameters

* `callback: ModelSchemaChildCheckCallback`

  The callback to be called. It is called with two parameters: [`ModelSchemaContext`](module_engine_model_schema-ModelSchemaContext.md) (context) instance and [`ModelSchemaCompiledItemDefinition`](module_engine_model_schema-ModelSchemaCompiledItemDefinition.md) (definition). The callback may return `true/false` to override `checkChild()`'s return value. If it does not return a boolean value, the default algorithm (or other callbacks) will define `checkChild()`'s return value.

* `itemName?: string`

  Name of the schema item for which the callback is registered. If specified, the callback will be run only for `checkChild()` calls which `def` parameter matches the `itemName`. Otherwise, the callback will run for every `checkChild` call.

#### Returns

* `void`

<a id="function-bind:DUAL_BIND">

### `bind( bindProperty1, bindProperty2 ) → ObservableDualBindChain<K1, ModelSchema[ K1 ], K2, ModelSchema[ K2 ]>` _(inherited)_

Binds [observable properties](#function-set:KEY_VALUE) to other objects implementing the [`Observable`](module_utils_observablemixin-Observable.md) interface.

Read more in the [dedicated](../framework/deep-dive/observables.md#property-bindings) guide covering the topic of property bindings with some additional examples.

Consider two objects: a `button` and an associated `command` (both `Observable`).

A simple property binding could be as follows:

```typescript
button.bind( 'isEnabled' ).to( command, 'isEnabled' );
```

or even shorter:

```typescript
button.bind( 'isEnabled' ).to( command );
```

which works in the following way:

* `button.isEnabled` **instantly equals** `command.isEnabled`,
* whenever `command.isEnabled` changes, `button.isEnabled` will immediately reflect its value.

**Note**: To release the binding, use [`unbind`](module_utils_observablemixin-Observable.md#function-unbind).

You can also "rename" the property in the binding by specifying the new name in the `to()` chain:

```typescript
button.bind( 'isEnabled' ).to( command, 'isWorking' );
```

It is possible to bind more than one property at a time to shorten the code:

```typescript
button.bind( 'isEnabled', 'value' ).to( command );
```

which corresponds to:

```typescript
button.bind( 'isEnabled' ).to( command );
button.bind( 'value' ).to( command );
```

The binding can include more than one observable, combining multiple data sources in a custom callback:

```typescript
button.bind( 'isEnabled' ).to( command, 'isEnabled', ui, 'isVisible',
	( isCommandEnabled, isUIVisible ) => isCommandEnabled && isUIVisible );
```

Using a custom callback allows processing the value before passing it to the target property:

```typescript
button.bind( 'isEnabled' ).to( command, 'value', value => value === 'heading1' );
```

It is also possible to bind to the same property in an array of observables. To bind a `button` to multiple commands (also `Observables`) so that each and every one of them must be enabled for the button to become enabled, use the following code:

```typescript
button.bind( 'isEnabled' ).toMany( [ commandA, commandB, commandC ], 'isEnabled',
	( isAEnabled, isBEnabled, isCEnabled ) => isAEnabled && isBEnabled && isCEnabled );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L996)

#### Type parameters

* * `K1`
  * `K2`

#### Parameters

* `bindProperty1: K1`

  Observable property that will be bound to other observable(s).

* `bindProperty2: K2`

  Observable property that will be bound to other observable(s).

#### Returns

* `ObservableDualBindChain<K1, ModelSchema[ K1 ], K2, ModelSchema[ K2 ]>`

  The bind chain with the `to()` and `toMany()` methods.

<a id="function-bind:MANY_BIND">

### `bind( bindProperties ) → ObservableMultiBindChain` _(inherited)_

Binds [observable properties](#function-set:KEY_VALUE) to other objects implementing the [`Observable`](module_utils_observablemixin-Observable.md) interface.

Read more in the [dedicated](../framework/deep-dive/observables.md#property-bindings) guide covering the topic of property bindings with some additional examples.

Consider two objects: a `button` and an associated `command` (both `Observable`).

A simple property binding could be as follows:

```typescript
button.bind( 'isEnabled' ).to( command, 'isEnabled' );
```

or even shorter:

```typescript
button.bind( 'isEnabled' ).to( command );
```

which works in the following way:

* `button.isEnabled` **instantly equals** `command.isEnabled`,
* whenever `command.isEnabled` changes, `button.isEnabled` will immediately reflect its value.

**Note**: To release the binding, use [`unbind`](module_utils_observablemixin-Observable.md#function-unbind).

You can also "rename" the property in the binding by specifying the new name in the `to()` chain:

```typescript
button.bind( 'isEnabled' ).to( command, 'isWorking' );
```

It is possible to bind more than one property at a time to shorten the code:

```typescript
button.bind( 'isEnabled', 'value' ).to( command );
```

which corresponds to:

```typescript
button.bind( 'isEnabled' ).to( command );
button.bind( 'value' ).to( command );
```

The binding can include more than one observable, combining multiple data sources in a custom callback:

```typescript
button.bind( 'isEnabled' ).to( command, 'isEnabled', ui, 'isVisible',
	( isCommandEnabled, isUIVisible ) => isCommandEnabled && isUIVisible );
```

Using a custom callback allows processing the value before passing it to the target property:

```typescript
button.bind( 'isEnabled' ).to( command, 'value', value => value === 'heading1' );
```

It is also possible to bind to the same property in an array of observables. To bind a `button` to multiple commands (also `Observables`) so that each and every one of them must be enabled for the button to become enabled, use the following code:

```typescript
button.bind( 'isEnabled' ).toMany( [ commandA, commandB, commandC ], 'isEnabled',
	( isAEnabled, isBEnabled, isCEnabled ) => isAEnabled && isBEnabled && isCEnabled );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L1074)

#### Parameters

* `bindProperties: Array<'off' | 'set' | 'bind' | 'unbind' | 'decorate' | 'stopListening' | 'on' | 'once' | 'listenTo' | 'fire' | 'delegate' | 'stopDelegating' | 'register' | 'extend' | 'getDefinitions' | 'getDefinition' | 'isRegistered' | 'isBlock' | 'isLimit' | 'isObject' | 'isInline' | 'isSelectable' | 'isContent' | 'checkChild' | 'checkAttribute' | 'checkMerge' | 'addChildCheck' | 'addAttributeCheck' | 'setAttributeProperties' | 'getAttributeProperties' | 'getLimitElement' | 'checkAttributeInSelection' | 'getValidRanges' | 'getNearestSelectionRange' | 'findAllowedParent' | 'setAllowedAttributes' | 'removeDisallowedAttributes' | 'getAttributesWithProperty' | 'createContext' | 'findOptimalInsertionRange'>`

  Observable properties that will be bound to other observable(s).

#### Returns

* `ObservableMultiBindChain`

  The bind chain with the `to()` and `toMany()` methods.

<a id="function-bind:SINGLE_BIND">

### `bind( bindProperty ) → ObservableSingleBindChain<K, ModelSchema[ K ]>` _(inherited)_

Binds [observable properties](#function-set:KEY_VALUE) to other objects implementing the [`Observable`](module_utils_observablemixin-Observable.md) interface.

Read more in the [dedicated](../framework/deep-dive/observables.md#property-bindings) guide covering the topic of property bindings with some additional examples.

Consider two objects: a `button` and an associated `command` (both `Observable`).

A simple property binding could be as follows:

```typescript
button.bind( 'isEnabled' ).to( command, 'isEnabled' );
```

or even shorter:

```typescript
button.bind( 'isEnabled' ).to( command );
```

which works in the following way:

* `button.isEnabled` **instantly equals** `command.isEnabled`,
* whenever `command.isEnabled` changes, `button.isEnabled` will immediately reflect its value.

**Note**: To release the binding, use [`unbind`](module_utils_observablemixin-Observable.md#function-unbind).

You can also "rename" the property in the binding by specifying the new name in the `to()` chain:

```typescript
button.bind( 'isEnabled' ).to( command, 'isWorking' );
```

It is possible to bind more than one property at a time to shorten the code:

```typescript
button.bind( 'isEnabled', 'value' ).to( command );
```

which corresponds to:

```typescript
button.bind( 'isEnabled' ).to( command );
button.bind( 'value' ).to( command );
```

The binding can include more than one observable, combining multiple data sources in a custom callback:

```typescript
button.bind( 'isEnabled' ).to( command, 'isEnabled', ui, 'isVisible',
	( isCommandEnabled, isUIVisible ) => isCommandEnabled && isUIVisible );
```

Using a custom callback allows processing the value before passing it to the target property:

```typescript
button.bind( 'isEnabled' ).to( command, 'value', value => value === 'heading1' );
```

It is also possible to bind to the same property in an array of observables. To bind a `button` to multiple commands (also `Observables`) so that each and every one of them must be enabled for the button to become enabled, use the following code:

```typescript
button.bind( 'isEnabled' ).toMany( [ commandA, commandB, commandC ], 'isEnabled',
	( isAEnabled, isBEnabled, isCEnabled ) => isAEnabled && isBEnabled && isCEnabled );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L918)

#### Type parameters

* `K`

#### Parameters

* `bindProperty: K`

  Observable property that will be bound to other observable(s).

#### Returns

* `ObservableSingleBindChain<K, ModelSchema[ K ]>`

  The bind chain with the `to()` and `toMany()` methods.

<a id="function-checkAttribute">

### `checkAttribute( context, attributeName ) → boolean`

Checks whether the given attribute can be applied in the given context (on the last item of the context).

```typescript
schema.checkAttribute( textNode, 'bold' ); // -> false

schema.extend( '$text', {
	allowAttributes: 'bold'
} );

schema.checkAttribute( textNode, 'bold' ); // -> true
```

Both [callback checks](#function-addAttributeCheck) and declarative rules (added when [registering](#function-register) and [extending](#function-extend) items) are evaluated when this method is called.

Note that callback checks have bigger priority than declarative rules checks and may overwrite them.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L459)

#### Parameters

* `context: ModelSchemaContextDefinition`

  The context in which the attribute will be checked.

* `attributeName: string`

  Name of attribute to check in the given context.

#### Returns

* `boolean`

#### Fires

* [checkAttribute](#event-checkAttribute)

<a id="function-checkAttributeInSelection">

### `checkAttributeInSelection( selection, attribute ) → boolean`

Checks whether the attribute is allowed in selection:

* if the selection is not collapsed, then checks if the attribute is allowed on any of nodes in that range,
* if the selection is collapsed, then checks if on the selection position there's a text with the specified attribute allowed.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L793)

#### Parameters

* `selection: ModelSelection | ModelDocumentSelection`

  Selection which will be checked.

* `attribute: string`

  The name of the attribute to check.

#### Returns

* `boolean`

<a id="function-checkChild">

### `checkChild( context, def ) → boolean`

Checks whether the given node can be a child of the given context.

```typescript
schema.checkChild( model.document.getRoot(), paragraph ); // -> false

schema.register( 'paragraph', {
	allowIn: '$root'
} );

schema.checkChild( model.document.getRoot(), paragraph ); // -> true
```

Both [callback checks](#function-addChildCheck) and declarative rules (added when [registering](#function-register) and [extending](#function-extend) items) are evaluated when this method is called.

Note that callback checks have bigger priority than declarative rules checks and may overwrite them.

Note that when verifying whether the given node can be a child of the given context, the schema also verifies the entire context – from its root to its last element. Therefore, it is possible for `checkChild()` to return `false` even though the `context` last element can contain the checked child. It happens if one of the `context` elements does not allow its child. When `context` is verified, [custom checks](#function-addChildCheck) are considered as well.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L426)

#### Parameters

* `context: ModelSchemaContextDefinition`

  The context in which the child will be checked.

* `def: string | ModelNode | ModelDocumentFragment`

  The child to check.

#### Returns

* `boolean`

#### Fires

* [checkChild](#event-checkChild)

<a id="function-checkMerge">

### `checkMerge( baseElement, elementToMerge ) → boolean`

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L476)

#### Parameters

* `baseElement: ModelElement`
* `elementToMerge: ModelElement`

#### Returns

* `boolean`

<a id="function-checkMerge">

### `checkMerge( position ) → boolean`

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L475)

#### Parameters

* `position: ModelPosition`

#### Returns

* `boolean`

<a id="function-createContext">

### `createContext( context ) → ModelSchemaContext`

Creates an instance of the schema context.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1021)

#### Parameters

* `context: ModelSchemaContextDefinition`

#### Returns

* `ModelSchemaContext`

<a id="function-decorate">

### `decorate( methodName ) → void` _(inherited)_

Turns the given methods of this object into event-based ones. This means that the new method will fire an event (named after the method) and the original action will be plugged as a listener to that event.

Read more in the [dedicated](../framework/deep-dive/observables.md#decorating-object-methods) guide covering the topic of decorating methods with some additional examples.

Decorating the method does not change its behavior (it only adds an event), but it allows to modify it later on by listening to the method's event.

For example, to cancel the method execution the event can be [stopped](module_utils_eventinfo-EventInfo.md#member-stop):

```typescript
class Foo extends ObservableMixin() {
	constructor() {
		super();
		this.decorate( 'method' );
	}

	method() {
		console.log( 'called!' );
	}
}

const foo = new Foo();
foo.on( 'method', ( evt ) => {
	evt.stop();
}, { priority: 'high' } );

foo.method(); // Nothing is logged.
```

**Note**: The high [priority](module_utils_priorities-PriorityString.md) listener has been used to execute this particular callback before the one which calls the original method (which uses the "normal" priority).

It is also possible to change the returned value:

```typescript
foo.on( 'method', ( evt ) => {
	evt.return = 'Foo!';
} );

foo.method(); // -> 'Foo'
```

Finally, it is possible to access and modify the arguments the method is called with:

```typescript
method( a, b ) {
	console.log( `${ a }, ${ b }`  );
}

// ...

foo.on( 'method', ( evt, args ) => {
	args[ 0 ] = 3;

	console.log( args[ 1 ] ); // -> 2
}, { priority: 'high' } );

foo.method( 1, 2 ); // -> '3, 2'
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L1159)

#### Parameters

* `methodName: 'off' | 'set' | 'bind' | 'unbind' | 'decorate' | 'stopListening' | 'on' | 'once' | 'listenTo' | 'fire' | 'delegate' | 'stopDelegating' | 'register' | 'extend' | 'getDefinitions' | 'getDefinition' | 'isRegistered' | 'isBlock' | 'isLimit' | 'isObject' | 'isInline' | 'isSelectable' | 'isContent' | 'checkChild' | 'checkAttribute' | 'checkMerge' | 'addChildCheck' | 'addAttributeCheck' | 'setAttributeProperties' | 'getAttributeProperties' | 'getLimitElement' | 'checkAttributeInSelection' | 'getValidRanges' | 'getNearestSelectionRange' | 'findAllowedParent' | 'setAllowedAttributes' | 'removeDisallowedAttributes' | 'getAttributesWithProperty' | 'createContext' | 'findOptimalInsertionRange'`

  Name of the method to decorate.

#### Returns

* `void`

<a id="function-delegate">

### `delegate( events ) → EmitterMixinDelegateChain` _(inherited)_

Delegates selected events to another [`Emitter`](module_utils_emittermixin-Emitter.md). For instance:

```typescript
emitterA.delegate( 'eventX' ).to( emitterB );
emitterA.delegate( 'eventX', 'eventY' ).to( emitterC );
```

then `eventX` is delegated (fired by) `emitterB` and `emitterC` along with `data`:

```typescript
emitterA.fire( 'eventX', data );
```

and `eventY` is delegated (fired by) `emitterC` along with `data`:

```typescript
emitterA.fire( 'eventY', data );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L539)

#### Parameters

* `events: Array<string>`

  Event names that will be delegated to another emitter.

#### Returns

* `EmitterMixinDelegateChain`

<a id="function-extend">

### `extend( itemName, definition ) → void`

Extends a [registered](#function-register) item's definition.

Extending properties such as `allowIn` will add more items to the existing properties, while redefining properties such as `isBlock` will override the previously defined ones.

```typescript
schema.register( 'foo', {
	allowIn: '$root',
	isBlock: true;
} );
schema.extend( 'foo', {
	allowIn: 'blockQuote',
	isBlock: false
} );

schema.getDefinition( 'foo' );
//	{
//		allowIn: [ '$root', 'blockQuote' ],
// 		isBlock: false
//	}
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L165)

#### Parameters

* `itemName: string`
* `definition: ModelSchemaItemDefinition`

#### Returns

* `void`

<a id="function-findAllowedParent">

### `findAllowedParent( position, node ) → ModelElement | null`

Tries to find position ancestors that allow to insert a given node. It starts searching from the given position and goes node by node to the top of the model tree as long as a [limit element](#function-isLimit), an [object element](#function-isObject) or a topmost ancestor is not reached.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L922)

#### Parameters

* `position: ModelPosition`

  The position that the search will start from.

* `node: string | ModelNode`

  The node for which an allowed parent should be found or its name.

#### Returns

* `ModelElement | null`

  Allowed parent or null if nothing was found.

<a id="function-fire">

### `fire( eventOrInfo, args ) → GetEventInfo<TEvent>[ 'return' ]` _(inherited)_

Fires an event, executing all callbacks registered for it.

The first parameter passed to callbacks is an [`EventInfo`](module_utils_eventinfo-EventInfo.md) object, followed by the optional `args` provided in the `fire()` method call.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L512)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type describing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `eventOrInfo: GetNameOrEventInfo<TEvent>`

  The name of the event or `EventInfo` object if event is delegated.

* `args: TEvent[ 'args' ]`

  Additional arguments to be passed to the callbacks.

#### Returns

* `GetEventInfo<TEvent>[ 'return' ]`

  By default the method returns `undefined`. However, the return value can be changed by listeners through modification of the [`evt.return`](module_utils_eventinfo-EventInfo.md#member-return)'s property (the event info is the first param of every callback).

<a id="function-getAttributeProperties">

### `getAttributeProperties( attributeName ) → ModelAttributeProperties`

Returns properties associated with a given model attribute. See [`setAttributeProperties()`](#function-setAttributeProperties).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L736)

#### Parameters

* `attributeName: string`

  A name of the attribute.

#### Returns

* `ModelAttributeProperties`

<a id="function-getAttributesWithProperty">

### `getAttributesWithProperty( node, propertyName, propertyValue ) → Record<string, unknown>`

Gets attributes of a node that have a given property.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1000)

#### Parameters

* `node: ModelNode`

  Node to get attributes from.

* `propertyName: string`

  Name of the property that attribute must have to return it.

* `propertyValue: unknown`

  Desired value of the property that we want to check. When `undefined` attributes will be returned if they have set a given property no matter what the value is. If specified it will return attributes which given property's value is equal to this parameter.

#### Returns

* `Record<string, unknown>`

  Object with attributes' names as key and attributes' values as value.

<a id="function-getDefinition">

### `getDefinition( item ) → ModelSchemaCompiledItemDefinition | undefined`

Returns a definition of the given item or `undefined` if an item is not registered.

This method should normally be used for reflection purposes (e.g. defining a clone of a certain element, checking a list of all block elements, etc). Use specific methods (such as [`checkChild()`](#function-checkChild) or [`isLimit()`](#function-isLimit)) in other cases.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L210)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `ModelSchemaCompiledItemDefinition | undefined`

<a id="function-getDefinitions">

### `getDefinitions() → Record<string, ModelSchemaCompiledItemDefinition>`

Returns data of all registered items.

This method should normally be used for reflection purposes (e.g. defining a clone of a certain element, checking a list of all block elements, etc). Use specific methods (such as [`checkChild()`](#function-checkChild) or [`isLimit()`](#function-isLimit)) in other cases.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L194)

#### Returns

* `Record<string, ModelSchemaCompiledItemDefinition>`

<a id="function-getLimitElement">

### `getLimitElement( selectionOrRangeOrPosition ) → ModelElement`

Returns the lowest [limit element](#function-isLimit) containing the entire selection/range/position or the root otherwise.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L747)

#### Parameters

* `selectionOrRangeOrPosition: ModelPosition | ModelRange | ModelSelection | ModelDocumentSelection`

  The selection/range/position to check.

#### Returns

* `ModelElement`

  The lowest limit element containing the entire `selectionOrRangeOrPosition`.

<a id="function-getNearestSelectionRange">

### `getNearestSelectionRange( position, direction ) → ModelRange | null`

Basing on given `position`, finds and returns a [range](module_engine_model_range-ModelRange.md) which is nearest to that `position` and is a correct range for selection.

The correct selection range might be collapsed when it is located in a position where the text node can be placed. Non-collapsed range is returned when selection can be placed around element marked as an "object" in the [schema](module_engine_model_schema-ModelSchema.md).

Direction of searching for the nearest correct selection range can be specified as:

* `both` - searching will be performed in both ways,
* `forward` - searching will be performed only forward,
* `backward` - searching will be performed only backward.

When valid selection range cannot be found, `null` is returned.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L863)

#### Parameters

* `position: ModelPosition`

  Reference position where new selection range should be looked for.

* `direction: 'forward' | 'backward' | 'both'`

  Search direction.

  Defaults to `'both'`

#### Returns

* `ModelRange | null`

  Nearest selection range or `null` if one cannot be found.

<a id="function-getValidRanges">

### `getValidRanges( ranges, attribute, options = { options.includeEmptyRanges? } ) → IterableIterator<ModelRange>`

Transforms the given set of ranges into a set of ranges where the given attribute is allowed (and can be applied).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L831)

#### Parameters

* `ranges: Iterable<ModelRange>`

  Ranges to be validated.

* `attribute: string`

  The name of the attribute to check.

* `options: object`

  Optional configuration.

  Properties

  * `options.includeEmptyRanges?: boolean`

    When `true`, empty ranges that allow the attribute are also included in the returned ranges.

  Defaults to `{}`

#### Returns

* `IterableIterator<ModelRange>`

  Ranges in which the attribute is allowed.

<a id="function-isBlock">

### `isBlock( item ) → boolean`

Returns `true` if the given item is defined to be a block by the [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md)'s `isBlock` property.

```typescript
schema.isBlock( 'paragraph' ); // -> true
schema.isBlock( '$root' ); // -> false

const paragraphElement = writer.createElement( 'paragraph' );
schema.isBlock( paragraphElement ); // -> true
```

See the [Block elements](../framework/deep-dive/schema.md#block-elements) section of the [Schema deep-dive](../framework/deep-dive/schema.md) guide for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L256)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-isContent">

### `isContent( item ) → boolean`

Returns `true` if the given item is defined to be a content by the [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md)'s `isContent` property.

```typescript
schema.isContent( 'paragraph' ); // -> false
schema.isContent( 'heading1' ); // -> false
schema.isContent( 'imageBlock' ); // -> true
schema.isContent( 'horizontalLine' ); // -> true

const text = writer.createText( 'foo' );
schema.isContent( text ); // -> true
```

See the [Content elements section](../framework/deep-dive/schema.md#content-elements) of the [Schema deep-dive](../framework/deep-dive/schema.md) guide for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L387)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-isInline">

### `isInline( item ) → boolean`

Returns `true` if the given item is defined to be an inline element by the [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md)'s `isInline` property.

```typescript
schema.isInline( 'paragraph' ); // -> false
schema.isInline( 'softBreak' ); // -> true

const text = writer.createText( 'foo' );
schema.isInline( text ); // -> true
```

See the [Inline elements](../framework/deep-dive/schema.md#inline-elements) section of the [Schema deep-dive](../framework/deep-dive/schema.md) guide for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L337)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-isLimit">

### `isLimit( item ) → boolean`

Returns `true` if the given item should be treated as a limit element.

It considers an item to be a limit element if its [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md)'s [`isLimit`](module_engine_model_schema-ModelSchemaItemDefinition.md#member-isLimit) or [`isObject`](module_engine_model_schema-ModelSchemaItemDefinition.md#member-isObject) property was set to `true`.

```typescript
schema.isLimit( 'paragraph' ); // -> false
schema.isLimit( '$root' ); // -> true
schema.isLimit( editor.model.document.getRoot() ); // -> true
schema.isLimit( 'imageBlock' ); // -> true
```

See the [Limit elements](../framework/deep-dive/schema.md#limit-elements) section of the [Schema deep-dive](../framework/deep-dive/schema.md) guide for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L281)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-isObject">

### `isObject( item ) → boolean`

Returns `true` if the given item should be treated as an object element.

It considers an item to be an object element if its [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md)'s [`isObject`](module_engine_model_schema-ModelSchemaItemDefinition.md#member-isObject) property was set to `true`.

```typescript
schema.isObject( 'paragraph' ); // -> false
schema.isObject( 'imageBlock' ); // -> true

const imageElement = writer.createElement( 'imageBlock' );
schema.isObject( imageElement ); // -> true
```

See the [Object elements](../framework/deep-dive/schema.md#object-elements) section of the [Schema deep-dive](../framework/deep-dive/schema.md) guide for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L310)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-isRegistered">

### `isRegistered( item ) → boolean`

Returns `true` if the given item is registered in the schema.

```typescript
schema.isRegistered( 'paragraph' ); // -> true
schema.isRegistered( editor.model.document.getRoot() ); // -> true
schema.isRegistered( 'foo' ); // -> false
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L237)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-isSelectable">

### `isSelectable( item ) → boolean`

Returns `true` if the given item is defined to be a selectable element by the [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md)'s `isSelectable` property.

```typescript
schema.isSelectable( 'paragraph' ); // -> false
schema.isSelectable( 'heading1' ); // -> false
schema.isSelectable( 'imageBlock' ); // -> true
schema.isSelectable( 'tableCell' ); // -> true

const text = writer.createText( 'foo' );
schema.isSelectable( text ); // -> false
```

See the [Selectable elements section](../framework/deep-dive/schema.md#selectable-elements) of the [Schema deep-dive](../framework/deep-dive/schema.md) guide for more details.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L360)

#### Parameters

* `item: string | ModelDocumentFragment | ModelItem | ModelSchemaContextItem`

#### Returns

* `boolean`

<a id="function-listenTo:BASE_EMITTER">

### `listenTo( emitter, event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed when an event is fired in a specific (emitter) object.

Events can be grouped in namespaces using `:`. When namespaced event is fired, it additionally fires all callbacks for that namespace.

```typescript
// myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ).
myEmitter.on( 'myGroup', genericCallback );
myEmitter.on( 'myGroup:myEvent', specificCallback );

// genericCallback is fired.
myEmitter.fire( 'myGroup' );
// both genericCallback and specificCallback are fired.
myEmitter.fire( 'myGroup:myEvent' );
// genericCallback is fired even though there are no callbacks for "foo".
myEmitter.fire( 'myGroup:foo' );
```

An event callback can [stop the event](module_utils_eventinfo-EventInfo.md#member-stop) and set the [return value](module_utils_eventinfo-EventInfo.md#member-return) of the [`fire`](#function-fire) method.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L475)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type describing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `emitter: Emitter`

  The object that fires the event.

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: GetCallbackOptions<TEvent>`

  Additional options.

#### Returns

* `void`

<a id="function-off">

### `off( event, callback ) → void` _(inherited)_

Stops executing the callback on the given event. Shorthand for [`this.stopListening( this, event, callback )`](#function-stopListening:BASE_STOP).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L444)

#### Parameters

* `event: string`

  The name of the event.

* `callback: Function`

  The function to stop being called.

#### Returns

* `void`

<a id="function-on">

### `on( event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed when an event is fired.

Shorthand for [`this.listenTo( this, event, callback, options )`](#function-listenTo:BASE_EMITTER) (it makes the emitter listen on itself).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L416)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type descibing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: GetCallbackOptions<TEvent>`

  Additional options.

#### Returns

* `void`

<a id="function-once">

### `once( event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed on the next time the event is fired only. This is similar to calling [`on`](#function-on) followed by [`off`](#function-off) in the callback.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L431)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type descibing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: GetCallbackOptions<TEvent>`

  Additional options.

#### Returns

* `void`

<a id="function-register">

### `register( itemName, definition? ) → void`

Registers a schema item. Can only be called once for every item name.

```typescript
schema.register( 'paragraph', {
	inheritAllFrom: '$block'
} );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L105)

#### Parameters

* `itemName: string`
* `definition?: ModelSchemaItemDefinition`

#### Returns

* `void`

<a id="function-removeDisallowedAttributes">

### `removeDisallowedAttributes( nodes, writer ) → void`

Removes attributes disallowed by the schema.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L967)

#### Parameters

* `nodes: Iterable<ModelNode>`

  Nodes that will be filtered.

* `writer: ModelWriter`

#### Returns

* `void`

<a id="function-set:OBJECT">

### `set( values ) → void` _(inherited)_

Creates and sets the value of an observable properties of this object. Such a property becomes a part of the state and is observable.

It accepts a single object literal containing key/value pairs with properties to be set.

This method throws the `observable-set-cannot-override` error if the observable instance already has a property with the given property name. This prevents from mistakenly overriding existing properties and methods, but means that `foo.set( 'bar', 1 )` may be slightly slower than `foo.bar = 1`.

In TypeScript, those properties should be declared in class using `declare` keyword. In example:

```typescript
public declare myProp1: number;
public declare myProp2: string;

constructor() {
	this.set( {
		'myProp1: 2,
		'myProp2: 'foo'
	} );
}
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L843)

#### Parameters

* `values: object & object`

  An object with `name=>value` pairs.

#### Returns

* `void`

<a id="function-set:KEY_VALUE">

### `set( name, value ) → void` _(inherited)_

Creates and sets the value of an observable property of this object. Such a property becomes a part of the state and is observable.

This method throws the `observable-set-cannot-override` error if the observable instance already has a property with the given property name. This prevents from mistakenly overriding existing properties and methods, but means that `foo.set( 'bar', 1 )` may be slightly slower than `foo.bar = 1`.

In TypeScript, those properties should be declared in class using `declare` keyword. In example:

```typescript
public declare myProp: number;

constructor() {
	this.set( 'myProp', 2 );
}
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L815)

#### Type parameters

* `K`

#### Parameters

* `name: K`

  The property's name.

* `value: ModelSchema[ K ]`

  The property's value.

#### Returns

* `void`

<a id="function-setAllowedAttributes">

### `setAllowedAttributes( node, attributes, writer ) → void`

Sets attributes allowed by the schema on a given node.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L948)

#### Parameters

* `node: ModelNode`

  A node to set attributes on.

* `attributes: Record<string, unknown>`

  Attributes keys and values.

* `writer: ModelWriter`

  An instance of the model writer.

#### Returns

* `void`

<a id="function-setAttributeProperties">

### `setAttributeProperties( attributeName, properties ) → void`

This method allows assigning additional metadata to the model attributes. For example, [`AttributeProperties#isFormatting` property](module_engine_model_schema-ModelAttributeProperties.md) is used to mark formatting attributes (like `bold` or `italic`).

```typescript
// Mark bold as a formatting attribute.
schema.setAttributeProperties( 'bold', {
	isFormatting: true
} );

// Override code not to be considered a formatting markup.
schema.setAttributeProperties( 'code', {
	isFormatting: false
} );
```

Properties are not limited to members defined in the [`AttributeProperties` type](module_engine_model_schema-ModelAttributeProperties.md) and you can also use custom properties:

```typescript
schema.setAttributeProperties( 'blockQuote', {
	customProperty: 'value'
} );
```

Subsequent calls with the same attribute will extend its custom properties:

```typescript
schema.setAttributeProperties( 'blockQuote', {
	one: 1
} );

schema.setAttributeProperties( 'blockQuote', {
	two: 2
} );

console.log( schema.getAttributeProperties( 'blockQuote' ) );
// Logs: { one: 1, two: 2 }
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L727)

#### Parameters

* `attributeName: string`

  A name of the attribute to receive the properties.

* `properties: ModelAttributeProperties`

  A dictionary of properties.

#### Returns

* `void`

<a id="function-stopDelegating">

### `stopDelegating( event?, emitter? ) → void` _(inherited)_

Stops delegating events. It can be used at different levels:

* To stop delegating all events.
* To stop delegating a specific event to all emitters.
* To stop delegating a specific event to a specific emitter.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L552)

#### Parameters

* `event?: string`

  The name of the event to stop delegating. If omitted, stops it all delegations.

* `emitter?: Emitter`

  (requires `event`) The object to stop delegating a particular event to. If omitted, stops delegation of `event` to all emitters.

#### Returns

* `void`

<a id="function-stopListening:BASE_STOP">

### `stopListening( emitter?, event?, callback? ) → void` _(inherited)_

Stops listening for events. It can be used at different levels:

* To stop listening to a specific callback.
* To stop listening to a specific event.
* To stop listening to all events fired by a specific object.
* To stop listening to all events fired by all objects.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L497)

#### Parameters

* `emitter?: Emitter`

  The object to stop listening to. If omitted, stops it for all objects.

* `event?: string`

  (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it for all events from `emitter`.

* `callback?: Function`

  (Requires the `event`) The function to be removed from the call list for the given `event`.

#### Returns

* `void`

<a id="function-unbind">

### `unbind( unbindProperties ) → void` _(inherited)_

Removes the binding created with [`bind`](#function-bind:SINGLE_BIND).

```typescript
// Removes the binding for the 'a' property.
A.unbind( 'a' );

// Removes bindings for all properties.
A.unbind();
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L1090)

#### Parameters

* `unbindProperties: Array<'off' | 'set' | 'bind' | 'unbind' | 'decorate' | 'stopListening' | 'on' | 'once' | 'listenTo' | 'fire' | 'delegate' | 'stopDelegating' | 'register' | 'extend' | 'getDefinitions' | 'getDefinition' | 'isRegistered' | 'isBlock' | 'isLimit' | 'isObject' | 'isInline' | 'isSelectable' | 'isContent' | 'checkChild' | 'checkAttribute' | 'checkMerge' | 'addChildCheck' | 'addAttributeCheck' | 'setAttributeProperties' | 'getAttributeProperties' | 'getLimitElement' | 'checkAttributeInSelection' | 'getValidRanges' | 'getNearestSelectionRange' | 'findAllowedParent' | 'setAllowedAttributes' | 'removeDisallowedAttributes' | 'getAttributesWithProperty' | 'createContext' | 'findOptimalInsertionRange'>`

  Observable properties to be unbound. All the bindings will be released if no properties are provided.

#### Returns

* `void`

<a id="function-findOptimalInsertionRange">

### `findOptimalInsertionRange( selection, place? ) → ModelRange` _(internal)_

Returns a model range which is optimal (in terms of UX) for inserting a widget block.

For instance, if a selection is in the middle of a paragraph, the collapsed range before this paragraph will be returned so that it is not split. If the selection is at the end of a paragraph, the collapsed range after this paragraph will be returned.

Note: If the selection is placed in an empty block, the range in that block will be returned. If that range is then passed to [`insertContent`](module_engine_model_model-Model.md#function-insertContent), the block will be fully replaced by the inserted widget block.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1233)

#### Parameters

* `selection: ModelSelection | ModelDocumentSelection`

  The selection based on which the insertion position should be calculated.

* `place?: 'auto' | 'before' | 'after'`

  The place where to look for optimal insertion range. The `auto` value will determine itself the best position for insertion. The `before` value will try to find a position before selection. The `after` value will try to find a position after selection.

#### Returns

* `ModelRange`

  The optimal range.

<a id="function-_checkContextMatch">

### `_checkContextMatch( context, def ) → boolean` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1090)

#### Parameters

* `context: ModelSchemaContext`
* `def: ModelSchemaCompiledItemDefinition`

#### Returns

* `boolean`

<a id="function-_clearCache">

### `_clearCache() → void` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1025)

#### Returns

* `void`

<a id="function-_compile">

### `_compile() → void` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1029)

#### Returns

* `void`

<a id="function-_evaluateAttributeChecks">

### `_evaluateAttributeChecks( context, attributeName ) → boolean | undefined` _(private)_

Calls attribute check callbacks to decide whether `attributeName` can be set on the last element of `context`. It uses both generic and specific (defined for `attributeName`) callbacks. If neither callback makes a decision, `undefined` is returned.

Note that the first callback that makes a decision "wins", i.e., if any callback returns `true` or `false`, then the processing is over and that result is returned.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1150)

#### Parameters

* `context: ModelSchemaContext`
* `attributeName: string`

#### Returns

* `boolean | undefined`

<a id="function-_evaluateChildChecks">

### `_evaluateChildChecks( context, def ) → boolean | undefined` _(private)_

Calls child check callbacks to decide whether `def` is allowed in `context`. It uses both generic and specific (defined for `def` item) callbacks. If neither callback makes a decision, `undefined` is returned.

Note that the first callback that makes a decision "wins", i.e., if any callback returns `true` or `false`, then the processing is over and that result is returned.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1130)

#### Parameters

* `context: ModelSchemaContext`
* `def: ModelSchemaCompiledItemDefinition`

#### Returns

* `boolean | undefined`

<a id="function-_getValidRangesForRange">

### `_getValidRangesForRange( range, attribute, options = { options.includeEmptyRanges? } ) → Iterable<ModelRange>` _(private)_

Takes a flat range and an attribute name. Traverses the range recursively and deeply to find and return all ranges inside the given range on which the attribute can be applied.

This is a helper function for [`getValidRanges`](#function-getValidRanges).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1173)

#### Parameters

* `range: ModelRange`

  The range to process.

* `attribute: string`

  The name of the attribute to check.

* `options: object`

  Properties

  * `options.includeEmptyRanges?: boolean`

#### Returns

* `Iterable<ModelRange>`

  Ranges in which the attribute is allowed.

<a id="events">

## Events

<a id="event-change:%7Bproperty%7D">

### `change:{property}( eventInfo, name, value, oldValue )` _(inherited)_

Fired when a property changed value.

```typescript
observable.set( 'prop', 1 );

observable.on<ObservableChangeEvent<number>>( 'change:prop', ( evt, propertyName, newValue, oldValue ) => {
	console.log( `${ propertyName } has changed from ${ oldValue } to ${ newValue }` );
} );

observable.prop = 2; // -> 'prop has changed from 1 to 2'
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L1190)

#### Parameters

* `eventInfo: EventInfo`

  An object containing information about the fired event.

* `name: string`

  The property name.

* `value: TValue`

  The new property value.

* `oldValue: TValue`

  The previous property value.

<a id="event-checkAttribute">

### `checkAttribute( eventInfo, args )`

Event fired when the [`checkAttribute`](#function-checkAttribute) method is called. It allows plugging in additional behavior, for example implementing rules which cannot be defined using the declarative [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md) interface.

**Note:** The [`addAttributeCheck`](#function-addAttributeCheck) method is a more handy way to register callbacks. Internally, it registers a listener to this event but comes with a simpler API and it is the recommended choice in most of the cases.

The [`checkAttribute`](#function-checkAttribute) method fires an event because it is [decorated](module_utils_observablemixin-Observable.md#function-decorate) with it. Thanks to that you can use this event in various ways, but the most important use case is overriding the standard behavior of the `checkAttribute()` method. Let's see a typical listener template:

```typescript
schema.on( 'checkAttribute', ( evt, args ) => {
	const context = args[ 0 ];
	const attributeName = args[ 1 ];
}, { priority: 'high' } );
```

The listener is added with a `high` priority to be executed before the default method is really called. The `args` callback parameter contains arguments passed to `checkAttribute( context, attributeName )`. However, the `context` parameter is already normalized to a [`ModelSchemaContext`](module_engine_model_schema-ModelSchemaContext.md) instance, so you do not have to worry about the various ways how `context` may be passed to `checkAttribute()`.

So, in order to implement a rule "disallow `bold` in a text which is in a `heading1`, you can add such a listener:

```typescript
schema.on( 'checkAttribute', ( evt, args ) => {
	const context = args[ 0 ];
	const attributeName = args[ 1 ];

	if ( context.endsWith( 'heading1 $text' ) && attributeName == 'bold' ) {
		// Prevent next listeners from being called.
		evt.stop();
		// Set the checkAttribute()'s return value.
		evt.return = false;
	}
}, { priority: 'high' } );
```

Allowing attributes in specific contexts will be a far less common use case, because it is normally handled by the `allowAttributes` rule from [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md). But if you have a complex scenario where `bold` should be allowed only in element `foo` which must be in element `bar`, then this would be the way:

```typescript
schema.on( 'checkAttribute', ( evt, args ) => {
	const context = args[ 0 ];
	const attributeName = args[ 1 ];

	if ( context.endsWith( 'bar foo $text' ) && attributeName == 'bold' ) {
		// Prevent next listeners from being called.
		evt.stop();
		// Set the checkAttribute()'s return value.
		evt.return = true;
	}
}, { priority: 'high' } );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1406)

#### Parameters

* `eventInfo: EventInfo`

  An object containing information about the fired event.

* `args: [ context: ModelSchemaContext, attributeName: string ]`

  The `checkAttribute()`'s arguments.

<a id="event-checkChild">

### `checkChild( eventInfo, args )`

Event fired when the [`checkChild`](#function-checkChild) method is called. It allows plugging in additional behavior, for example implementing rules which cannot be defined using the declarative [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md) interface.

**Note:** The [`addChildCheck`](#function-addChildCheck) method is a more handy way to register callbacks. Internally, it registers a listener to this event but comes with a simpler API and it is the recommended choice in most of the cases.

The [`checkChild`](#function-checkChild) method fires an event because it is [decorated](module_utils_observablemixin-Observable.md#function-decorate) with it. Thanks to that you can use this event in various ways, but the most important use case is overriding standard behavior of the `checkChild()` method. Let's see a typical listener template:

```typescript
schema.on( 'checkChild', ( evt, args ) => {
	const context = args[ 0 ];
	const childDefinition = args[ 1 ];
}, { priority: 'high' } );
```

The listener is added with a `high` priority to be executed before the default method is really called. The `args` callback parameter contains arguments passed to `checkChild( context, child )`. However, the `context` parameter is already normalized to a [`ModelSchemaContext`](module_engine_model_schema-ModelSchemaContext.md) instance and `child` to a [`ModelSchemaCompiledItemDefinition`](module_engine_model_schema-ModelSchemaCompiledItemDefinition.md) instance, so you do not have to worry about the various ways how `context` and `child` may be passed to `checkChild()`.

**Note:** `childDefinition` may be `undefined` if `checkChild()` was called with a non-registered element.

So, in order to implement a rule "disallow `heading1` in `blockQuote`", you can add such a listener:

```typescript
schema.on( 'checkChild', ( evt, args ) => {
	const context = args[ 0 ];
	const childDefinition = args[ 1 ];

	if ( context.endsWith( 'blockQuote' ) && childDefinition && childDefinition.name == 'heading1' ) {
		// Prevent next listeners from being called.
		evt.stop();
		// Set the checkChild()'s return value.
		evt.return = false;
	}
}, { priority: 'high' } );
```

Allowing elements in specific contexts will be a far less common use case, because it is normally handled by the `allowIn` rule from [`ModelSchemaItemDefinition`](module_engine_model_schema-ModelSchemaItemDefinition.md). But if you have a complex scenario where `listItem` should be allowed only in element `foo` which must be in element `bar`, then this would be the way:

```typescript
schema.on( 'checkChild', ( evt, args ) => {
	const context = args[ 0 ];
	const childDefinition = args[ 1 ];

	if ( context.endsWith( 'bar foo' ) && childDefinition.name == 'listItem' ) {
		// Prevent next listeners from being called.
		evt.stop();
		// Set the checkChild()'s return value.
		evt.return = true;
	}
}, { priority: 'high' } );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/model/schema.ts#L1338)

#### Parameters

* `eventInfo: EventInfo`

  An object containing information about the fired event.

* `args: [ context: ModelSchemaContext, def: ModelSchemaCompiledItemDefinition ]`

  The `checkChild()`'s arguments.

<a id="event-set:%7Bproperty%7D">

### `set:{property}( eventInfo, name, value, oldValue )` _(inherited)_

Fired when a property value is going to be set but is not set yet (before the `change` event is fired).

You can control the final value of the property by using the [event's `return` property](module_utils_eventinfo-EventInfo.md#member-return).

```typescript
observable.set( 'prop', 1 );

observable.on<ObservableSetEvent<number>>( 'set:prop', ( evt, propertyName, newValue, oldValue ) => {
	console.log( `Value is going to be changed from ${ oldValue } to ${ newValue }` );
	console.log( `Current property value is ${ observable[ propertyName ] }` );

	// Let's override the value.
	evt.return = 3;
} );

observable.on<ObservableChangeEvent<number>>( 'change:prop', ( evt, propertyName, newValue, oldValue ) => {
	console.log( `Value has changed from ${ oldValue } to ${ newValue }` );
} );

observable.prop = 2; // -> 'Value is going to be changed from 1 to 2'
					 // -> 'Current property value is 1'
					 // -> 'Value has changed from 1 to 3'
```

**Note:** The event is fired even when the new value is the same as the old value.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/observablemixin.ts#L1228)

#### Parameters

* `eventInfo: EventInfo`

  An object containing information about the fired event.

* `name: string`

  The property name.

* `value: TValue`

  The new property value.

* `oldValue: TValue`

  The previous property value.

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
