Search code examples
javascripteventstinymcetinymce-4

TinyMCE v4+ top level event for adding and removing editors?


Working on getting my chrome extension to insert content into tinymce editors that exist on web pages. Issue is that in versions 4+ I am unable to set up a listener to check if a new editor instance has been added which I use to dynamically update my UI.

Version 3:

window.tinymce.onAddEditor.add(listenerFunction);
window.tinymce.onRemoveEditor.add(listenerFunction);

In versions 4 and above those functions were removed and I can only see editorInstance.on("remove", callback) which I can add to all the existing editors on the page, but I'm unable to listen for when a new one is added.

Tried using the .on listener on the top level window.tinymce, but no events are fired.


Solution

  • The TinyMCE documentation provides a full list of events that can be used:

    https://www.tiny.cloud/docs/advanced/events

    The specific sort of event you are after is tied to the Editor Manager:

    https://www.tiny.cloud/docs/advanced/events/#editormanagerevents