npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

monaco-spellchecker

v0.6.0

Published

A spellchecker for Monaco Editor

Readme

monaco-spellchecker

This library provides a simple approach to spellchecking words in the Monaco Editor. Try it out!

Installation

npm install monaco-spellchecker

Dictionary Setup Using typo-js

Please install the typo-js library if you want to use it as a dictionary for spellchecking.

npm install typo-js

Example

Below is an example of how to create a dictionary and use it with monaco-spellchecker:

import * as monaco from 'monaco-editor'
import Typo from 'typo-js'
import { getSpellchecker } from 'monaco-spellchecker'
import affData from 'typo-js/dictionaries/en_US/en_US.aff?raw'
import wordsData from 'typo-js/dictionaries/en_US/en_US.dic?raw'

const editor = monaco.editor.create(/* ...existing code... */)

// Create dictionary
const dictionary = new Typo("en_US", affData, wordsData)

// Get Spell Checker
const spellchecker = getSpellchecker(monaco, editor, {
  check: (word) => dictionary.check(word),
  suggest: (word) => dictionary.suggest(word),
  ignore: (word) => {
    console.log('Ignore word:', word)
    // ...existing code...
  },
  addWord: (word) => {
    console.log('Add word:', word)
    // ...existing code...
  }
})

const process = debounce(spellchecker.process, 500)

// Process the editor content after it has been changed
editor.onDidChangeModelContent(() => {
  process()
})

// Register code action provider
monaco.languages.registerCodeActionProvider('markdown', spellchecker.codeActionProvider)

API Reference

getSpellchecker(monaco, editor, options)

Parameters:

  • monaco: The Monaco instance.
  • editor: The Editor instance.
  • options: An object with the following properties: | Property | Type | Description | |--------------------|----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| | check | (word: string) => (boolean \| Promise<boolean>) | Function to check if a word is spelled correctly. | | suggest | (word: string) => (string[] \| Promise<string[]>) | Function to provide suggestions for a misspelled word. | | languageSelector | Monaco.languages.LanguageSelector | Optional Monaco language selector. Default is *. | | severity | Monaco.MarkerSeverity | Optional severity level for the diagnostic. Default is monaco.MarkerSeverity.Warning. | | tokenize | (text: string) => { word: string, pos: number }[] \| Iterable<{ word: string, pos: number }> | Optional function to tokenize the text. If not provided, the default behavior is to match /\b[a-zA-Z']+\b/g. | | ignore | (word: string) => (void \| Promise<void>) | Optional function to ignore a word. If not provided, the default behavior is to hide the ignore button. | | addWord | (word: string) => (void \| Promise<void>) | Optional function to add a word to the dictionary. If not provided, the default behavior is to hide the add button. | | messageBuilder | (type: 'hover-message' \| 'ignore' \| 'add-word' \| 'apply-suggestion', word: string, range?: XRange, opts?: Options) => string | Optional function to build message. |

Returns an object with:

  1. process(): Re-scans the editor content for misspelled words.
  2. dispose(): Disposes the spellchecker.