Skip to content

API reference / Common / Engine types / TextPosition

Interface: TextPosition ​

A position in a page's text: a codepoint offset into show op run of the text object object.

A model coordinate, not a layout one — run counts the object's show ops in stream order (regular_runs) and offset the codepoints of that op's Unicode realization. That makes a stored position read the same on every peer (they realize the same bytes). The layout maps it to a caret / highlight rect (a ligature code is one glyph but several codepoints, so the geometry snaps to the nearest glyph edge while the offset stays codepoint-exact), and its derived blocks give two positions their reading order.

The offset is a plain codepoint count (Unicode scalar values — one per char), the same unit Loro edits in; it is never a UTF-8 byte index.

Properties ​

PropertyDescription
object
string
The text object.
run
number
The show op, by its index among the object's show ops in stream order.
offset
number
Codepoint offset within that show op.