splitAndInsert

Type: Function

Splits from the selectionRange until the splitUntilNode and inserts the second half of the split, wrapped in the stencil, in the contextNode.

Splitting and inserting takes the following approach:

Input: context node I, split until II, cursor in textnode (child of III)

Other

         I
         |
         II
         |
        III

The following split is made:

Other

        I
        |
        II
       /  \
     III  III'

After the split, the stencil is inserted after the highest ancestor of the selection within the contextNode.

Other

          I
         / \
       II   S
      /  \
   III  III'

The remainder (second half) of the split node is inserted in the gap in the inserted stencil

Other

        I
       / \
     II   S
     /     \
   III    III'

Refer to primitives for more information on how to include this primitive.

Arguments

  1. contextNode

    (Required)

    Type: Node

    The node to insert the structure at

  2. splitUntilSelector

    (Required)

    Type: String

    The node to stop at when splitting

  3. stencilJsonMl

    (Required)

    Type: JsonML

    The stencil to insert in the contextNode

  4. model

    (Optional)

    Type: Model

    The model to apply to the stencil

  5. blueprint

    (Required)

    Type: Blueprint

    The blueprint

  6. format

    (Required)

    Type: Format

    The format

  7. selectionRange

    (Required)

    The selectionRange of the cursor

Returns

Type: Boolean

Whether the split can be validly made. If true, the blueprint represents the state after the split