Make WordPress Core

Changeset 43889 for branches/5.0


Ignore:
Timestamp:
11/12/2018 10:34:50 AM (8 years ago)
Author:
azaozz
Message:

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.

Fixes #45264.

Location:
branches/5.0/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/css/editor.css

    r43784 r43889  
    360360.mce-toolbar .mce-btn-group {
    361361        margin: 0;
     362}
     363
     364/* Classic block hide/show toolbars */
     365.block-library-classic__toolbar .mce-toolbar-grp .mce-toolbar:not(:first-child) {
     366        display: none;
     367}
     368
     369.block-library-classic__toolbar.has-advanced-toolbar .mce-toolbar-grp .mce-toolbar {
     370        display: block;
    362371}
    363372
  • branches/5.0/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r43472 r43889  
    2121        function toggleToolbars( state ) {
    2222                var iframe, initial, toolbars,
    23                         pixels = 0;
    24 
    25                 initial = ( state === 'hide' );
     23                        pixels = 0,
     24                        classicBlockToolbar = tinymce.$( '.block-library-classic__toolbar' );
     25
     26                if ( state === 'hide' ) {
     27                        initial = true;
     28                } else if ( classicBlockToolbar.length && ! classicBlockToolbar.hasClass( 'has-advanced-toolbar' ) ) {
     29                        // Show the second, third, etc. toolbar rows in the Classic block instance.
     30                        classicBlockToolbar.addClass( 'has-advanced-toolbar' );
     31                        state = 'show';
     32                }
    2633
    2734                if ( editor.theme.panel ) {
     
    2936                }
    3037
    31                 if ( ! toolbars || toolbars.length < 2 || ( state === 'hide' && ! toolbars[1].visible() ) ) {
    32                         return;
    33                 }
    34 
    35                 if ( ! state && toolbars[1].visible() ) {
    36                         state = 'hide';
    37                 }
    38 
    39                 each( toolbars, function( toolbar, i ) {
    40                         if ( i > 0 ) {
    41                                 if ( state === 'hide' ) {
    42                                         toolbar.hide();
    43                                         pixels += 30;
    44                                 } else {
    45                                         toolbar.show();
    46                                         pixels -= 30;
    47                                 }
    48                         }
    49                 });
    50 
    51                 if ( pixels && ! initial ) {
    52                         // Resize iframe, not needed in iOS
    53                         if ( ! tinymce.Env.iOS ) {
    54                                 iframe = editor.getContentAreaContainer().firstChild;
    55                                 DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels );
    56                         }
    57 
     38                if ( toolbars && toolbars.length > 1 ) {
     39                        if ( ! state && toolbars[1].visible() ) {
     40                                state = 'hide';
     41                        }
     42
     43                        each( toolbars, function( toolbar, i ) {
     44                                if ( i > 0 ) {
     45                                        if ( state === 'hide' ) {
     46                                                toolbar.hide();
     47                                                pixels += 30;
     48                                        } else {
     49                                                toolbar.show();
     50                                                pixels -= 30;
     51                                        }
     52                                }
     53                        });
     54                }
     55
     56                // Resize editor iframe, not needed for iOS and inline instances.
     57                if ( pixels && ! tinymce.Env.iOS && editor.iframeElement ) {
     58                        DOM.setStyle( editor.iframeElement, 'height', editor.iframeElement.clientHeight + pixels );
     59                }
     60
     61                if ( ! initial ) {
    5862                        if ( state === 'hide' ) {
    59                                 setUserSetting('hidetb', '0');
     63                                setUserSetting( 'hidetb', '0' );
    6064                                wpAdvButton && wpAdvButton.active( false );
    6165                        } else {
    62                                 setUserSetting('hidetb', '1');
     66                                setUserSetting( 'hidetb', '1' );
    6367                                wpAdvButton && wpAdvButton.active( true );
    6468                        }
     
    7478                onPostRender: function() {
    7579                        wpAdvButton = this;
    76                         wpAdvButton.active( getUserSetting( 'hidetb' ) === '1' ? true : false );
     80                        wpAdvButton.active( getUserSetting( 'hidetb' ) === '1' );
    7781                }
    7882        });
     
    8286                if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) {
    8387                        toggleToolbars( 'hide' );
     88                } else {
     89                        tinymce.$( '.block-library-classic__toolbar' ).addClass( 'has-advanced-toolbar' );
    8490                }
    8591        });
     
    427433        });
    428434
    429         // Menubar
    430435        // Insert->Add Media
    431436        if ( wp && wp.media && wp.media.editor ) {
     437                editor.addButton( 'wp_add_media', {
     438                        tooltip: 'Add Media',
     439                        icon: 'dashicon dashicons-admin-media',
     440                        cmd: 'WP_Medialib',
     441                } );
     442
    432443                editor.addMenuItem( 'add_media', {
    433444                        text: 'Add Media',
  • branches/5.0/src/wp-includes/script-loader.php

    r43884 r43889  
    526526                'spellchecker',
    527527                'wp_add_media',
    528                 'kitchensink',
     528                'wp_adv',
    529529        );
    530530
Note: See TracChangeset for help on using the changeset viewer.