SpellCheckingTextEditor
A drop-in text editor composable with integrated spell checking.
Wraps BasicTextEditor and overlays spell-check decorations driven by a SpellCheckState. Edits are observed reactively: affected spans are invalidated immediately and re-checked once typing goes quiet, and replacing the document wholesale re-checks all of it. Secondary clicks and taps on a flagged span open a context menu of Suggestions for the misspelled word or sentence-level Correction, as do Shift+F10 and the Menu key with the caret in one.
Parameters
The EditorSpellChecker backing spell checks; used to build a default state when none is provided. May be null to disable checking.
The SpellCheckState coordinating spell checking over the underlying TextEditorState. Defaults to a remembered state built from spellChecker.
The Modifier applied to the editor surface.
Padding applied around the editor content.
Whether the editor accepts input and focus. A disabled editor offers no spell check menu.
Shows the caret for navigation and selection but takes no edits; see BasicTextEditor. The menu on a flagged span offers Ignore, Add to dictionary and spellCheckMenuItems, but no corrections or fixes.
Fills the height given, grows with the text between a minimum and maximum number of lines, or keeps it to one row that scrolls sideways; see BasicTextEditor.
Whether the editor requests focus on first composition.
The TextEditorStyle controlling appearance.
Localized strings for the built-in context menu.
Localized strings for the spell check menu.
Adds a word to the host's dictionary. When set, the menu on a flagged word offers "Add to dictionary", which calls this and stops flagging the word for the session, so it clears at once however the host's dictionary reaches the checker. It receives the word as flagged, capitals included; the session matches it across case as SpellCheckState.ignoreWord does.
Host items for the context menu opened on a flagged span, rendered after the built-in "Ignore" and "Add to dictionary" in a group below the suggestions. For a misspelled word they appear together with the suggestions once those have loaded. Not consulted while the editor is disabled. Read when the menu opens, so it may close over changing state.
Underlines from a checker other than spelling, such as grammar, kept up to date as the text changes. Its TextDiagnosticsState.textState must be state's. A secondary click or tap on one, or Shift+F10 or the Menu key with the caret in it, opens a menu of its message and fixes.
Optional listener for clicks on other rich spans; spell-check and diagnostic spans are handled internally.
The same clicks as onRichSpanClick, with the modifier keys that were held.
Opens a link's URL on Ctrl+click, or Cmd+click under the macOS keyBindings; see BasicTextEditor.
Chord-to-command mapping, defaulting to LocalKeyBindings.
The editor's label for accessibility services; see BasicTextEditor.
Whether lines wrap at the editor's width; with false a line stays one row and the editor scrolls sideways. See BasicTextEditor.