EditorSession

interface EditorSession

An editor session holds the editor state and dispatches transactions.

Create instances via the EditorSession factory function or the rememberEditorSession composable.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val coroutineScope: CoroutineScope

CoroutineScope tied to the composition lifecycle.

Link copied to clipboard
abstract val editable: Boolean

Whether the editor is in editable mode.

Link copied to clipboard
abstract val state: EditorState

The current editor state.

Link copied to clipboard
abstract val textDirection: Direction

The overall text direction of the editor content.

Functions

Link copied to clipboard
abstract fun bidiSpans(line: Line): List<BidiSpan>

Get the bidirectional text spans for a line.

Link copied to clipboard
abstract fun coordsAtPos(pos: Int, side: Int = 1): Rect?

Get the document coordinates of a position. Returns null when outside the viewport.

Link copied to clipboard

Delete the text between from and to.

Link copied to clipboard
abstract fun dispatch(vararg specs: TransactionSpec)

Dispatch one or more transaction specs against the current state.

Link copied to clipboard

Dispatch a transaction built via DSL.

Link copied to clipboard

Dispatch a fully-built transaction.

Link copied to clipboard

Insert text at the given pos in the document.

Link copied to clipboard
abstract fun phrase(phrase: String, vararg insert: Any): String

Translate a phrase, optionally inserting values.

Link copied to clipboard
abstract fun <V : PluginValue> plugin(plugin: ViewPlugin<V>): V?

Get the current value of a view plugin, or null if the plugin is not active.

Link copied to clipboard
abstract fun posAtCoords(x: Float, y: Float): Int?

Get the document position for on-screen coordinates. Returns null when outside the editor.

Link copied to clipboard

Remember the current value of a Facet, recomposing only when its value changes.

Link copied to clipboard

Remember the current value of a StateField, recomposing only when its value changes.

Link copied to clipboard
fun EditorSession.select(anchor: DocPos, head: DocPos = anchor)

Set the selection to a range from anchor to head. If head is not provided, creates a cursor at anchor.

Link copied to clipboard

Select the entire document.

Link copied to clipboard

Replace the entire document content with text.

Link copied to clipboard
abstract fun textDirectionAt(pos: Int): Direction

Get the text direction at a specific position.