{"id":15621756,"url":"https://github.com/pirtleshell/codemirror-typo","last_synced_at":"2025-04-28T14:09:40.284Z","repository":{"id":57202462,"uuid":"72167576","full_name":"pirtleshell/codemirror-typo","owner":"pirtleshell","description":":snail: Spellcheck your CodeMirror editor in style with the dictionary of your choice","archived":false,"fork":false,"pushed_at":"2020-06-18T13:02:17.000Z","size":25,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T14:09:33.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pirtle.xyz/codemirror-typo/demo/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pirtleshell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-28T02:48:57.000Z","updated_at":"2020-11-21T14:31:31.000Z","dependencies_parsed_at":"2022-09-15T13:12:16.991Z","dependency_job_id":null,"html_url":"https://github.com/pirtleshell/codemirror-typo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirtleshell%2Fcodemirror-typo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirtleshell%2Fcodemirror-typo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirtleshell%2Fcodemirror-typo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirtleshell%2Fcodemirror-typo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pirtleshell","download_url":"https://codeload.github.com/pirtleshell/codemirror-typo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251326848,"owners_count":21571636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T09:51:44.532Z","updated_at":"2025-04-28T14:09:40.256Z","avatar_url":"https://github.com/pirtleshell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codemirror-typo\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\n\u003e :snail: Spellcheck your [CodeMirror](https://codemirror.net/) editor in style with the dictionary of your choice\n\n[Play with a live demo](https://pirtle.xyz/codemirror-typo/demo/).\n\n\n## Install\n\n**Browser inclusion** - Include `lib/codemirror-typo.min.js` into your `head`:\n```html\n\u003cscript src='codemirror-typo.min.js'\u003e\u003c/script\u003e\n```\n\nThis is a minified version of `codemirror-typo`, bundled using [browserify](http://browserify.org/).\n\n**Working in Node** - Install it as a dependency:\n```sh\n$ npm install --save codemirror-typo\n```\n\n\n## Usage\n\nLocate a [Hunspell dictionary](https://hunspell.github.io/) you'd like to use. You'll need a `*.aff` and `*.dic` for your spellcheck language. Below, there is more [dictionary information](#dictionaries), and a list of [where to get dictionaries](#dictionary-repos).\n\n**Load `lib/codemirror-typo.min.css` into your `head`:**\n```html\n\u003cstyle rel='stylesheet' href='codemirror-typo.min.css'\u003e\u003c/style\u003e\n```\n\n**Register `codeMirrorTypo`**:\n\nIn Node, `require` it:\n```js\nvar codeMirrorTypo = require('codemirror-typo');\n```\n\nIn the browser, it is registered through adding the `lib/codemirror.min.js` script.\n\n**Now just plug and play!**\n```js\nvar cm = CodeMirror(document.body); // your CodeMirror instance\n\ncodeMirrorTypo(cm, lang[, options]);\n```\n\n* `cm` - `CodeMirorr` instance to overlay spellchecker\n* `lang` - `string` - dictionary language\n* `options` - `string` or `object` - optional, either a `string` path to dictionary files or an options object\n\nThere are now red highlighted overlays on words not recognized by the dictionary. Upon focus, gutter marks provide a menu of suggestions of close matches from dictionary for easy fixing.\n\n\n## Dictionaries\n\n`codemirror-typo` uses [typo-js](https://github.com/cfinke/Typo.js/) that makes use of [Hunspell dictionaries](https://hunspell.github.io/), a popular open-source dictionary framework used by Firefox, Google Chrome, LibreOffice and more. These consist of a `*.dic` file of words and a `*.aff` of various spelling rules.\n\nSee below for a [list of Hunspell dictionary repos](#dictionary-repos) for downloading `aff` and `dic` files.\n\n\n## Options Parameters\n### Dictionary Path Options\n\n**No Path:**\nPassing just `lang` looks for `dictionary/lang/lang.aff` \u0026 `dictionary/lang/lang.dic`:\n```js\ncodeMirrorTypo(cm, 'en_US'); // for files in dictionary/en_US/\n```\n\nNote that this is a relative path.\n\n**String Path:**\nPassing `lang` and a path `string` looks for `path/lang.aff`, `path/lang.dic`:\n```js\ncodeMirrorTypo(cm, 'en_US', 'path/to/dictionary');\n```\nThe path can be **relative, absolute, or an external web address**:\n```js\ncodeMirrorTypo(cm, 'German', 'https://cdn.rawgit.com/titoBouzout/Dictionaries/master/');\n```\n\n### Options Object Parameters\n\n`codemirror-typo` follows this schema when looking for dictionary files:\n\n\u003e `dictPath`/`dictFolder`/[`affFile`.aff, `arrFile`.dic]\n\n**Defaults**\n```js\n{\n  dictPath: 'dictionary/' + lang,          // replaced by options parameter if string\n  dictFolder: '',                           // optional subdirectory of dictPath\n\n  filename: '',                             // name of both aff and dic file\n  affFile: lang,                            // name of aff file, overrides filename\n  dicFile: lang,                            // name of dic file, overrides filename\n\n  typoClass: 'typo',                         // CSS class applied to all spelling errors,\n                                            // will be prefixed with 'cm-'\n  typoCSS: 'background: rgba(255,0,0,.25)'  // CSS applied to typoClass\n\n  gutterClass: 'typoFlags',                 // CSS class and name of CodeMirror gutter\n  gutterMarkClass: 'typoMark'               // CSS class of gutter markers\n}\n```\n\nNote that `dictPath` may be an absolute or relative directory path, or a web address, with or without a trailing `/`.\n\n\n## Dictionary Repos\n\n* [LibreOffice](https://cgit.freedesktop.org/libreoffice/dictionaries/tree/)\n* [@titoBouzout's Dictionaries](https://github.com/titoBouzout/Dictionaries)\n\n\n## Known Problems\n\n**The gutter markers and spelling suggestions are very much in beta.** They're functional but definitely need improvement. **Suggestions, issues \u0026 PR's welcome!**\n\n* **_Long_ load time for spelling suggestion menu**, especially if word is not in dictionary. The menu should render as it's generated, but it is waiting until the whole element exists before rendering it...\n* **Gutter marks**: they don't load in as soon as the CodeMirror instance does, and they don't work on lines currently being written.\n\n\n## TODO:\n\n- [X] dictionary path configuration options\n- [X] gutter mark typos\n- [X] context menu spelling suggestions\n- [X] make and host a [demo](https://pirtle.xyz/codemirror-typo/demo/)\n- [ ] better browser compatibility\n- [ ] general code cleanup\n- [ ] cache an ignore word list aka \"Add to dictionary\"\n- [ ] add devTool for auto-downloading dictionaries\n\n\n## License\n\nMIT © [Robert Pirtle](https://pirtle.xyz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirtleshell%2Fcodemirror-typo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpirtleshell%2Fcodemirror-typo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirtleshell%2Fcodemirror-typo/lists"}