Make WordPress Core

Ticket #28788: 28788.2.patch

File 28788.2.patch, 3.6 KB (added by iseulde, 9 years ago)
  • src/wp-includes/js/mce-view.js

     
    4646                                        '<div class="wpview-loading"><ins></ins></div>' +
    4747                                '</div>';
    4848                },
    49                 render: function() {
    50                         this.setContent(
    51                                 '<p class="wpview-selection-before">\u00a0</p>' +
    52                                 '<div class="wpview-body" contenteditable="false">' +
    53                                         '<div class="toolbar">' +
    54                                                 ( _.isFunction( views[ this.type ].edit ) ? '<div class="dashicons dashicons-edit edit"></div>' : '' ) +
    55                                                 '<div class="dashicons dashicons-no-alt remove"></div>' +
    56                                         '</div>' +
    57                                         '<div class="wpview-content wpview-type-' + this.type + '">' +
    58                                                 ( this.getHtml() || this.loadingPlaceholder() ) +
     49                render: function( force ) {
     50                        if ( force || ! this.rendered() ) {
     51                                this.unbind();
     52
     53                                this.setContent(
     54                                        '<p class="wpview-selection-before">\u00a0</p>' +
     55                                        '<div class="wpview-body" contenteditable="false">' +
     56                                                '<div class="toolbar">' +
     57                                                        ( _.isFunction( views[ this.type ].edit ) ? '<div class="dashicons dashicons-edit edit"></div>' : '' ) +
     58                                                        '<div class="dashicons dashicons-no-alt remove"></div>' +
     59                                                '</div>' +
     60                                                '<div class="wpview-content wpview-type-' + this.type + '">' +
     61                                                        ( this.getHtml() || this.loadingPlaceholder() ) +
     62                                                '</div>' +
     63                                                ( this.overlay ? '<div class="wpview-overlay"></div>' : '' ) +
    5964                                        '</div>' +
    60                                         ( this.overlay ? '<div class="wpview-overlay"></div>' : '' ) +
    61                                 '</div>' +
    62                                 '<p class="wpview-selection-after">\u00a0</p>',
    63                                 'wrap'
    64                         );
     65                                        '<p class="wpview-selection-after">\u00a0</p>',
     66                                        'wrap'
     67                                );
     68
     69                                $( this ).trigger( 'ready' );
    6570
    66                         $( this ).trigger( 'ready' );
     71                                this.rendered( true );
     72                        }
    6773                },
    6874                unbind: function() {},
    6975                getEditors: function( callback ) {
     
    186192                                        '<p>' + message + '</p>' +
    187193                                '</div>'
    188194                        );
     195                },
     196                rendered: function( value ) {
     197                        var notRendered;
     198
     199                        this.getNodes( function( editor, node ) {
     200                                if ( value != null ) {
     201                                        $( node ).data( 'rendered', value === true );
     202                                } else {
     203                                        notRendered = notRendered || ! $( node ).data( 'rendered' );
     204                                }
     205                        } );
     206
     207                        return ! notRendered;
    189208                }
    190209        } );
    191210
     
    386405                                instances[ encodedText ] = instance;
    387406                        }
    388407
    389                         wp.mce.views.render();
     408                        instance.render();
    390409                },
    391410
    392411                getInstance: function( encodedText ) {
     
    402421                 * To generate wrapper elements, pass your content through
    403422                 * `wp.mce.view.toViews( content )`.
    404423                 */
    405                 render: function() {
     424                render: function( force ) {
    406425                        _.each( instances, function( instance ) {
    407                                 instance.render();
     426                                instance.render( force );
    408427                        } );
    409428                },
    410429
     
    434453                        },
    435454
    436455                        fetch: function() {
     456                                var self = this;
     457
    437458                                this.attachments = wp.media.gallery.attachments( this.shortcode, this.postID );
    438                                 this.dfd = this.attachments.more().done( _.bind( this.render, this ) );
     459                                this.dfd = this.attachments.more().done( function() {
     460                                        self.render( true );
     461                                } );
    439462                        },
    440463
    441464                        getHtml: function() {
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    205205                        removeView( selected );
    206206                }
    207207
    208                 if ( ! event.initial ) {
    209                         wp.mce.views.unbind( editor );
    210                 }
    211 
    212208                node = editor.selection.getNode();
    213209
    214210                // When a url is pasted, only try to embed it when pasted in an empty paragrapgh.