WordPress is using TinyMCE editor for visual editor.
I want to hook typing in this editor. I have this code:
tinyMCE.activeEditor.onKeyUp.add(function(ed, e) {
console.debug(
tinyMCE.activeEditor.getContent({format : 'raw'})
)
});
This is working, but I am getting error if Editor is not active in the moment when page is loaded and I am getting message “Deprecated TinyMCE API call: .onKeyPress.add(..)”
What is the best code to hook typing in this editor
If you are using V4 of tinymce, the binding of events has changed since V3. The new way to bind events is
See this DEMO
To add an event listener to an element you need to select it properly first.
For example:
<textarea id="visual_editor_selector"></textarea>
In JQuery, the id attribute is called with a #, like: