{"_id":"electron-spell-check-provider","_rev":"229-18e31c6f6e163c0e1f90222ac7edabca","name":"electron-spell-check-provider","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"electron-spell-check-provider","version":"1.0.0","keywords":["electron","spellchecker","spell","checker","spell-checker"],"author":{"url":"https://mixmax.com","name":"Jeff Wear","email":"jeff@mixmax.com"},"license":"MIT","_id":"electron-spell-check-provider@1.0.0","maintainers":[{"name":"wearhere","email":"jeffreywear@gmail.com"}],"homepage":"https://github.com/mixmaxhq/electron-spell-check-provider#readme","bugs":{"url":"https://github.com/mixmaxhq/electron-spell-check-provider/issues"},"dist":{"shasum":"8ab046979bc36787cb20a558709aef3a24fdb805","tarball":"https://registry.npmjs.org/electron-spell-check-provider/-/electron-spell-check-provider-1.0.0.tgz","integrity":"sha512-xbU8Kxv2ZyCv0+NX2ykQBaX1loxjkV49W+9XR181N2yr85+OuIUKPHIMcbKStJIJVF+KieTRo+qKE6VVJjkEHA==","signatures":[{"sig":"MEUCIQCD4h5efdHh0CdaNTyKWf+NhS74VvgMgE6YFuBtfgRGAQIgKYCpXhW6t5hj60uw0qA9sBWA2A/x6KC2gMHuLk+cgi0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/index.js","_from":".","_shasum":"8ab046979bc36787cb20a558709aef3a24fdb805","gitHead":"e871dd53b321877f51d6b36f9665d6f2700db4c5","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"wearhere","email":"jeffreywear@gmail.com"},"repository":{"url":"git+https://github.com/mixmaxhq/electron-spell-check-provider.git","type":"git"},"_npmVersion":"2.14.7","description":"Because Electron's spell-check APIs are just a little too low-level.","directories":{},"_nodeVersion":"4.2.1","dependencies":{"underscore":"^1.8.3","spellchecker":"^3.2.1"},"_npmOperationalInternal":{"tmp":"tmp/electron-spell-check-provider-1.0.0.tgz_1454721899080_0.977215773658827","host":"packages-5-east.internal.npmjs.com"}},"1.1.0":{"name":"electron-spell-check-provider","version":"1.1.0","keywords":["electron","spellchecker","spell","checker","spell-checker"],"author":{"url":"https://mixmax.com","name":"Jeff Wear","email":"jeff@mixmax.com"},"license":"MIT","_id":"electron-spell-check-provider@1.1.0","maintainers":[{"name":"alex-mcnamara-mixmax","email":"alex@mixmax.com"},{"name":"bradvogel","email":"bradavogel@gmail.com"},{"name":"chanpory","email":"junk@rith.com"},{"name":"chuy-mixmax","email":"chuy@mixmax.com"},{"name":"jenskene","email":"jen+npm@mixmax.com"},{"name":"jmixmax","email":"jeremy+npm@mixmax.com"},{"name":"mixmax-codeship","email":"admin+mixmax-codeship-npm@mixmax.com"},{"name":"olofster","email":"olofmathe@hotmail.com"},{"name":"pricj004","email":"pricj004@gmail.com"},{"name":"scb","email":"me@spencer.sx"},{"name":"simonxca","email":"simoncxiong@gmail.com"},{"name":"ssorallen","email":"rossgit@gmail.com"},{"name":"thas","email":"thas@mixmax.com"},{"name":"ttacon","email":"ttacon@gmail.com"},{"name":"wearhere","email":"jeffreywear@gmail.com"}],"homepage":"https://github.com/mixmaxhq/electron-spell-check-provider#readme","bugs":{"url":"https://github.com/mixmaxhq/electron-spell-check-provider/issues"},"dist":{"shasum":"d1410b6ff2ffcba197db30bf886e37e0e39aec2e","tarball":"https://registry.npmjs.org/electron-spell-check-provider/-/electron-spell-check-provider-1.1.0.tgz","integrity":"sha512-sM5z+triA2cSmt7i7Ciscm02RQSiY3zJf/N3nH0/+jFHEIrgSyZVFIayyOEP8+wjxTinGBbMEd2Yo6fQr/WDVQ==","signatures":[{"sig":"MEQCIGV0T+wnxY0PRGrW0AKwAWVET/b1kOpyvBqM+OuFKwAGAiBkV9wrHq0yML0J770jFRQknxyL0ll4FeW8w01vyiaCkQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/index.js","_from":".","_shasum":"d1410b6ff2ffcba197db30bf886e37e0e39aec2e","gitHead":"62e26247d308b0dff8e818883dd16063f56115b6","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"wearhere","email":"jeffreywear@gmail.com"},"repository":{"url":"git+https://github.com/mixmaxhq/electron-spell-check-provider.git","type":"git"},"_npmVersion":"4.1.2","description":"Because Electron's spell-check APIs are just a little too low-level.","directories":{},"_nodeVersion":"7.6.0","dependencies":{"underscore":"^1.8.3","spellchecker":"^3.2.1"},"_npmOperationalInternal":{"tmp":"tmp/electron-spell-check-provider-1.1.0.tgz_1491856630381_0.9984642723575234","host":"packages-12-west.internal.npmjs.com"}},"1.1.1":{"name":"electron-spell-check-provider","version":"1.1.1","keywords":["electron","spellchecker","spell","checker","spell-checker"],"author":{"url":"https://mixmax.com","name":"Jeff Wear","email":"jeff@mixmax.com"},"license":"MIT","_id":"electron-spell-check-provider@1.1.1","maintainers":[{"name":"wearhere","email":"jeffreywear@gmail.com"},{"name":"wbw20","email":"wbw20@case.edu"},{"name":"mericsson","email":"mericsson@gmail.com"},{"name":"simonxca","email":"simoncxiong@gmail.com"},{"name":"logandavis","email":"logankeahidavis@gmail.com"},{"name":"ghmeier","email":"meier.garret@gmail.com"},{"name":"skeggse","email":"skeggse@gmail.com"},{"name":"olofster","email":"olofmathe@hotmail.com"},{"name":"jenskene","email":"jen+npm@mixmax.com"},{"name":"chanpory","email":"junk@rith.com"},{"name":"pricj004","email":"pricj004@gmail.com"},{"name":"bradvogel","email":"bradavogel@gmail.com"},{"name":"mixmax-codeship","email":"admin+mixmax-codeship-npm@mixmax.com"},{"name":"chuy-mixmax","email":"chuy@mixmax.com"},{"name":"scb","email":"me@spencer.sx"},{"name":"ttacon","email":"ttacon@gmail.com"}],"homepage":"https://github.com/mixmaxhq/electron-spell-check-provider#readme","bugs":{"url":"https://github.com/mixmaxhq/electron-spell-check-provider/issues"},"dist":{"shasum":"bbb521dcb314f9da020b4afca53f4e7a8e08955e","tarball":"https://registry.npmjs.org/electron-spell-check-provider/-/electron-spell-check-provider-1.1.1.tgz","integrity":"sha512-MXetFfJ9AkVgPehpL11mJwdDRX7N07ev1ZbUHAEYO2YOMYHNJ0gMI7AHEAw8KKN4vjaAut7Tlli9QgU8MGgtNA==","signatures":[{"sig":"MEYCIQDH6yTzPeuX5CAu5APnhH/gUTXBinG2/EDY2SeHt6FhKgIhAN3CPAA8GF4ohcKpqVl3hknl5DiEVuBn7uS68tynzvIL","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2pZZCRA9TVsSAnZWagAAmnQP/3eSj6RsxGFa4SRkiMWj\nhPkVxufiGLpL+P8+5/4l1rFJVziMKhuYBiA/7TWhmuK51INJyXwb3HJ6bzpP\nrS/eL9hQUjIgN1r/tWRj0PjHbWXEwISviok9LRexY7ptJF3QlkGBgvguAwME\nQQx9topU1+EHEzkuP8HH/1CUyRQzINpwDUg7MU4fzT7pnEl2ckdVHlFaK1sO\n7UvyD20BBUbp01nXRg0IneVMuhoS+43kDh1eMgVaewtdaoAJIqUT3zOyYIy7\nXbAdz9D5TFopxvTOczp9HGzXXOGpiPZNyr1iNxDe341YgDcJDN9MNLvml4WF\nKRdfUODlq+eS/Jjv5zEQdkmQV83cKQQnaGdnDXhszl6kTYK+1oI5pUo9JHm2\n6aDiRZUABDHQSGebEqelxFZ3g6rcNMyhbHlaFldnfRt01F3mCf1iyNmm5ESh\n5Eo4swbv23GqPxZSQdItfCP6iU4yJBkLLfMwxh1NzBscZRI3Izqwy4pufFb4\nK6nhePmvJeZ4vksNIygN+0CJgybRQz3M9NIhECHvybe9rB4jFUdkIxguelOl\n37R/TgYp116WnKoD0oEGoBoUOpZzDT7UJan3wJV/WY4I7Mda843xU6s+ZryN\nee6bsUC8EVhicgdhr/60iX2JvKrldWtMWJ4G5QAjNqJHo/G0vJgE+2GpfnMD\nJHzI\r\n=+cIR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","gitHead":"3579a5979f63f2d4fbead155385b24fbe1cbf4e3","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"bradvogel","email":"bradavogel@gmail.com"},"repository":{"url":"git+https://github.com/mixmaxhq/electron-spell-check-provider.git","type":"git"},"_npmVersion":"5.4.1","description":"Because Electron's spell-check APIs are just a little too low-level.","directories":{},"_nodeVersion":"6.9.1","dependencies":{"underscore":"^1.8.3","spellchecker":"^3.4.4"},"_npmOperationalInternal":{"tmp":"tmp/electron-spell-check-provider-1.1.1.tgz_1514749137032_0.4709201150108129","host":"s3://npm-registry-packages"}}},"time":{"created":"2016-02-06T01:25:01.603Z","modified":"2026-06-01T18:28:44.409Z","1.0.0":"2016-02-06T01:25:01.603Z","1.1.0":"2017-04-10T20:37:10.650Z","1.1.1":"2017-12-31T19:38:57.177Z"},"bugs":{"url":"https://github.com/mixmaxhq/electron-spell-check-provider/issues"},"author":{"url":"https://mixmax.com","name":"Jeff Wear","email":"jeff@mixmax.com"},"license":"MIT","homepage":"https://github.com/mixmaxhq/electron-spell-check-provider#readme","keywords":["electron","spellchecker","spell","checker","spell-checker"],"repository":{"url":"git+https://github.com/mixmaxhq/electron-spell-check-provider.git","type":"git"},"description":"Because Electron's spell-check APIs are just a little too low-level.","maintainers":[{"email":"mikusdominikcz@gmail.com","name":"mikusd"},{"email":"admin+mixmax-codeship-npm@mixmax.com","name":"mixmax-codeship"},{"email":"jesse@mixmax.com","name":"jessem3"},{"email":"syed.ahmed.anas@gmail.com","name":"ahmed-anas"},{"email":"guilhermem.j@hotmail.com","name":"guilhermemj"},{"email":"jordi@mixmax.com","name":"jsalvata"},{"email":"gabriel@mixmax.com","name":"gabriel-mixmax"},{"email":"raphael.b.souza@hotmail.com","name":"raphaelbs"},{"email":"it-ops@mixmax.com","name":"mixmax_it"},{"email":"leonardo@mixmax.com","name":"leonardo-mixmax"},{"email":"akashbhalla@gmail.com","name":"akashbhalla"},{"email":"jordi.nistal@gmail.com","name":"jordins"},{"email":"amina@mixmax.com","name":"aminao"},{"email":"misterpy@gmail.com","name":"misterpy"},{"email":"botond.dombi@gmail.com","name":"dombi"},{"email":"pialwlc@gmail.com","name":"mvpia"},{"email":"nirmal@mixmax.com","name":"its-nimo"},{"email":"alexander.k@mixmax.com","name":"kohlhofer_mixmax"},{"email":"jakub@mixmax.com","name":"jtutaj"},{"email":"acorretti@gmail.com","name":"acorretti"},{"email":"alexander.simovic@gmail.com","name":"simalexan"},{"email":"nikola@mixmax.com","name":"nzlaticmixmax"},{"email":"graham@mixmax.com","name":"grahammixmax"},{"email":"jpdjeredjian@gmail.com","name":"jpdjere"},{"email":"krisjanis@kallings.com","name":"magickriss"},{"email":"jeffreywear@gmail.com","name":"wearhere"}],"readme":"# electron-spell-check-provider\n\nElectron's [spell-check API][setSpellCheckProvider] looks straightforward… until\nyou have to pull in and configure `node-spellchecker`:\n\n```diff\nwebFrame.setSpellCheckProvider('en-US', true, {\nspellCheck: function(text) {\n+  return !(require('spellchecker').isMisspelled(text));\n}\n});\n```\n\nWhich improperly flags contractions:\n\n<img src=\"docs/false_positive.png\" height=\"300\" alt=\"false positive\">\n\nAnd only underlines misspelled words, leaving you to show suggestions [yourself][DIY context menu]…\n\nOr you can use this module:\n\n```js\nwebFrame.setSpellCheckProvider('en-US', true, new SpellCheckProvider('en-US'));\n```\n\n## Installation\n\n```js\nyarn add electron-spell-check-provider\n```\nor\n```js\nnpm install electron-spell-check-provider --save\n```\n\n_Note:_ This uses a native module, so you will need to [rebuild your modules][rebuild] after installing.\n\n## Usage\n\n```js\n// In the renderer process:\nvar webFrame = require('electron').webFrame;\nvar SpellCheckProvider = require('electron-spell-check-provider');\n\nwebFrame.setSpellCheckProvider('en-US', true, new SpellCheckProvider('en-US'));\n```\n\n'en-US' is the only supported language at present.\n\n### But how do I show spelling suggestions (in the context menu)?\n\nAs the text selection changes, Electron will poll the spell-check provider.\nIf the current word is misspelled, the provider will emit a `'misspelling'` event\nwith spelling suggestions:\n\n```js\nwebFrame.setSpellCheckProvider('en-US', true,\n  new SpellCheckProvider('en-US').on('misspelling', function(suggestions) {\n    console.log('The text at the site of the cursor is misspelled.',\n      'Maybe the user meant to type:', suggestions);\n  }\n}));\n```\n\nIf you save these suggestions, you can then show them in a [menu][menu] when the\n`'contextmenu'` event next fires.\n\nHere's a full implementation that uses\n[`electron-editor-context-menu`][electron-editor-context-menu] to build the menu\nfor you in addition to handling some other gotchas:\n\n```js\n/**\n * Enables spell-checking and the right-click context menu in text editors.\n * Electron (`webFrame.setSpellCheckProvider`) only underlines misspelled words;\n * we must manage the menu ourselves.\n *\n * Run this in the renderer process.\n */\nvar remote = require('electron').remote;\nvar webFrame = require('electron').webFrame;\nvar SpellCheckProvider = require('electron-spell-check-provider');\n// `remote.require` since `Menu` is a main-process module.\nvar buildEditorContextMenu = remote.require('electron-editor-context-menu');\n\nvar selection;\nfunction resetSelection() {\n  selection = {\n    isMisspelled: false,\n    spellingSuggestions: []\n  };\n}\nresetSelection();\n\n// Reset the selection when clicking around, before the spell-checker runs and the context menu shows.\nwindow.addEventListener('mousedown', resetSelection);\n\n// The spell-checker runs when the user clicks on text and before the 'contextmenu' event fires.\n// Thus, we may retrieve spell-checking suggestions to put in the menu just before it shows.\nwebFrame.setSpellCheckProvider(\n  'en-US',\n  // Not sure what this parameter (`autoCorrectWord`) does: https://github.com/atom/electron/issues/4371\n  // The documentation for `webFrame.setSpellCheckProvider` passes `true` so we do too.\n  true,\n  new SpellCheckProvider('en-US').on('misspelling', function(suggestions) {\n    // Prime the context menu with spelling suggestions _if_ the user has selected text. Electron\n    // may sometimes re-run the spell-check provider for an outdated selection e.g. if the user\n    // right-clicks some misspelled text and then an image.\n    if (window.getSelection().toString()) {\n      selection.isMisspelled = true;\n      // Take the first three suggestions if any.\n      selection.spellingSuggestions = suggestions.slice(0, 3);\n    }\n  }));\n\nwindow.addEventListener('contextmenu', function(e) {\n  // Only show the context menu in text editors.\n  if (!e.target.closest('textarea, input, [contenteditable=\"true\"]')) return;\n\n  var menu = buildEditorContextMenu(selection);\n\n  // The 'contextmenu' event is emitted after 'selectionchange' has fired but possibly before the\n  // visible selection has changed. Try to wait to show the menu until after that, otherwise the\n  // visible selection will update after the menu dismisses and look weird.\n  setTimeout(function() {\n    menu.popup(remote.getCurrentWindow());\n  }, 30);\n});\n```\n\n### Adding words to the dictionary\n\nYou can add a word to the spell-check dictionary by calling the `add` instance method. Pass the word to add as an argument. Additions to the dictionary are persistent.\n\n```javascript\nlet provider = new SpellCheckProvider('en-US');\n// ...\nlet newWord = window.getSelection().toString();\nprovider.add(newWord);\n```\n\nYou can do this in a context menu click handler function for an \"Add to Dictionary\" menu item.\n\n## Contributing\n\nWe welcome pull requests! In particular, we'd love to see support for additional\nlanguages.\n\nPlease lint your code.\n\n## Copyright and License\n\nCopyright 2016 Mixmax, Inc., licensed under the MIT License.\n\n[setSpellCheckProvider]: https://github.com/atom/electron/blob/master/docs/api/web-frame.md#webframesetspellcheckproviderlanguage-autocorrectword-provider\n[DIY context menu]: https://github.com/atom/electron/pull/942#issuecomment-136223543\n[menu]: https://github.com/atom/electron/blob/master/docs/api/menu.md\n[electron-editor-context-menu]: https://github.com/mixmaxhq/electron-editor-context-menu\n[rebuild]: https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md#the-easy-way\n\n## Release History\n\n* 1.1.0 Support adding words to the dictionary (#6)\n* 1.0.0 Initial release.\n\n","readmeFilename":"README.md","users":{"beshur":true}}