NoteShapeUtil
Table of contents
- migrations
- props
- type
- canBeLaidOut
- canCrop
- canEdit
- canEditInReadOnly
- canResize
- canScroll
- canSnap
- editor
- hideResizeHandles
- hideRotateHandle
- hideSelectionBoundsBg
- hideSelectionBoundsFg
- isAspectRatioLocked
- onBeforeCreate
- onBeforeUpdate
- onChildrenChange
- onClick
- onDoubleClick
- onDoubleClickEdge
- onDoubleClickHandle
- onDragShapesOut
- onDragShapesOver
- onDropShapesOver
- onEditEnd
- onHandleDrag
- onResize
- onResizeEnd
- onResizeStart
- onRotate
- onRotateEnd
- onRotateStart
- onTranslate
- onTranslateEnd
- onTranslateStart
- Properties
- Methods
Extends ShapeUtil<TLNoteShape>.
class NoteShapeUtil extends ShapeUtil<TLNoteShape> {}
ShapeUtilConstructs a new instance of the ShapeUtil class
| Name | Description | 
|---|---|
| 
 |  | 
Properties
static migrations: import('@tldraw/editor').TLPropsMigrations
static props: import('@tldraw/editor').RecordProps<TLNoteShape>
static type: 'note'
ShapeUtilWhether the shape participates in stacking, aligning, and distributing.
canBeLaidOut: TLShapeUtilFlag<Shape>
ShapeUtilWhether the shape can be cropped.
canCrop: TLShapeUtilFlag<Shape>
canEdit: () => boolean
ShapeUtilWhether the shape can be edited in read-only mode.
canEditInReadOnly: TLShapeUtilFlag<Shape>
ShapeUtilWhether the shape can be resized.
canResize: TLShapeUtilFlag<Shape>
ShapeUtilWhether the shape can be scrolled while editing.
canScroll: TLShapeUtilFlag<Shape>
ShapeUtilWhether the shape can be snapped to by another shape.
canSnap: TLShapeUtilFlag<Shape>
ShapeUtileditor: Editor
hideResizeHandles: () => boolean
ShapeUtilWhether the shape should hide its rotation handles when selected.
hideRotateHandle: TLShapeUtilFlag<Shape>
ShapeUtilWhether the shape should hide its selection bounds background when selected.
hideSelectionBoundsBg: TLShapeUtilFlag<Shape>
hideSelectionBoundsFg: () => boolean
ShapeUtilWhether the shape's aspect ratio is locked.
isAspectRatioLocked: TLShapeUtilFlag<Shape>
onBeforeCreate: (next: TLNoteShape) =>
  | {
      id: TLShapeId
      index: 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'
        font: 'draw' | 'mono' | 'sans' | 'serif'
        fontSizeAdjustment: number
        growY: number
        scale: number
        size: 'l' | 'm' | 's' | 'xl'
        text: string
        url: string
        verticalAlign: 'end' | 'middle' | 'start'
      }
      rotation: number
      type: 'note'
      typeName: 'shape'
      x: number
      y: number
    }
  | undefined
onBeforeUpdate: (
  prev: TLNoteShape,
  next: TLNoteShape
) =>
  | {
      id: TLShapeId
      index: 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'
        font: 'draw' | 'mono' | 'sans' | 'serif'
        fontSizeAdjustment: number
        growY: number
        scale: number
        size: 'l' | 'm' | 's' | 'xl'
        text: string
        url: string
        verticalAlign: 'end' | 'middle' | 'start'
      }
      rotation: number
      type: 'note'
      typeName: 'shape'
      x: number
      y: number
    }
  | undefined
ShapeUtilA callback called when a shape's children change.
onChildrenChange?: TLOnChildrenChangeHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
ShapeUtilA callback called when a shape is clicked.
onClick?: TLOnClickHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
ShapeUtilA callback called when a shape is double clicked.
onDoubleClick?: TLOnDoubleClickHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
ShapeUtilA callback called when a shape's edge is double clicked.
onDoubleClickEdge?: TLOnDoubleClickHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
ShapeUtilA callback called when a shape's handle is double clicked.
onDoubleClickHandle?: TLOnDoubleClickHandleHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
| 
 | The handle that is double-clicked. | 
ShapeUtilA callback called when some other shapes are dragged out of this one.
onDragShapesOut?: TLOnDragHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
| 
 | The shapes that are being dragged out. | 
ShapeUtilA callback called when some other shapes are dragged over this one.
onDragShapesOver?: TLOnDragHandler<Shape>
onDragShapesOver = (shape, shapes) => {
  this.editor.reparentShapes(shapes, shape.id)
}
| Name | Description | 
|---|---|
| 
 | The shape. | 
| 
 | The shapes that are being dragged over this one. | 
ShapeUtilA callback called when some other shapes are dropped over this one.
onDropShapesOver?: TLOnDragHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
| 
 | The shapes that are being dropped over this one. | 
onEditEnd: TLOnEditEndHandler<TLNoteShape>
ShapeUtilA callback called when a shape's handle changes.
onHandleDrag?: TLOnHandleDragHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The current shape. | 
| 
 | An object containing the handle and whether the handle is 'precise' or not. | 
ShapeUtilA callback called when a shape changes from a resize.
onResize?: TLOnResizeHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape at the start of the resize. | 
| 
 | Info about the resize. | 
ShapeUtilA callback called when a shape finishes resizing.
onResizeEnd?: TLOnResizeEndHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape at the start of the resize. | 
| 
 | The current shape. | 
ShapeUtilA callback called when a shape starts being resized.
onResizeStart?: TLOnResizeStartHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
ShapeUtilA callback called when a shape changes from a rotation.
onRotate?: TLOnRotateHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape at the start of the rotation. | 
| 
 | The current shape. | 
ShapeUtilA callback called when a shape finishes rotating.
onRotateEnd?: TLOnRotateEndHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape at the start of the rotation. | 
| 
 | The current shape. | 
ShapeUtilA callback called when a shape starts being rotated.
onRotateStart?: TLOnRotateStartHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
ShapeUtilA callback called when a shape changes from a translation.
onTranslate?: TLOnTranslateHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape at the start of the translation. | 
| 
 | The current shape. | 
ShapeUtilA callback called when a shape finishes translating.
onTranslateEnd?: TLOnTranslateEndHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape at the start of the translation. | 
| 
 | The current shape. | 
ShapeUtilA callback called when a shape starts being translated.
onTranslateStart?: TLOnTranslateStartHandler<Shape>
| Name | Description | 
|---|---|
| 
 | The shape. | 
Methods
ShapeUtilWhether the shape can be bound to. See TLShapeUtilCanBindOpts for details.
canBind(opts: TLShapeUtilCanBindOpts<Shape>): boolean
| Name | Description | 
|---|---|
| 
 |  | 
boolean
ShapeUtilGet whether the shape can receive children of a given type.
canDropShapes(shape: Shape, shapes: TLShape[]): boolean
| Name | Description | 
|---|---|
| 
 | The shape type. | 
| 
 | The shapes that are being dropped. | 
boolean
ShapeUtilGet whether the shape can receive children of a given type.
canReceiveNewChildrenOfType(shape: Shape, type: TLShape['type']): boolean
| Name | Description | 
|---|---|
| 
 |  | 
| 
 | The shape type. | 
boolean
component(shape: TLNoteShape): import('react/jsx-runtime').JSX.Element
| Name | Description | 
|---|---|
| 
 |  | 
import('react/jsx-runtime').JSX.Element
ShapeUtilGet the geometry to use when snapping to this this shape in translate/resize operations. See BoundsSnapGeometry for details.
getBoundsSnapGeometry(shape: Shape): BoundsSnapGeometry
| Name | Description | 
|---|---|
| 
 |  | 
BoundsSnapGeometry
ShapeUtilReturn elements to be added to the <defs> section of the canvases SVG context. This can be
used to define SVG content (e.g. patterns & masks) that can be referred to by ID from svg
elements returned by component.
Each def should have a unique key. If multiple defs from different shapes all have the same
key, only one will be used.
getCanvasSvgDefs(): TLShapeUtilCanvasSvgDef[]
getDefaultProps(): TLNoteShape['props']
getGeometry(shape: TLNoteShape): Group2d
| Name | Description | 
|---|---|
| 
 |  | 
Group2d
getHandles(shape: TLNoteShape): TLHandle[]
| Name | Description | 
|---|---|
| 
 |  | 
TLHandle[]
ShapeUtilGet the geometry to use when snapping handles to this shape. See HandleSnapGeometry for details.
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry
| Name | Description | 
|---|---|
| 
 |  | 
HandleSnapGeometry
ShapeUtilGet the interpolated props for an animating shape. This is an optional method.
getInterpolatedProps?(
  startShape: Shape,
  endShape: Shape,
  progress: number
): Shape['props']
util.getInterpolatedProps?.(startShape, endShape, t)
| Name | Description | 
|---|---|
| 
 | The initial shape. | 
| 
 | The initial shape. | 
| 
 | The normalized progress between zero (start) and 1 (end). | 
Shape['props']
indicator(shape: TLNoteShape): import('react/jsx-runtime').JSX.Element
| Name | Description | 
|---|---|
| 
 |  | 
import('react/jsx-runtime').JSX.Element
ShapeUtilGet the shape's background layer as an SVG object.
toBackgroundSvg?(
  shape: Shape,
  ctx: SvgExportContext
): null | Promise<null | ReactElement> | ReactElement
| Name | Description | 
|---|---|
| 
 | The shape. | 
| 
 | ctx - The export context for the SVG - used for adding e.g. <def>s | 
null | Promise<null | ReactElement> | ReactElement
An SVG element.
toSvg(
  shape: TLNoteShape,
  ctx: SvgExportContext
): import('react/jsx-runtime').JSX.Element
| Name | Description | 
|---|---|
| 
 |  | 
| 
 |  | 
import('react/jsx-runtime').JSX.Element

