Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.39k stars 316 forks source link

Remote spellcheck server #331

Open leonardorame opened 3 years ago

leonardorame commented 3 years ago

Hi, I'm evaluating the replacement of CKEditor to EasyMDE and I wonder how the spell checker works. Is there a way to do the spellchecking server side?, I need this because our system has a central dictionary of medical terms, and it would be awesome to use it from EasyMDE.

smundro commented 3 years ago

EasyMDE employs sparksuite / codemirror-spell-checker. I've opened a PR to allow for specifying a custom spell checker (#333) which would theoretically allow you to create your own fork that points to a custom dictionary.

Ionaru commented 3 years ago

@leonardorame

I think #333 will solve your issue, you can use it in the config like this:

const editor = new EasyMDE({
    spellChecker: (editor) => {
        // Call to remote spellcheck server using values from 'editor'.
        // Process the response and edit 'editor' accordingly.
    },
});

You can look at https://github.com/sparksuite/codemirror-spell-checker/blob/master/src/js/spell-checker.js and use snippets to create your own spell checker, or fork/copy that repo and implement your needs into it.

The custom spellchecker functionality is currently available on the easymde@next branch and will be released after a few days if it satisfies the use-cases.

leonardorame commented 3 years ago

Hi @Ionaru, thanks for this.

Can I do, for example, this?:

const editor = new EasyMDE({ 
    spellchecker: (editor) => function(options) {
        console.log(options);
    },
})
leonardorame commented 3 years ago

Hi @Ionaru, is the #333 included in 2.15.0?

leonardorame commented 3 years ago

Sorry, I asked too fast. Where is the easymde@next branch? I cannot reach it from the branches dropdown menu.

leonardorame commented 3 years ago

Got it npm i easymde@2.15.1-473.0.

Ionaru commented 3 years ago

You can also run npm i easymde@next