import { Dom } from '../../dom'; /** * Where one client's caret sits, in the only coordinate system this document * format can express. * * Text is stored as plain strings in Y.Maps (no Y.Text), so there are no * relative positions to anchor against — a caret is a plain character offset, * and it goes stale if the block's text changes underneath it. That is * deliberate and bounded: presence is ephemeral awareness data, never part of * the document, and concurrent editing of the SAME block already resolves * last-write-wins on the whole string. A caret briefly landing a few characters * off is strictly less surprising than the text loss that case already has. * * `inputIndex` indexes the block's own `inputs`, because one block can own * several editable fields (a table's cells, a caption beside a figure) and an * offset means nothing without saying which one it counts into. */ export interface CaretPosition { blockId: string; inputIndex: number; /** Where the selection started. Equal to `head` when the caret is collapsed. */ anchor: number; /** Where the caret actually is — the end a user is moving. */ head: number; } /** * Can a peer draw a caret inside this input? * * A native ``/`