Make WordPress Core

Ticket #31158: 31158.4.patch

File 31158.4.patch, 1.2 KB (added by azaozz, 11 years ago)
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    173173                        return;
    174174                }
    175175
    176                 node = editor.selection.getNode();
     176                if ( ! event.load ) {
     177                        node = editor.selection.getNode();
    177178
    178                 // When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
    179                 if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) &&
    180                         ( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) {
     179                        if ( node && node.nodeName !== 'BODY' && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
     180                                // When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
     181                                node = editor.dom.getParent( node, 'p' );
    181182
    182                         return;
     183                                if ( node && /^[\s\uFEFF\u00A0]*$/.test( node.textContent || node.innerText ) ) {
     184                                        // Make sure there are no empty inline elements in the <p>
     185                                        node.innerHTML = '';
     186                                } else {
     187                                        return;
     188                                }
     189                        }
    183190                }
    184191
    185192                event.content = wp.mce.views.setMarkers( event.content );