WordPress.org

Make WordPress Core

Changeset 49996


Ignore:
Timestamp:
01/21/2021 12:29:12 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Editor: Trigger the tinymce-editor-init custom jQuery event on DOM ready.

Otherwise TinyMCE may initialize earlier and handlers attached on DOM ready may not get triggered. Fixes making the editor menu "sticky" and setting/resetting some screen options on the old Edit Post screen.

Props azaozz, majhajob, sabernhardt.
Merges [49911] to the 5.6 branch.
Fixes #52046, #51995.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js

    r47122 r49996  
    1717
    1818    if ( $ ) {
     19        // Runs as soon as TinyMCE has started initializing, while plugins are loading.
     20        // Handlers attached after the `tinymce.init()` call may not get triggered for this instance.
    1921        $( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
    2022    }
     
    541543
    542544        if ( $ ) {
    543             $( document ).triggerHandler( 'tinymce-editor-init', [editor] );
     545            // Run on DOM ready. Otherwise TinyMCE may initialize earlier and handlers attached
     546            // on DOM ready of after the `tinymce.init()` call may not get triggered.
     547            $( function() {
     548                $( document ).triggerHandler( 'tinymce-editor-init', [editor] );
     549            });
    544550        }
    545551
Note: See TracChangeset for help on using the changeset viewer.