I managed to do this for modal windows (I need callbacks to open / close), maybe you could build on it to also determine what type of window opens:
tinymce.init({ //... code and setup here setup: function(editor) { editor.on('init',function(e) { setModalEvents(editor); }); }, //... and more here perhaps });
and then the function itself:
// override modal methods to insert events function setModalEvents(editor) { editor.windowManager.oldOpen = editor.windowManager.open; // save for later editor.windowManager.open = function(t,r) { // replace with our own function alert("modal window opened, insert callback here"); var modal = this.oldOpen.apply(this, [t,r]); // call original modal.on('close', function() { // set event for close alert("modal window closed, insert callback here"); }); return modal; // Template plugin is dependent on this return value }; }
you could do similar overrides of other things in the tinymce core, so maybe this could be useful.
source share