platform-bible-react
    Preparing search index...

    Function getCaretPositionFromClick

    • Map a mouse click on a read-only footnote row to a caret position in the footnote's text, so an editor swapped into the row can place its caret where the user clicked (PT9-parity caret-where-you-clicked). Uses the browser caret APIs; positions land only at valid caret boundaries, so graphemes are never split.

      A click on a marker lands inside that marker, which the note editor renders as editable text; a click on the note's own marker or caller (the row's header cell) lands right after the caller, the first place in the note the user can type.

      Parameters

      • clientX: number

        Viewport X of the click (from the mouse event).

      • clientY: number

        Viewport Y of the click.

      • rowElement: HTMLElement

        The row's root element; the position is computed over the text of its .textual-note-body descendant (see RowTextKind in this module for what each piece of that text counts as).

      Returns FootnoteCaretPosition

      The position (see FootnoteCaretPosition), or 'end' when the click cannot be mapped (no browser support, click outside the row's text).