# ModelDocumentFragment

class

ModelDocumentFragment represents a part of model which does not have a common root but its top-level nodes can be seen as siblings. In other words, it is a detached part of model tree, without a root.

ModelDocumentFragment has own [`MarkerCollection`](module_engine_model_markercollection-MarkerCollection.md). Markers from this collection will be set to the [model markers](module_engine_model_model-Model.md#member-markers) by a [`insert`](module_engine_model_writer-ModelWriter.md#function-insert) function.

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

<a id="properties">

## Properties

<a id="member-childCount">

### `childCount: number` _(readonly)_

Number of this document fragment's children.

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

<a id="member-document">

### `document: null` _(readonly)_

Artificial owner of `ModelDocumentFragment`. Returns `null`. Added for compatibility reasons.

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

<a id="member-isEmpty">

### `isEmpty: boolean` _(readonly)_

Is `true` if there are no nodes inside this document fragment, `false` otherwise.

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

<a id="member-markers">

### `markers: Map<string, ModelRange>` _(readonly)_

ModelDocumentFragment static markers map. This is a list of names and [ranges](module_engine_model_range-ModelRange.md) which will be set as Markers to [model markers collection](module_engine_model_model-Model.md#member-markers) when ModelDocumentFragment will be inserted to the document.

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

<a id="member-maxOffset">

### `maxOffset: number` _(readonly)_

Sum of [offset sizes](module_engine_model_node-ModelNode.md#member-offsetSize) of all of this document fragment's children.

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

<a id="member-name">

### `name?: undefined`

Artificial element name. Returns `undefined`. Added for compatibility reasons.

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

<a id="member-nextSibling">

### `nextSibling: null` _(readonly)_

Artificial next sibling. Returns `null`. Added for compatibility reasons.

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

<a id="member-parent">

### `parent: null` _(readonly)_

Artificial parent of `ModelDocumentFragment`. Returns `null`. Added for compatibility reasons.

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

<a id="member-previousSibling">

### `previousSibling: null` _(readonly)_

Artificial previous sibling. Returns `null`. Added for compatibility reasons.

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

<a id="member-root">

### `root: ModelDocumentFragment` _(readonly)_

Artificial root of `ModelDocumentFragment`. Returns itself. Added for compatibility reasons.

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

<a id="member-rootName">

### `rootName?: undefined`

Artificial root name. Returns `undefined`. Added for compatibility reasons.

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

<a id="member-_children">

### `_children: ModelNodeList` _(private)_

List of nodes contained inside the document fragment.

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

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( children? )` _(internal)_

Creates an empty `ModelDocumentFragment`.

**Note:** Constructor of this class shouldn't be used directly in the code. Use the [`createDocumentFragment`](module_engine_model_writer-ModelWriter.md#function-createDocumentFragment) method instead.

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

#### Parameters

* `children?: ModelNode | Iterable<ModelNode>`

  Nodes to be contained inside the `ModelDocumentFragment`.

<a id="function-Symbol.iterator">

### `Symbol.iterator() → IterableIterator<ModelNode>`

Returns an iterator that iterates over all nodes contained inside this document fragment.

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

#### Returns

* `IterableIterator<ModelNode>`

<a id="function-getAncestors">

### `getAncestors() → Array<never>`

Returns empty array. Added for compatibility reasons.

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

#### Returns

* `Array<never>`

<a id="function-getChild">

### `getChild( index ) → ModelNode | null`

Gets the child at the given index. Returns `null` if incorrect index was passed.

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

#### Parameters

* `index: number`

  Index in this document fragment.

#### Returns

* `ModelNode | null`

  Child node.

<a id="function-getChildAtOffset">

### `getChildAtOffset( offset ) → ModelNode | null`

Gets the child at the given offset. Returns `null` if incorrect index was passed.

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

#### Parameters

* `offset: number`

  Offset in this document fragment.

#### Returns

* `ModelNode | null`

  Child node.

<a id="function-getChildIndex">

### `getChildIndex( node ) → number | null`

Returns an index of the given child node. Returns `null` if given node is not a child of this document fragment.

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

#### Parameters

* `node: ModelNode`

  Child node to look for.

#### Returns

* `number | null`

  Child node's index.

<a id="function-getChildStartOffset">

### `getChildStartOffset( node ) → number | null`

Returns the starting offset of given child. Starting offset is equal to the sum of [offset sizes](module_engine_model_node-ModelNode.md#member-offsetSize) of all node's siblings that are before it. Returns `null` if given node is not a child of this document fragment.

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

#### Parameters

* `node: ModelNode`

  Child node to look for.

#### Returns

* `number | null`

  Child node's starting offset.

<a id="function-getChildren">

### `getChildren() → IterableIterator<ModelNode>`

Returns an iterator that iterates over all of this document fragment's children.

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

#### Returns

* `IterableIterator<ModelNode>`

<a id="function-getNodeByPath">

### `getNodeByPath( relativePath ) → ModelNode | ModelDocumentFragment`

Returns a descendant node by its path relative to this element.

```typescript
// <this>a<b>c</b></this>
this.getNodeByPath( [ 0 ] );	 // -> "a"
this.getNodeByPath( [ 1 ] );	 // -> <b>
this.getNodeByPath( [ 1, 0 ] );  // -> "c"
```

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

#### Parameters

* `relativePath: Array<number>`

  Path of the node to find, relative to this element.

#### Returns

* `ModelNode | ModelDocumentFragment`

<a id="function-getPath">

### `getPath() → Array<number>`

Returns path to a `ModelDocumentFragment`, which is an empty array. Added for compatibility reasons.

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

#### Returns

* `Array<number>`

<a id="function-is:ELEMENT">

### `is( type ) → this is ModelElement | ModelRootElement` _(inherited)_

Checks whether the object is of type [`ModelElement`](module_engine_model_element-ModelElement.md) or its subclass.

```typescript
element.is( 'element' ); // -> true
element.is( 'node' ); // -> true
element.is( 'model:element' ); // -> true
element.is( 'model:node' ); // -> true

element.is( 'view:element' ); // -> false
element.is( 'documentSelection' ); // -> false
```

Assuming that the object being checked is an element, you can also check its [name](module_engine_model_element-ModelElement.md#member-name):

```typescript
element.is( 'element', 'imageBlock' ); // -> true if this is an <imageBlock> element
text.is( 'element', 'imageBlock' ); -> false
```

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

#### Parameters

* `type: 'element' | 'model:element'`

#### Returns

* `this is ModelElement | ModelRootElement`

<a id="function-is:TEXT">

### `is( type ) → this is ModelText` _(inherited)_

Checks whether the object is of type [`ModelText`](module_engine_model_text-ModelText.md).

```typescript
text.is( '$text' ); // -> true
text.is( 'node' ); // -> true
text.is( 'model:$text' ); // -> true
text.is( 'model:node' ); // -> true

text.is( 'view:$text' ); // -> false
text.is( 'documentSelection' ); // -> false
```

**Note:** Until version 20.0.0 this method wasn't accepting `'$text'` type. The legacy `'text'` type is still accepted for backward compatibility.

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

#### Parameters

* `type: '$text' | 'model:$text'`

#### Returns

* `this is ModelText`

<a id="function-is:POSITION">

### `is( type ) → this is ModelPosition | ModelLivePosition` _(inherited)_

Checks whether the object is of type [`ModelPosition`](module_engine_model_position-ModelPosition.md) or its subclass.

```typescript
position.is( 'position' ); // -> true
position.is( 'model:position' ); // -> true

position.is( 'view:position' ); // -> false
position.is( 'documentSelection' ); // -> false
```

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

#### Parameters

* `type: 'position' | 'model:position'`

#### Returns

* `this is ModelPosition | ModelLivePosition`

<a id="function-is:ROOT_ELEMENT">

### `is( type ) → this is ModelRootElement` _(inherited)_

Checks whether the object is of type [`ModelRootElement`](module_engine_model_rootelement-ModelRootElement.md).

```typescript
rootElement.is( 'rootElement' ); // -> true
rootElement.is( 'element' ); // -> true
rootElement.is( 'node' ); // -> true
rootElement.is( 'model:rootElement' ); // -> true
rootElement.is( 'model:element' ); // -> true
rootElement.is( 'model:node' ); // -> true

rootElement.is( 'view:element' ); // -> false
rootElement.is( 'documentFragment' ); // -> false
```

Assuming that the object being checked is an element, you can also check its [name](module_engine_model_element-ModelElement.md#member-name):

```typescript
rootElement.is( 'rootElement', '$root' ); // -> same as above
```

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

#### Parameters

* `type: 'rootElement' | 'model:rootElement'`

#### Returns

* `this is ModelRootElement`

<a id="function-is:LIVE_RANGE">

### `is( type ) → this is ModelLiveRange` _(inherited)_

Checks whether the object is of type [`ModelLiveRange`](module_engine_model_liverange-ModelLiveRange.md).

```typescript
liveRange.is( 'range' ); // -> true
liveRange.is( 'model:range' ); // -> true
liveRange.is( 'liveRange' ); // -> true
liveRange.is( 'model:liveRange' ); // -> true

liveRange.is( 'view:range' ); // -> false
liveRange.is( 'documentSelection' ); // -> false
```

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

#### Parameters

* `type: 'liveRange' | 'model:liveRange'`

#### Returns

* `this is ModelLiveRange`

<a id="function-is:MARKER">

### `is( type ) → this is Marker` _(inherited)_

Checks whether the object is of type [`Marker`](module_engine_model_markercollection-Marker.md).

```typescript
marker.is( 'marker' ); // -> true
marker.is( 'model:marker' ); // -> true

marker.is( 'view:element' ); // -> false
marker.is( 'documentSelection' ); // -> false
```

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

#### Parameters

* `type: 'marker' | 'model:marker'`

#### Returns

* `this is Marker`

<a id="function-is:TEXT_PROXY">

### `is( type ) → this is ModelTextProxy` _(inherited)_

Checks whether the object is of type [`ModelTextProxy`](module_engine_model_textproxy-ModelTextProxy.md).

```typescript
textProxy.is( '$textProxy' ); // -> true
textProxy.is( 'model:$textProxy' ); // -> true

textProxy.is( 'view:$textProxy' ); // -> false
textProxy.is( 'range' ); // -> false
```

**Note:** Until version 20.0.0 this method wasn't accepting `'$textProxy'` type. The legacy `'textProxt'` type is still accepted for backward compatibility.

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

#### Parameters

* `type: '$textProxy' | 'model:$textProxy'`

#### Returns

* `this is ModelTextProxy`

<a id="function-is:DOCUMENT_SELECTION">

### `is( type ) → this is ModelDocumentSelection` _(inherited)_

Checks whether the object is of type [`ModelDocumentSelection`](module_engine_model_documentselection-ModelDocumentSelection.md).

```typescript
selection.is( 'selection' ); // -> true
selection.is( 'documentSelection' ); // -> true
selection.is( 'model:selection' ); // -> true
selection.is( 'model:documentSelection' ); // -> true

selection.is( 'view:selection' ); // -> false
selection.is( 'element' ); // -> false
selection.is( 'node' ); // -> false
```

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

#### Parameters

* `type: 'documentSelection' | 'model:documentSelection'`

#### Returns

* `this is ModelDocumentSelection`

<a id="function-is:SELECTION">

### `is( type ) → this is ModelSelection | ModelDocumentSelection` _(inherited)_

Checks whether the object is of type [`ModelSelection`](module_engine_model_selection-ModelSelection.md) or [`ModelDocumentSelection`](module_engine_model_documentselection-ModelDocumentSelection.md).

```typescript
selection.is( 'selection' ); // -> true
selection.is( 'model:selection' ); // -> true

selection.is( 'view:selection' ); // -> false
selection.is( 'range' ); // -> false
```

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

#### Parameters

* `type: 'selection' | 'model:selection'`

#### Returns

* `this is ModelSelection | ModelDocumentSelection`

<a id="function-is:DOCUMENT_FRAGMENT">

### `is( type ) → this is ModelDocumentFragment` _(inherited)_

Checks whether the object is of type [`ModelDocumentFragment`](module_engine_model_documentfragment-ModelDocumentFragment.md).

```typescript
docFrag.is( 'documentFragment' ); // -> true
docFrag.is( 'model:documentFragment' ); // -> true

docFrag.is( 'view:documentFragment' ); // -> false
docFrag.is( 'element' ); // -> false
docFrag.is( 'node' ); // -> false
```

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

#### Parameters

* `type: 'documentFragment' | 'model:documentFragment'`

#### Returns

* `this is ModelDocumentFragment`

<a id="function-is:RANGE">

### `is( type ) → this is ModelRange | ModelLiveRange` _(inherited)_

Checks whether the object is of type [`ModelRange`](module_engine_model_range-ModelRange.md) or its subclass.

```typescript
range.is( 'range' ); // -> true
range.is( 'model:range' ); // -> true

range.is( 'view:range' ); // -> false
range.is( 'documentSelection' ); // -> false
```

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

#### Parameters

* `type: 'range' | 'model:range'`

#### Returns

* `this is ModelRange | ModelLiveRange`

<a id="function-is:LIVE_POSITION">

### `is( type ) → this is ModelLivePosition` _(inherited)_

Checks whether the object is of type [`ModelLivePosition`](module_engine_model_liveposition-ModelLivePosition.md).

```typescript
livePosition.is( 'position' ); // -> true
livePosition.is( 'model:position' ); // -> true
livePosition.is( 'liveposition' ); // -> true
livePosition.is( 'model:livePosition' ); // -> true

livePosition.is( 'view:position' ); // -> false
livePosition.is( 'documentSelection' ); // -> false
```

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

#### Parameters

* `type: 'livePosition' | 'model:livePosition'`

#### Returns

* `this is ModelLivePosition`

<a id="function-is:ELEMENT_NAME">

### `is( type, name ) → boolean` _(inherited)_

Checks whether the object is of type [`ModelElement`](module_engine_model_element-ModelElement.md) or its subclass and has the specified `name`.

```typescript
element.is( 'element', 'imageBlock' ); // -> true if this is an <imageBlock> element
text.is( 'element', 'imageBlock' ); -> false
```

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

#### Type parameters

* `N: extends string`

#### Parameters

* `type: 'element' | 'model:element'`
* `name: N`

#### Returns

* `boolean`

<a id="function-is:ROOT_ELEMENT_NAME">

### `is( type, name ) → boolean` _(inherited)_

Checks whether the object is of type [`ModelRootElement`](module_engine_model_rootelement-ModelRootElement.md) and has the specified `name`.

```typescript
rootElement.is( 'rootElement', '$root' );
```

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

#### Type parameters

* `N: extends string`

#### Parameters

* `type: 'rootElement' | 'model:rootElement'`
* `name: N`

#### Returns

* `boolean`

<a id="function-is:NODE">

### `is( type ) → this is ModelNode | ModelText | ModelElement | ModelRootElement` _(inherited)_

Checks whether the object is of type [`ModelNode`](module_engine_model_node-ModelNode.md) or its subclass.

This method is useful when processing model objects that are of unknown type. For example, a function may return a [`ModelDocumentFragment`](module_engine_model_documentfragment-ModelDocumentFragment.md) or a [`ModelNode`](module_engine_model_node-ModelNode.md) that can be either a text node or an element. This method can be used to check what kind of object is returned.

```typescript
someObject.is( 'element' ); // -> true if this is an element
someObject.is( 'node' ); // -> true if this is a node (a text node or an element)
someObject.is( 'documentFragment' ); // -> true if this is a document fragment
```

Since this method is also available on a range of view objects, you can prefix the type of the object with `model:` or `view:` to check, for example, if this is the model's or view's element:

```typescript
modelElement.is( 'model:element' ); // -> true
modelElement.is( 'view:element' ); // -> false
```

By using this method it is also possible to check a name of an element:

```typescript
imageElement.is( 'element', 'imageBlock' ); // -> true
imageElement.is( 'element', 'imageBlock' ); // -> same as above
imageElement.is( 'model:element', 'imageBlock' ); // -> same as above, but more precise
```

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

#### Parameters

* `type: 'node' | 'model:node'`

#### Returns

* `this is ModelNode | ModelText | ModelElement | ModelRootElement`

<a id="function-isAttached">

### `isAttached() → false`

Returns `false` as `ModelDocumentFragment` by definition is not attached to a document. Added for compatibility reasons.

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

#### Returns

* `false`

<a id="function-offsetToIndex">

### `offsetToIndex( offset ) → number`

Converts offset "position" to index "position".

Returns index of a node that occupies given offset. If given offset is too low, returns `0`. If given offset is too high, returns index after last child.

```typescript
const textNode = new Text( 'foo' );
const pElement = new Element( 'p' );
const docFrag = new ModelDocumentFragment( [ textNode, pElement ] );
docFrag.offsetToIndex( -1 ); // Returns 0, because offset is too low.
docFrag.offsetToIndex( 0 ); // Returns 0, because offset 0 is taken by `textNode` which is at index 0.
docFrag.offsetToIndex( 1 ); // Returns 0, because `textNode` has `offsetSize` equal to 3, so it occupies offset 1 too.
docFrag.offsetToIndex( 2 ); // Returns 0.
docFrag.offsetToIndex( 3 ); // Returns 1.
docFrag.offsetToIndex( 4 ); // Returns 2. There are no nodes at offset 4, so last available index is returned.
```

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

#### Parameters

* `offset: number`

  Offset to look for.

#### Returns

* `number`

  Index of a node that occupies given offset.

<a id="function-toJSON">

### `toJSON() → unknown`

Converts `ModelDocumentFragment` instance to plain object and returns it. Takes care of converting all of this document fragment's children.

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

#### Returns

* `unknown`

  `ModelDocumentFragment` instance converted to plain object.

<a id="function-_appendChild">

### `_appendChild( items ) → void` _(internal)_

[Inserts](#function-_insertChild) one or more nodes at the end of this document fragment.

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

#### Parameters

* `items: string | ModelItem | Iterable<( string | ModelItem )>`

  Items to be inserted.

#### Returns

* `void`

<a id="function-_insertChild">

### `_insertChild( index, items ) → void` _(internal)_

Inserts one or more nodes at the given index and sets [parent](module_engine_model_node-ModelNode.md#member-parent) of these nodes to this document fragment.

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

#### Parameters

* `index: number`

  Index at which nodes should be inserted.

* `items: string | ModelItem | Iterable<( string | ModelItem )>`

  Items to be inserted.

#### Returns

* `void`

<a id="function-_removeChildren">

### `_removeChildren( index, howMany ) → Array<ModelNode>` _(internal)_

Removes one or more nodes starting at the given index and sets [parent](module_engine_model_node-ModelNode.md#member-parent) of these nodes to `null`.

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

#### Parameters

* `index: number`

  Index of the first node to remove.

* `howMany: number`

  Number of nodes to remove.

  Defaults to `1`

#### Returns

* `Array<ModelNode>`

  Array containing removed nodes.

<a id="function-_removeChildrenArray">

### `_removeChildrenArray( nodes ) → void` _(internal)_

Removes children nodes provided as an array and sets the [parent](module_engine_model_node-ModelNode.md#member-parent) of these nodes to `null`.

These nodes do not need to be direct siblings.

This method is faster than removing nodes one by one, as it recalculates offsets only once.

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

#### Parameters

* `nodes: Array<ModelNode>`

  Array of nodes.

#### Returns

* `void`

#### Static methods

<a id="static-function-fromJSON">

### `fromJSON( json ) → ModelDocumentFragment` _(static)_

Creates a `ModelDocumentFragment` instance from given plain object (i.e. parsed JSON string). Converts `ModelDocumentFragment` children to proper nodes.

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

#### Parameters

* `json: any`

  Plain object to be converted to `ModelDocumentFragment`.

#### Returns

* `ModelDocumentFragment`

  `ModelDocumentFragment` instance created using given plain object.

---

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