Insertion (engine/model/utils)
@ckeditor/ckeditor5-engine/src/model/utils/insertcontent
Utility class for performing content insertion.
Filtering
Properties
-
canMergeWith : Setmodule:engine/model/utils/insertcontent~Insertion#canMergeWithElements 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 : Modelmodule:engine/model/utils/insertcontent~Insertion#modelThe 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 : Batchmodule:engine/model/utils/insertcontent~Insertion#writerBatch to which operations will be added.
-
private
_affectedEnd : LivePosition | nullmodule:engine/model/utils/insertcontent~Insertion#_affectedEndEnd of the affected range. See
getAffectedRange. -
private
_affectedStart : LivePosition | nullmodule:engine/model/utils/insertcontent~Insertion#_affectedStartBeginning of the affected range. See
getAffectedRange. -
private
_documentFragment : DocumentFragmentmodule:engine/model/utils/insertcontent~Insertion#_documentFragmentThe temporary DocumentFragment used for grouping multiple nodes for single insert operation.
-
private
_documentFragmentPosition : Positionmodule:engine/model/utils/insertcontent~Insertion#_documentFragmentPositionThe current position in the temporary DocumentFragment.
-
private
_filterAttributesOf : Array.<Node>module:engine/model/utils/insertcontent~Insertion#_filterAttributesOfThe array of nodes that should be cleaned of not allowed attributes.
-
The reference to the first inserted node.
-
private
_lastAutoParagraph : Nodemodule:engine/model/utils/insertcontent~Insertion#_lastAutoParagraphThe reference to the last auto paragraph node.
-
The reference to the last inserted node.
Methods
-
destroy()module:engine/model/utils/insertcontent~Insertion#destroyDestroys
Insertioninstance. -
getAffectedRange() → Range | nullmodule:engine/model/utils/insertcontent~Insertion#getAffectedRangeReturns 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
nullif no changes were done.Returns
Range | null
-
getSelectionRange() → Range | nullmodule:engine/model/utils/insertcontent~Insertion#getSelectionRangeReturns range to be selected after insertion. Returns
nullif there is no valid range to select after insertion.Returns
Range | null
-
handleNodes( nodes )module:engine/model/utils/insertcontent~Insertion#handleNodes -
private
_appendToFragment( node )module:engine/model/utils/insertcontent~Insertion#_appendToFragment -
private
_canMergeLeft( node ) → Booleanmodule:engine/model/utils/insertcontent~Insertion#_canMergeLeftChecks whether specified node can be merged with previous sibling element.
Parameters
node : NodeThe node which could potentially be merged.
Returns
Boolean
-
private
_canMergeRight( node ) → Booleanmodule:engine/model/utils/insertcontent~Insertion#_canMergeRightChecks whether specified node can be merged with next sibling element.
Parameters
node : NodeThe node which could potentially be merged.
Returns
Boolean
-
private
_checkAndAutoParagraphToAllowedPosition( node ) → Booleanmodule:engine/model/utils/insertcontent~Insertion#_checkAndAutoParagraphToAllowedPositionChecks 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 : NodeThe node.
Returns
BooleanWhether an allowed position was found.
falseis returned if the node isn't allowed at the current position or in auto paragraph,trueif was.
-
private
_checkAndSplitToAllowedPosition( node ) → Booleanmodule:engine/model/utils/insertcontent~Insertion#_checkAndSplitToAllowedPositionParameters
node : Node
Returns
BooleanWhether an allowed position was found.
falseis returned if the node isn't allowed at any position up in the tree,trueif was.
-
private
_getAllowedIn( contextElement, childNode ) → Element | nullmodule:engine/model/utils/insertcontent~Insertion#_getAllowedIn -
private
_handleDisallowedNode( node )module:engine/model/utils/insertcontent~Insertion#_handleDisallowedNode -
-
-
private
_insertPartialFragment()module:engine/model/utils/insertcontent~Insertion#_insertPartialFragmentInserts the temporary DocumentFragment into the model.
-
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.
-
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.
-
private
_setAffectedBoundaries( position )module:engine/model/utils/insertcontent~Insertion#_setAffectedBoundariesSets
_affectedStartand_affectedEndto 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.
_affectedStartand_affectedEndare also changed during merging, but the logic there is more complicated so it is left out of this function.Parameters
position : Position
-
private
_tryAutoparagraphing( node )module:engine/model/utils/insertcontent~Insertion#_tryAutoparagraphingTries wrapping the node in a new paragraph and inserting it this way.
Parameters
node : NodeThe node which needs to be autoparagraphed.
-
private
_updateLastNodeFromAutoParagraph( node )module:engine/model/utils/insertcontent~Insertion#_updateLastNodeFromAutoParagraphUpdates the last node after the auto paragraphing.
Parameters
node : NodeThe last auto paragraphing node.
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.