TinyMCE: Fix initialization when the editor is in a postbox by delaying it until `document.readyState === 'complete'`.
Props metalandcoffee, desrosj, patkemper, herrvigg, spikeuk1, dway, mkdgs, azaozz. Fixes #52133, #52050. Built from https://develop.svn.wordpress.org/trunk@51082 git-svn-id: http://core.svn.wordpress.org/trunk@50691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
50fd820621
commit
47fb9c7f3d
|
@ -1663,19 +1663,24 @@ final class _WP_Editors {
|
|||
?>
|
||||
|
||||
( function() {
|
||||
var init, id, $wrap;
|
||||
var initialize = function() {
|
||||
var init, id, inPostbox, $wrap;
|
||||
var readyState = document.readyState;
|
||||
|
||||
if ( typeof tinymce !== 'undefined' ) {
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie < 11 ) {
|
||||
tinymce.$( '.wp-editor-wrap ' ).removeClass( 'tmce-active' ).addClass( 'html-active' );
|
||||
if ( readyState !== 'complete' && readyState !== 'interactive' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( id in tinyMCEPreInit.mceInit ) {
|
||||
init = tinyMCEPreInit.mceInit[id];
|
||||
$wrap = tinymce.$( '#wp-' + id + '-wrap' );
|
||||
init = tinyMCEPreInit.mceInit[id];
|
||||
$wrap = tinymce.$( '#wp-' + id + '-wrap' );
|
||||
inPostbox = $wrap.parents( '.postbox' ).length > 0;
|
||||
|
||||
if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) {
|
||||
if (
|
||||
! init.wp_skip_init &&
|
||||
( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) &&
|
||||
( readyState === 'complete' || ( ! inPostbox && readyState === 'interactive' ) )
|
||||
) {
|
||||
tinymce.init( init );
|
||||
|
||||
if ( ! window.wpActiveEditor ) {
|
||||
|
@ -1685,6 +1690,18 @@ final class _WP_Editors {
|
|||
}
|
||||
}
|
||||
|
||||
if ( typeof tinymce !== 'undefined' ) {
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie < 11 ) {
|
||||
tinymce.$( '.wp-editor-wrap ' ).removeClass( 'tmce-active' ).addClass( 'html-active' );
|
||||
} else {
|
||||
if ( document.readyState === 'complete' ) {
|
||||
initialize();
|
||||
} else {
|
||||
document.addEventListener( 'readystatechange', initialize );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( typeof quicktags !== 'undefined' ) {
|
||||
for ( id in tinyMCEPreInit.qtInit ) {
|
||||
quicktags( tinyMCEPreInit.qtInit[id] );
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-51081';
|
||||
$wp_version = '5.8-alpha-51082';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue