Skip to Content

Text Editor

A rich text (WYSIWYG) editor for formatted content. Used by RenderFormFields for ColumnTypeEnum.TEXT_EDITOR fields.


Import

import { TextEditor } from "@phpcreation/frontend-components-react-nextjs-bundle/components/TextEditor";

Props

PropTypeDefaultDescription
valuestring""HTML string content
onChange(value: string) => voidChange handler
placeholderstring""Placeholder text
disabledbooleanfalseRead-only mode
classNamestringAdditional CSS classes

Usage

import { TextEditor } from "..."; <TextEditor value={content} onChange={setContent} placeholder="Enter description..." />

With React Hook Form

<FormField control={form.control} name="description" render={({ field }) => ( <FormItem> <FormLabel>Description</FormLabel> <FormControl> <TextEditor value={field.value} onChange={field.onChange} placeholder="Enter description..." /> </FormControl> <FormMessage /> </FormItem> )} />

The editor outputs HTML strings. When rendering saved content, use dangerouslySetInnerHTML or a safe HTML renderer.


Last updated on