# ModelSchemaItemDefinition

interface

A definition of a [schema](module_engine_model_schema-ModelSchema.md) item.

You can define the following rules:

* [`allowIn`](#member-allowIn) – Defines in which other items this item will be allowed.
* [`allowChildren`](#member-allowChildren) – Defines which other items are allowed inside this item.
* [`allowAttributes`](#member-allowAttributes) – Defines allowed attributes of the given item.
* [`disallowIn`](#member-disallowIn) – Defines in which other items this item will be disallowed.
* [`disallowChildren`](#member-disallowChildren) – Defines which other items are disallowed inside this item.
* [`disallowAttributes`](#member-disallowAttributes) – Defines disallowed attributes of the given item.
* [`allowContentOf`](#member-allowContentOf) – Makes this item allow children that are also allowed in the specified items. This acknowledges disallow rules.
* [`allowWhere`](#member-allowWhere) – Makes this item allowed where the specified items are allowed. This acknowledges disallow rules.
* [`allowAttributesOf`](#member-allowAttributesOf) – Inherits attributes from other items. This acknowledges disallow rules.
* [`inheritTypesFrom`](#member-inheritTypesFrom) – Inherits `is*` properties of other items.
* [`inheritAllFrom`](#member-inheritAllFrom) – A shorthand for `allowContentOf`, `allowWhere`, `allowAttributesOf`, `inheritTypesFrom`.

#### The `is*` properties

There are a couple commonly used `is*` properties. Their role is to assign additional semantics to schema items.

* [`isBlock`](#member-isBlock) – Whether this item is paragraph-like. Generally speaking, content is usually made out of blocks like paragraphs, list items, images, headings, etc.
* [`isInline`](#member-isInline) – Whether an item is "text-like" and should be treated as an inline node. Examples of inline elements: `$text`, `softBreak` (`<br>`), etc.
* [`isLimit`](#member-isLimit) – It can be understood as whether this element should not be split by `Enter`. Examples of limit elements: `$root`, table cell, image caption, etc. In other words, all actions that happen inside a limit element are limited to its content. All objects are treated as limit elements, too.
* [`isObject`](#member-isObject) – Whether an item is "self-contained" and should be treated as a whole. Examples of object elements: `imageBlock`, `table`, `video`, etc. An object is also a limit, so [`isLimit()`](module_engine_model_schema-ModelSchema.md#function-isLimit) returns `true` for object elements automatically.

Read more about the meaning of these types in the [dedicated section of the Schema deep-dive](../framework/deep-dive/schema.md#defining-additional-semantics) guide.

#### Generic items

There are several generic items (classes of elements) available: `$root`, `$container`, `$block`, `$blockObject`, `$inlineObject`, and `$text`. They are defined as follows:

```typescript
schema.register( '$root', {
	isLimit: true
} );

schema.register( '$container', {
	allowIn: [ '$root', '$container' ]
} );

schema.register( '$block', {
	allowIn: [ '$root', '$container' ],
	isBlock: true
} );

schema.register( '$blockObject', {
	allowWhere: '$block',
	isBlock: true,
	isObject: true
} );

schema.register( '$inlineObject', {
	allowWhere: '$text',
	allowAttributesOf: '$text',
	isInline: true,
	isObject: true
} );

schema.register( '$text', {
	allowIn: '$block',
	isInline: true,
	isContent: true
} );
```

They reflect typical editor content that is contained within one root, consists of several blocks (paragraphs, lists items, headings, images) which, in turn, may contain text inside.

By inheriting from the generic items you can define new items which will get extended by other editor features. Read more about generic types in the [Schema deep-dive](../framework/deep-dive/schema.md) guide.

#### Example definitions

Allow `paragraph` in roots and block quotes:

```typescript
schema.register( 'paragraph', {
	allowIn: [ '$root', 'blockQuote' ],
	isBlock: true
} );
```

Allow `paragraph` everywhere where `$block` is allowed (i.e. in `$root`):

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

Allow `paragraph` inside a `$root` and allow `$text` as a `paragraph` child:

```typescript
schema.register( 'paragraph', {
	allowIn: '$root',
	allowChildren: '$text',
	isBlock: true
} );
```

The previous rule can be written in a shorter form using inheritance:

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

Make `imageBlock` a block object, which is allowed everywhere where `$block` is. Also, allow `src` and `alt` attributes in it:

```typescript
schema.register( 'imageBlock', {
	inheritAllFrom: '$blockObject',
	allowAttributes: [ 'src', 'alt' ],
} );
```

Make `caption` allowed in `imageBlock` and make it allow all the content of `$block`s (usually, `$text`). Also, mark it as a limit element so it cannot be split:

```typescript
schema.register( 'caption', {
	allowIn: 'imageBlock',
	allowContentOf: '$block',
	isLimit: true
} );
```

Register `inlineImage` as a kind of an inline object but disallow it inside captions:

```typescript
schema.register( 'imageInline', {
	inheritAllFrom: '$inlineObject',
	disallowIn: [ 'caption' ]
} );
```

Make `listItem` inherit all from `$block` but also allow additional attributes:

```typescript
schema.register( 'listItem', {
	inheritAllFrom: '$block',
	allowAttributes: [ 'listType', 'listIndent' ]
} );
```

Which translates to:

```typescript
schema.register( 'listItem', {
	allowWhere: '$block',
	allowContentOf: '$block',
	allowAttributesOf: '$block',
	inheritTypesFrom: '$block',
	allowAttributes: [ 'listType', 'listIndent' ]
} );
```

#### Tips

* Check schema definitions of existing features to see how they are defined.
* If you want to publish your feature so other developers can use it, try to use generic items as much as possible.
* Keep your model clean. Limit it to the actual data and store information in a normalized way.
* Remember about defining the `is*` properties. They do not affect the allowed structures, but they can affect how the editor features treat your elements.

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

<a id="properties">

## Properties

<a id="member-allowAttributes">

### `allowAttributes?: string | Array<string>`

Defines allowed attributes of the given item.

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

<a id="member-allowAttributesOf">

### `allowAttributesOf?: string | Array<string>`

Inherits "allowed attributes" from other items.

Note that the item's "own" rules take precedence over "inherited" rules and can overwrite them.

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

<a id="member-allowChildren">

### `allowChildren?: string | Array<string>`

Defines which other items are allowed inside this item.

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

<a id="member-allowContentOf">

### `allowContentOf?: string | Array<string>`

Inherits "allowed children" from other items.

Note that the item's "own" rules take precedence over "inherited" rules and can overwrite them.

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

<a id="member-allowIn">

### `allowIn?: string | Array<string>`

Defines in which other items this item will be allowed.

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

<a id="member-allowWhere">

### `allowWhere?: string | Array<string>`

Inherits "allowed in" from other items.

Note that the item's "own" rules take precedence over "inherited" rules and can overwrite them.

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

<a id="member-disallowAttributes">

### `disallowAttributes?: string | Array<string>`

Defines disallowed attributes for this item. Takes precedence over allow rules.

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

<a id="member-disallowChildren">

### `disallowChildren?: string | Array<string>`

Defines which other items are disallowed inside this item. Takes precedence over allow rules.

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

<a id="member-disallowIn">

### `disallowIn?: string | Array<string>`

Defines in which other items this item will be disallowed. Takes precedence over allow rules.

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

<a id="member-inheritAllFrom">

### `inheritAllFrom?: string`

A shorthand for `allowContentOf`, `allowWhere`, `allowAttributesOf`, `inheritTypesFrom`.

Note that the item's "own" rules take precedence over "inherited" rules and can overwrite them.

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

<a id="member-inheritTypesFrom">

### `inheritTypesFrom?: string | Array<string>`

Inherits `is*` properties of other items.

Note that the item's "own" rules take precedence over "inherited" rules and can overwrite them.

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

<a id="member-isBlock">

### `isBlock?: boolean`

Whether this item is paragraph-like. Generally speaking, content is usually made out of blocks like paragraphs, list items, images, headings, etc. All these elements are marked as blocks. A block should not allow another block inside. Note: There is also the `$block` generic item which has `isBlock` set to `true`. Most block type items will inherit from `$block` (through `inheritAllFrom`).

Read more about the block elements in the [Block elements section](../framework/deep-dive/schema.md#block-elements) of 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#L1672)

<a id="member-isContent">

### `isContent?: boolean`

An item is a content when it always finds its way to the editor data output regardless of the number and type of its descendants. Examples of content elements: `$text`, `imageBlock`, `table`, etc. (but not `paragraph`, `heading1` or `tableCell`).

**Note:** An object is also a content element, so [`isContent()`](module_engine_model_schema-ModelSchema.md#function-isContent) returns `true` for object elements automatically.

Read more about content elements in the [Content elements section](../framework/deep-dive/schema.md#content-elements) of 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#L1730)

<a id="member-isInline">

### `isInline?: boolean`

Whether an item is "text-like" and should be treated as an inline node. Examples of inline elements: `$text`, `softBreak` (`<br>`), etc.

Read more about the inline elements in the [Inline elements section](../framework/deep-dive/schema.md#inline-elements) of the Schema deep-dive guide.

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

<a id="member-isLimit">

### `isLimit?: boolean`

It can be understood as whether this element should not be split by `Enter`. Examples of limit elements: `$root`, table cell, image caption, etc. In other words, all actions that happen inside a limit element are limited to its content.

Read more about the limit elements in the [Limit elements section](../framework/deep-dive/schema.md#limit-elements) of 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#L1692)

<a id="member-isObject">

### `isObject?: boolean`

Whether an item is "self-contained" and should be treated as a whole. Examples of object elements: `imageBlock`, `table`, `video`, etc.

**Note:** An object is also a limit, so [`isLimit()`](module_engine_model_schema-ModelSchema.md#function-isLimit) returns `true` for object elements automatically.

Read more about the object elements in the [Object elements section](../framework/deep-dive/schema.md#object-elements) of the Schema deep-dive guide.

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

<a id="member-isSelectable">

### `isSelectable?: boolean`

`true` when an element should be selectable as a whole by the user. Examples of selectable elements: `imageBlock`, `table`, `tableCell`, etc.

**Note:** An object is also a selectable element, so [`isSelectable()`](module_engine_model_schema-ModelSchema.md#function-isSelectable) returns `true` for object elements automatically.

Read more about selectable elements in the [Selectable elements section](../framework/deep-dive/schema.md#selectable-elements) of 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#L1717)

---

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