interface TextEditorProps

Passed to TextEditor by the component that owns the text, which keeps it in its state (the editor is controlled).

Properties

value: string
onChange: (value: string) => void

Called on typing, and with the Markdown of the images once uploaded.

optional
placeholder: string
optional
disabled: boolean
optional
rows: number
optional
id: string
optional
className: string
optional
autoResize: boolean

Grows the textarea with its text instead of scrolling it.

optional
onSubmit: () => void

Called on Ctrl/Cmd+Enter, but not while an image is still uploading.

optional
onCancel: () => void

Called on Escape when no popup of the editor is left to close. Inline editors (an edit, a reply) pass it to mean "never mind".

optional
onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void

Runs after the editor's own keys (autocompletes, Ctrl+Enter), and never while an IME is composing, so an Enter that confirms a candidate isn't taken for "send".

optional
maxLength: number

Shows a counter and marks the textarea invalid past it. It doesn't stop the typing, so the caller must still refuse a longer text.

optional
countFrom: number

The length from which the counter shows, 80% of maxLength by default: a standing "0 / 5000" is noise, but the counter should turn up well before the warning colour does.

optional
mentionEveryone: boolean

Offers @everyone among the mention suggestions. The chat's composer sets it for a role with chat:everyone, the one place it notifies.

optional
aria-invalid: boolean
optional
aria-describedby: string

Joined with the id of the editor's own upload notice when it shows one.

Usage

import { type TextEditorProps } from "src/components/editor/TextEditor.tsx";