Ticket #31158: 31158.3.patch
| File 31158.3.patch, 2.0 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
167 167 // matching view patterns, and transform the matches into 168 168 // view wrappers. 169 169 editor.on( 'BeforeSetContent', function( event ) { 170 var pastedStr = event.content, 171 trim = tinymce.trim, 172 node; 170 var node; 173 171 174 if ( ! pastedStr) {172 if ( ! event.content ) { 175 173 return; 176 174 } 177 175 178 if ( selected ) {179 removeView( selected );180 }181 182 176 node = editor.selection.getNode(); 183 177 184 pastedStr = pastedStr.replace( /<[^>]+>/g, '' );185 pastedStr = trim( pastedStr );186 187 178 // When a url is pasted, only try to embed it when pasted in an empty paragrapgh. 188 if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {189 event.content = pastedStr;179 if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) && 180 ( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) { 190 181 191 node = editor.dom.getParent( node, function( node ) { 192 if ( node.parentNode === editor.getBody() ) { 193 return node; 194 } 195 } ); 196 197 if ( node.nodeName !== 'P' || trim( node.textContent || node.innerText ) ) { 198 return; 199 } 182 return; 200 183 } 201 184 202 185 event.content = wp.mce.views.setMarkers( event.content ); 203 186 }); 204 187 188 // When pasting strip all tags and check if the string is an URL. 189 // Then replace the pasted content with the cleaned URL. 190 editor.on( 'pastePreProcess', function( event ) { 191 var pastedStr = event.content; 192 193 if ( pastedStr ) { 194 pastedStr = tinymce.trim( pastedStr.replace( /<[^>]+>/g, '' ) ); 195 196 if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) { 197 event.content = pastedStr; 198 } 199 } 200 }); 201 205 202 // When the editor's content has been updated and the DOM has been 206 203 // processed, render the views in the document. 207 204 editor.on( 'SetContent', function() {
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)