Skip to content

vyaz-monorepo / core/src / TextFrame

Interface: TextFrame ​

Defined in: core/src/types/Document.ts:694

Root text container — a text box on a canvas.

This replaces the earlier RichTextDocument. It holds geometry, text flow settings, and the paragraph array.

Wrap & Autofit interaction:

  • When wrap is true, the layout engine breaks lines at width.
  • When autofit.enabled is true, the engine shrinks the font proportionally to fit the text inside width × height.

Example ​

ts
{
  width: 600,
  height: 400,
  wrap: true,
  autofit: { enabled: true, minFontSize: 10, maxFontSize: 24 },
  writingMode: "horizontal-tb",
  verticalAlignment: "top",
  paragraphs: [ /* ... */ ]
}

Properties ​

autofit? ​

optional autofit?: AutofitConfig

Defined in: core/src/types/Document.ts:716

Autofit (auto font-size reduction) configuration.


columns? ​

optional columns?: MultiColumnConfig

Defined in: core/src/types/Document.ts:777

Experimental

Multi-column layout configuration. When set, paragraphs are automatically broken into columns. Accepted in the type but ignored by the layout engine (no-op until implemented).


defaultStyle? ​

optional defaultStyle?: Partial<Omit<TextRun, "type" | "text" | "inlineWidget">>

Defined in: core/src/types/Document.ts:784

Default style inherited by all TextRun children. Any field omitted in a TextRun will fall back to this value.


direction? ​

optional direction?: "ltr" | "rtl"

Defined in: core/src/types/Document.ts:745

Base text direction (important for bidi). 'ltr' = left-to-right, 'rtl' = right-to-left.


dominantBaseline? ​

optional dominantBaseline?: DominantBaseline

Defined in: core/src/types/Document.ts:752

Experimental

Dominant baseline for inline alignment. Accepted in the type but ignored by the layout engine (no-op until implemented).


height? ​

optional height?: number

Defined in: core/src/types/Document.ts:708

Container height in px.

When set — may clip content or trigger autofit. When undefined — auto (content determines height, contentHeight from the layout result).


lineFitEdge? ​

optional lineFitEdge?: LineFitEdge

Defined in: core/src/types/Document.ts:757

Experimental

Font metric edge used for line box height. Accepted in the type but ignored by the layout engine (no-op until implemented).


padding? ​

optional padding?: object

Defined in: core/src/types/Document.ts:762

Inner padding of the frame. Text layout starts at x + padding.left, y + padding.top.

bottom ​

bottom: number

Bottom padding in px.

left ​

left: number

Left padding in px.

right: number

Right padding in px.

top ​

top: number

Top padding in px.


paragraphs ​

paragraphs: Paragraph[]

Defined in: core/src/types/Document.ts:779

Paragraphs forming the text content.


rotation? ​

optional rotation?: number

Defined in: core/src/types/Document.ts:740

Rigid clockwise rotation of the whole text block, in degrees, applied after layout as an affine transform about the frame-box centre. This does not affect line breaking, measurement or positioning — only the final render transform. Mirrors PowerPoint's shape rotation (<a:xfrm rot>).

Composes with writingMode: 'sideways-*' (which contributes its own ±90°). 0, 90, 180, 270 are the exercised values; other angles are accepted and rotate about the centre without expanding the canvas bounding box.

The engine folds this together with the writing-mode rotation and reports the result on TextFrameLayoutResult.transform.


textOrientation? ​

optional textOrientation?: TextOrientation

Defined in: core/src/types/Document.ts:726

Character orientation in vertical mode. Ignored when writingMode === 'horizontal-tb'.


verticalAlignment? ​

optional verticalAlignment?: VerticalAlignment

Defined in: core/src/types/Document.ts:747

Vertical alignment of the content block inside the frame.


width? ​

optional width?: number

Defined in: core/src/types/Document.ts:701

Container width in px.

When set — text wraps by this width (if wrap=true). Used as the inline-size for horizontal-tb writing mode. When undefined — auto (fit-content).


wrap ​

wrap: boolean

Defined in: core/src/types/Document.ts:714

Whether line wrapping is enabled. true = lines break when they exceed width (or height in vertical mode). false = text overflows (may be clipped or trigger autofit).


writingMode? ​

optional writingMode?: WritingMode

Defined in: core/src/types/Document.ts:721

Writing mode (block flow direction). Defaults to 'horizontal-tb' when absent.

Released under the MIT License.