Class

SplitOperation (engine/model/operation)

@ckeditor/ckeditor5-engine/src/model/operation/splitoperation

class

Operation to split an element at given split position into two elements, both containing a part of the element's original content.

Filtering

Properties

  • baseVersion : Number

    inherited

    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.

  • batch : Batch | null

    inherited

    Batch to which the operation is added or null if the operation is not added to any batch yet.

  • graveyardPosition : Position | null

    Position in the graveyard root before the element which should be used as a parent of the nodes after position. If it is not set, a copy of the the position parent will be used.

    The default behavior is to clone the split element. Element from graveyard is used during undo.

  • howMany : Number

    Total offset size of elements that are in the split element after position.

  • insertionPosition : Position

    Position at which the clone of split element (or element from graveyard) will be inserted.

  • isDocumentOperation : Boolean

    readonly inherited

    Defines whether operation is executed on attached or detached items.

  • moveTargetPosition : Position

    readonly

    Position inside the new clone of a split element.

    This is a position where nodes that are after the split position will be moved to.

  • movedRange : Range

    readonly

    Artificial range that contains all the nodes from the split element that will be moved to the new element. The range starts at splitPosition and ends in the same parent, at POSITIVE_INFINITY offset.

  • splitPosition : Position

    Position at which an element should be split.

  • type : String

    readonly inherited

    Operation type.

Static properties

  • className : String

    inherited static

    Name of the operation class used for serialization.

Methods

  • constructor( splitPosition, howMany, insertionPosition, graveyardPosition, baseVersion )

    Creates a split operation.

    Parameters

    splitPosition : Position

    Position at which an element should be split.

    howMany : Number

    Total offset size of elements that are in the split element after position.

    insertionPosition : Position

    Position at which the clone of split element (or element from graveyard) will be inserted.

    graveyardPosition : Position | null

    Position in the graveyard root before the element which should be used as a parent of the nodes after position. If it is not set, a copy of the the position parent will be used.

    baseVersion : Number | null

    Document version on which operation can be applied or null if the operation operates on detached (non-document) tree.

  • clone() → SplitOperation

    Creates and returns an operation that has the same parameters as this operation.

    Returns

    SplitOperation

    Clone of this operation.

  • getReversed() → MergeOperation

  • toJSON() → Object

    inherited

    Custom toJSON method to solve child-parent circular dependencies.

    Returns

    Object

    Clone of this object with the operation property replaced with string.

  • _execute()

    protected inherited

    Executes the operation - modifications described by the operation properties will be applied to the model tree.

  • _validate()

    protected inherited

    Checks whether the operation's parameters are correct and the operation can be correctly executed. Throws an error if operation is not valid.

Static methods

  • fromJSON( json, document ) → SplitOperation

    static

    Creates SplitOperation object from deserilized object, i.e. from parsed JSON string.

    Parameters

    json : Object

    Deserialized JSON object.

    document : Document

    Document on which this operation will be applied.

    Returns

    SplitOperation
  • getInsertionPosition( splitPosition ) → Position

    static

    Helper function that returns a default insertion position basing on given splitPosition. The default insertion position is after the split element.

    Parameters

    splitPosition : Position

    Returns

    Position