Make WordPress Core

Changeset 35261


Ignore:
Timestamp:
10/18/2015 11:04:33 AM (11 years ago)
Author:
iseulde
Message:

TinyMCE: Drag and drop link with image

Make sure images don't loose their link after drag and drop.

Fixes #28272.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

    r35199 r35261  
    964964                        if ( node.nodeName === 'IMG' ) {
    965965                                wrap = editor.dom.getParent( node, '.mceTemp' );
     966
     967                                if ( ! wrap && node.parentNode.nodeName === 'A' && ! hasTextContent( node.parentNode ) ) {
     968                                        wrap = node.parentNode;
     969                                }
    966970                        }
    967971                } );
    968972
    969973                editor.on( 'drop', function( event ) {
    970                         var rng;
    971 
    972                         if ( wrap && ( rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() ) ) ) {
     974                        var dom = editor.dom,
     975                                rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() );
     976
     977                        // Don't allow anything to be dropped in a captioned image.
     978                        if ( dom.getParent( rng.startContainer, '.mceTemp' ) ) {
    973979                                event.preventDefault();
    974 
    975                                 if ( ! editor.dom.getParent( rng.startContainer, '.mceTemp' ) ) {
    976                                         editor.undoManager.transact( function() {
    977                                                 editor.selection.setRng( rng );
    978                                                 editor.selection.setNode( wrap );
    979                                                 editor.dom.remove( wrap );
    980                                         } );
    981                                 }
     980                        } else if ( wrap ) {
     981                                event.preventDefault();
     982
     983                                editor.undoManager.transact( function() {
     984                                        editor.selection.setRng( rng );
     985                                        editor.selection.setNode( wrap );
     986                                        dom.remove( wrap );
     987                                } );
    982988                        }
    983989
Note: See TracChangeset for help on using the changeset viewer.