# typing/utils/getlasttextline

module

<a id="type-definitions">

## Type Definitions

<a id="typedef-LastTextLineData">

### `LastTextLineData`

<a id="functions">

## Functions

<a id="function-getLastTextLine">

### `getLastTextLine( range, model ) → LastTextLineData`

Returns the last text line from the given range.

"The last text line" is understood as text (from one or more text nodes) which is limited either by a parent block or by inline elements (e.g. `<softBreak>`).

```typescript
const rangeToCheck = model.createRange(
	model.createPositionAt( paragraph, 0 ),
	model.createPositionAt( paragraph, 'end' )
);

const { text, range } = getLastTextLine( rangeToCheck, model );
```

For model below, the returned `text` will be "Foo bar baz" and `range` will be set on whole `<paragraph>` content:

```xml
<paragraph>Foo bar baz<paragraph>
```

However, in below case, `text` will be set to "baz" and `range` will be set only on "baz".

```xml
<paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
```

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

#### Parameters

* `range: ModelRange`
* `model: Model`

#### Returns

* `LastTextLineData`

---

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