@@ -3,7 +3,8 @@ import { useQuickReactor, useValue } from '@tldraw/state-react'
33import { TLHandle , TLShapeId } from '@tldraw/tlschema'
44import { dedupe , modulate , objectMapValues } from '@tldraw/utils'
55import classNames from 'classnames'
6- import { Fragment , JSX , useEffect , useRef , useState } from 'react'
6+ import { Fragment , JSX , ReactElement , useEffect , useRef , useState } from 'react'
7+ import type { TLRenderingShape } from '../../editor/Editor'
78import { tlenv } from '../../globals/environment'
89import { useCanvasEvents } from '../../hooks/useCanvasEvents'
910import { useCoarsePointer } from '../../hooks/useCoarsePointer'
@@ -450,21 +451,30 @@ function CullingController() {
450451}
451452
452453function ShapesToDisplay ( ) {
453- const editor = useEditor ( )
454-
455- const renderingShapes = useValue ( 'rendering shapes' , ( ) => editor . getRenderingShapes ( ) , [ editor ] )
454+ const { ShapeRenderer } = useEditorComponents ( )
455+ const Renderer = ShapeRenderer ?? DefaultShapeRenderer
456456
457457 return (
458458 < ShapeCullingProvider >
459- { renderingShapes . map ( ( result ) => (
460- < Shape key = { result . id + '_shape' } { ...result } />
461- ) ) }
459+ < Renderer renderShape = { ( shape ) => < Shape key = { shape . id + '_shape' } { ...shape } /> } />
462460 < CullingController />
463461 { tlenv . isSafari && < ReflowIfNeeded /> }
464462 </ ShapeCullingProvider >
465463 )
466464}
467465
466+ /** @public */
467+ export interface TLShapeRendererProps {
468+ renderShape ( shape : TLRenderingShape ) : ReactElement
469+ }
470+
471+ /** @public @react */
472+ export function DefaultShapeRenderer ( { renderShape } : TLShapeRendererProps ) {
473+ const editor = useEditor ( )
474+ const renderingShapes = useValue ( 'rendering shapes' , ( ) => editor . getRenderingShapes ( ) , [ editor ] )
475+ return renderingShapes . map ( ( shape ) => renderShape ( shape ) )
476+ }
477+
468478function HintedShapeIndicator ( ) {
469479 const editor = useEditor ( )
470480 const { ShapeIndicator } = useEditorComponents ( )
0 commit comments