Insertion (engine/model/utils)
@ckeditor/ckeditor5-engine/src/model/utils/insertcontent
Utility class for performing content insertion.
Filtering
Properties
-
canMergeWith : Set
module:engine/model/utils/insertcontent~Insertion#canMergeWith
Elements with which the inserted elements can be merged.
<p>x^</p><p>y</p> + <p>z</p> (can merge to <p>x</p>) <p>x</p><p>^y</p> + <p>z</p> (can merge to <p>y</p>) <p>x^y</p> + <p>z</p> (can merge to <p>xy</p> which will be split during the action, so both its pieces will be added to this set)
-
model : Model
module:engine/model/utils/insertcontent~Insertion#model
The model in context of which the insertion should be performed.
-
The position at which (or near which) the next node will be inserted.
-
Schema of the model.
-
writer : Batch
module:engine/model/utils/insertcontent~Insertion#writer
Batch to which operations will be added.
-
_affectedEnd : LivePosition | null
module:engine/model/utils/insertcontent~Insertion#_affectedEnd
private
End of the affected range. See
getAffectedRange
. -
_affectedStart : LivePosition | null
module:engine/model/utils/insertcontent~Insertion#_affectedStart
private
Beginning of the affected range. See
getAffectedRange
. -
_documentFragment : DocumentFragment
module:engine/model/utils/insertcontent~Insertion#_documentFragment
private
The temporary DocumentFragment used for grouping multiple nodes for single insert operation.
-
_documentFragmentPosition : Position
module:engine/model/utils/insertcontent~Insertion#_documentFragmentPosition
private
The current position in the temporary DocumentFragment.
-
_filterAttributesOf : Array.<Node>
module:engine/model/utils/insertcontent~Insertion#_filterAttributesOf
private
The array of nodes that should be cleaned of not allowed attributes.
-
_firstNode : Node
module:engine/model/utils/insertcontent~Insertion#_firstNode
private
The reference to the first inserted node.
-
_lastAutoParagraph : Node
module:engine/model/utils/insertcontent~Insertion#_lastAutoParagraph
private
The reference to the last auto paragraph node.
-
The reference to the last inserted node.
Methods
-
destroy()
module:engine/model/utils/insertcontent~Insertion#destroy
Destroys
Insertion
instance. -
getAffectedRange() → Range | null
module:engine/model/utils/insertcontent~Insertion#getAffectedRange
Returns a range which contains all the performed changes. This is a range that, if removed, would return the model to the state before the insertion. Returns
null
if no changes were done.Returns
Range | null
-
getSelectionRange() → Range | null
module:engine/model/utils/insertcontent~Insertion#getSelectionRange
Returns range to be selected after insertion. Returns
null
if there is no valid range to select after insertion.Returns
Range | null
-
handleNodes( nodes )
module:engine/model/utils/insertcontent~Insertion#handleNodes
Handles insertion of a set of nodes.
Parameters
nodes : Iterable.<Node>
Nodes to insert.
-
_appendToFragment( node )
module:engine/model/utils/insertcontent~Insertion#_appendToFragment
private
Append a node to the temporary DocumentFragment.
Parameters
node : Node
The node to insert.
-
_canMergeLeft( node ) → Boolean
module:engine/model/utils/insertcontent~Insertion#_canMergeLeft
private
Checks whether specified node can be merged with previous sibling element.
-
_canMergeRight( node ) → Boolean
module:engine/model/utils/insertcontent~Insertion#_canMergeRight
private
Checks whether specified node can be merged with next sibling element.
-
_checkAndAutoParagraphToAllowedPosition( node ) → Boolean
module:engine/model/utils/insertcontent~Insertion#_checkAndAutoParagraphToAllowedPosition
private
Checks if a node can be inserted in the given position or it would be accepted if a paragraph would be inserted. It also handles inserting the paragraph.
Parameters
node : Node
The node.
Returns
Boolean
Whether an allowed position was found.
false
is returned if the node isn't allowed at the current position or in auto paragraph,true
if was.
-
_checkAndSplitToAllowedPosition( node ) → Boolean
module:engine/model/utils/insertcontent~Insertion#_checkAndSplitToAllowedPosition
private
Parameters
node : Node
Returns
Boolean
Whether an allowed position was found.
false
is returned if the node isn't allowed at any position up in the tree,true
if was.
-
_getAllowedIn( contextElement, childNode ) → Element | null
module:engine/model/utils/insertcontent~Insertion#_getAllowedIn
private
Gets the element in which the given node is allowed. It checks the passed element and all its ancestors.
-
_handleDisallowedNode( node )
module:engine/model/utils/insertcontent~Insertion#_handleDisallowedNode
private
Parameters
node : Node
The disallowed node which needs to be handled.
-
_handleNode( node )
module:engine/model/utils/insertcontent~Insertion#_handleNode
private
Handles insertion of a single node.
Parameters
node : Node
-
_handleObject( node )
module:engine/model/utils/insertcontent~Insertion#_handleObject
private
Parameters
node : Element
The object element.
-
_insertPartialFragment()
module:engine/model/utils/insertcontent~Insertion#_insertPartialFragment
private
Inserts the temporary DocumentFragment into the model.
-
_mergeOnLeft()
module:engine/model/utils/insertcontent~Insertion#_mergeOnLeft
private
Merges the previous sibling of the first node if it should be merged.
After the content was inserted we may try to merge it with its siblings. This should happen only if the selection was in those elements initially.
-
_mergeOnRight()
module:engine/model/utils/insertcontent~Insertion#_mergeOnRight
private
Merges the next sibling of the last node if it should be merged.
After the content was inserted we may try to merge it with its siblings. This should happen only if the selection was in those elements initially.
-
_setAffectedBoundaries( position )
module:engine/model/utils/insertcontent~Insertion#_setAffectedBoundaries
private
Sets
_affectedStart
and_affectedEnd
to the givenposition
. Should be used before a change is done during insertion process to mark the affected range.This method is used before inserting a node or splitting a parent node.
_affectedStart
and_affectedEnd
are also changed during merging, but the logic there is more complicated so it is left out of this function.Parameters
position : Position
-
_tryAutoparagraphing( node )
module:engine/model/utils/insertcontent~Insertion#_tryAutoparagraphing
private
Tries wrapping the node in a new paragraph and inserting it this way.
Parameters
node : Node
The node which needs to be autoparagraphed.
-
_updateLastNodeFromAutoParagraph( node )
module:engine/model/utils/insertcontent~Insertion#_updateLastNodeFromAutoParagraph
private
Updates the last node after the auto paragraphing.
Parameters
node : Node
The last auto paragraphing node.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.