@mocanvas/mocanvas · class

TextShapeUtil

declare class TextShapeUtil extends ShapeUtil<TextShape, TextShapeUtilDisplayValues>

This one ships without a description. The signature above is read from the package, and the guides cover the area it belongs to.


Methods · 14

canEdit(_shape: TextShape): boolean
component(shape: TextShape): ReactNode
getDefaultProps(): TextShapeProps
getFontFaces(shape: TextShape): TLFontFace[]

A text shape is nothing but a label, so it always needs its family's faces.

getGeometry(shape: TextShape): Geometry2d
getIndicatorPath(shape: TextShape): Path2D
getRenderStyle(shape: TextShape): StyleWords | null

A texture of the rasterized label, so the GPU draws the text instead of the DOM. The shape being edited (and any environment without a canvas) keeps the DOM path; fill is the text colour so the level-of-detail quad the engine draws below a few pixels still looks right.

getText(shape: TextShape): string
isAspectRatioLocked(_shape: TextShape): boolean
needsOverlay(shape: TextShape): boolean

The DOM label stands in while editing and until the texture is ready.

onBeforeCreate(next: TextShape): TextShape | void

Auto-sized text keeps w in sync with its measured width.

onBeforeUpdate(prev: TextShape, next: TextShape): TextShape | void
onEditEnd(shape: TextShape): void

A text shape left empty after editing is removed.

onResize(shape: TextShape, info: ResizeInfo<TextShape>): Partial<TextShape>

Resizing a text shape changes its wrap width and turns auto-size off.


Properties · 5

static migrations: _mocanvas_editor.PropsMigrations
static options: TextShapeOptions
readonly options: TextShapeOptions
static props: _mocanvas_editor.RecordProps<TextShape>
static type: "text"

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.