Table of contents

Public class

Signature
class TextShapeUtil extends ShapeUtil<TLTextShape> {}
References

ShapeUtil, TLTextShape

Source

packages/tldraw/src/lib/shapes/text/TextShapeUtil.tsx


Properties

canEdit

Public property

Signature
canEdit: () => boolean

isAspectRatioLocked

Public property

Signature
isAspectRatioLocked: TLShapeUtilFlag<TLTextShape>
References

TLShapeUtilFlag, TLTextShape


migrations

Public static property

Signature
static migrations: import('@tldraw/editor').Migrations
References

Migrations


onBeforeCreate

Public property

Signature
onBeforeCreate: (shape: TLTextShape) =>
  | {
      x: number
      y: number
      type: 'text'
      rotation: number
      index: string
      parentId: import('@tldraw/editor').TLParentId
      isLocked: boolean
      opacity: number
      props: {
        color:
          | 'black'
          | 'blue'
          | 'green'
          | 'grey'
          | 'light-blue'
          | 'light-green'
          | 'light-red'
          | 'light-violet'
          | 'orange'
          | 'red'
          | 'violet'
          | 'yellow'
        size: 'l' | 'm' | 's' | 'xl'
        font: 'draw' | 'mono' | 'sans' | 'serif'
        align:
          | 'end-legacy'
          | 'end'
          | 'middle-legacy'
          | 'middle'
          | 'start-legacy'
          | 'start'
        w: number
        text: string
        scale: number
        autoSize: boolean
      }
      meta: import('@tldraw/editor').JsonObject
      id: import('@tldraw/editor').TLShapeId
      typeName: 'shape'
    }
  | undefined
References

TLTextShape, TLParentId, TLShapeId


onBeforeUpdate

Public property

Signature
onBeforeUpdate: (
  prev: TLTextShape,
  next: TLTextShape
) =>
  | {
      x: number
      y: number
      props: {
        w: number
        color:
          | 'black'
          | 'blue'
          | 'green'
          | 'grey'
          | 'light-blue'
          | 'light-green'
          | 'light-red'
          | 'light-violet'
          | 'orange'
          | 'red'
          | 'violet'
          | 'yellow'
        size: 'l' | 'm' | 's' | 'xl'
        font: 'draw' | 'mono' | 'sans' | 'serif'
        align:
          | 'end-legacy'
          | 'end'
          | 'middle-legacy'
          | 'middle'
          | 'start-legacy'
          | 'start'
        text: string
        scale: number
        autoSize: boolean
      }
      type: 'text'
      rotation: number
      index: string
      parentId: import('@tldraw/editor').TLParentId
      isLocked: boolean
      opacity: number
      meta: import('@tldraw/editor').JsonObject
      id: import('@tldraw/editor').TLShapeId
      typeName: 'shape'
    }
  | undefined
References

TLTextShape, TLParentId, TLShapeId


onDoubleClickEdge

Public property

Signature
onDoubleClickEdge: (shape: TLTextShape) =>
  | {
      id: import('@tldraw/editor').TLShapeId
      type: 'text'
      props: {
        autoSize: boolean
        scale?: undefined
      }
    }
  | {
      id: import('@tldraw/editor').TLShapeId
      type: 'text'
      props: {
        scale: number
        autoSize?: undefined
      }
    }
  | undefined
References

TLTextShape, TLShapeId


onEditEnd

Public property

Signature
onEditEnd: TLOnEditEndHandler<TLTextShape>
References

TLOnEditEndHandler, TLTextShape


onResize

Public property

Signature
onResize: TLOnResizeHandler<TLTextShape>
References

TLOnResizeHandler, TLTextShape


props

Public static property

Signature
static props: {
  color: import('@tldraw/editor').EnumStyleProp<
    | 'black'
    | 'blue'
    | 'green'
    | 'grey'
    | 'light-blue'
    | 'light-green'
    | 'light-red'
    | 'light-violet'
    | 'orange'
    | 'red'
    | 'violet'
    | 'yellow'
  >
  size: import('@tldraw/editor').EnumStyleProp<'l' | 'm' | 's' | 'xl'>
  font: import('@tldraw/editor').EnumStyleProp<
    'draw' | 'mono' | 'sans' | 'serif'
  >
  align: import('@tldraw/editor').EnumStyleProp<
    | 'end-legacy'
    | 'end'
    | 'middle-legacy'
    | 'middle'
    | 'start-legacy'
    | 'start'
  >
  w: import('@tldraw/editor').Validator<number>
  text: import('@tldraw/editor').Validator<string>
  scale: import('@tldraw/editor').Validator<number>
  autoSize: import('@tldraw/editor').Validator<boolean>
}
References

EnumStyleProp, Validator


type

Public static property

Signature
static type: 'text'

Methods

component()

Public method

Signature
component(shape: TLTextShape): import('react/jsx-runtime').JSX.Element
Parameters
NameDescription

shape

TLTextShape
Returns
import('react/jsx-runtime').JSX.Element
References

TLTextShape


getDefaultProps()

Public method

Signature
getDefaultProps(): TLTextShape['props']
References

TLTextShape


getGeometry()

Public method

Signature
getGeometry(shape: TLTextShape): Rectangle2d
Parameters
NameDescription

shape

TLTextShape
Returns
Rectangle2d
References

TLTextShape, Rectangle2d


getMinDimensions()

Public method

Signature
getMinDimensions(shape: TLTextShape): {
  height: number
  width: number
}
Parameters
NameDescription

shape

TLTextShape
Returns
{
  height: number
  width: number
}
References

TLTextShape


indicator()

Public method

Signature
indicator(shape: TLTextShape): import('react/jsx-runtime').JSX.Element | null
Parameters
NameDescription

shape

TLTextShape
Returns
import('react/jsx-runtime').JSX.Element | null
References

TLTextShape


toSvg()

Public method

Signature
toSvg(shape: TLTextShape, ctx: SvgExportContext): SVGGElement
Parameters
NameDescription

shape

TLTextShape

ctx

SvgExportContext
Returns
SVGGElement
References

TLTextShape, SvgExportContext


TextShapeToolTLDRAW_FILE_EXTENSION