Make WordPress Core

Changeset 27177


Ignore:
Timestamp:
02/13/2014 08:12:46 PM (11 years ago)
Author:
azaozz
Message:

TinyMCE: add support for audio and video shortcodes without closing, fix jshint warning, see #27016.

Location:
trunk/src/wp-includes/js/tinymce
Files:
2 edited

Legend:

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

    r27169 r27177  
    44    function replaceGalleryShortcodes( content ) {
    55        return content.replace( /\[gallery([^\]]*)\]/g, function( match ) {
    6             var data = window.encodeURIComponent( match );
    7 
    8             return '<img src="' + tinymce.Env.transparentSrc + '" class="wp-media wp-gallery mceItem" ' +
    9                 'data-wp-media="' + data + '" data-mce-resize="false" data-mce-placeholder="1" />';
     6            return html( 'wp-gallery', match );
    107        });
    118    }
    129
     10    function html( cls, data ) {
     11        data = window.encodeURIComponent( data );
     12        return '<img src="' + tinymce.Env.transparentSrc + '" class="wp-media mceItem ' + cls + '" ' +
     13            'data-wp-media="' + data + '" data-mce-resize="false" data-mce-placeholder="1" />';
     14    }
     15
     16    function replaceCallback( match, type, close ) {
     17        var index;
     18
     19        if ( close && close.indexOf( '[' + type ) > -1 ) {
     20            index = match.length - close.length;
     21            return html( 'wp-' + type, match.substring( 0, index ) ) + match.substring( index );
     22        }
     23
     24        return html( 'wp-' + type, match );
     25    }
     26
    1327    function replaceAVShortcodes( content ) {
    14         return content.replace( /\[(audio|video)[^\]]*\][\s\S]*?\[\/\1\]/g, function( match, type ) {
    15             var data = window.encodeURIComponent( match ),
    16                 cls = 'wp-media mceItem wp-' + type;
     28        var testRegex = /\[(audio|video)[^\]]*\]/,
     29            replaceRegex = /\[(audio|video)[^\]]*\]([\s\S]*?\[\/\1\])?/;
    1730
    18             return '<img src="' + tinymce.Env.transparentSrc + '" class="' + cls + '" ' +
    19                 'data-wp-media="' + data + '" data-mce-resize="false" data-mce-placeholder="1" />';
    20         });
     31        while ( testRegex.test( content ) ) {
     32            content = content.replace( replaceRegex, replaceCallback );
     33        }
     34
     35        return content;
    2136    }
    2237
     
    6277        } else {
    6378            // temp
    64             window.console && console.log( 'Edit AV shortcode ' + window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) ) );
     79            window.console && window.console.log( 'Edit AV shortcode ' + window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) ) );
    6580        }
    6681    }
     
    93108            node = event.target;
    94109
     110        function unselect() {
     111            dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' );
     112        }
     113
    95114        if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
    96115            // Don't trigger on right-click
     
    98117                if ( dom.hasClass( node, 'wp-media-selected' ) ) {
    99118                    editMedia( node );
    100                     dom.removeClass( node, 'wp-media-selected' );
    101119                } else {
     120                    unselect();
    102121                    dom.addClass( node, 'wp-media-selected' );
    103122                }
    104123            }
    105124        } else {
    106             dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' );
     125            unselect();
    107126        }
    108127    });
  • trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

    r27169 r27177  
    184184}
    185185
     186.mce-content-body img[data-mce-resize="false"] {
     187    outline: 0;
     188}
     189
    186190img.wp-oembed {
    187191    border: 1px dashed #888;
Note: See TracChangeset for help on using the changeset viewer.