SpellCheckState

class SpellCheckState(val textState: TextEditorState, var spellChecker: EditorSpellChecker?, enableSpellChecking: Boolean = true, var spellCheckMode: SpellCheckMode = SpellCheckMode.Word)(source)

State holder that coordinates spell checking over a TextEditorState.

Tracks misspelled words and sentence-level Corrections, manages the spell-check decoration spans rendered in the document, and runs full or partial checks through an EditorSpellChecker. Span mutations are performed atomically after any asynchronous lookup completes so that a cancelled check never leaves the document with its decorations wiped.

Parameters

enableSpellChecking

Whether spell checking is active initially; exposed via spellCheckingEnabled.

Constructors

Link copied to clipboard
constructor(textState: TextEditorState, spellChecker: EditorSpellChecker?, enableSpellChecking: Boolean = true, spellCheckMode: SpellCheckMode = SpellCheckMode.Word)

Properties

Link copied to clipboard

The EditorSpellChecker used to evaluate words and sentences; checks are no-ops while this is null.

Link copied to clipboard

Whether spell checking is currently active. Toggle via setSpellCheckingEnabled.

Link copied to clipboard

Whether checking operates per-word or per-sentence; see SpellCheckMode.

Link copied to clipboard

The underlying editor state whose content is spell checked.

Functions

Link copied to clipboard
fun applySentenceCorrection(correction: Correction, selectedSuggestion: String)

Apply a sentence-level correction.

Link copied to clipboard
suspend fun checkWordSegment(segment: WordSegment): Boolean

Run spell check on a specific word segment. This will remove any existing spell check spans for the word and add a new one if misspelled.

Link copied to clipboard
fun correctSpelling(segment: WordSegment, correction: String)

Replace a misspelled word with the chosen correction.

Link copied to clipboard
suspend fun getSuggestions(word: String): List<Suggestion>

Gather correction suggestions for a word.

Link copied to clipboard

Handle click for sentence-level corrections only. Use this when you specifically need a Correction.

Link copied to clipboard

Handle click on a spell check span.

Link copied to clipboard

Handle click for word-level misspellings only. Use this when you specifically need a WordSegment.

Link copied to clipboard

Remove spell-check decorations affected by an edit operation.

Link copied to clipboard
suspend fun runFullSpellCheck()

Run full spell check based on the current mode.

Link copied to clipboard

Run partial spell check based on the current mode.

Link copied to clipboard
suspend fun setSpellCheckingEnabled(value: Boolean)

Enable or disable spell checking.

Link copied to clipboard
fun SpellCheckState.withMarkdown(initialConfiguration: MarkdownConfiguration = MarkdownConfiguration.DEFAULT, imageProvider: ImageProvider? = null): MarkdownExtension

Enable markdown import and export on a spell-checked editor.