Make WordPress Core

Ticket #40854: 40854.2.diff

File 40854.2.diff, 2.7 KB (added by azaozz, 8 years ago)
  • src/wp-admin/js/editor.js

     
    545545        wp.editor.initialize = function( id, settings ) {
    546546                var init;
    547547                var defaults;
     548                var addMediaButton;
    548549
    549550                if ( ! $ || ! id || ! wp.editor.getDefaultSettings ) {
    550551                        return;
     
    559560                        };
    560561                }
    561562
     563                if ( settings.mediaButtons ) {
     564                        addMediaButton = $( '<button type="button" class="button insert-media add_media">' );
     565                        addMediaButton.append( '<span class="wp-media-buttons-icon"></span>' );
     566                        addMediaButton.append( document.createTextNode( ' ' + 'Add Media' ) ); // @todo i18n, window.tinymce.translate is not available if ! user_can_richedit().
     567                        addMediaButton.data( 'editor', id );
     568                }
     569
    562570                // Add wrap and the Visual|Text tabs.
    563571                if ( settings.tinymce && settings.quicktags ) {
    564572                        var $textarea = $( '#' + id );
     573
    565574                        var $wrap = $( '<div>' ).attr( {
    566575                                        'class': 'wp-core-ui wp-editor-wrap tmce-active',
    567576                                        id: 'wp-' + id + '-wrap'
    568577                                } );
     578
    569579                        var $editorContainer = $( '<div class="wp-editor-container">' );
     580
    570581                        var $button = $( '<button>' ).attr( {
    571582                                        type: 'button',
    572583                                        'data-wp-editor-id': id
    573584                                } );
    574585
     586                        var $editorTools = $( '<div class="wp-editor-tools">' );
     587
     588                        if ( settings.mediaButtons ) {
     589                                $editorTools.append(
     590                                        $( '<div class="wp-media-buttons">' )
     591                                                .append( addMediaButton )
     592                                );
     593                        }
     594
    575595                        $wrap.append(
    576                                 $( '<div class="wp-editor-tools">' )
     596                                $editorTools
    577597                                        .append( $( '<div class="wp-editor-tabs">' )
    578598                                                .append( $button.clone().attr({
    579599                                                        id: id + '-tmce',
  • src/wp-admin/js/widgets/text-widgets.js

     
    230230                                // The user has disabled TinyMCE.
    231231                                if ( typeof window.tinymce === 'undefined' ) {
    232232                                        wp.editor.initialize( id, {
    233                                                 quicktags: true
     233                                                quicktags: true,
     234                                                mediaButtons: true
    234235                                        });
    235236
    236237                                        return;
     
    242243                                        wp.editor.remove( id );
    243244                                }
    244245
     246                                // Add or enable the `wpview` plugin.
     247                                $( document ).one( 'wp-before-tinymce-init.text-widget-init', function( event, init ) {
     248                                        // If somebody has removed all plugins, they must have a good reason.
     249                                        // Keep it that way.
     250                                        if ( ! init.plugins ) {
     251                                                return;
     252                                        } else if ( ! /\bwpview\b/.test( init.plugins ) ) {
     253                                                init.plugins += ',wpview';
     254                                        }
     255                                } );
     256
    245257                                wp.editor.initialize( id, {
    246258                                        tinymce: {
    247259                                                wpautop: true
    248260                                        },
    249                                         quicktags: true
     261                                        quicktags: true,
     262                                        mediaButtons: true
    250263                                });
    251264
    252265                                /**