Add the CodeMirror Speak-and-Spell plugin code.
Review Request #14475 — Created June 25, 2025 and submitted
This is the full plugin for CodeMirror Speak-and-Spell for CodeMirror 5.
It allows native browser/OS features such as spell checking,
speech-to-text, AI-assisted writing/rewriting, and other text
replacements to work with CodeMirror.It does this by intercepting the
beforeinput
events emitted by the
browser before any text would be inserted or replaced, canceling the
change, and then replaying the same change using CodeMirror's API.By doing it this way, we avoid the thrashing that occurs with
CodeMirror's own attempts at supporting these features. Normally,
CodeMirror will listen for aninput
change and then wait 40ms before
relaying changes back into CodeMirror, but in practice this doesn't
consistently work. It's okay on Firefox, but has a tendency to undo
replaced changes on Chrome and Safari. Taking the browser's DOM
manipulations out of the equation removes the source of this problem
entirely.A sample file has been provided to experience the plugin on different
browsers.
Tested Chrome, Firefox, and Safari with both the sample page and with
the plugin used in Review Board.My tests involved the following on each:
- General typing and text formatting using Review Board's toolbar.
- Inline spelling/grammar suggestions with text replaced.
- Dialog-based spelling/grammar suggestions with replacements.
- Safari's text transformations (Capitalize, Make Upper Case, Make Lower Case).
- AI-assisted writing, re-writing, and summarizations.
- Speech-to-text.
These were tested at various places within a test document. I checked
that this all worked regardless of where the cursor was.Unlike with default behavior, I didn't see any document thrashing at any
point, or any data loss.
Summary | ID |
---|---|
c561bbe98153c5499fee18ef23f03f603c7fceed |
Description | From | Last Updated |
---|---|---|
Do we need the cmOps.ts file? It's just an exact copy of cmUtils.ts |
![]() |