Insertion (engine/model/utils)
@ckeditor/ckeditor5-engine/src/model/utils/insertcontent
Utility class for performing content insertion.
Filtering
Properties
-
canMergeWith : Set
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
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
Batch to which operations will be added.
Methods
-
getSelectionRange() → Range | null
Returns range to be selected after insertion. Returns null if there is no valid range to select after insertion.
Returns
Range | null
-
handleNodes( nodes, parentContext )
Handles insertion of a set of nodes.
Parameters
nodes : Iterable.<Node>
Nodes to insert.
parentContext : Object
Context in which parent of these nodes was supposed to be inserted. If the parent context is passed it means that the parent element was stripped (was not allowed).
-
_canMergeLeft( node, context ) → Boolean
private
Checks whether specified node can be merged with previous sibling element.
-
_canMergeRight( node, context ) → Boolean
private
Checks whether specified node can be merged with next sibling element.
-
_checkAndSplitToAllowedPosition( node ) → Boolean
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( node, element ) → Element | null
private
-
_handleDisallowedNode( node, context )
private
Parameters
node : Node
The disallowed node which needs to be handled.
context : Object
-
_handleNode( node, context = { context.isFirst, context.isLast } )
private
Handles insertion of a single node.
Parameters
node : Node
context : Object
-
Properties
context.isFirst : Boolean
Whether the given node is the first one in the content to be inserted.
context.isLast : Boolean
Whether the given node is the last one in the content to be inserted.
-
_handleObject( node, context )
private
Parameters
node : Element
The object element.
context : Object
-
_insert( node )
private
Parameters
node : Node
The node to insert.
-
_mergeSiblingsOf( node, context )
private
Parameters
node : Node
The node which could potentially be merged.
context : Object
-
_tryAutoparagraphing( node, context )
private
Tries wrapping the node in a new paragraph and inserting it this way.
Parameters
node : Node
The node which needs to be autoparagraphed.
context : Object