RichTextState
A state object that can be hoisted to control and observe changes to RichTextEditor.
This state manages the underlying RichString, including the raw text and its associated formatting attributes (RichSpans). It acts as the single source of truth for the editor, integrating seamlessly with standard Compose text APIs.
Parameters
The initial RichString to display in the editor. Defaults to an empty RichString.
The initial TextRange selection or cursor position. Defaults to the end of initialText.
Constructors
Properties
The merged attributes at the current cursor position.
The current selection range within the text field. Returns TextRange.Zero when no selection is active (cursor at position 0).
Attributes that will be applied to the next character typed via the keyboard.
Manages the undo and redo history for this state. Use this property to programmatically trigger undo/redo operations or observe their availability.
Functions
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.
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.
Clears all currently active formats.
Clears all typing attributes, reverting to the cursor's inherited attributes.
Scans the current text for URLs and applies LinkKey attributes to them.
Edits the underlying RichString state using a builder DSL. This allows you to apply or remove multiple attributes within a RichTextBuffer, as well as insert, delete, or replace text.
Removes the format associated with the given key.
Removes a single attribute from the current typing attributes. Has no effect when a text range is selected (non-collapsed selection).
Replaces the entire text and formatting attributes of this state with the given richString.
Adds or overwrites a single attribute in the current typing attributes. Has no effect when a text range is selected (non-collapsed selection).