Typo.js icon indicating copy to clipboard operation
Typo.js copied to clipboard

API for adding custom words

Open mikeb-celtx opened this issue 7 years ago • 3 comments

It would be much appreciated if there were a way to add new custom words to the working dictionary. Right now I'm reloading the whole thing, though I saw on another PR that there is a hackaround to add single words using internal members. It seems like this is an obvious candidate for API extension.

mikeb-celtx avatar Apr 28 '18 05:04 mikeb-celtx

What is the PR where it shows the hackaround? Currently trying to get adding single custom words to work in typo js, thanks.

dportuesi avatar Nov 10 '20 18:11 dportuesi

When adding a new word, would you expect to ever be specifying flags for the word, or would it always be just "learn this exact word"?

FWIW, without a proper API, the way to add a word to an existing Typo instance should be:

var newWord = "cromulent";

var typo = new Typo([...]);
...
typo.dictionaryTable[newWord] = null

cfinke avatar Oct 20 '21 00:10 cfinke

The command line version of Hunspell only allows simple word lists in personal dictionary files. Perhaps that would be a good place to start, and possibly simpler with no need for flags?

Maybe there could be a public addPersonalDictionary method, that you pass a file name/file data to, and it calls _parseDIC under the hood?

whawker avatar Sep 02 '22 19:09 whawker