wp/wp-includes/js/tinymce/plugins/wordpress/plugin.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-includes/js/tinymce/plugins/wordpress/plugin.js	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/js/tinymce/plugins/wordpress/plugin.js	Wed Sep 21 18:19:35 2022 +0200
@@ -16,6 +16,8 @@
 		wpTooltips = false;
 
 	if ( $ ) {
+		// Runs as soon as TinyMCE has started initializing, while plugins are loading.
+		// Handlers attached after the `tinymce.init()` call may not get triggered for this instance.
 		$( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
 	}
 
@@ -540,7 +542,11 @@
 		});
 
 		if ( $ ) {
-			$( document ).triggerHandler( 'tinymce-editor-init', [editor] );
+			// Run on DOM ready. Otherwise TinyMCE may initialize earlier and handlers attached
+			// on DOM ready of after the `tinymce.init()` call may not get triggered.
+			$( function() {
+				$( document ).triggerHandler( 'tinymce-editor-init', [editor] );
+			});
 		}
 
 		if ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {