import React from 'react' import { BaseBoxShapeUtil, HTMLContainer, toDomPrecision } from '@tldraw/tldraw' import { CCBaseShape } from './cc-types' import { logger } from '../../../debugConfig' export interface ToolbarItem { id: string icon: string | React.ReactNode label: string onClick: (e: React.MouseEvent, shape: CCBaseShape) => void isActive?: boolean } export abstract class CCBaseShapeUtil extends BaseBoxShapeUtil { abstract renderContent: (shape: T) => React.ReactElement indicator(shape: T) { return ( ) } // eslint-disable-next-line @typescript-eslint/no-unused-vars getToolbarItems(shape: T): ToolbarItem[] { return [] } onAfterCreate(shape: T) { logger.info('cc-base-shape-util', 'onAfterCreate', shape) return shape } component(shape: T) { const { props: { w, h, isLocked, headerColor }, } = shape const toolbarItems = this.getToolbarItems(shape) return ( {/* Header */}
{shape.props.title}
{toolbarItems.map((item) => ( ))} {isLocked && 🔒}
{/* Content */}
{this.renderContent(shape)}
) } }