Table of contents

Extends ShapeUtil<TLArrowShape>.

class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {}

Constructor

from ShapeUtil

Constructs a new instance of the ShapeUtil class

Parameters
NameDescription

editor

Editor

Properties

migrations

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

props

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

type

static type: 'arrow'

canBeLaidOut

canBeLaidOut: TLShapeUtilFlag<TLArrowShape>

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

canSnap: () => boolean

editor

from ShapeUtil
editor: Editor

hideResizeHandles

hideResizeHandles: TLShapeUtilFlag<TLArrowShape>

hideRotateHandle

hideRotateHandle: TLShapeUtilFlag<TLArrowShape>

hideSelectionBoundsBg

hideSelectionBoundsBg: TLShapeUtilFlag<TLArrowShape>

hideSelectionBoundsFg

hideSelectionBoundsFg: TLShapeUtilFlag<TLArrowShape>

isAspectRatioLocked

from ShapeUtil

Whether the shape's aspect ratio is locked.

isAspectRatioLocked: TLShapeUtilFlag<Shape>

onBeforeCreate

from ShapeUtil

A callback called just before a shape is created. This method provides a last chance to modify the created shape.

onBeforeCreate?: TLOnBeforeCreateHandler<Shape>
Example
onBeforeCreate = (next) => {
  return { ...next, x: next.x + 1 }
}
Parameters
NameDescription

next

The next shape.


onBeforeUpdate

from ShapeUtil

A callback called just before a shape is updated. This method provides a last chance to modify the updated shape.

onBeforeUpdate?: TLOnBeforeUpdateHandler<Shape>
Example
onBeforeUpdate = (prev, next) => {
  if (prev.x === next.x) {
    return { ...next, x: next.x + 1 }
  }
}
Parameters
NameDescription

prev

The previous shape.

next

The next shape.


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

from ShapeUtil

A callback called when a shape is double clicked.

onDoubleClick?: TLOnDoubleClickHandler<Shape>
Parameters
NameDescription

shape

The shape.


onDoubleClickEdge

from ShapeUtil

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

onDoubleClickEdge?: TLOnDoubleClickHandler<Shape>
Parameters
NameDescription

shape

The shape.


onDoubleClickHandle

onDoubleClickHandle: (
  shape: TLArrowShape,
  handle: TLHandle
) => TLShapePartial<TLArrowShape> | void

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<TLArrowShape>

onHandleDrag

onHandleDrag: TLOnHandleDragHandler<TLArrowShape>

onResize

onResize: TLOnResizeHandler<TLArrowShape>

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

onTranslate?: TLOnTranslateHandler<TLArrowShape>

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

onTranslateStart: TLOnTranslateStartHandler<TLArrowShape>

Methods

canBind()

canBind({ toShapeType }: TLShapeUtilCanBindOpts<TLArrowShape>): boolean
Parameters
NameDescription

{ toShapeType }

TLShapeUtilCanBindOpts<TLArrowShape>
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: TLArrowShape): import('react/jsx-runtime').JSX.Element | null
Parameters
NameDescription

shape

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

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(): TLArrowShape['props']

getGeometry()

getGeometry(shape: TLArrowShape): Group2d
Parameters
NameDescription

shape

TLArrowShape
Returns
Group2d

getHandles()

getHandles(shape: TLArrowShape): TLHandle[]
Parameters
NameDescription

shape

TLArrowShape
Returns
TLHandle[]

getHandleSnapGeometry()

from ShapeUtil

Get the geometry to use when snapping handles to this shape. See HandleSnapGeometry for details.

getHandleSnapGeometry(shape: Shape): HandleSnapGeometry
Parameters
NameDescription

shape

Shape
Returns
HandleSnapGeometry

getInterpolatedProps()

getInterpolatedProps(
  startShape: TLArrowShape,
  endShape: TLArrowShape,
  progress: number
): TLArrowShapeProps
Parameters
NameDescription

startShape

TLArrowShape

endShape

TLArrowShape

progress

number
Returns
TLArrowShapeProps

indicator()

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

shape

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

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: TLArrowShape,
  ctx: SvgExportContext
): import('react/jsx-runtime').JSX.Element
Parameters
NameDescription

shape

TLArrowShape

ctx

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

ArrowShapeToolBookmarkShapeUtil