Type: Operation

Replace the selected content with the specified structure.

Replaces the selected content with the specified structure, inserted under the specified ancestor of the selection. The selected content will be inserted at the specified location within the structure to be inserted, effectively 'wrapping' it in the structure.

#tip When the selection is empty, the behavior of this operation will be similar to vertical-insert (albeit with a pre-determined parent node), causing the structure to simply be inserted at the current cursor position. Users will often expect the entire containing child of the passed contextNode (usually a paragraph, or similar) to be 'converted' (wrapped inside) to the specified structure instead. We therefore recommend to use wrap-selection-or-container-in-structure instead, which handles this case in the expected way.

Imported operation data

  1. contextNodeId


    Type: NodeId

    The node under which the structure is to be inserted

  2. childNodeStructure


    A stencil describing the structure to be inserted. The stencil should contain a single optional multi-node gap called transclude, indicating the position in the structure where the selected content will be placed.

  3. model


    Type: Object

    (Optional) model to be bound to the stencil after insertion

  4. overrideRange


    The range to operate on instead of the selectionRange

  5. allowNesting=false


    Type: Boolean

    By default, this operation is disabled if it would create a nested structure (if an ancestor of the context node or the context node matches the childNodeStructure stencil). Set this parameter to true to allow nesting.