@arcstudio-labs/electron-system-spellcheck
v0.1.0
Published
Minimal macOS and Windows native system spellchecker addon for Electron
Readme
electron-system-spellcheck
Minimal native system spellchecking addon for Electron/Node.
Originally forked from Atom's node-spellchecker; MIT attribution is preserved in LICENSE.md.
Scope
- macOS:
NSSpellChecker - Windows 10+: Windows Spell Checking API (
ISpellCheckerFactory/ISpellChecker) - Node-API via
node-addon-api
Linux, Hunspell, dictionary downloads/files, DOM/editor integrations, tokenization helpers, and legacy Atom compatibility APIs are intentionally not included.
API
type SpellingError = { start: number; length: number }
class SpellChecker {
getLanguages(): string[]
setLanguage(language: string): boolean
check(text: string): SpellingError[]
getSuggestions(word: string): string[]
addWord(word: string): void
}const { SpellChecker } = require('@arcstudio-labs/electron-system-spellcheck')
const checker = new SpellChecker()
checker.setLanguage('en-US')
console.log(checker.check('This sentence contains an obviousmisspeling.'))
console.log(checker.getSuggestions('obviousmisspeling'))check(text) passes the complete string to the native OS spellchecker and returns misspelled ranges as JavaScript UTF-16 code-unit { start, length } offsets. The addon does not tokenize text in JavaScript or C++.
Installation
Published packages include prebuilt binaries where available. If a matching prebuild is not present for your platform/architecture, installation falls back to node-gyp rebuild.
Platform notes
On macOS, NSSpellChecker is process-shared and has process-global language state. This synchronous wrapper reapplies each instance's selected language before native operations; avoid using one process-global spellchecker concurrently from multiple JS worker threads with different languages.
On Windows, each SpellChecker instance owns the active language-specific ISpellChecker and recreates it on setLanguage().
