|
| 1 | +--- |
| 2 | +title: Spell check |
| 3 | +sidebarTitle: Overview |
| 4 | +keywords: "spell check, spellcheck, proofing, spelling suggestions, custom proofing provider, typo.js, languagetool, hunspell" |
| 5 | +--- |
| 6 | + |
| 7 | +SuperDoc can show spelling issues in the editor without browser-native spellcheck. You provide a spell-check provider. SuperDoc extracts document text, maps returned spelling issues back to document ranges, renders underlines, and shows right-click replacements. |
| 8 | + |
| 9 | +<Note> |
| 10 | +The configuration key is `proofing` because the provider contract is designed to support spelling, grammar, and style issues. The current UI renders spelling issues only. |
| 11 | +</Note> |
| 12 | + |
| 13 | +## Quick setup |
| 14 | + |
| 15 | +```javascript |
| 16 | +const provider = { |
| 17 | + id: 'my-spell-check', |
| 18 | + async check({ segments, maxSuggestions, signal }) { |
| 19 | + const response = await fetch('/api/spell-check', { |
| 20 | + method: 'POST', |
| 21 | + headers: { 'Content-Type': 'application/json' }, |
| 22 | + body: JSON.stringify({ segments, maxSuggestions }), |
| 23 | + signal, |
| 24 | + }); |
| 25 | + |
| 26 | + if (!response.ok) { |
| 27 | + throw new Error(`Spell-check request failed: ${response.status}`); |
| 28 | + } |
| 29 | + |
| 30 | + return response.json(); |
| 31 | + }, |
| 32 | +}; |
| 33 | + |
| 34 | +new SuperDoc({ |
| 35 | + selector: '#editor', |
| 36 | + document: 'contract.docx', |
| 37 | + proofing: { |
| 38 | + enabled: true, |
| 39 | + provider, |
| 40 | + defaultLanguage: 'en-US', |
| 41 | + maxSuggestions: 3, |
| 42 | + allowIgnoreWord: true, |
| 43 | + }, |
| 44 | +}); |
| 45 | +``` |
| 46 | + |
| 47 | +## What SuperDoc handles |
| 48 | + |
| 49 | +- Extracts text segments from body and table-cell paragraphs |
| 50 | +- Schedules visible pages first, continues in the background |
| 51 | +- Hashes segments and only rechecks the ones that changed |
| 52 | +- Maps provider offsets back to editor positions |
| 53 | +- Paints spelling underlines after each render |
| 54 | +- Shows replacements and Ignore in the right-click menu |
| 55 | +- Suppresses the word under the caret while you type |
| 56 | + |
| 57 | +## What your provider handles |
| 58 | + |
| 59 | +- The dictionary or spell-check engine |
| 60 | +- Language behavior and per-segment language hints |
| 61 | +- Where checking runs (local, on-device, remote) |
| 62 | +- Persisting ignored words if you want them to survive reloads |
| 63 | + |
| 64 | +<Note> |
| 65 | +SuperDoc does not bundle a dictionary or send your text anywhere. The provider is the data engine. Local options like Typo.js or Hunspell-WASM run entirely in the browser. Remote options like LanguageTool or your own API send segments over the network. |
| 66 | +</Note> |
| 67 | + |
| 68 | +## Current scope |
| 69 | + |
| 70 | +- Spelling issues render in v1 |
| 71 | +- Grammar and style issue kinds are accepted by the provider contract but not rendered yet |
| 72 | +- Headers and footers are not checked in v1 |
| 73 | +- Spell-check state is runtime UI state, not written into the DOCX |
| 74 | +- Spell check is not part of the Document API |
| 75 | + |
| 76 | +<Note> |
| 77 | +Ignore is local SuperDoc suppression. It survives reloads only if your app stores the ignored words and passes them back through `proofing.ignoredWords`. |
| 78 | +</Note> |
| 79 | + |
| 80 | +## Where it works |
| 81 | + |
| 82 | +Spell check runs inside the layout-engine editor surface. |
| 83 | + |
| 84 | +- Standard print layout works out of the box |
| 85 | +- For web layout, set `layoutEngineOptions.flowMode: 'semantic'` so the layout engine stays active |
| 86 | + |
| 87 | +```javascript |
| 88 | +new SuperDoc({ |
| 89 | + selector: '#editor', |
| 90 | + document: 'contract.docx', |
| 91 | + viewOptions: { layout: 'web' }, |
| 92 | + layoutEngineOptions: { flowMode: 'semantic' }, |
| 93 | + proofing: { |
| 94 | + enabled: true, |
| 95 | + provider, |
| 96 | + }, |
| 97 | +}); |
| 98 | +``` |
| 99 | + |
| 100 | +## Provider options |
| 101 | + |
| 102 | +SuperDoc does not include a spell-check engine. You bring your own. |
| 103 | + |
| 104 | +- [Typo.js](https://github.com/cfinke/Typo.js) - local browser spell check. Good for lightweight demos, privacy-sensitive flows, and no-backend setups. See the [Typo.js example](https://github.com/superdoc-dev/superdoc/tree/main/examples/editor/proofing/typo-js). |
| 105 | +- [LanguageTool](https://languagetool.org/) - API or self-hosted spell check with broader language support. See the [LanguageTool self-hosted example](https://github.com/superdoc-dev/superdoc/tree/main/examples/editor/proofing/language-tool-self-hosted). |
| 106 | +- [hunspell-asm](https://www.npmjs.com/package/hunspell-asm) - local WebAssembly Hunspell. A stronger on-device option than pure-JS dictionaries. |
| 107 | + |
| 108 | +## Examples |
| 109 | + |
| 110 | +- [Typo.js example](https://github.com/superdoc-dev/superdoc/tree/main/examples/editor/proofing/typo-js) - browser-only, no backend |
| 111 | +- [LanguageTool self-hosted example](https://github.com/superdoc-dev/superdoc/tree/main/examples/editor/proofing/language-tool-self-hosted) - HTTP spell check with Docker |
| 112 | + |
| 113 | +## Next steps |
| 114 | + |
| 115 | +- See [Configuration](/editor/superdoc/configuration#proofing) for all options |
| 116 | +- See [Custom spell-check provider](/editor/spell-check/custom-provider) to wire your own service |
0 commit comments