# list/list/utils/view

module

<a id="functions">

## Functions

<a id="function-createListElement">

### `createListElement( writer, indent, type, id ) → ViewAttributeElement` _(internal)_

Creates a list attribute element (ol or ul).

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

#### Parameters

* `writer: ViewDowncastWriter`

* `indent: number`

* `type: ListType`

* `id: string`

  Defaults to `...`

#### Returns

* `ViewAttributeElement`

<a id="function-createListItemElement">

### `createListItemElement( writer, indent, id ) → ViewAttributeElement` _(internal)_

Creates a list item attribute element (li).

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

#### Parameters

* `writer: ViewDowncastWriter`
* `indent: number`
* `id: string`

#### Returns

* `ViewAttributeElement`

<a id="function-getIndent">

### `getIndent( listItem ) → number` _(internal)_

Calculates the indent value for a list item. Handles HTML compliant and non-compliant lists.

Also, fixes non HTML compliant lists indents:

```
before:                                     fixed list:
OL                                          OL
|-> LI (parent LIs: 0)                      |-> LI     (indent: 0)
    |-> OL                                  |-> OL
        |-> OL                                  |
        |   |-> OL                              |
        |       |-> OL                          |
        |           |-> LI (parent LIs: 1)      |-> LI (indent: 1)
        |-> LI (parent LIs: 1)                  |-> LI (indent: 1)

before:                                     fixed list:
OL                                          OL
|-> OL                                      |
    |-> OL                                  |
         |-> OL                             |
             |-> LI (parent LIs: 0)         |-> LI        (indent: 0)

before:                                     fixed list:
OL                                          OL
|-> LI (parent LIs: 0)                      |-> LI         (indent: 0)
|-> OL                                          |-> OL
    |-> LI (parent LIs: 0)                          |-> LI (indent: 1)
```

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

#### Parameters

* `listItem: ViewElement`

#### Returns

* `number`

<a id="function-getViewElementIdForListType">

### `getViewElementIdForListType( type?, indent? ) → string` _(internal)_

Returns a view element ID for the given list type and indent.

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

#### Parameters

* `type?: ListType`
* `indent?: number`

#### Returns

* `string`

<a id="function-getViewElementNameForListType">

### `getViewElementNameForListType( type? ) → 'ol' | 'ul'` _(internal)_

Returns a view element name for the given list type.

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

#### Parameters

* `type?: ListType`

#### Returns

* `'ol' | 'ul'`

<a id="function-isListItemView">

### `isListItemView( viewElement ) → boolean` _(internal)_

Checks if view element is a list item (li).

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

#### Parameters

* `viewElement: ViewNode | ViewDocumentFragment`

#### Returns

* `boolean`

<a id="function-isListView">

### `isListView( viewElement ) → boolean` _(internal)_

Checks if view element is a list type (ul or ol).

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

#### Parameters

* `viewElement: ViewNode | ViewDocumentFragment`

#### Returns

* `boolean`

---

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