dashingdove
dashingdove

Reputation: 435

Can I detect changes in Toast UI Editor?

I'm using Toast UI Editor and I'd like to detect when there is a change to the input. Usually I would do something like textarea.addEventListener('change', function) but I haven't been able to find any documentation as to how I can listen for changes on the editor. If anyone knows, it would be much appreciated.

Upvotes: 0

Views: 116

Answers (1)

dashingdove
dashingdove

Reputation: 435

I haven't found the official way of doing this but the editor uses a contenteditable div which you can target with .toastui-editor-contents. The below works:

document.querySelector('.toastui-editor-contents').addEventListener('input', fn);

The answer here explains how to detect a 'change' event for contenteditable elements.

Upvotes: 0

Related Questions