Make WordPress Core

Ticket #31158: 31158.patch

File 31158.patch, 1.2 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                        node;
    171172
    172                 if ( ! event.content ) {
     173                if ( ! pastedStr ) {
    173174                        return;
    174175                }
    175176
     
    179180
    180181                node = editor.selection.getNode();
    181182
     183                pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
     184                pastedStr = tinymce.trim( pastedStr );
     185
    182186                // 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;
     187                if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {
     188                        event.content = pastedStr;
     189
     190                        if ( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) {
     191                                return;
     192                        }
    186193                }
    187194
    188195                event.content = wp.mce.views.setMarkers( event.content );