Skip to content

Type Editor


Type Editor / @type-editor/dom-change-util / parse-change/parse-between / parseBetween

Function: parseBetween()

ts
function parseBetween(view, from_, to_): ParseBetweenResult;

Defined in: parse-change/parse-between.ts:35

Parses a range of DOM content into a ProseMirror document fragment.

This function is the core of DOM change detection. It takes a range of positions in the document, finds the corresponding DOM nodes, parses them into a ProseMirror document, and attempts to reconstruct the selection state. It also applies various browser-specific workarounds during the parsing process.

The parsing process:

  1. Determines the DOM range to parse
  2. Builds position tracking for selection reconstruction
  3. Applies browser-specific adjustments (e.g., Chrome backspace bug)
  4. Parses the DOM into a ProseMirror document
  5. Reconstructs selection from tracked positions

Parameters

ParameterTypeDescription
viewPmEditorViewThe editor view containing the document and DOM
from_numberStart position in the ProseMirror document (absolute position)
to_numberEnd position in the ProseMirror document (absolute position)

Returns

ParseBetweenResult

Parsed document information including the parsed content, selection state, and the actual from/to positions used (which may differ from input)

See

adjustForChromeBackspaceBug for browser-specific adjustments