@motion-script/core / NodeTextLayout
Interface: NodeTextLayout
Defined in: runtime/text-geometry.ts:23
Where a Text node's caret slots landed on screen — the measurement a host needs to draw its own text cursor and selection over the rendered glyphs.
Space. Viewport space, exactly as NodeBox: origin at the viewport centre, y-up, viewport units, camera folded in. A caret and the selection box around it therefore come out of the same walk and cannot disagree.
Why the host draws it. Anything approximating glyph positions outside the
shaper — a DOM input laid over the canvas, say — drifts from the render the
moment the font, the line height or the wrapping does, and CSS line-height
and Skia's height multiplier are not the same quantity to begin with. Handing
over the real slots means the rendered text stays the thing being edited.
Properties
carets
carets:
TextCaret[]
Defined in: runtime/text-geometry.ts:36
Every caret slot, in offset order: carets[i] sits before character i,
and the last sits after the final character — so there are text.length + 1
of them, and a caret offset is always a valid index.
Each is a segment, not a point, because a rotated node's cursor is a
rotated line: draw from top to bottom.
lines
lines:
object[]
Defined in: runtime/text-geometry.ts:42
Line ranges over caret offsets, for Home/End and vertical arrow keys. A
hard line break belongs to neither line, so lines[n].end and
lines[n + 1].start differ by one where the break is.
end
end:
number
start
start:
number
path
path:
string
Defined in: runtime/text-geometry.ts:25
Structural path of the node measured, as NodeBox.path.
text
text:
string
Defined in: runtime/text-geometry.ts:27
The string the slots describe.