Make WordPress Core

Ticket #22257: 22257.patch

File 22257.patch, 3.5 KB (added by azaozz, 13 years ago)
  • wp-includes/js/mce-view.js

     
    236236                // To render the views, call `wp.mce.view.render( scope )`.
    237237                toViews: function( content ) {
    238238                        var pieces = [ { content: content } ],
    239                                 current;
     239                                current, string = '';
    240240
    241241                        _.each( views, function( view, viewType ) {
    242242                                current = pieces.slice();
     
    254254
    255255                                        // Iterate through the string progressively matching views
    256256                                        // and slicing the string as we go.
    257                                         while ( remaining && (result = view.toView( remaining )) ) {
     257                                        while ( remaining && ( result = view.toView( remaining ) ) ) {
    258258                                                // Any text before the match becomes an unprocessed piece.
    259259                                                if ( result.index )
    260260                                                        pieces.push({ content: remaining.substring( 0, result.index ) });
     
    276276                                });
    277277                        });
    278278
    279                         return _.pluck( pieces, 'content' ).join('');
     279                        // Put the content back together.
     280                        // Add padding before and after a view to allow the caret to go there.
     281                        _.each( pieces, function( piece ) {
     282                                if ( piece.processed ) {
     283                                        // Pad before a view if it's first or the current string doesn't end with a space
     284                                        if ( ! (/[ \uFEFF]$/).test(string) )
     285                                                string += '\uFEFF '
     286
     287                                        string += piece.content;
     288                                        return;
     289                                }
     290
     291                                // Pad after a view if the current piece doesn't begin with a space
     292                                if ( string && ! (/^[ \uFEFF]/).test(piece.content) )
     293                                        string += ' \uFEFF';
     294
     295                                string += piece.content;
     296                        });
     297                       
     298                        // Last bit is a view, pad the end
     299                        if ( pieces[ pieces.length - 1 ].processed )
     300                                string += ' \uFEFF';
     301
     302                        return string;
    280303                },
    281304
    282305                toView: function( viewType, options ) {
     
    300323                        // called in the view's `render` method without a conditional.
    301324                        instance.$wrapper = $();
    302325
     326                        // todo: remove "tag" from options
    303327                        return wp.html.string({
    304                                 // If the view is a span, wrap it in a span.
    305                                 tag: 'span' === instance.tagName ? 'span' : 'div',
    306 
     328                                tag: 'span',
    307329                                attrs: {
    308330                                        'class':           'wp-view-wrap wp-view-type-' + viewType,
    309331                                        'data-wp-view':    id,
     
    344366                // Scans an HTML `content` string and replaces any view instances with
    345367                // their respective text representations.
    346368                toText: function( content ) {
    347                         return content.replace( /<(?:div|span)[^>]+data-wp-view="([^"]+)"[^>]*>.*?<span[^>]+data-wp-view-end[^>]*><\/span><\/(?:div|span)>/g, function( match, id ) {
     369                        return content.replace( /(?:\uFEFF )?<span[^>]+?data-wp-view="([^"]+)"[^>]*>.*?<span[^>]+data-wp-view-end[^>]*><\/span><\/span>(?: \uFEFF)?/g, function( match, id ) {
    348370                                var instance = instances[ id ],
    349371                                        view;
    350372
     
    721743                        }
    722744                }
    723745        });
    724 }(jQuery));
    725  No newline at end of file
     746}(jQuery));
  • wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css

     
    161161        box-shadow: none;
    162162}
    163163
    164 .wp-view-wrap.alignnone {
    165         display: block;
    166 }
    167 
    168164.wp-view-wrap.aligncenter {
    169165        display: block;
    170166        text-align: center;
     
    264260.editor-attachment {
    265261        display: inline-block;
    266262        position: relative;
    267         margin-top: 10px;
    268         margin-right: 10px;
    269263        overflow: hidden;
    270264}
    271265
     
    285279}
    286280
    287281.wp-view-type-gallery {
    288         display: block;
     282        width: 99%;
    289283}
    290284
    291285.editor-gallery {