MoveOperation
Operation to move a range of model items to given target position.
Properties
affectedSelectable : ModelSelectablereadonlymodule:engine/model/operation/moveoperation~MoveOperation#affectedSelectableA selectable that will be affected by the operation after it is executed.
The exact returned parameter differs between operation types.
baseVersion : null | numberinheritedmodule:engine/model/operation/moveoperation~MoveOperation#baseVersionversionon 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#batchBatch to which the operation is added or
nullif 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 : numbermodule:engine/model/operation/moveoperation~MoveOperation#howManyOffset size of moved range.
isDocumentOperation : booleanreadonlyinheritedmodule:engine/model/operation/moveoperation~MoveOperation#isDocumentOperationDefines whether operation is executed on attached or detached items.
module:engine/model/operation/moveoperation~MoveOperation#sourcePositionPosition before the first model item to move.
module:engine/model/operation/moveoperation~MoveOperation#targetPositionPosition at which moved nodes will be inserted.
type : 'remove' | 'move' | 'reinsert'readonlymodule:engine/model/operation/moveoperation~MoveOperation#typeOperation type.
Static properties
className : stringreadonlystaticmodule:engine/model/operation/moveoperation~MoveOperation.classNameName of the operation class used for serialization.
Methods
constructor( sourcePosition, howMany, targetPosition, baseVersion )module:engine/model/operation/moveoperation~MoveOperation#constructorCreates a move operation.
Parameters
sourcePosition : ModelPositionPosition before the first model item to move.
howMany : numberOffset size of moved range. Moved range will start from
sourcePositionand end atsourcePositionwith offset shifted byhowMany.targetPosition : ModelPositionPosition at which moved nodes will be inserted.
baseVersion : null | numberDocument
versionon which operation can be applied ornullif the operation operates on detached (non-document) tree.
clone() → MoveOperationmodule:engine/model/operation/moveoperation~MoveOperation#cloneCreates and returns an operation that has the same parameters as this operation.
Returns
module:engine/model/operation/moveoperation~MoveOperation#getMovedRangeStartReturns the start position of the moved range after it got moved. This may be different than
targetPositionin 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 4Copy codeReturns
getReversed() → Operationmodule:engine/model/operation/moveoperation~MoveOperation#getReversedtoJSON() → unknownmodule:engine/model/operation/moveoperation~MoveOperation#toJSONCustom toJSON method to solve child-parent circular dependencies.
Returns
unknownClone of this object with the operation property replaced with string.
_execute() → voidinternalmodule:engine/model/operation/moveoperation~MoveOperation#_executeExecutes the operation - modifications described by the operation properties will be applied to the model tree.
Returns
void
_validate() → voidinternalmodule:engine/model/operation/moveoperation~MoveOperation#_validateChecks 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 ) → MoveOperationstaticmodule:engine/model/operation/moveoperation~MoveOperation.fromJSONCreates
MoveOperationobject from deserialized object, i.e. from parsed JSON string.Parameters
json : anyDeserialized JSON object.
document : ModelDocumentDocument on which this operation will be applied.
Returns