Changeset 32678
- Timestamp:
- 06/01/2015 06:08:19 PM (10 years ago)
- Location:
- trunk/src/wp-includes/js
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/mce-view.js
r32258 r32678 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 ) { … … 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. … … 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 } ); … … 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 … … 417 418 replaceMarkers: function() { 418 419 this.getMarkers( function( editor, node ) { 419 if ( $( node ).text() !== this.text ) {420 if ( ! this.loader && $( node ).text() !== this.text ) { 420 421 editor.dom.setAttrib( node, 'data-wpview-marker', null ); 421 422 return; -
trunk/src/wp-includes/js/media-audiovideo.js
r32125 r32678 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 '" />' -
trunk/src/wp-includes/js/media/views/frame/video-details.js
r31935 r32678 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 '" />' -
trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js
r32257 r32678 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 }); 160 161 return content.replace( / data-wpview-marker="[^"]+"/g, '' ); 155 function resetViewsCallback( match, viewText ) { 156 return '<p>' + window.decodeURIComponent( viewText ) + '</p>'; 157 } 158 159 // Replace the view tags with the view string 160 function resetViews( content ) { 161 return content.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*|\.)<\/div>/g, resetViewsCallback ) 162 .replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback ); 162 163 } 163 164 … … 165 166 editor.on( 'BeforeAddUndo', function( event ) { 166 167 if ( event.level.content ) { 167 event.level.content = emptyViews( event.level.content );168 event.level.content = resetViews( event.level.content ); 168 169 } 169 170 }); … … 349 350 }); 350 351 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 } 352 // Empty the wpview wrap and marker nodes 353 function emptyViewNodes( rootNode ) { 354 $( 'div[data-wpview-text], p[data-wpview-marker]', rootNode ).each( function( i, node ) { 355 node.innerHTML = '.'; 360 356 }); 361 362 // Remove marker attributes 363 $( 'p[data-wpview-marker]', rootNode ).attr( 'data-wpview-marker', null ); 364 } 365 357 } 358 359 // Run that before the DOM cleanup 366 360 editor.on( 'PreProcess', function( event ) { 367 // Replace the view nodes with their text in the DOM clone. 368 resetViews( event.node ); 361 emptyViewNodes( event.node ); 369 362 }, true ); 370 363 371 364 editor.on( 'hide', function() { 372 // Replace the view nodes with their text directly in the editor body.373 365 wp.mce.views.unbind(); 374 366 deselect(); 375 resetViews( editor.getBody() ); 367 emptyViewNodes(); 368 }); 369 370 editor.on( 'PostProcess', function( event ) { 371 if ( event.content ) { 372 event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g, resetViewsCallback ) 373 .replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback ); 374 } 376 375 }); 377 376
Note: See TracChangeset
for help on using the changeset viewer.