]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
WordPress 4.3
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wpeditimage / plugin.js
index 025603b41ef91a4842669b90338ed49ff85c7fe7..662a92a1edfc202c60e45921ae75be0dcc597ac3 100644 (file)
@@ -2,6 +2,7 @@
 tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
        var toolbar, serializer,
                each = tinymce.each,
+               trim = tinymce.trim,
                iOS = tinymce.Env.iOS;
 
        function isPlaceholder( node ) {
@@ -95,8 +96,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
 
        function parseShortcode( content ) {
                return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
-                       var id, align, classes, caption, img, width,
-                               trim = tinymce.trim;
+                       var id, align, classes, caption, img, width;
 
                        id = b.match( /id=['"]([^'"]*)['"] ?/ );
                        if ( id ) {
@@ -525,12 +525,10 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
        }
 
        function removeImage( node ) {
-               var wrap;
+               var wrap = editor.dom.getParent( node, 'div.mceTemp' );
 
-               if ( node.nodeName === 'DIV' && editor.dom.hasClass( node, 'mceTemp' ) ) {
-                       wrap = node;
-               } else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) {
-                       wrap = editor.dom.getParent( node, 'div.mceTemp' );
+               if ( ! wrap && node.nodeName === 'IMG' ) {
+                       wrap = editor.dom.getParent( node, 'a' );
                }
 
                if ( wrap ) {
@@ -865,7 +863,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
                                replacement = ' ' + align;
                        }
 
-                       node.className = node.className.replace( / ?align(left|center|right|none)/g, '' ) + replacement;
+                       node.className = trim( node.className.replace( / ?align(left|center|right|none)/g, '' ) + replacement );
 
                        editor.nodeChanged();
                        event.preventDefault();