wrap-selection-in-structure

How to get wrap-selection-in-structure

Depend on fontoxml-base-flow to make this operation available.

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

Name Type Description
contextNodeId NodeId

The node under which the structure is to be inserted

childNodeStructure StencilJsonML

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.

[model] Object

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

[overrideRange] OverrideRange

The range to operate on instead of the selectionRange

[allowNesting=false] 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.