Skip to content

Type Editor


Type Editor / @type-editor/dom-change-util / parse-change/resolve-selection / resolveSelection

Function: resolveSelection()

ts
function resolveSelection(view, doc, parsedSel): PmSelection;

Defined in: parse-change/resolve-selection.ts:24

Resolves a selection from parsed anchor/head positions.

This function converts numeric positions from the parsed document into a proper ProseMirror Selection object. It performs validation and uses the selectionBetween helper to create the appropriate selection type (TextSelection, NodeSelection, etc.).

The function returns null if the positions are invalid (outside document bounds). This can happen if the selection was in a part of the document that wasn't parsed or if parsing failed to find the positions.

Parameters

ParameterTypeDescription
viewPmEditorViewThe editor view, used for creating the selection via selectionBetween
docNode_2The document to resolve positions in (typically the transaction's document)
parsedSel{ anchor: number; head: number; }Parsed selection with anchor and head positions (numeric offsets)
parsedSel.anchornumber-
parsedSel.headnumber-

Returns

PmSelection

A resolved Selection object, or null if the positions are out of bounds

See

selectionBetween for selection creation logic