ArrowShapeUtil
See source codeTable of contents
- migrations
 - props
 - type
 - editor
 - Properties
 - Methods
- canBeLaidOut
 - canBind
 - canCrop
 - canDropShapes
 - canEdit
 - canEditInReadOnly
 - canReceiveNewChildrenOfType
 - canResize
 - canScroll
 - canSnap
 - component
 - getBoundsSnapGeometry
 - getCanvasSvgDefs
 - getDefaultProps
 - getGeometry
 - getHandles
 - getHandleSnapGeometry
 - getInterpolatedProps
 - getText
 - hideResizeHandles
 - hideRotateHandle
 - hideSelectionBoundsBg
 - hideSelectionBoundsFg
 - indicator
 - isAspectRatioLocked
 - onBeforeCreate
 - onBeforeUpdate
 - onChildrenChange
 - onClick
 - onDoubleClick
 - onDoubleClickEdge
 - onDoubleClickHandle
 - onDragShapesOut
 - onDragShapesOver
 - onDropShapesOver
 - onEditEnd
 - onHandleDrag
 - onResize
 - onResizeEnd
 - onResizeStart
 - onRotate
 - onRotateEnd
 - onRotateStart
 - onTranslate
 - onTranslateEnd
 - onTranslateStart
 - toBackgroundSvg
 - toSvg
 
 
Extends ShapeUtil<TLArrowShape>.
class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {}Constructor
Constructs a new instance of the ShapeUtil class
Parameters
| Name | Description | 
|---|---|
  | 
Properties
migrations
static migrations: import('@tldraw/editor').MigrationSequenceprops
static props: import('@tldraw/editor').RecordProps<TLArrowShape>type
static type: 'arrow'editor
editor: EditorMethods
canBeLaidOut()
canBeLaidOut(shape: TLArrowShape): booleanParameters
| Name | Description | 
|---|---|
  | 
Returns
booleancanBind()
canBind({ toShapeType }: TLShapeUtilCanBindOpts<TLArrowShape>): booleanParameters
| Name | Description | 
|---|---|
  | 
Returns
booleancanCrop()
Whether the shape can be cropped.
canCrop(_shape: Shape): booleanParameters
| Name | Description | 
|---|---|
  |  | 
Returns
booleancanDropShapes()
Get whether the shape can receive children of a given type.
canDropShapes(_shape: Shape, _shapes: TLShape[]): booleanParameters
| Name | Description | 
|---|---|
  |  | 
  |  | 
Returns
booleancanEdit()
canEdit(): booleancanEditInReadOnly()
Whether the shape can be edited in read-only mode.
canEditInReadOnly(_shape: Shape): booleanParameters
| Name | Description | 
|---|---|
  |  | 
Returns
booleancanReceiveNewChildrenOfType()
Get whether the shape can receive children of a given type.
canReceiveNewChildrenOfType(_shape: Shape, _type: TLShape['type']): booleanParameters
| Name | Description | 
|---|---|
  |  | 
  |  | 
Returns
booleancanResize()
Whether the shape can be resized.
canResize(_shape: Shape): booleanParameters
| Name | Description | 
|---|---|
  |  | 
Returns
booleancanScroll()
Whether the shape can be scrolled while editing.
canScroll(_shape: Shape): booleanParameters
| Name | Description | 
|---|---|
  |  | 
Returns
booleancanSnap()
canSnap(): booleancomponent()
component(shape: TLArrowShape): import('react/jsx-runtime').JSX.Element | nullParameters
| Name | Description | 
|---|---|
  | 
Returns
import('react/jsx-runtime').JSX.Element | nullgetBoundsSnapGeometry()
Get the geometry to use when snapping to this this shape in translate/resize operations. See BoundsSnapGeometry for details.
getBoundsSnapGeometry(_shape: Shape): BoundsSnapGeometryParameters
| Name | Description | 
|---|---|
  |  | 
Returns
getCanvasSvgDefs()
getCanvasSvgDefs(): TLShapeUtilCanvasSvgDef[]getDefaultProps()
getDefaultProps(): TLArrowShape['props']getGeometry()
getGeometry(shape: TLArrowShape): Group2dParameters
| Name | Description | 
|---|---|
  | 
Returns
getHandles()
getHandles(shape: TLArrowShape): TLHandle[]Parameters
| Name | Description | 
|---|---|
  | 
Returns
TLHandle[]getHandleSnapGeometry()
Get the geometry to use when snapping handles to this shape. See HandleSnapGeometry for details.
getHandleSnapGeometry(_shape: Shape): HandleSnapGeometryParameters
| Name | Description | 
|---|---|
  |  | 
Returns
getInterpolatedProps()
getInterpolatedProps(
  startShape: TLArrowShape,
  endShape: TLArrowShape,
  progress: number
): TLArrowShapePropsParameters
| Name | Description | 
|---|---|
  | |
  | |
  |  | 
Returns
getText()
getText(shape: TLArrowShape): stringParameters
| Name | Description | 
|---|---|
  | 
Returns
stringhideResizeHandles()
hideResizeHandles(): booleanhideRotateHandle()
hideRotateHandle(): booleanhideSelectionBoundsBg()
hideSelectionBoundsBg(): booleanhideSelectionBoundsFg()
hideSelectionBoundsFg(): booleanindicator()
indicator(shape: TLArrowShape): import('react/jsx-runtime').JSX.Element | nullParameters
| Name | Description | 
|---|---|
  | 
Returns
import('react/jsx-runtime').JSX.Element | nullisAspectRatioLocked()
Whether the shape's aspect ratio is locked.
isAspectRatioLocked(_shape: Shape): booleanParameters
| Name | Description | 
|---|---|
  |  | 
Returns
booleanonBeforeCreate()
A callback called just before a shape is created. This method provides a last chance to modify the created shape.
onBeforeCreate?(next: Shape): Shape | voidExample
onBeforeCreate = (next) => {
  return { ...next, x: next.x + 1 }
}Parameters
| Name | Description | 
|---|---|
  | The next shape.  | 
Returns
Shape | voidThe next shape or void.
onBeforeUpdate()
A callback called just before a shape is updated. This method provides a last chance to modify the updated shape.
onBeforeUpdate?(prev: Shape, next: Shape): Shape | voidExample
onBeforeUpdate = (prev, next) => {
  if (prev.x === next.x) {
    return { ...next, x: next.x + 1 }
  }
}Parameters
| Name | Description | 
|---|---|
  | The previous shape.  | 
  | The next shape.  | 
Returns
Shape | voidThe next shape or void.
onChildrenChange()
A callback called when a shape's children change.
onChildrenChange?(shape: Shape): TLShapePartial[] | voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
Returns
TLShapePartial[] | voidAn array of shape updates, or void.
onClick()
A callback called when a shape is clicked.
onClick?(shape: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onDoubleClick()
A callback called when a shape is double clicked.
onDoubleClick?(shape: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onDoubleClickEdge()
A callback called when a shape's edge is double clicked.
onDoubleClickEdge?(shape: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onDoubleClickHandle()
onDoubleClickHandle(
  shape: TLArrowShape,
  handle: TLHandle
): TLShapePartial<TLArrowShape> | voidParameters
| Name | Description | 
|---|---|
  | |
  | 
Returns
TLShapePartial<TLArrowShape> | voidonDragShapesOut()
A callback called when some other shapes are dragged out of this one.
onDragShapesOut?(shape: Shape, shapes: TLShape[]): voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
  | The shapes that are being dragged out.  | 
Returns
voidonDragShapesOver()
A callback called when some other shapes are dragged over this one.
onDragShapesOver?(shape: Shape, shapes: TLShape[]): voidExample
onDragShapesOver = (shape, shapes) => {
  this.editor.reparentShapes(shapes, shape.id)
}Parameters
| Name | Description | 
|---|---|
  | The shape.  | 
  | The shapes that are being dragged over this one.  | 
Returns
voidonDropShapesOver()
A callback called when some other shapes are dropped over this one.
onDropShapesOver?(shape: Shape, shapes: TLShape[]): voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
  | The shapes that are being dropped over this one.  | 
Returns
voidonEditEnd()
onEditEnd(shape: TLArrowShape): voidParameters
| Name | Description | 
|---|---|
  | 
Returns
voidonHandleDrag()
onHandleDrag(
  shape: TLArrowShape,
  { handle, isPrecise }: TLHandleDragInfo<TLArrowShape>
): {
  id: import('@tldraw/editor').TLShapeId
  meta?: Partial<import('@tldraw/editor').JsonObject> | undefined
  props?: Partial<TLArrowShapeProps> | undefined
  type: 'arrow'
} & Partial<Omit<TLArrowShape, 'id' | 'meta' | 'props' | 'type'>>Parameters
| Name | Description | 
|---|---|
  | |
  | 
Returns
{
  id: import('@tldraw/editor').TLShapeId
  meta?: Partial<import('@tldraw/editor').JsonObject> | undefined
  props?: Partial<TLArrowShapeProps> | undefined
  type: 'arrow'
} & Partial<Omit<TLArrowShape, 'id' | 'meta' | 'props' | 'type'>>onResize()
onResize(
  shape: TLArrowShape,
  info: TLResizeInfo<TLArrowShape>
): {
  props: {
    bend: number
    end: import('@tldraw/editor').VecModel
    start: import('@tldraw/editor').VecModel
  }
}Parameters
| Name | Description | 
|---|---|
  | |
  | 
Returns
{
  props: {
    bend: number
    end: import('@tldraw/editor').VecModel
    start: import('@tldraw/editor').VecModel
  }
}onResizeEnd()
A callback called when a shape finishes resizing.
onResizeEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape at the start of the resize.  | 
  | The current shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onResizeStart()
A callback called when a shape starts being resized.
onResizeStart?(shape: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onRotate()
A callback called when a shape changes from a rotation.
onRotate?(initial: Shape, current: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape at the start of the rotation.  | 
  | The current shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onRotateEnd()
A callback called when a shape finishes rotating.
onRotateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape at the start of the rotation.  | 
  | The current shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onRotateStart()
A callback called when a shape starts being rotated.
onRotateStart?(shape: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onTranslate()
onTranslate(initialShape: TLArrowShape, shape: TLArrowShape): voidParameters
| Name | Description | 
|---|---|
  | |
  | 
Returns
voidonTranslateEnd()
A callback called when a shape finishes translating.
onTranslateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | voidParameters
| Name | Description | 
|---|---|
  | The shape at the start of the translation.  | 
  | The current shape.  | 
Returns
TLShapePartial<Shape> | voidA change to apply to the shape, or void.
onTranslateStart()
onTranslateStart(shape: TLArrowShape): voidParameters
| Name | Description | 
|---|---|
  | 
Returns
voidtoBackgroundSvg()
Get the shape's background layer as an SVG object.
toBackgroundSvg?(
  shape: Shape,
  ctx: SvgExportContext
): null | Promise<null | ReactElement> | ReactElementParameters
| Name | Description | 
|---|---|
  | The shape.  | 
  | ctx - The export context for the SVG - used for adding e.g. <def>s  | 
Returns
null | Promise<null | ReactElement> | ReactElementAn SVG element.
toSvg()
toSvg(
  shape: TLArrowShape,
  ctx: SvgExportContext
): import('react/jsx-runtime').JSX.ElementParameters
| Name | Description | 
|---|---|
  | |
  | 
Returns
import('react/jsx-runtime').JSX.Element