# engine/model/position

module

<a id="classes">

## Classes

<a id="class-ModelPosition">

### [ModelPosition](module_engine_model_position-ModelPosition.md)

<a id="type-definitions">

## Type Definitions

<a id="typedef-ModelPositionOffset">

### `ModelPositionOffset`

<a id="typedef-ModelPositionRelation">

### `ModelPositionRelation`

<a id="typedef-ModelPositionStickiness">

### `ModelPositionStickiness`

<a id="functions">

## Functions

<a id="function-getNodeAfterPosition">

### `getNodeAfterPosition( position, positionParent, textNode ) → ModelNode | null` _(internal)_

Returns the node after the given position.

This is a helper function optimized to reuse the position parent instance and the calculation of the text node at the specific position for performance reasons.

Normally, you should use [`Position#nodeAfter`](module_engine_model_position-ModelPosition.md#member-nodeAfter). If you start hitting performance issues with [`Position#parent`](module_engine_model_position-ModelPosition.md#member-parent) and/or [`Position#textNode`](module_engine_model_position-ModelPosition.md#member-textNode) check if your algorithm does not access those properties multiple times (which can happen directly or indirectly via other position properties).

See https\://github.com/ckeditor/ckeditor5/issues/6579 and https\://github.com/ckeditor/ckeditor5/issues/6582.

See also:

* [`getTextNodeAtPosition`](#function-getTextNodeAtPosition)
* [`getNodeBeforePosition`](#function-getNodeBeforePosition)

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

#### Parameters

* `position: ModelPosition`

  Position to check.

* `positionParent: ModelElement | ModelDocumentFragment`

  The parent of the given position.

* `textNode: ModelText | null`

  Text node at the given position.

#### Returns

* `ModelNode | null`

<a id="function-getNodeBeforePosition">

### `getNodeBeforePosition( position, positionParent, textNode ) → ModelNode | null` _(internal)_

Returns the node before the given position.

Refer to [`getNodeBeforePosition`](#function-getNodeBeforePosition) for documentation on when to use this util method.

See also:

* [`getTextNodeAtPosition`](#function-getTextNodeAtPosition)
* [`getNodeAfterPosition`](#function-getNodeAfterPosition)

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

#### Parameters

* `position: ModelPosition`

  Position to check.

* `positionParent: ModelElement | ModelDocumentFragment`

  The parent of the given position.

* `textNode: ModelText | null`

  Text node at the given position.

#### Returns

* `ModelNode | null`

<a id="function-getTextNodeAtPosition">

### `getTextNodeAtPosition( position, positionParent ) → ModelText | null` _(internal)_

Returns a text node at the given position.

This is a helper function optimized to reuse the position parent instance for performance reasons.

Normally, you should use [`Position#textNode`](module_engine_model_position-ModelPosition.md#member-textNode). If you start hitting performance issues with [`Position#parent`](module_engine_model_position-ModelPosition.md#member-parent) check if your algorithm does not access it multiple times (which can happen directly or indirectly via other position properties).

See https\://github.com/ckeditor/ckeditor5/issues/6579.

See also:

* [`getNodeAfterPosition`](#function-getNodeAfterPosition)
* [`getNodeBeforePosition`](#function-getNodeBeforePosition)

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

#### Parameters

* `position: ModelPosition`

* `positionParent: ModelElement | ModelDocumentFragment`

  The parent of the given position.

#### Returns

* `ModelText | null`

---

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