RichTextUndoState

Manages the undo and redo history for a RichTextState.

This state allows you to programmatically trigger undo, redo, and clearHistory operations, as well as observe the availability of these operations via canUndo and canRedo.

Snapshot Granularity

The undo history is recorded automatically based on the following rules:

  • Consecutive single-character typing (e.g., typing "abc") is merged into a single undo step.

  • Whitespace, newlines, text deletions (e.g., Backspace, Delete), and pasting multiple characters always create a separate undo step.

Properties

Link copied to clipboard

Whether a redo operation is available. Returns true if there is at least one action that can be redone.

Link copied to clipboard

Whether an undo operation is available. Returns true if there is at least one action that can be undone.

Functions

Link copied to clipboard

Clears both the undo and redo history. This resets canUndo and canRedo to false.

Link copied to clipboard
fun redo()

Reapplies the most recent change that was undone. If canRedo is false, this operation does nothing.

Link copied to clipboard
fun undo()

Reverts the most recent change made to the text or rich text spans. If canUndo is false, this operation does nothing.