Ticket #32078: 32078.2.patch
| File 32078.2.patch, 4.7 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/mce-view.js
93 93 setMarkers: function( content ) { 94 94 var pieces = [ { content: content } ], 95 95 self = this, 96 instance, 97 current; 96 instance, current; 98 97 99 98 _.each( views, function( view, type ) { 100 99 current = pieces.slice(); … … 102 101 103 102 _.each( current, function( piece ) { 104 103 var remaining = piece.content, 105 result ;104 result, text; 106 105 107 106 // Ignore processed pieces, but retain their location. 108 107 if ( piece.processed ) { … … 119 118 } 120 119 121 120 instance = self.createInstance( type, result.content, result.options ); 121 text = instance.loader ? '.' : instance.text; 122 122 123 123 // Add the processed piece for the match. 124 124 pieces.push( { 125 content: '<p data-wpview-marker="' + instance.encodedText + '">' + instance.text + '</p>',125 content: '<p data-wpview-marker="' + instance.encodedText + '">' + text + '</p>', 126 126 processed: true 127 127 } ); 128 128 … … 138 138 } ); 139 139 } ); 140 140 141 return _.pluck( pieces, 'content' ).join( '' ); 141 content = _.pluck( pieces, 'content' ).join( '' ); 142 return content.replace( /<p>\s*<p data-wpview-marker=/g, '<p data-wpview-marker=' ).replace( /<\/p>\s*<\/p>/g, '</p>' ); 142 143 }, 143 144 144 145 /** … … 416 417 */ 417 418 replaceMarkers: function() { 418 419 this.getMarkers( function( editor, node ) { 419 if ( $( node ).text() !== this.text ) { 420 421 if ( ! this.loader && $( node ).text() !== this.text ) { 420 422 editor.dom.setAttrib( node, 'data-wpview-marker', null ); 421 423 return; 422 424 } -
src/wp-includes/js/media-audiovideo.js
704 704 705 705 if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) { 706 706 content += [ 707 '<track srclang="en" label="English" kind="subtitles" src="',707 '<track srclang="en" label="English" kind="subtitles" src="', 708 708 attachment.get( 'url' ), 709 709 '" />' 710 710 ].join(''); -
src/wp-includes/js/media/views/frame/video-details.js
120 120 121 121 if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) { 122 122 content += [ 123 '<track srclang="en" label="English" kind="subtitles" src="',123 '<track srclang="en" label="English" kind="subtitles" src="', 124 124 attachment.get( 'url' ), 125 125 '" />' 126 126 ].join(''); -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
348 348 } 349 349 }); 350 350 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' ) || '' ); 351 function resetViewsCallback( match, viewText ) { 352 return '<p>' + window.decodeURIComponent( viewText ) + '</p>'; 353 } 356 354 357 if ( text && node.parentNode ) { 358 $node.replaceWith( $( editor.dom.create('p') ).text( text ) ); 359 } 355 // Empty the wpview wrap and marker nodes 356 function emptyViews( rootNode ) { 357 $( 'div[data-wpview-text], p[data-wpview-marker]', rootNode ).each( function( i, node ) { 358 node.innerHTML = '.'; 360 359 }); 361 362 // Remove marker attributes363 $( 'p[data-wpview-marker]', rootNode ).attr( 'data-wpview-marker', null );364 360 } 365 361 366 362 editor.on( 'PreProcess', function( event ) { 367 // Replace the view nodes with their text in the DOM clone. 368 resetViews( event.node ); 363 emptyViews( event.node ); 369 364 }, true ); 370 365 371 366 editor.on( 'hide', function() { 372 // Replace the view nodes with their text directly in the editor body.373 367 wp.mce.views.unbind(); 374 368 deselect(); 375 resetViews( editor.getBody());369 emptyViews(); 376 370 }); 377 371 372 editor.on( 'PostProcess', function( event ) { 373 if ( event.content ) { 374 event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g, resetViewsCallback ) 375 .replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback ); 376 } 377 }); 378 378 379 // Excludes arrow keys, delete, backspace, enter, space bar. 379 380 // Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode 380 381 function isSpecialKey( key ) {