Make WordPress Core

Changeset 31732


Ignore:
Timestamp:
03/11/2015 10:40:56 PM (11 years ago)
Author:
azaozz
Message:

TinyMCE: initialize the floating toolbars on preinit so we can attach other events on init.
Props iseulde. Fixes #30619.

Location:
trunk/src/wp-includes/js/tinymce/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

    r31725 r31732  
    11/* global tinymce */
    22tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
    3         var floatingToolbar, serializer,
     3        var toolbar, serializer,
    44                each = tinymce.each,
    55                iOS = tinymce.Env.iOS;
     
    6060        } );
    6161
     62        editor.once( 'preinit', function() {
     63                toolbar = editor.wp._createToolbar( [
     64                        'wp_img_alignleft',
     65                        'wp_img_aligncenter',
     66                        'wp_img_alignright',
     67                        'wp_img_alignnone',
     68                        'wp_img_edit',
     69                        'wp_img_remove'
     70                ] );
     71        } );
     72
    6273        editor.on( 'wptoolbar', function( event ) {
    6374                if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) {
    64                         event.toolbar = floatingToolbar;
     75                        event.toolbar = toolbar;
    6576                }
    6677        } );
     
    7889                                }, 200 );
    7990                        } else {
    80                                 floatingToolbar.hide();
     91                                toolbar.hide();
    8192                        }
    8293                } );
     
    545556                dom.addClass( editor.getBody(), captionClass );
    546557
    547                 if ( editor.wp._createToolbar ) {
    548                         floatingToolbar = editor.wp._createToolbar( [
    549                                 'wp_img_alignleft',
    550                                 'wp_img_aligncenter',
    551                                 'wp_img_alignright',
    552                                 'wp_img_alignnone',
    553                                 'wp_img_edit',
    554                                 'wp_img_remove'
    555                         ] );
    556                 }
    557 
    558558                // Add caption field to the default image dialog
    559559                editor.on( 'wpLoadImageForm', function( event ) {
     
    868868                        event.preventDefault();
    869869
    870                         if ( floatingToolbar ) {
    871                                 floatingToolbar.reposition();
     870                        if ( toolbar ) {
     871                                toolbar.reposition();
    872872                        }
    873873
  • trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    r31725 r31732  
    241241                        MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
    242242
    243                 toolbar = editor.wp._createToolbar( [
    244                         'wp_view_edit',
    245                         'wp_view_remove'
    246                 ] );
    247 
    248243                // When a view is selected, ensure content that is being pasted
    249244                // or inserted is added to a text node (instead of the view).
     
    674669        } );
    675670
     671        editor.once( 'preinit', function() {
     672                toolbar = editor.wp._createToolbar( [
     673                        'wp_view_edit',
     674                        'wp_view_remove'
     675                ] );
     676        } );
     677
    676678        editor.on( 'wptoolbar', function( event ) {
    677679                if ( selected ) {
Note: See TracChangeset for help on using the changeset viewer.