@biscuitpants/codemirror-spell-checker

中文文档
0.0.12发布于 2021/08/10MITCommonJS近 30 天下载 2366

Tweaked and updated spell checker for CodeMirror

原始使用文档
文档目录6 节
  1. Fork
  2. Install
  3. Quick start
  4. Customizing
  5. Dictionaries
  6. Configuration

CodeMirror Spell Checker

Spell checking so simple, you can set up in 60 seconds. It will highlight any misspelled words in light red. Works great in conjunction with other CodeMirror modes, like GitHub Flavored Markdown.

Fork

This is a fork of sparksuite's codemirror-spell-checker.

Added fixes:

Screenshot

Install

Via npm.

npm install @biscuitpants/codemirror-spell-checker --save

Via bower.

bower install @biscuitpants/codemirror-spell-checker --save

Via jsDelivr. Please note, jsDelivr may take a few days to update to the latest release.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@biscuitpants/codemirror-spell-checker/latest/spell-checker.min.css">
<script src="https://cdn.jsdelivr.net/npm/@biscuitpants/codemirror-spell-checker/latest/spell-checker.min.js"></script>

Quick start

Once CodeMirror is installed and loaded, first provide CodeMirror Spell Checker with the correct CodeMirror function. Then, just set the primary mode to "spell-checker" and the backdrop mode to your desired mode. Be sure to load/require overlay.min.js if you haven't already.

CodeMirrorSpellChecker({
    codeMirrorInstance: CodeMirror,
});

CodeMirror.fromTextArea(document.getElementById("textarea"), {
    mode: "spell-checker",
    backdrop: "gfm" // Your desired mode
});

That's it!

Customizing

You can customize the misspelled word appearance by updating the CSS. All misspelled words will have the .cm-spell-error class.

.CodeMirror .cm-spell-error{
    /* Your styling here */
}

Dictionaries

Dictionaries are loaded from here.

Configuration

  • customWords: Custom array of words (or function that returns an array) that will not be treated as misspelled. Defaults to an empty array.
  • ignoreRegex: Custom regex to check if a matched word should be ignored. Defaults to /[0-9'_-]+/
  • wordRegex: Custom regex to match on words to be checked against the dictionary. Defaults to /^[^!"#$%&()*+,\-./:;<=>?@[\\\]^_{|}~\s]+/`
  • onDictionaryLoad: Function to run once the dictionaries have been loaded into memory.
  • dictionaryLanguage: String name of dictionary to use. Supported dictionaries can be found here.
  • commentStart: String that denotes the start of a comment line. Spelling will be ignored for comments.
// Most options demonstrate the non-default behavior
CodeMirrorSpellChecker({
    codeMirrorInstance: CodeMirror,
    customWords: ["CodeMirror", "GitHub"],
});

customWords can be both an Array of strings or a function that returns an Array of strings.

CodeMirrorSpellChecker({
    codeMirrorInstance: CodeMirror,
    customWords: function() { return ["NPM", "Javascript"]; },
});

版本与发布记录

@biscuitpants/codemirror-spell-checker 共发布 12 个版本,首次发布于 2021/07/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.12latest2021/08/105 年前
0.0.112021/08/055 年前
0.0.102021/08/035 年前
0.0.92021/08/035 年前
0.0.82021/07/265 年前
0.0.72021/07/265 年前

关于 @biscuitpants/codemirror-spell-checker 的常见问题

@biscuitpants/codemirror-spell-checker 是什么?

Tweaked and updated spell checker for CodeMirror

如何安装 @biscuitpants/codemirror-spell-checker?

在项目目录运行 npm install @biscuitpants/codemirror-spell-checker,或使用 pnpm add / yarn add / bun add。

@biscuitpants/codemirror-spell-checker 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/biscuitpants__codemirror-spell-checker 是否存在。

@biscuitpants/codemirror-spell-checker 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@biscuitpants/codemirror-spell-checker 可以商用吗?

@biscuitpants/codemirror-spell-checker 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@biscuitpants/codemirror-spell-checker 的下载量有多少?

根据 npm 官方下载统计,@biscuitpants/codemirror-spell-checker 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,366 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@biscuitpants/codemirror-spell-checker 还在维护吗?

最新版本 0.0.12 发布于 2021/08/10(5 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/07/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。