Block Editor: Fix the TinyMCE `wordpress` plugin to handle hiding/showing of toolbars in the classic block. Change the classic block toolbar to use the (now fixed) `wp_adv` button.
Props azaozz. Merges [43889] and [43890] to trunk. Fixes #45264. Built from https://develop.svn.wordpress.org/trunk@44247 git-svn-id: http://core.svn.wordpress.org/trunk@44077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8f1ed83852
commit
e8cbdf9405
|
@ -361,6 +361,15 @@ div.mce-toolbar-grp > div {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Classic block hide/show toolbars */
|
||||||
|
.block-library-classic__toolbar .mce-toolbar-grp .mce-toolbar:not(:first-child) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-library-classic__toolbar.has-advanced-toolbar .mce-toolbar-grp .mce-toolbar {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
div.mce-statusbar {
|
div.mce-statusbar {
|
||||||
border-top: 1px solid #e5e5e5;
|
border-top: 1px solid #e5e5e5;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -361,6 +361,15 @@ div.mce-toolbar-grp > div {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Classic block hide/show toolbars */
|
||||||
|
.block-library-classic__toolbar .mce-toolbar-grp .mce-toolbar:not(:first-child) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-library-classic__toolbar.has-advanced-toolbar .mce-toolbar-grp .mce-toolbar {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
div.mce-statusbar {
|
div.mce-statusbar {
|
||||||
border-top: 1px solid #e5e5e5;
|
border-top: 1px solid #e5e5e5;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -19,47 +19,51 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleToolbars( state ) {
|
function toggleToolbars( state ) {
|
||||||
var iframe, initial, toolbars,
|
var initial, toolbars,
|
||||||
pixels = 0;
|
pixels = 0,
|
||||||
|
classicBlockToolbar = tinymce.$( '.block-library-classic__toolbar' );
|
||||||
|
|
||||||
initial = ( state === 'hide' );
|
if ( state === 'hide' ) {
|
||||||
|
initial = true;
|
||||||
|
} else if ( classicBlockToolbar.length && ! classicBlockToolbar.hasClass( 'has-advanced-toolbar' ) ) {
|
||||||
|
// Show the second, third, etc. toolbar rows in the Classic block instance.
|
||||||
|
classicBlockToolbar.addClass( 'has-advanced-toolbar' );
|
||||||
|
state = 'show';
|
||||||
|
}
|
||||||
|
|
||||||
if ( editor.theme.panel ) {
|
if ( editor.theme.panel ) {
|
||||||
toolbars = editor.theme.panel.find('.toolbar:not(.menubar)');
|
toolbars = editor.theme.panel.find('.toolbar:not(.menubar)');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! toolbars || toolbars.length < 2 || ( state === 'hide' && ! toolbars[1].visible() ) ) {
|
if ( toolbars && toolbars.length > 1 ) {
|
||||||
return;
|
if ( ! state && toolbars[1].visible() ) {
|
||||||
}
|
state = 'hide';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! state && toolbars[1].visible() ) {
|
each( toolbars, function( toolbar, i ) {
|
||||||
state = 'hide';
|
if ( i > 0 ) {
|
||||||
}
|
if ( state === 'hide' ) {
|
||||||
|
toolbar.hide();
|
||||||
each( toolbars, function( toolbar, i ) {
|
pixels += 30;
|
||||||
if ( i > 0 ) {
|
} else {
|
||||||
if ( state === 'hide' ) {
|
toolbar.show();
|
||||||
toolbar.hide();
|
pixels -= 30;
|
||||||
pixels += 30;
|
}
|
||||||
} else {
|
|
||||||
toolbar.show();
|
|
||||||
pixels -= 30;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
if ( pixels && ! initial ) {
|
// Resize editor iframe, not needed for iOS and inline instances.
|
||||||
// Resize iframe, not needed in iOS
|
if ( pixels && ! tinymce.Env.iOS && editor.iframeElement ) {
|
||||||
if ( ! tinymce.Env.iOS ) {
|
DOM.setStyle( editor.iframeElement, 'height', editor.iframeElement.clientHeight + pixels );
|
||||||
iframe = editor.getContentAreaContainer().firstChild;
|
}
|
||||||
DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ( ! initial ) {
|
||||||
if ( state === 'hide' ) {
|
if ( state === 'hide' ) {
|
||||||
setUserSetting('hidetb', '0');
|
setUserSetting( 'hidetb', '0' );
|
||||||
wpAdvButton && wpAdvButton.active( false );
|
wpAdvButton && wpAdvButton.active( false );
|
||||||
} else {
|
} else {
|
||||||
setUserSetting('hidetb', '1');
|
setUserSetting( 'hidetb', '1' );
|
||||||
wpAdvButton && wpAdvButton.active( true );
|
wpAdvButton && wpAdvButton.active( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +77,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
cmd: 'WP_Adv',
|
cmd: 'WP_Adv',
|
||||||
onPostRender: function() {
|
onPostRender: function() {
|
||||||
wpAdvButton = this;
|
wpAdvButton = this;
|
||||||
wpAdvButton.active( getUserSetting( 'hidetb' ) === '1' ? true : false );
|
wpAdvButton.active( getUserSetting( 'hidetb' ) === '1' );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,6 +85,8 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
editor.on( 'PostRender', function() {
|
editor.on( 'PostRender', function() {
|
||||||
if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) {
|
if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) {
|
||||||
toggleToolbars( 'hide' );
|
toggleToolbars( 'hide' );
|
||||||
|
} else {
|
||||||
|
tinymce.$( '.block-library-classic__toolbar' ).addClass( 'has-advanced-toolbar' );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -426,9 +432,14 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
stateSelector: 'code'
|
stateSelector: 'code'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Menubar
|
|
||||||
// Insert->Add Media
|
// Insert->Add Media
|
||||||
if ( wp && wp.media && wp.media.editor ) {
|
if ( wp && wp.media && wp.media.editor ) {
|
||||||
|
editor.addButton( 'wp_add_media', {
|
||||||
|
tooltip: 'Add Media',
|
||||||
|
icon: 'dashicon dashicons-admin-media',
|
||||||
|
cmd: 'WP_Medialib'
|
||||||
|
} );
|
||||||
|
|
||||||
editor.addMenuItem( 'add_media', {
|
editor.addMenuItem( 'add_media', {
|
||||||
text: 'Add Media',
|
text: 'Add Media',
|
||||||
icon: 'wp-media-library',
|
icon: 'wp-media-library',
|
||||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -517,7 +517,7 @@ function wp_default_packages_inline_scripts( &$scripts ) {
|
||||||
'wp_more',
|
'wp_more',
|
||||||
'spellchecker',
|
'spellchecker',
|
||||||
'wp_add_media',
|
'wp_add_media',
|
||||||
'kitchensink',
|
'wp_adv',
|
||||||
);
|
);
|
||||||
|
|
||||||
/* This filter is documented in wp-includes/class-wp-editor.php */
|
/* This filter is documented in wp-includes/class-wp-editor.php */
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.1-alpha-44246';
|
$wp_version = '5.1-alpha-44247';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue