split-and-insert

Type: Operation

Split a node in two, wrap the latter part, and insert it after the selection.

This can be used to split a paragraph into a paragraph and some thing else, wrapping the part of the paragraph after the start of the selection into the other node.

There is no mirrored equivalent of this operation.

Example

Other

"something-insert": {
  "description": "inserts a something.",
  "steps": [
    {
      "type": "transform/setContextNodeIdToSelectionAncestor",
      "data": {"selectionAncestorNodeSpec": "self::someAncestor"}
    },
    {
       "type": "operation/split-and-insert",
       "data": {
         "childNodeStructure": [
           "something",
           [{"multiple": true, "bindTo": "remainder"}]
         ],
         "contextNodeId": "{{contextNodeId}}",
         "splitUntilNodeSpecOrSelector": "self::someParent"
       }
     }
  ]
}

This will perform the following mutation:

Other

<!-- input -->
<someAncestor>
  <someParent>
     A piece of text with the cursor HERE, and more text
  </someParent>
</someAncestor>
<!-- output -->
<someAncestor>
  <someParent>
     A piece of text with the cursor HE
  </someParent>
  <something>
     RE, and more text
  </something>
</someAncestor>

Imported operation data

  1. contextNodeId

    (Required)

    Type: NodeId

    The node to place the cursor in.

  2. childNodeStructure

    (Required)

    A stencil describing the structure to be inserted. The stencil should contain a single optional gap called remainder, indicating the position in the structure where the selected content will be placed. A gap called selection in this stencil can be used to influence the position of the selection after the operation is executed.

  3. model

    (Required)

    Type: Object

    model to be bound to the stencil after insertion.

  4. overrideRange

    (Optional)

    The range to operate on instead of the selectionRange

  5. splitUntilNodeSpecOrSelector

    (Optional)

    Type: XPathTest

    (Optional, either pass this or splitUntilAncestorThatMatchesOneOf) Selector used to find the node until where a split must happen. Must match an ancestor of the context node, or the contextNode itself.

  6. splitUntilAncestorThatMatchesOneOf

    (Optional)

    Type: XPathTest[]

    (Optional, either pass this or splitUntilNodeSpecOrSelector) Selectors used to find the ancestor which must be split. Should be an array of selectors.