> For the complete documentation index, see [llms.txt](/llms.txt).
> The full corpus is at [llms-full.txt](/llms-full.txt).

# getFragment

> `const` **getFragment**: `EditorSelector`\<`object`[]\>

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

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

Starts from [getSelectedValue](/api/selectors/variables/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.

A selection whose endpoints terminate at the root level (collapsed at
a root-level node, or expanded across root siblings without descending
into them) is treated as the user pointing AT the named node(s) rather
than INTO them; the envelope is returned as-is and the unwrap walk is
skipped. This is how a chrome drag carries the container itself rather
than its unwrapped content.

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.