mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
TinyMCE: Drag and drop link with image
Make sure images don't loose their link after drag and drop. Fixes #28272. Built from https://develop.svn.wordpress.org/trunk@35261 git-svn-id: http://core.svn.wordpress.org/trunk@35227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
532e1fb856
commit
9845e08340
@ -963,22 +963,28 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||||||
|
|
||||||
if ( node.nodeName === 'IMG' ) {
|
if ( node.nodeName === 'IMG' ) {
|
||||||
wrap = editor.dom.getParent( node, '.mceTemp' );
|
wrap = editor.dom.getParent( node, '.mceTemp' );
|
||||||
|
|
||||||
|
if ( ! wrap && node.parentNode.nodeName === 'A' && ! hasTextContent( node.parentNode ) ) {
|
||||||
|
wrap = node.parentNode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
editor.on( 'drop', function( event ) {
|
editor.on( 'drop', function( event ) {
|
||||||
var rng;
|
var dom = editor.dom,
|
||||||
|
rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() );
|
||||||
|
|
||||||
if ( wrap && ( rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() ) ) ) {
|
// Don't allow anything to be dropped in a captioned image.
|
||||||
|
if ( dom.getParent( rng.startContainer, '.mceTemp' ) ) {
|
||||||
|
event.preventDefault();
|
||||||
|
} else if ( wrap ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if ( ! editor.dom.getParent( rng.startContainer, '.mceTemp' ) ) {
|
editor.undoManager.transact( function() {
|
||||||
editor.undoManager.transact( function() {
|
editor.selection.setRng( rng );
|
||||||
editor.selection.setRng( rng );
|
editor.selection.setNode( wrap );
|
||||||
editor.selection.setNode( wrap );
|
dom.remove( wrap );
|
||||||
editor.dom.remove( wrap );
|
} );
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap = null;
|
wrap = null;
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-35260';
|
$wp_version = '4.4-alpha-35261';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user