MarkdownEditor

Der MarkdownEditor formatiert Text per Markdown-Syntax und bietet eine Vorschau.
import { MarkdownEditor } from "@mittwald/flow-react-components";

<MarkdownEditor
  aria-label="Nachricht"
  placeholder="Schreibe eine Nachricht ..."
/>

Best Practices

  • Wähle die Höhe über das Property rows passend zur erwarteten Textmenge.
  • Nutze die FieldDescription für Beispiele, Formatierungshinweise oder Kontext.
  • Formuliere Fehlermeldungen klar, hilfreich und lösungsorientiert.
  • Setze Custom Buttons sparsam ein. So bleibt die Toolbar übersichtlich und die Standard-Aktionen erkennbar.
  • Lass Custom Buttons die aktuelle Text- und Cursor-Position berücksichtigen. So lässt sich nahtlos weiterarbeiten.
  • Wähle für die Custom Buttons ein aussagekräftiges Icon und formuliere das Label prägnant und leicht verständlich.

Character Count

Mit der Property showCharacterCount wird automatisch eine <FieldDescription /> ergänzt, die die aktuelle Zeichenanzahl und – sofern angegeben – die maximale Zeichenanzahl anzeigt.

0/100 characters

Resize

Automatisch

Mit der Property autoResizeMaxRows lässt sich eine maximale Höhe definieren, bis zu der sich der MarkdownEditor automatisch an den Inhalt anpasst.

Manuell

Über die Properties allowResize, allowVerticalResize oder allowHorizontalResize kann die Größe des MarkdownEditors manuell verändert werden.

Kombiniert

Beide Resize-Varianten lassen sich auch miteinander kombinieren. In diesem Fall passt sich der MarkdownEditor zunächst automatisch an, bis die Größe einmal manuell geändert wird. Danach bleibt er in der eingestellten Größe bestehen.


Custom Buttons

Ergänze die Toolbar des MarkdownEditors, indem du zusätzliche Actions direkt als Children von <MarkdownEditor /> deklarierst. So lassen sich einfache Buttons ebenso integrieren wie komplexere Trigger wie <ContextMenuTrigger /> oder <ModalTrigger />.


Disabled

Achte bei der Verwendung von Disabled darauf, dass aus dem Kontext klar wird, warum der User gerade nicht mit dem MarkdownEditor interagieren kann.


Kombiniere mit ...

Chat

Verwende den MarkdownEditor als Eingabefeld innerhalb eines Chat, um Nachrichten zu verfassen.

React Hook Form

Weitere Details zur Formularlogik und -validierung findest du in der Component Form (React Hook Form).


Properties

PropertyTypeDescription
allowHorizontalResize
boolean
@deprecated Use `allowResize` instead.
allowResize
boolean | horizontal | vertical
Allows the user to manually resize the textArea horizontally.
allowVerticalResize
boolean
@deprecated Use `allowResize` instead.
autoComplete
string
Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
autoCorrect
string
An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocomplete).
autoFocus
boolean
Whether the element should receive focus on render.
autoResizeMaxRows
number
Whether the text area should grow if its content gets longer than its initial height.
children
ReactNode
className
ClassNameOrFunction<TextFieldRenderProps>default: 'react-aria-TextField'
The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.
defaultValue
TimeValue
The default value (uncontrolled).
dir
string
enterKeyHint
enter | done | go | next | previous | search | send
An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).
excludeFromTabOrder
boolean
Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.
form
string
The `<form>` element to associate the input with. The value of this attribute must be the id of a `<form>` in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).
headingOffset
numberdefault: 0
Shifts all heading levels by the given offset.
hidden
boolean
id
string
The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
inert
boolean
inputMode
text | none | search | url | tel | email | numeric | decimal
Hints at the type of data that might be entered by the user while editing the element or its contents. See [MDN](https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute).
isDisabled
boolean
Whether the input is disabled.
isInvalid
boolean
Whether the value is invalid.
isReadOnly
boolean
Whether the input can be selected but not changed by the user.
isRequired
boolean
Whether user input is required on the input before form submission.
lang
string
markdownComponent
ComponentType<MarkdownProps>
Allows replacing the markdown preview renderer implementation. Defaults to the internal `Markdown` component.
maxLength
number
The maximum number of characters supported by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefmaxlength).
minLength
number
The minimum number of characters required by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefminlength).
name
string
The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
pattern
string
Regex pattern that the value of the input must match to be valid. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefpattern).
render
DOMRenderFunction<"div", TooltipRenderProps>
Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
showCharacterCount
boolean
Whether a character count should be displayed inside the field description.
slot
string
A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent.
spellCheck
string
An enumerated attribute that defines whether the element may be checked for spelling errors. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).
style
StyleOrFunction<TooltipRenderProps>
The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state.
translate
yes | no
type
text (default) | search | url | tel | email | password | (string & {})
The type of input to render. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).
validate
((value: TimeValue) => true | ValidationError | null)
A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if `validationBehavior="native"`. For realtime validation, use the `isInvalid` prop instead.
validationBehavior
native (default) | aria
Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.
value
TimeValue
The current value (controlled).
wrapWith
ReactElement<unknown, string | JSXElementConstructor<any>>
A React element the component is wrapped with. The element is cloned and receives the component as its only child — useful to render the component inside a link, a tooltip trigger or any other wrapper without changing the surrounding markup.

Events

PropertyTypeDescription
onBeforeInput
FormEventHandler<HTMLInputElement>
Handler that is called when the input value is about to be modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event).
onBlur
((e: FocusEvent<Element, Element>) => void)
Handler that is called when the element loses focus.
onChange
((value: TimeValue | null) => void)
Handler that is called when the value changes.
onClick
MouseEventHandler<HTMLDivElement>
onCompositionEnd
CompositionEventHandler<HTMLInputElement>
Handler that is called when a text composition system completes or cancels the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event).
onCompositionStart
CompositionEventHandler<HTMLInputElement>
Handler that is called when a text composition system starts a new text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event).
onCompositionUpdate
CompositionEventHandler<HTMLInputElement>
Handler that is called when a new character is received in the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionupdate_event).
onCopy
ClipboardEventHandler<HTMLInputElement>
Handler that is called when the user copies text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncopy).
onCut
ClipboardEventHandler<HTMLInputElement>
Handler that is called when the user cuts text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncut).
onFocus
((e: FocusEvent<Element, Element>) => void)
Handler that is called when the element receives focus.
onFocusChange
((isFocused: boolean) => void)
Handler that is called when the element's focus status changes.
onInput
FormEventHandler<HTMLInputElement>
Handler that is called when the input value is modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event).
onKeyDown
((e: KeyboardEvent) => void)
Handler that is called when a key is pressed.
onKeyUp
((e: KeyboardEvent) => void)
Handler that is called when a key is released.
onPaste
ClipboardEventHandler<HTMLInputElement>
Handler that is called when the user pastes text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/onpaste).
onSelect
ReactEventHandler<HTMLInputElement>
Handler that is called when text in the input is selected. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/select_event).

Accessibility

PropertyTypeDescription
aria-activedescendant
string
Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
aria-autocomplete
list | none | inline | both
Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.
aria-controls
string
Identifies the element (or elements) whose contents or presence are controlled by the current element.
aria-describedby
string
Identifies the element (or elements) that describes the object.
aria-details
string
Identifies the element (or elements) that provide a detailed, extended description for the object.
aria-errormessage
string
Identifies the element that provides an error message for the object.
aria-haspopup
boolean | false | true | menu | listbox | tree | grid | dialog
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
aria-hidden
Booleanish
Indicates whether the element is exposed to an accessibility API. @see aria-disabled.
aria-label
string
Defines a string value that labels the current element.
aria-labelledby
string
Identifies the element (or elements) that labels the current element.

Auf dieser Seite