Make WordPress Core

Ticket #32078: 32078.patch

File 32078.patch, 4.0 KB (added by azaozz, 11 years ago)
  • src/wp-includes/js/mce-view.js

     
    9393                setMarkers: function( content ) {
    9494                        var pieces = [ { content: content } ],
    9595                                self = this,
    96                                 instance,
    97                                 current;
     96                                instance, current;
    9897
    9998                        _.each( views, function( view, type ) {
    10099                                current = pieces.slice();
     
    138137                                } );
    139138                        } );
    140139
    141                         return _.pluck( pieces, 'content' ).join( '' );
     140                        content = _.pluck( pieces, 'content' ).join( '' );
     141                        return content.replace( /<p>\s*<p data-wpview-marker=/g, '<p data-wpview-marker=' ).replace( /<\/p>\s*<\/p>/g, '</p>' );
    142142                },
    143143
    144144                /**
     
    416416                 */
    417417                replaceMarkers: function() {
    418418                        this.getMarkers( function( editor, node ) {
    419                                 if ( $( node ).text() !== this.text ) {
     419                                if ( ! this.shortcode && $( node ).html() !== this.text ) {
    420420                                        editor.dom.setAttrib( node, 'data-wpview-marker', null );
    421421                                        return;
    422422                                }
  • src/wp-includes/js/media-audiovideo.js

     
    704704
    705705                        if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
    706706                                content += [
    707                                         '<track srclang="en" label="English"kind="subtitles" src="',
     707                                        '<track srclang="en" label="English" kind="subtitles" src="',
    708708                                        attachment.get( 'url' ),
    709709                                        '" />'
    710710                                ].join('');
  • src/wp-includes/js/media/views/frame/video-details.js

     
    120120
    121121                        if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
    122122                                content += [
    123                                         '<track srclang="en" label="English"kind="subtitles" src="',
     123                                        '<track srclang="en" label="English" kind="subtitles" src="',
    124124                                        attachment.get( 'url' ),
    125125                                        '" />'
    126126                                ].join('');
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    348348                }
    349349        });
    350350
    351         function resetViews( rootNode ) {
    352                 // Replace view nodes
    353                 $( 'div[data-wpview-text]', rootNode ).each( function( i, node ) {
    354                         var $node = $( node ),
    355                                 text = window.decodeURIComponent( $node.attr( 'data-wpview-text' ) || '' );
    356 
    357                         if ( text && node.parentNode ) {
    358                                 $node.replaceWith( $( editor.dom.create('p') ).text( text ) );
    359                         }
     351        editor.on( 'PreProcess', function( event ) {
     352                // Empty the wpview wrap and marker nodes
     353                $( 'div[data-wpview-text], p[data-wpview-marker]', event.node ).each( function( i, node ) {
     354                        node.innerHTML = ',';
    360355                });
    361 
    362                 // Remove marker attributes
    363                 $( 'p[data-wpview-marker]', rootNode ).attr( 'data-wpview-marker', null );
    364         }
    365 
    366         editor.on( 'PreProcess', function( event ) {
    367                 // Replace the view nodes with their text in the DOM clone.
    368                 resetViews( event.node );
    369356        }, true );
    370357
    371358        editor.on( 'hide', function() {
    372                 // Replace the view nodes with their text directly in the editor body.
    373359                wp.mce.views.unbind();
    374360                deselect();
    375                 resetViews( editor.getBody() );
    376361        });
    377362
     363        function resetViewsCallback( match, viewText ) {
     364                return '<p>' + window.decodeURIComponent( viewText ) + '</p>';
     365        }
     366
     367        editor.on( 'PostProcess', function( event ) {
     368                if ( event.content ) {
     369                        event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g, resetViewsCallback )
     370                                .replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback );
     371                }
     372        });
     373
    378374        // Excludes arrow keys, delete, backspace, enter, space bar.
    379375        // Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
    380376        function isSpecialKey( key ) {