From 1bc97d1fe49cf1d0b45f176eef26eea619b51476 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 19 Jan 2014 23:21:07 +0000 Subject: [PATCH] TinyMCE: add a custom jQuery event 'tinymce-editor-init' triggered on initialization of every editor instance. This makes it a lot more convenient to hook into the instance compared to the init.setup callback. See #24067, see #26872. git-svn-id: https://develop.svn.wordpress.org/trunk@26983 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wordpress/plugin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js index 1a2dda3d67..8529c483e1 100644 --- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -310,10 +310,14 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { e.content = e.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, ''); } }); + + if ( typeof window.jQuery !== 'undefined' ) { + window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] ); + } }); // Word count - if ( typeof jQuery !== 'undefined' ) { + if ( typeof window.jQuery !== 'undefined' ) { editor.on( 'keyup', function( e ) { var key = e.keyCode || e.charCode; @@ -322,7 +326,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } if ( 13 === key || 8 === last || 46 === last ) { - jQuery(document).triggerHandler( 'wpcountwords', [ editor.getContent({ format : 'raw' }) ] ); + window.jQuery( document ).triggerHandler( 'wpcountwords', [ editor.getContent({ format : 'raw' }) ] ); } last = key;