AutoStyleExtension for Medium Editor

AutoStyleExtension for Medium Editor allows auto-styling of words.

The auto-styling is defined in a configuration object, which gets passed to the constructur. In detail:
  1. Words and the CSS style to be applied to these words,
  2. whether case matching is to be performed,
  3. whether words only are matched, or substrings, too.

Code Example

        var editor = new MediumEditor('.editable', {
            disableReturn: true,
            disableExtraSpaces: true,
            toolbar: false,
            extensions: {
                'auto-highlight': new AutoStyleExtension(
                    config: [{
                        matchcase: false,
                        wordsonly: false,
                        styles: [{
                            style: 'background-color:yellow;',
                            words: ['yellow']
                        }, {
                            style: 'background-color:gray;',
                            words: ['gray', 'grey']
                        }]
                    }, {
                        matchcase: true,
                        wordsonly: true,
                        styles: [{
                            style: 'color:red;',
                            words: ['RED']
                        }, {
                            style: 'background-color:orange;',
                            words: ['oraNGE']
                        }]
                    }]
                )
            }
        });
    

Playground

Play around with the words yellow, gray, grey, RED and oraNGE.