RichTextEditor

fun RichTextEditor(state: RichTextState, modifier: Modifier = Modifier, enabled: Boolean = true, readOnly: Boolean = false, textStyle: TextStyle = TextStyle.Default, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, onKeyboardAction: KeyboardActionHandler? = null, lineLimits: TextFieldLineLimits = TextFieldLineLimits.Default, onTextLayout: Density.(getResult: () -> TextLayoutResult?) -> Unit? = null, scrollState: ScrollState = rememberScrollState(), interactionSource: MutableInteractionSource? = null, cursorBrush: Brush = SolidColor(Color.Black), decorator: TextFieldDecorator? = null, styleResolver: AttributeStyleResolver = DefaultAttributeStyleResolver, listMarkerResolver: ListMarkerResolver = DefaultListMarkerResolver, onSpanClick: (SpanClickEvent) -> Unit? = null, autocompleteTriggers: List<AutocompleteTrigger> = emptyList(), onAutocompleteChange: (AutocompleteMatch?) -> Unit? = null)

A basic text editor component tailored for editing and displaying RichText content.

Parameters

state

The RichTextState holding the text and its attributes.

modifier

The modifier to be applied to the text field.

enabled

Controls the enabled state of the text field. When false, the text field is not focusable or editable, and pointer interactions are disabled.

readOnly

Controls the editable state of the text field. When true, the text cannot be modified, but it can still be focused and spans can still be clicked.

textStyle

The TextStyle to be applied to the text.

keyboardOptions

Software keyboard options that configure keyboard behaviors such as keyboard type and IME action.

onKeyboardAction

Called when the user triggers an IME action on the software keyboard.

lineLimits

Whether the text field should be single line, or multi line with specific bounds.

onTextLayout

Callback that is executed when a new text layout is calculated.

scrollState

Scroll state that manages the vertical scroll position of the editor content.

interactionSource

The MutableInteractionSource representing the stream of interactions for this text field.

cursorBrush

The brush used to draw the cursor.

decorator

Allows modifying how the text field is drawn with decorations around it (e.g. placeholder, border).

styleResolver

A resolver that specifies how AttributeContainers should be translated into visually rendered Compose SpanStyles.

listMarkerResolver

A resolver that specifies how list markers (e.g. bullets, ordered numbers) should be rendered.

onSpanClick

Optional callback invoked when a RichSpan is tapped or clicked.

autocompleteTriggers

The list of AutocompleteTrigger patterns to observe during typing.

onAutocompleteChange

Callback invoked whenever the active AutocompleteMatch changes, or null when no trigger is matched.