import { FieldSchema, StructureSchema, ValueType } from '@ephox/boulder'; import type { Optional, Result } from '@ephox/katamari'; import * as ComponentSchema from '../../core/ComponentSchema'; import { type FormComponentWithLabel, formComponentWithLabelFields, type FormComponentWithLabelSpec } from './FormComponent'; export interface TextAreaSpec extends FormComponentWithLabelSpec { type: 'textarea'; placeholder?: string; maximized?: boolean; enabled?: boolean; context?: string; spellcheck?: boolean; } export interface TextArea extends FormComponentWithLabel { type: 'textarea'; maximized: boolean; placeholder: Optional; enabled: boolean; context: string; spellcheck: Optional; } const textAreaFields = formComponentWithLabelFields.concat([ FieldSchema.optionString('placeholder'), FieldSchema.defaultedBoolean('maximized', false), ComponentSchema.enabled, FieldSchema.defaultedString('context', 'mode:design'), FieldSchema.optionBoolean('spellcheck'), ]); export const textAreaSchema = StructureSchema.objOf(textAreaFields); export const textAreaDataProcessor = ValueType.string; export const createTextArea = (spec: TextAreaSpec): Result> => StructureSchema.asRaw