Make WordPress Core

Ticket #39337: 39337.2.patch

File 39337.2.patch, 1.4 KB (added by azaozz, 6 years ago)
  • src/wp-includes/js/mce-view.js

     
    116116                                                }
    117117
    118118                                                instance = self.createInstance( type, result.content, result.options );
    119                                                 text = instance.loader ? '.' : instance.text;
     119                                                text = instance.text;
    120120
    121121                                                // Add the processed piece for the match.
    122122                                                pieces.push( {
     
    428428                 */
    429429                replaceMarkers: function() {
    430430                        this.getMarkers( function( editor, node ) {
    431                                 var $viewNode;
     431                                var viewNode;
    432432
    433433                                if ( ! this.loader && $( node ).text() !== this.text ) {
    434434                                        editor.dom.setAttrib( node, 'data-wpview-marker', null );
     
    435435                                        return;
    436436                                }
    437437
    438                                 $viewNode = editor.$(
    439                                         '<div class="wpview wpview-wrap" data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '" contenteditable="false"></div>'
    440                                 );
     438                                viewNode = editor.dom.create( 'div', {
     439                                        'class': 'wpview wpview-wrap',
     440                                        'data-wpview-text': this.encodedText,
     441                                        'data-wpview-type': this.type,
     442                                        'contenteditable': 'false'
     443                                } );                                   
    441444
    442                                 editor.$( node ).replaceWith( $viewNode );
     445                                editor.$( node ).replaceWith( viewNode );
     446
     447                                if ( ! viewNode.nextSibling ) {
     448                                        editor.selection.select( viewNode );
     449
     450                                        setTimeout( function() {
     451                                                editor.selection.collapse();
     452                                        } );
     453                                }
    443454                        } );
    444455                },
    445456