Skip to content

getFragment

const getFragment: EditorSelector<object[]>

Defined in: selector.get-fragment.ts:30

Returns the smallest top-level-valid fragment of the editor’s value that covers the current selection.

Starts from getSelectedValue’s envelope and unwraps it toward the selection’s lowest common ancestor, stopping at the deepest level whose siblings are all root-accepted types. Intermediate single-child containers (a single row inside a table, a single cell inside a row) are walked through to look for a deeper unwrap target; an intermediate level with multiple siblings (the lowest common ancestor across two cells in one row) ends the walk and the last root-valid wrapping is returned.

Backs every registered clipboard converter, editor.getFragment() (which projects to blocks only), and the drag preview pipeline (which uses the paths to find DOM nodes). Exposed for custom converters and any consumer that needs the clipboard-shaped view of the current selection without redundant ancestor envelopes.