wrap-selection-or-container-in-structure

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. If the selection is empty, the child of the specified ancestor containing the selection will be wrapped in its entirety.

Example

Other

 "note-insert": {
       "label": "Note",
   "description": "Contains text that is related to the main text.",
   "icon": "sticky-note-o",
       "steps": [
        {
            "type": "operation/note-set-context-node-id-to-valid-parent"
        },
        {
            "type": "operation/wrap-selection-or-container-in-structure",
           "data": {
                   "childNodeStructure": [
                     "note",
                       { "type": "note" },
                       [{ "bindTo": "selection.start", "empty": true }],
                       [{ "bindTo": "transclude", "multiple": true, "required": false }],
                       [{ "bindTo": "selection.end", "empty": true }]
                 ],
                   "contextNodeId": "{{contextNodeId}}"
           }
        }
  ]

Imported operation data

  1. contextNodeId

    (Required)

    Type: NodeId

    The node under which the structure is to be inserted

  2. childNodeStructure

    (Required)

    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

    (Optional)

    Type: Object

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

  4. overrideRange

    (Optional)

    The range to operate on instead of the selectionRange

  5. allowNesting=false

    (Optional)

    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.