Table of contents

Extends BaseBoxShapeUtil<TLGeoShape>.

class GeoShapeUtil extends BaseBoxShapeUtil<TLGeoShape> {}

Constructor

from ShapeUtil

Constructs a new instance of the ShapeUtil class

Parameters
NameDescription

editor

Editor

Properties

migrations

static migrations: import('@tldraw/editor').TLPropsMigrations

props

static props: import('@tldraw/editor').RecordProps<TLGeoShape>

type

static type: 'geo'

canBeLaidOut

from ShapeUtil

Whether the shape participates in stacking, aligning, and distributing.

canBeLaidOut: TLShapeUtilFlag<Shape>

canCrop

from ShapeUtil

Whether the shape can be cropped.

canCrop: TLShapeUtilFlag<Shape>

canEdit

canEdit: () => boolean

canEditInReadOnly

from ShapeUtil

Whether the shape can be edited in read-only mode.

canEditInReadOnly: TLShapeUtilFlag<Shape>

canResize

from ShapeUtil

Whether the shape can be resized.

canResize: TLShapeUtilFlag<Shape>

canScroll

from ShapeUtil

Whether the shape can be scrolled while editing.

canScroll: TLShapeUtilFlag<Shape>

canSnap

from ShapeUtil

Whether the shape can be snapped to by another shape.

canSnap: TLShapeUtilFlag<Shape>

editor

from ShapeUtil
editor: Editor

hideResizeHandles

from ShapeUtil

Whether the shape should hide its resize handles when selected.

hideResizeHandles: TLShapeUtilFlag<Shape>

hideRotateHandle

from ShapeUtil

Whether the shape should hide its rotation handles when selected.

hideRotateHandle: TLShapeUtilFlag<Shape>

hideSelectionBoundsBg

from ShapeUtil

Whether the shape should hide its selection bounds background when selected.

hideSelectionBoundsBg: TLShapeUtilFlag<Shape>

hideSelectionBoundsFg

from ShapeUtil

Whether the shape should hide its selection bounds foreground when selected.

hideSelectionBoundsFg: TLShapeUtilFlag<Shape>

isAspectRatioLocked

from ShapeUtil

Whether the shape's aspect ratio is locked.

isAspectRatioLocked: TLShapeUtilFlag<Shape>

onBeforeCreate

onBeforeCreate: (shape: TLGeoShape) =>
  | {
      id: import('@tldraw/editor').TLShapeId
      index: import('@tldraw/editor').IndexKey
      isLocked: boolean
      meta: import('@tldraw/editor').JsonObject
      opacity: number
      parentId: import('@tldraw/editor').TLParentId
      props: {
        align:
          | 'end-legacy'
          | 'end'
          | 'middle-legacy'
          | 'middle'
          | 'start-legacy'
          | 'start'
        color:
          | 'black'
          | 'blue'
          | 'green'
          | 'grey'
          | 'light-blue'
          | 'light-green'
          | 'light-red'
          | 'light-violet'
          | 'orange'
          | 'red'
          | 'violet'
          | 'white'
          | 'yellow'
        dash: 'dashed' | 'dotted' | 'draw' | 'solid'
        fill: 'fill' | 'none' | 'pattern' | 'semi' | 'solid'
        font: 'draw' | 'mono' | 'sans' | 'serif'
        geo:
          | 'arrow-down'
          | 'arrow-left'
          | 'arrow-right'
          | 'arrow-up'
          | 'check-box'
          | 'cloud'
          | 'diamond'
          | 'ellipse'
          | 'heart'
          | 'hexagon'
          | 'octagon'
          | 'oval'
          | 'pentagon'
          | 'rectangle'
          | 'rhombus-2'
          | 'rhombus'
          | 'star'
          | 'trapezoid'
          | 'triangle'
          | 'x-box'
        growY: number
        h: number
        labelColor:
          | 'black'
          | 'blue'
          | 'green'
          | 'grey'
          | 'light-blue'
          | 'light-green'
          | 'light-red'
          | 'light-violet'
          | 'orange'
          | 'red'
          | 'violet'
          | 'white'
          | 'yellow'
        scale: number
        size: 'l' | 'm' | 's' | 'xl'
        text: string
        url: string
        verticalAlign: 'end' | 'middle' | 'start'
        w: number
      }
      rotation: number
      type: 'geo'
      typeName: 'shape'
      x: number
      y: number
    }
  | undefined

onBeforeUpdate

onBeforeUpdate: (
  prev: TLGeoShape,
  next: TLGeoShape
) =>
  | {
      id: import('@tldraw/editor').TLShapeId
      index: import('@tldraw/editor').IndexKey
      isLocked: boolean
      meta: import('@tldraw/editor').JsonObject
      opacity: number
      parentId: import('@tldraw/editor').TLParentId
      props: {
        align:
          | 'end-legacy'
          | 'end'
          | 'middle-legacy'
          | 'middle'
          | 'start-legacy'
          | 'start'
        color:
          | 'black'
          | 'blue'
          | 'green'
          | 'grey'
          | 'light-blue'
          | 'light-green'
          | 'light-red'
          | 'light-violet'
          | 'orange'
          | 'red'
          | 'violet'
          | 'white'
          | 'yellow'
        dash: 'dashed' | 'dotted' | 'draw' | 'solid'
        fill: 'fill' | 'none' | 'pattern' | 'semi' | 'solid'
        font: 'draw' | 'mono' | 'sans' | 'serif'
        geo:
          | 'arrow-down'
          | 'arrow-left'
          | 'arrow-right'
          | 'arrow-up'
          | 'check-box'
          | 'cloud'
          | 'diamond'
          | 'ellipse'
          | 'heart'
          | 'hexagon'
          | 'octagon'
          | 'oval'
          | 'pentagon'
          | 'rectangle'
          | 'rhombus-2'
          | 'rhombus'
          | 'star'
          | 'trapezoid'
          | 'triangle'
          | 'x-box'
        growY: number
        h: number
        labelColor:
          | 'black'
          | 'blue'
          | 'green'
          | 'grey'
          | 'light-blue'
          | 'light-green'
          | 'light-red'
          | 'light-violet'
          | 'orange'
          | 'red'
          | 'violet'
          | 'white'
          | 'yellow'
        scale: number
        size: 'l' | 'm' | 's' | 'xl'
        text: string
        url: string
        verticalAlign: 'end' | 'middle' | 'start'
        w: number
      }
      rotation: number
      type: 'geo'
      typeName: 'shape'
      x: number
      y: number
    }
  | undefined

onChildrenChange

from ShapeUtil

A callback called when a shape's children change.

onChildrenChange?: TLOnChildrenChangeHandler<Shape>
Parameters
NameDescription

shape

The shape.


onClick

from ShapeUtil

A callback called when a shape is clicked.

onClick?: TLOnClickHandler<Shape>
Parameters
NameDescription

shape

The shape.


onDoubleClick

onDoubleClick: (shape: TLGeoShape) =>
  | {
      id: import('@tldraw/editor').TLShapeId
      index: import('@tldraw/editor').IndexKey
      isLocked: boolean
      meta: import('@tldraw/editor').JsonObject
      opacity: number
      parentId: import('@tldraw/editor').TLParentId
      props: {
        geo: 'check-box'
      }
      rotation: number
      type: 'geo'
      typeName: 'shape'
      x: number
      y: number
    }
  | {
      id: import('@tldraw/editor').TLShapeId
      index: import('@tldraw/editor').IndexKey
      isLocked: boolean
      meta: import('@tldraw/editor').JsonObject
      opacity: number
      parentId: import('@tldraw/editor').TLParentId
      props: {
        geo: 'rectangle'
      }
      rotation: number
      type: 'geo'
      typeName: 'shape'
      x: number
      y: number
    }
  | undefined

onDoubleClickEdge

from ShapeUtil

A callback called when a shape's edge is double clicked.

onDoubleClickEdge?: TLOnDoubleClickHandler<Shape>
Parameters
NameDescription

shape

The shape.


onDoubleClickHandle

from ShapeUtil

A callback called when a shape's handle is double clicked.

onDoubleClickHandle?: TLOnDoubleClickHandleHandler<Shape>
Parameters
NameDescription

shape

The shape.

handle

The handle that is double-clicked.


onDragShapesOut

from ShapeUtil

A callback called when some other shapes are dragged out of this one.

onDragShapesOut?: TLOnDragHandler<Shape>
Parameters
NameDescription

shape

The shape.

shapes

The shapes that are being dragged out.


onDragShapesOver

from ShapeUtil

A callback called when some other shapes are dragged over this one.

onDragShapesOver?: TLOnDragHandler<Shape>
Example
onDragShapesOver = (shape, shapes) => {
  this.editor.reparentShapes(shapes, shape.id)
}
Parameters
NameDescription

shape

The shape.

shapes

The shapes that are being dragged over this one.


onDropShapesOver

from ShapeUtil

A callback called when some other shapes are dropped over this one.

onDropShapesOver?: TLOnDragHandler<Shape>
Parameters
NameDescription

shape

The shape.

shapes

The shapes that are being dropped over this one.


onEditEnd

onEditEnd: TLOnEditEndHandler<TLGeoShape>

onHandleDrag

from ShapeUtil

A callback called when a shape's handle changes.

onHandleDrag?: TLOnHandleDragHandler<Shape>
Parameters
NameDescription

shape

The current shape.

info

An object containing the handle and whether the handle is 'precise' or not.


onResize

onResize: TLOnResizeHandler<TLGeoShape>

onResizeEnd

from ShapeUtil

A callback called when a shape finishes resizing.

onResizeEnd?: TLOnResizeEndHandler<Shape>
Parameters
NameDescription

initial

The shape at the start of the resize.

current

The current shape.


onResizeStart

from ShapeUtil

A callback called when a shape starts being resized.

onResizeStart?: TLOnResizeStartHandler<Shape>
Parameters
NameDescription

shape

The shape.


onRotate

from ShapeUtil

A callback called when a shape changes from a rotation.

onRotate?: TLOnRotateHandler<Shape>
Parameters
NameDescription

initial

The shape at the start of the rotation.

current

The current shape.


onRotateEnd

from ShapeUtil

A callback called when a shape finishes rotating.

onRotateEnd?: TLOnRotateEndHandler<Shape>
Parameters
NameDescription

initial

The shape at the start of the rotation.

current

The current shape.


onRotateStart

from ShapeUtil

A callback called when a shape starts being rotated.

onRotateStart?: TLOnRotateStartHandler<Shape>
Parameters
NameDescription

shape

The shape.


onTranslate

from ShapeUtil

A callback called when a shape changes from a translation.

onTranslate?: TLOnTranslateHandler<Shape>
Parameters
NameDescription

initial

The shape at the start of the translation.

current

The current shape.


onTranslateEnd

from ShapeUtil

A callback called when a shape finishes translating.

onTranslateEnd?: TLOnTranslateEndHandler<Shape>
Parameters
NameDescription

initial

The shape at the start of the translation.

current

The current shape.


onTranslateStart

from ShapeUtil

A callback called when a shape starts being translated.

onTranslateStart?: TLOnTranslateStartHandler<Shape>
Parameters
NameDescription

shape

The shape.


Methods

canBind()

from ShapeUtil

Whether the shape can be bound to. See TLShapeUtilCanBindOpts for details.

canBind(opts: TLShapeUtilCanBindOpts<Shape>): boolean
Parameters
NameDescription

opts

TLShapeUtilCanBindOpts<Shape>
Returns
boolean

canDropShapes()

from ShapeUtil

Get whether the shape can receive children of a given type.

canDropShapes(shape: Shape, shapes: TLShape[]): boolean
Parameters
NameDescription

shape

Shape

The shape type.

shapes

TLShape[]

The shapes that are being dropped.

Returns
boolean

canReceiveNewChildrenOfType()

from ShapeUtil

Get whether the shape can receive children of a given type.

canReceiveNewChildrenOfType(shape: Shape, type: TLShape['type']): boolean
Parameters
NameDescription

shape

Shape

type

TLShape['type']

The shape type.

Returns
boolean

component()

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

shape

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

getBoundsSnapGeometry()

from ShapeUtil

Get the geometry to use when snapping to this this shape in translate/resize operations. See BoundsSnapGeometry for details.

getBoundsSnapGeometry(shape: Shape): BoundsSnapGeometry
Parameters
NameDescription

shape

Shape
Returns
BoundsSnapGeometry

getCanvasSvgDefs()

getCanvasSvgDefs(): TLShapeUtilCanvasSvgDef[]

getDefaultProps()

getDefaultProps(): TLGeoShape['props']

getGeometry()

getGeometry(shape: TLGeoShape): Group2d
Parameters
NameDescription

shape

TLGeoShape
Returns
Group2d

getHandles()

from ShapeUtil

Get an array of handle models for the shape. This is an optional method.

getHandles?(shape: Shape): TLHandle[]
Example
util.getHandles?.(myShape)
Parameters
NameDescription

shape

Shape

The shape.

Returns
TLHandle[]

getHandleSnapGeometry()

getHandleSnapGeometry(shape: TLGeoShape): HandleSnapGeometry
Parameters
NameDescription

shape

TLGeoShape
Returns
HandleSnapGeometry

getInterpolatedProps()

from BaseBoxShapeUtil
getInterpolatedProps(
  startShape: Shape,
  endShape: Shape,
  t: number
): Shape['props']
Parameters
NameDescription

startShape

Shape

endShape

Shape

t

number
Returns
Shape['props']

indicator()

indicator(shape: TLGeoShape): import('react/jsx-runtime').JSX.Element
Parameters
NameDescription

shape

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

toBackgroundSvg()

from ShapeUtil

Get the shape's background layer as an SVG object.

toBackgroundSvg?(
  shape: Shape,
  ctx: SvgExportContext
): null | Promise<null | ReactElement> | ReactElement
Parameters
NameDescription

shape

Shape

The shape.

ctx

SvgExportContext

ctx - The export context for the SVG - used for adding e.g. <def>s

Returns
null | Promise<null | ReactElement> | ReactElement

An SVG element.


toSvg()

toSvg(
  shape: TLGeoShape,
  ctx: SvgExportContext
): import('react/jsx-runtime').JSX.Element
Parameters
NameDescription

shape

TLGeoShape

ctx

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

GeoShapeToolHandTool