import { type RefObject, useCallback } from "react"; /** A `[start, end)` character range into a step's original `description` string — same convention as `StepTechStepView.start`/`end`. */ export interface TextSelectionRange { start: number; end: number; } /** * Reads the browser's current text selection, translated into a * {@link TextSelectionRange} into a step's original `description` string — * the shape `POST /recipes/:id/steps/:stepId/corrections` expects (see * `SubmitTechStepCorrectionInput`, `packages/shared`). * * Works by walking up from each end of the selection's `Range` to the * nearest ancestor carrying a `data-offset` attribute — set by * `StepDescription`'s editable mode on every {@link DescriptionSegment}'s * own wrapping element (``/`