Skip to content

Type Editor


Type Editor / @type-editor/commands / toggle-wrap-in / toggleWrapIn

Function: toggleWrapIn()

ts
function toggleWrapIn(nodeType, attrs?, allowUnwrap?): Command;

Defined in: toggle-wrap-in.ts:20

Creates a command that toggles wrapping of the selected content in the given node type.

If the selection is already inside a node of the specified type and allowUnwrap is true, the command will lift (unwrap) the content. Otherwise, it will wrap the selected block range in a node of the given type.

Parameters

ParameterTypeDefault valueDescription
nodeTypeNodeTypeundefinedThe node type to wrap the selection in (e.g., blockquote, list).
attrsReadonly<Record<string, any>>nullOptional attributes to apply to the wrapping node.
allowUnwrapbooleantrueWhether to allow unwrapping when already inside the node type. Defaults to true.

Returns

Command

A command that toggles the wrapping and returns true if the command was applicable.