Make WordPress Core

Ticket #28003: 28003.2.patch

File 28003.2.patch, 1.5 KB (added by iseulde, 8 years ago)
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

     
    782782                        }
    783783                });
    784784
    785                 dom.bind( editor.getDoc(), 'dragstart', function( event ) {
    786                         var node = editor.selection.getNode();
    787 
    788                         // Prevent dragging images out of the caption elements
    789                         if ( node.nodeName === 'IMG' && dom.getParent( node, '.wp-caption' ) ) {
    790                                 event.preventDefault();
    791                         }
    792                 });
    793 
    794785                // Prevent IE11 from making dl.wp-caption resizable
    795786                if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) {
    796787                        // The 'mscontrolselect' event is supported only in IE11+
     
    964955                }
    965956        });
    966957
     958        ( function() {
     959                var wrap;
     960
     961                editor.on( 'dragstart', function() {
     962                        var node = editor.selection.getNode();
     963
     964                        if ( node.nodeName === 'IMG' ) {
     965                                wrap = editor.dom.getParent( node, '.mceTemp' );
     966                        }
     967                } );
     968
     969                editor.on( 'drop', function( event ) {
     970                        var rng;
     971
     972                        if ( wrap && ( rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() ) ) ) {
     973                                event.preventDefault();
     974
     975                                editor.undoManager.transact( function() {
     976                                        editor.selection.setRng( rng );
     977                                        editor.selection.setNode( wrap );
     978                                        editor.dom.remove( wrap );
     979                                } );
     980                        }
     981
     982                        wrap = null;
     983                } );
     984        } )();
     985
    967986        // Add to editor.wp
    968987        editor.wp = editor.wp || {};
    969988        editor.wp.isPlaceholder = isPlaceholder;