Rich text / foldkit-richtext-dom

rangeToPosition

function · packages/richtext-dom/src/index.ts:558

function rangeToPosition(
  dom: EditorDom,
  container: Node,
  containerOffset: number,
): RichText.Position | undefined

Maps a browser selection endpoint back to a semantic position: a caret in a run's text, or on an element inside the owned subtree (read as the text boundary it stands at). Anything outside the subtree, the page around the editor or another editor's runs, has no position here and returns undefined.