SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Function composeCaretRect

    • Compose the viewport-space caret rect from the three measured boxes — the pure core of the caret geometry, split out so it can be unit-tested without a layout engine (jsdom does no layout).

      The caret's offset within the content is marker.left/top − mirror.left/top: because the mirror copies the textarea's border + padding, that delta measured from the mirror's border-box corner equals the same offset from the textarea's border-box corner. Add the textarea's viewport position and subtract its scroll to land on the on-screen caret.

      Parameters

      • p: {
            markerRect: { height: number; left: number; top: number };
            mirrorRect: { left: number; top: number };
            scrollLeft: number;
            scrollTop: number;
            textareaRect: { left: number; top: number };
        }
        • markerRect: { height: number; left: number; top: number }

          The caret marker span's box: origin (viewport space) + its line-box height (the caret height).

        • mirrorRect: { left: number; top: number }

          The mirror's border-box origin, viewport space.

        • scrollLeft: number

          textarea.scrollLeft — the caret shifts left as the field scrolls right.

        • scrollTop: number

          textarea.scrollTop.

        • textareaRect: { left: number; top: number }

          The textarea's border-box origin, viewport space (textarea.getBoundingClientRect()).

      Returns CaretRect