Ticket #32078: 32078.3.patch
| File 32078.3.patch, 4.9 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/mce-view.js
102 102 103 103 _.each( current, function( piece ) { 104 104 var remaining = piece.content, 105 result ;105 result, text; 106 106 107 107 // Ignore processed pieces, but retain their location. 108 108 if ( piece.processed ) { … … 119 119 } 120 120 121 121 instance = self.createInstance( type, result.content, result.options ); 122 text = instance.loader ? '.' : instance.text; 122 123 123 124 // Add the processed piece for the match. 124 125 pieces.push( { 125 content: '<p data-wpview-marker="' + instance.encodedText + '">' + instance.text + '</p>',126 content: '<p data-wpview-marker="' + instance.encodedText + '">' + text + '</p>', 126 127 processed: true 127 128 } ); 128 129 … … 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/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/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/tinymce/plugins/wpview/plugin.js
152 152 }; 153 153 } 154 154 155 // Remove the content of view wrappers from HTML string 156 function emptyViews( content ) { 157 content = content.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*<\/div>/g, function( all, match ) { 158 return '<p>' + window.decodeURIComponent( match ) + '</p>'; 159 }); 155 function resetViewsCallback( match, viewText ) { 156 return '<p>' + window.decodeURIComponent( viewText ) + '</p>'; 157 } 160 158 161 return content.replace( / data-wpview-marker="[^"]+"/g, '' ); 159 // Remove the content of view wrappers from HTML string 160 function resetViews( content ) { 161 return content 162 .replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*<\/div>/g, resetViewsCallback ) 163 .replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]+?<\/p>/g, resetViewsCallback ); 162 164 } 163 165 164 166 // Prevent adding undo levels on changes inside a view wrapper 165 167 editor.on( 'BeforeAddUndo', function( event ) { 166 168 if ( event.level.content ) { 167 event.level.content = emptyViews( event.level.content );169 event.level.content = resetViews( event.level.content ); 168 170 } 169 } );171 } ); 170 172 171 173 // When the editor's content changes, scan the new content for 172 174 // matching view patterns, and transform the matches into … … 348 350 } 349 351 }); 350 352 351 function resetViews( rootNode ) {352 // Replace view nodes353 $( '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 }360 });361 362 // Remove marker attributes363 $( '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 );369 }, true );370 371 353 editor.on( 'hide', function() { 372 // Replace the view nodes with their text directly in the editor body.373 354 wp.mce.views.unbind(); 374 355 deselect(); 375 resetViews( editor.getBody() ); 376 }); 356 $( '.wpview-content' ).empty(); 357 } ); 358 359 editor.on( 'PostProcess', function( event ) { 360 event.content = resetViews( event.content ); 361 } ); 377 362 378 363 // Excludes arrow keys, delete, backspace, enter, space bar. 379 364 // Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode