TinyMCE: when pasting an URL, check if the node it is pasted at is empty and remove any empty inline child elements.
Fixes #31158. Built from https://develop.svn.wordpress.org/trunk@31856 git-svn-id: http://core.svn.wordpress.org/trunk@31835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cedee3dd1c
commit
4bb5d76abc
|
@ -173,13 +173,20 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = editor.selection.getNode();
|
if ( ! event.load ) {
|
||||||
|
node = editor.selection.getNode();
|
||||||
|
|
||||||
// When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
|
if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
|
||||||
if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) &&
|
// When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
|
||||||
( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) {
|
node = editor.dom.getParent( node, 'p' );
|
||||||
|
|
||||||
return;
|
if ( node && /^[\s\uFEFF\u00A0]*$/.test( node.textContent || node.innerText ) ) {
|
||||||
|
// Make sure there are no empty inline elements in the <p>
|
||||||
|
node.innerHTML = '';
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.content = wp.mce.views.setMarkers( event.content );
|
event.content = wp.mce.views.setMarkers( event.content );
|
||||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue