Make WordPress Core

Ticket #28788: 28788.patch

File 28788.patch, 2.5 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() {
     49                render: function( force ) {
     50                        if ( this.rendered() && ! force ) {
     51                                return;
     52                        }
     53
     54                        this.unbind();
     55
    5056                        this.setContent(
    5157                                '<p class="wpview-selection-before">\u00a0</p>' +
    5258                                '<div class="wpview-body" contenteditable="false">' +
     
    6470                        );
    6571
    6672                        $( this ).trigger( 'ready' );
     73
     74                        this.rendered( true );
    6775                },
    6876                unbind: function() {},
    6977                getEditors: function( callback ) {
     
    186194                                        '<p>' + message + '</p>' +
    187195                                '</div>'
    188196                        );
     197                },
     198                rendered: function( value ) {
     199                        var notRendered;
     200
     201                        this.getNodes( function( editor, node ) {
     202                                if ( value != null ) {
     203                                        $( node ).data( 'rendered', value === true );
     204                                } else {
     205                                        notRendered = notRendered || ! $( node ).data( 'rendered' );
     206                                }
     207                        } );
     208
     209                        return ! notRendered;
    189210                }
    190211        } );
    191212
     
    386407                                instances[ encodedText ] = instance;
    387408                        }
    388409
    389                         wp.mce.views.render();
     410                        instance.render( true );
    390411                },
    391412
    392413                getInstance: function( encodedText ) {
     
    402423                 * To generate wrapper elements, pass your content through
    403424                 * `wp.mce.view.toViews( content )`.
    404425                 */
    405                 render: function() {
     426                render: function( force ) {
    406427                        _.each( instances, function( instance ) {
    407                                 instance.render();
     428                                instance.render( force );
    408429                        } );
    409430                },
    410431
     
    434455                        },
    435456
    436457                        fetch: function() {
     458                                var self = this;
     459
    437460                                this.attachments = wp.media.gallery.attachments( this.shortcode, this.postID );
    438                                 this.dfd = this.attachments.more().done( _.bind( this.render, this ) );
     461                                this.dfd = this.attachments.more().done( function() {
     462                                        self.render( true );
     463                                } );
    439464                        },
    440465
    441466                        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.