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.45k stars 319 forks source link

Change event not raised if you only delete some characters #255

Open mokhosh opened 4 years ago

mokhosh commented 4 years ago

Describe the bug If you add something to the text the change event is raised, but if you only delete some characters it doesn't.

Version information

mokhosh commented 4 years ago

Here's a little pen: https://codepen.io/mokhosh/pen/MWeeRbq?editors=1001

Write something, leave the editor, see the console. Delete some characters, leave the editor, see the console again.

Ionaru commented 4 years ago

EasyMDE has no internal change event, instead you should subscribe to the change event of the exposed codemirror instance.

const editor = new EasyMDE();
editor.codemirror.on('change', () => { /* do something */ });
mokhosh commented 4 years ago

I wish there was a way to work with native browser events, since many packages work with those out of the box.

mokhosh commented 4 years ago

Also, codemirror fires change for what is called input in javascript.