instructure-react / react-tinymce

React TinyMCE component
181 stars 115 forks source link

onChange not fired often enough #10

Closed dave-handy closed 8 years ago

dave-handy commented 8 years ago

It seems that onChange is only fired when you change the cursor location in the document, not whenever the document content changes (as you type). I expected any changes in the text to receive a callback.

mzabriskie commented 8 years ago

Would gladly accept a PR for this.

mzabriskie commented 8 years ago

I should note that I am not doing anything special to handle onChange, or any other event. This component is simply a React wrapper for tinymce. This module only proxies all the events. So if you're having a problem with events not firing often enough, it is likely an issue with tinymce itself.

dave-handy commented 8 years ago

Now that I'm thinking through this further, you don't need onChange if you have:

That's actually a better approach than I had planned when I thought onChange would work ;)

Maybe just a note in the README.md to warn about onChange?

mzabriskie commented 8 years ago

Sounds like you've got it figured out. Okay to close this?

amcsi commented 8 years ago

I'm having the same issue that onChange is only fired on blur, and I need this to also fire when a key is entered (e.g. like with the onkeyup event).

I have tried adding the same callback as I did to onChange, but for onKeyup, however the event it's passing as an argument points to a different target than what onChange does, so I'm getting this issue on keyup:

Uncaught TypeError: e.target.getContent is not a function

How do I get this working? I've also tried the onNodeChange event, but that seems to only work when I do backspace, not when actually typing letters

w- commented 7 years ago

@amcsi I ran into the same issue but after going through source i figured out the solution i describe here: https://github.com/instructure-react/react-tinymce/issues/41#issuecomment-262758123

hope it helps.

natterstefan commented 6 years ago

@w- thanks for the hint. Works for me :)