Structural transform operations: lift, wrap, split, join, and related utility functions.
Ports structure.ts from prosemirror-transform.
Summary
Functions
Test whether the blocks before and after a given position can be joined.
Check whether splitting at the given position is allowed.
Finds a position at or around the given position where the given slice can be inserted. Will look at parent nodes' nearest boundary. Returns nil when no position was found.
Try to find a valid way to wrap the content in the given range in a node of the given type. May introduce extra nodes around and inside the wrapper node. Returns nil if no valid wrapping could be found.
Try to find a point where a node of the given type can be inserted
near pos, by searching up the node hierarchy when pos itself
isn't a valid place but is at the start or end of a node.
Returns nil if no position was found.
Join the blocks around the given position.
Find an ancestor of the given position that can be joined to the
block before (or after if dir is positive). Returns the joinable
point, or nil.
Lift the content in the given range out of its parent to the given target depth.
Try to find a target depth to which the content in the given range can be lifted. Will not go across isolating parent nodes. Returns an integer depth or nil.
Set the type of all textblocks (partly) between from and to to the
given node type with the given attributes.
Change the type, attributes, and/or marks of the node at pos.
When type is nil, the existing node type is preserved.
Split the node at the given position, creating new sibling nodes.
Wrap the content in the given range in the given wrapper nodes.
Functions
Test whether the blocks before and after a given position can be joined.
Check whether splitting at the given position is allowed.
Finds a position at or around the given position where the given slice can be inserted. Will look at parent nodes' nearest boundary. Returns nil when no position was found.
Try to find a valid way to wrap the content in the given range in a node of the given type. May introduce extra nodes around and inside the wrapper node. Returns nil if no valid wrapping could be found.
Try to find a point where a node of the given type can be inserted
near pos, by searching up the node hierarchy when pos itself
isn't a valid place but is at the start or end of a node.
Returns nil if no position was found.
Join the blocks around the given position.
Find an ancestor of the given position that can be joined to the
block before (or after if dir is positive). Returns the joinable
point, or nil.
Lift the content in the given range out of its parent to the given target depth.
Try to find a target depth to which the content in the given range can be lifted. Will not go across isolating parent nodes. Returns an integer depth or nil.
Set the type of all textblocks (partly) between from and to to the
given node type with the given attributes.
Change the type, attributes, and/or marks of the node at pos.
When type is nil, the existing node type is preserved.
Split the node at the given position, creating new sibling nodes.
Wrap the content in the given range in the given wrapper nodes.