Package-level declarations

Types

Link copied to clipboard
class AttributeSerializer<T>(val key: <Error class: unknown class><T>, val saver: Saver<T, Any>)

Defines how to serialize and deserialize custom AttributeKey values for RichTextState.Saver.

Link copied to clipboard

Builder for creating custom AttributeStyleResolver instances.

Link copied to clipboard

Resolves an AttributeContainer to Compose styles (SpanStyle and/or ParagraphStyle) for rendering rich text.

Link copied to clipboard
data class AutocompleteMatch(val trigger: AutocompleteTrigger, val query: String, val range: IntRange, val queryRange: IntRange, val cursorPosition: Int, val cursorRect: Rect? = null)

Represents an active autocompletion trigger match at the current cursor position.

Link copied to clipboard
data class AutocompleteTrigger(val prefix: String, val id: String = prefix, val requireLeadingWhitespace: Boolean = true, val allowSpacesInQuery: Boolean = false, val maxQueryLength: Int = 50)

Defines a trigger pattern for autocompletion (e.g. '@' for mentions, '#' for tags, ':' for emojis).

Link copied to clipboard
fun interface ListMarkerResolver

Resolves a ListItem to a marker text string for display.

Link copied to clipboard
data class ResolvedRichStyle(val spanStyle: SpanStyle? = null, val paragraphStyle: ParagraphStyle? = null)

A container representing the resolved visual styles for a set of attributes.

Link copied to clipboard

A buffer for safely mutating both text and attributes of a RichTextState within an edit block. This class provides attribute operations by delegating to RichStringScope and adds text operations like insert, delete, and replace.

Link copied to clipboard
class RichTextState(initialText: <Error class: unknown class> = RichString(""), initialSelection: TextRange = TextRange(initialText.text.length))

A state object that can be hoisted to control and observe changes to RichTextEditor.

Link copied to clipboard

Manages the undo and redo history for a RichTextState.

Link copied to clipboard
class SpanClickEvent(val span: <Error class: unknown class>)

Represents a click or tap event on a RichSpan within the rich text editor.

Properties

Link copied to clipboard

The standard default AttributeStyleResolver mapping the semantic attributes to Compose SpanStyle.

Functions

Link copied to clipboard
fun RichTextState.applyCompletion(match: AutocompleteMatch, replacement: <Error class: unknown class>)

Replaces the range matched by match with the given RichString, preserving its styling attributes and positioning the cursor immediately after the replacement.

Replaces the range matched by match with the given replacement plain text, and positions the cursor immediately after the replacement.

fun RichTextState.applyCompletion(match: AutocompleteMatch, replacement: String, attributes: <Error class: unknown class>)

Replaces the range matched by match with the given replacement text, applies attributes using the specified attributes to the replacement, and positions the cursor immediately after it.

Link copied to clipboard
fun <T : Any> RichTextState.applyFormat(key: <Error class: unknown class><T>, value: T)

Applies the given value for a ParagraphAttributeKey.

fun <T : Any> RichTextState.applyFormat(key: <Error class: unknown class><T>, value: T)

Applies the given value for a SpanAttributeKey.

Link copied to clipboard
fun <T> attributeSerializer(key: <Error class: unknown class><T>, save: SaverScope.(value: T) -> Any?, restore: (value: Any) -> T?): AttributeSerializer<T>

Creates an AttributeSerializer using functional save and restore lambdas.

Link copied to clipboard

Creates an AttributeStyleResolver using a declarative DSL. Optionally accepts a base resolver. The styles constructed by this builder will take precedence and be merged on top of the styles produced by the base resolver.

Link copied to clipboard
fun <Error class: unknown class>.backgroundColor(color: Color)

Convenience function to set the background color using a Compose Color.

Link copied to clipboard

Clears all currently active formats.

Link copied to clipboard

Creates a PopupPositionProvider that positions a suggestion popup below (or above if constrained) the cursor of this AutocompleteMatch.

Link copied to clipboard

Scans the current text for URLs and applies LinkKey attributes to them.

Link copied to clipboard

Detects whether an active autocompletion trigger pattern is present immediately before the cursor.

Link copied to clipboard
fun RichTextBuffer.editAttributes(selection: TextRange, editAction: <Error class: unknown class>.() -> Unit)

Applies a set of attribute mutations to the range specified by the given TextRange. This is a convenience overload that converts TextRange to IntRange.

Link copied to clipboard
fun <Error class: unknown class>.fontSize(size: TextUnit)

Convenience function to set the font size using a Compose TextUnit.

Link copied to clipboard
fun rememberRichTextState(initialText: <Error class: unknown class> = RichString("")): RichTextState

Creates and remembers a RichTextState across configuration changes and process death using RichTextState.Saver.

fun rememberRichTextState(initialText: <Error class: unknown class> = RichString(""), saver: Saver<RichTextState, *>): RichTextState

Creates and remembers a RichTextState with a custom saver (e.g. supporting custom attribute keys).

Link copied to clipboard
fun RichTextState.removeFormat(key: <Error class: unknown class><out <Error class: unknown class>>)

Removes the format associated with the given key.

Link copied to clipboard
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.

Link copied to clipboard
fun <Error class: unknown class>.textColor(color: Color)

Convenience function to set the text color using a Compose Color.

Link copied to clipboard
fun <Error class: unknown class>.toColor(): Color

Converts an RgbaColor domain model to a Compose Color. Defaults to Color.Unspecified if the RgbaColor is unspecified.

Link copied to clipboard
fun RichTextState.toggleFormat(key: <Error class: unknown class><Unit>)

Toggles a ParagraphAttributeKey that does not require a value (i.e. its value is Unit).

fun RichTextState.toggleFormat(key: <Error class: unknown class><Unit>)

Toggles a SpanAttributeKey that does not require a value (i.e. its value is Unit).

Link copied to clipboard
fun Color.toRgbaColor(): <Error class: unknown class>

Converts a Compose Color to an RgbaColor domain model. Defaults to RgbaColor.Unspecified if the Color is unspecified.

Link copied to clipboard
fun TextUnit.toTextSize(): <Error class: unknown class>

Converts a Compose TextUnit using 'sp' to a TextSize domain model. Defaults to TextSize.Unspecified if the TextUnit is unspecified.

Link copied to clipboard
fun <Error class: unknown class>.toTextUnit(): TextUnit

Converts a TextSize domain model to a Compose TextUnit using 'sp'.