'use client' import * as React from 'react' import { TextBlock as TextBlockType } from '../types' interface TextBlockProps { block: TextBlockType onChange: (block: TextBlockType) => void isEditing?: boolean /** Optional custom rich text editor component. Receives content, onChange, placeholder, and className. */ renderEditor?: (props: { content: string onChange: (html: string) => void placeholder?: string className?: string }) => React.ReactNode } export function TextBlockEditor({ block, onChange, isEditing = true, renderEditor }: TextBlockProps) { if (!isEditing) { return (

' }} /> ) } // If a custom editor is provided, use it if (renderEditor) { return (
{renderEditor({ content: block.content, onChange: (html) => onChange({ ...block, content: html }), placeholder: 'Write your content...', className: 'min-h-[60px] border-0', })}
) } // Default fallback: simple contentEditable div return (
onChange({ ...block, content: e.currentTarget.innerHTML })} />
) }