MoveOperation
Operation to move a range of model items to given target position.
Properties
-
affectedSelectable : ModelSelectable
readonlymodule:engine/model/operation/moveoperation~MoveOperation#affectedSelectable
A selectable that will be affected by the operation after it is executed.
The exact returned parameter differs between operation types.
-
baseVersion : null | number
inheritedmodule:engine/model/operation/moveoperation~MoveOperation#baseVersion
version
on which operation can be applied. If you try to apply operation with different base version than the document version the model-document-applyOperation-wrong-version error is thrown. -
module:engine/model/operation/moveoperation~MoveOperation#batch
Batch to which the operation is added or
null
if the operation is not added to any batch yet.Note, that a non-document operation has this property always set to
null
, and is never added to any batch. -
howMany : number
module:engine/model/operation/moveoperation~MoveOperation#howMany
Offset size of moved range.
-
isDocumentOperation : boolean
readonlyinheritedmodule:engine/model/operation/moveoperation~MoveOperation#isDocumentOperation
Defines whether operation is executed on attached or detached items.
-
module:engine/model/operation/moveoperation~MoveOperation#sourcePosition
Position before the first model item to move.
-
module:engine/model/operation/moveoperation~MoveOperation#targetPosition
Position at which moved nodes will be inserted.
-
type : 'remove' | 'move' | 'reinsert'
readonlymodule:engine/model/operation/moveoperation~MoveOperation#type
Operation type.
Static properties
-
className : string
readonlystaticmodule:engine/model/operation/moveoperation~MoveOperation.className
Name of the operation class used for serialization.
Methods
-
constructor( sourcePosition, howMany, targetPosition, baseVersion )
module:engine/model/operation/moveoperation~MoveOperation#constructor
Creates a move operation.
Parameters
sourcePosition : ModelPosition
Position before the first model item to move.
howMany : number
Offset size of moved range. Moved range will start from
sourcePosition
and end atsourcePosition
with offset shifted byhowMany
.targetPosition : ModelPosition
Position at which moved nodes will be inserted.
baseVersion : null | number
Document
version
on which operation can be applied ornull
if the operation operates on detached (non-document) tree.
-
clone() → MoveOperation
module:engine/model/operation/moveoperation~MoveOperation#clone
Creates and returns an operation that has the same parameters as this operation.
Returns
-
module:engine/model/operation/moveoperation~MoveOperation#getMovedRangeStart
Returns the start position of the moved range after it got moved. This may be different than
targetPosition
in some cases, i.e. when a range is moved inside the same parent but targetPosition is after sourcePosition.vv vv abcdefg ===> adefbcg ^ ^ targetPos movedRangeStart offset 6 offset 4
Returns
-
getReversed() → Operation
module:engine/model/operation/moveoperation~MoveOperation#getReversed
-
toJSON() → unknown
module:engine/model/operation/moveoperation~MoveOperation#toJSON
Custom toJSON method to solve child-parent circular dependencies.
Returns
unknown
Clone of this object with the operation property replaced with string.
-
_execute() → void
internalmodule:engine/model/operation/moveoperation~MoveOperation#_execute
Executes the operation - modifications described by the operation properties will be applied to the model tree.
Returns
void
-
_validate() → void
internalmodule:engine/model/operation/moveoperation~MoveOperation#_validate
Checks whether the operation's parameters are correct and the operation can be correctly executed. Throws an error if operation is not valid.
Returns
void
Static methods
-
fromJSON( json, document ) → MoveOperation
staticmodule:engine/model/operation/moveoperation~MoveOperation.fromJSON
Creates
MoveOperation
object from deserialized object, i.e. from parsed JSON string.Parameters
json : any
Deserialized JSON object.
document : ModelDocument
Document on which this operation will be applied.
Returns