Make WordPress Core

Ticket #31158: 31158.2.patch

File 31158.2.patch, 1.4 KB (added by iseulde, 11 years ago)
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    167167        // matching view patterns, and transform the matches into
    168168        // view wrappers.
    169169        editor.on( 'BeforeSetContent', function( event ) {
    170                 var node;
     170                var pastedStr = event.content,
     171                        trim = tinymce.trim,
     172                        node;
    171173
    172                 if ( ! event.content ) {
     174                if ( ! pastedStr ) {
    173175                        return;
    174176                }
    175177
     
    179181
    180182                node = editor.selection.getNode();
    181183
     184                pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
     185                pastedStr = trim( pastedStr );
     186
    182187                // When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
    183                 if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) &&
    184                         ( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) {
    185                         return;
     188                if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {
     189                        event.content = pastedStr;
     190
     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 ) || trim( node.innerText ) ) {
     198                                return;
     199                        }
    186200                }
    187201
    188202                event.content = wp.mce.views.setMarkers( event.content );