# list/legacylist/legacyutils

module

<a id="functions">

## Functions

<a id="function-createViewListItemElement">

### `createViewListItemElement( writer ) → ViewContainerElement` _(internal)_

Creates a list item [`ViewContainerElement`](module_engine_view_containerelement-ViewContainerElement.md).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L31)

#### Parameters

* `writer: ViewDowncastWriter`

  The writer instance.

#### Returns

* `ViewContainerElement`

<a id="function-findNestedList">

### `findNestedList( viewElement ) → ViewElement | null` _(internal)_

Returns a first list view element that is direct child of the given view element.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L285)

#### Parameters

* `viewElement: ViewElement`

#### Returns

* `ViewElement | null`

<a id="function-generateLiInUl">

### `generateLiInUl( modelItem, conversionApi ) → ViewContainerElement` _(internal)_

Helper function that creates a `<ul><li></li></ul>` or (`<ol>`) structure out of the given `modelItem` model `listItem` element. Then, it binds the created view list item (`<li>`) with the model `listItem` element. The function then returns the created view list item (`<li>`).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L49)

#### Parameters

* `modelItem: ModelItem`

  Model list item.

* `conversionApi: DowncastConversionApi`

  Conversion interface.

#### Returns

* `ViewContainerElement`

  View list element.

<a id="function-getListTypeFromListStyleType">

### `getListTypeFromListStyleType( listStyleType ) → 'numbered' | 'bulleted' | null` _(internal)_

Checks whether the given list-style-type is supported by numbered or bulleted list.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L439)

#### Parameters

* `listStyleType: string`

#### Returns

* `'numbered' | 'bulleted' | null`

<a id="function-getSelectedListItems">

### `getSelectedListItems( model ) → Array<ModelElement>` _(internal)_

Returns an array with all `listItem` elements in the model selection.

It returns all the items even if only a part of the list is selected, including items that belong to nested lists. If no list is selected, it returns an empty array. The order of the elements is not specified.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L397)

#### Parameters

* `model: Model`

#### Returns

* `Array<ModelElement>`

<a id="function-getSiblingListItem">

### `getSiblingListItem( modelItem, options = { options.direction?, options.listIndent?, options.sameIndent?, options.smallerIndent? } ) → ModelElement | null` _(internal)_

Helper function that searches for a previous list item sibling of a given model item that meets the given criteria passed by the options object.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L248)

#### Parameters

* `modelItem: ModelItem | null`

* `options: object`

  Search criteria.

  Properties

  * `options.direction?: 'forward' | 'backward'`

    Walking direction.

  * `options.listIndent?: number`

    The reference indentation.

  * `options.sameIndent?: boolean`

    Whether the sought sibling should have the same indentation.

  * `options.smallerIndent?: boolean`

    Whether the sought sibling should have a smaller indentation.

#### Returns

* `ModelElement | null`

<a id="function-getSiblingNodes">

### `getSiblingNodes( position, direction ) → Array<ModelElement>` _(internal)_

Returns an array with all `listItem` elements that represent the same list.

It means that values of `listIndent`, `listType`, `listStyle`, `listReversed` and `listStart` for all items are equal.

Additionally, if the `position` is inside a list item, that list item will be returned as well.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L306)

#### Parameters

* `position: ModelPosition`

  Starting position.

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

  Walking direction.

#### Returns

* `Array<ModelElement>`

<a id="function-injectViewList">

### `injectViewList( modelItem, injectedItem, conversionApi, model ) → void` _(internal)_

Helper function that inserts a view list at a correct place and merges it with its siblings. It takes a model list item element (`modelItem`) and a corresponding view list item element (`injectedItem`). The view list item should be in a view list element (`<ul>` or `<ol>`) and should be its only child. See comments below to better understand the algorithm.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L76)

#### Parameters

* `modelItem: ModelElement`

  Model list item.

* `injectedItem: ViewContainerElement`

* `conversionApi: DowncastConversionApi`

  Conversion interface.

* `model: Model`

  The model instance.

#### Returns

* `void`

<a id="function-mergeViewLists">

### `mergeViewLists( viewWriter, firstList, secondList ) → ViewPosition | null` _(internal)_

Helper function that takes two parameters that are expected to be view list elements, and merges them. The merge happens only if both parameters are list elements of the same type (the same element name and the same class attributes).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L199)

#### Parameters

* `viewWriter: ViewDowncastWriter`

  The writer instance.

* `firstList: ViewItem`

  The first element to compare.

* `secondList: ViewItem`

  The second element to compare.

#### Returns

* `ViewPosition | null`

  The position after merge or `null` when there was no merge.

<a id="function-positionAfterUiElements">

### `positionAfterUiElements( viewPosition ) → ViewPosition` _(internal)_

Helper function that for a given `view.Position`, returns a `view.Position` that is after all `view.UIElement`s that are after the given position.

For example: `<container:p>foo^<ui:span></ui:span><ui:span></ui:span>bar</container:p>` For position ^, the position before "bar" will be returned.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-list/src/legacylist/legacyutils.ts#L233)

#### Parameters

* `viewPosition: ViewPosition`

#### Returns

* `ViewPosition`

---

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