import type { TextBlock } from '@/marketing/cms-types';
import { LabeledRichText } from '../sections/shared';

type Props = {
    value: TextBlock;
    onChange: (next: TextBlock) => void;
    errors?: Record<string, string>;
};

export default function TextEditor({ value, onChange, errors }: Props) {
    const e = errors ?? {};
    return (
        <LabeledRichText
            id={`${value.id}-html`}
            label="Body text"
            value={value.html ?? ''}
            onChange={(html) => onChange({ ...value, html })}
            error={e.html}
            placeholder="Paragraph body — supports rich formatting (bold, italic, links, lists)."
            minHeight={120}
            // Custom > Text is the one place admins compose freely with no
            // section layout dictating alignment — surface Left/Center/Right
            // here. All other rich-text fields stay align-fixed.
            enableTextAlign
        />
    );
}
