jakiestfu / Medium.js

A tiny JavaScript library for making contenteditable beautiful (Like Medium's editor)
http://jakiestfu.github.io/Medium.js/
4.39k stars 404 forks source link

Colorise Specific Words while Typing #201

Open xErik opened 7 years ago

xErik commented 7 years ago

Hello!

I like to colorise a specific group of words (house, mouse, ...) in a specific color (red). Another word group (tree, apple, ...) should be coloured differently (green).

I'd like to checks the words for colouring while typing with the keyup() event. (keyup() will get debounced for some milliseconds.)

I gave it a shoot by using medium.value(colorizedString)but this causes the caret to jump around.

What would be the appropriate way to achieve this elegantly with Medium?