Make WordPress Core

Ticket #27527: 27527-01.patch

File 27527-01.patch, 2.3 KB (added by gcorne, 12 years ago)
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

    diff --git src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
    index 3ba19b4..63afb3a 100644
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    102102                        });
    103103
    104104                        if ( out.indexOf('[caption') !== 0 ) {
    105                                 // the caption html seems brocken, try to find the image that may be wrapped in a link
     105                                // the caption html seems broken, try to find the image that may be wrapped in a link
    106106                                // and may be followed by <p> with the caption text.
    107107                                out = b.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
    108108                        }
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    339339                } else {
    340340                        editor.dom.remove( node );
    341341                }
     342                removeToolbar();
    342343        }
    343344
    344345        function addToolbar( node ) {
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    755756                        selection = editor.selection,
    756757                        dom = editor.dom;
    757758
     759                node = selection.getNode();
     760
    758761                if ( event.keyCode === tinymce.util.VK.ENTER ) {
    759762                        // When pressing Enter inside a caption move the caret to a new parapraph under it
    760                         node = selection.getNode();
    761763                        wrap = dom.getParent( node, 'div.mceTemp' );
    762764
    763765                        if ( wrap ) {
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    783785                                selection.setCursorLocation( P, 0 );
    784786                        }
    785787                } else if ( event.keyCode === tinymce.util.VK.DELETE || event.keyCode === tinymce.util.VK.BACKSPACE ) {
    786                         node = selection.getNode();
    787788
    788789                        if ( node.nodeName === 'DIV' && dom.hasClass( node, 'mceTemp' ) ) {
    789790                                wrap = node;
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    797798                                return false;
    798799                        }
    799800                }
     801
     802                // Key presses will replace the image so we need to remove the toolbar
     803                if ( dom.getAttrib( node, 'data-wp-imgselect' ) ) {
     804                        removeToolbar();
     805                }
    800806        });
    801807
    802808        editor.on( 'mousedown', function( event ) {
    tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 
    828834
    829835                                if ( dom.hasClass( node, 'remove' ) ) {
    830836                                        removeImage( image );
    831                                         removeToolbar();
    832837                                } else if ( dom.hasClass( node, 'edit' ) ) {
    833838                                        editImage( image );
    834839                                }