toggleFormat

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

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

If text is selected, the format is applied to the selection. If no text is selected (cursor is collapsed), the format is applied to the next typed characters. In either case, if the attribute is currently active, it is removed. Otherwise, it is applied.


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

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

The format is applied to the paragraph(s) overlapping the current cursor position or selection. If the attribute is currently active, it is removed. Otherwise, it is applied.