Make WordPress Core

Changeset 29317


Ignore:
Timestamp:
07/28/2014 11:44:28 PM (10 years ago)
Author:
azaozz
Message:

TinyMCE:

  • Use data-wp-* for processing and styling of the more and nextpage placeholders, keep the class names for back-compat. Makes them "immune" to "Clear formatting".
  • Translate the titles of the placeholders.

Fixes #28772.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-editor.php

    r29214 r29317  
    945945            'Toolbar Toggle' => __( 'Toolbar Toggle' ),
    946946            'Insert Read More tag' => __( 'Insert Read More tag' ),
     947            'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor
    947948            'Distraction Free Writing' => __( 'Distraction Free Writing' ),
    948949        );
  • trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r29049 r29317  
    3838        });
    3939
    40         if (  pixels && ! initial ) {
     40        if ( pixels && ! initial ) {
    4141            // Resize iframe, not needed in iOS
    4242            if ( ! tinymce.Env.iOS ) {
     
    8484    // Replace Read More/Next Page tags with images
    8585    editor.on( 'BeforeSetContent', function( e ) {
     86        var title;
     87
    8688        if ( e.content ) {
    8789            if ( e.content.indexOf( '<!--more' ) !== -1 ) {
     90                title = editor.editorManager.i18n.translate( 'Read more...' );
     91
    8892                e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
    89                     return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="' + moretext + '" ' +
    90                         'class="wp-more-tag mce-wp-more" title="Read More..." data-mce-resize="false" data-mce-placeholder="1" />';
     93                    return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="more" data-wp-more-text="' + moretext + '" ' +
     94                        'class="wp-more-tag mce-wp-more" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />';
    9195                });
    9296            }
    9397
    9498            if ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
     99                title = editor.editorManager.i18n.translate( 'Page break' );
     100
    95101                e.content = e.content.replace( /<!--nextpage-->/g,
    96                     '<img src="' + tinymce.Env.transparentSrc + '" class="wp-more-tag mce-wp-nextpage" ' +
    97                         'title="Page break" data-mce-resize="false" data-mce-placeholder="1" />' );
     102                    '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" ' +
     103                        'title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' );
    98104            }
    99105        }
     
    106112                var match, moretext = '';
    107113
    108                 if ( image.indexOf('wp-more-tag') !== -1 ) {
    109                     if ( image.indexOf('mce-wp-more') !== -1 ) {
    110                         if ( match = image.match( /data-wp-more="([^"]+)"/ ) ) {
    111                             moretext = match[1];
    112                         }
    113 
    114                         image = '<!--more' + moretext + '-->';
    115                     } else if ( image.indexOf('mce-wp-nextpage') !== -1 ) {
    116                         image = '<!--nextpage-->';
     114                if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) {
     115                    if ( match = image.match( /data-wp-more-text="([^"]+)"/ ) ) {
     116                        moretext = match[1];
    117117                    }
     118
     119                    image = '<!--more' + moretext + '-->';
     120                } else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) {
     121                    image = '<!--nextpage-->';
    118122                }
    119123
     
    124128
    125129    // Display the tag name instead of img in element path
    126     editor.on( 'ResolveName', function( e ) {
    127         var dom = editor.dom,
    128             target = e.target;
    129 
    130         if ( target.nodeName === 'IMG' && dom.hasClass( target, 'wp-more-tag' ) ) {
    131             if ( dom.hasClass( target, 'mce-wp-more' ) ) {
    132                 e.name = 'more';
    133             } else if ( dom.hasClass( target, 'mce-wp-nextpage' ) ) {
    134                 e.name = 'nextpage';
    135             }
     130    editor.on( 'ResolveName', function( event ) {
     131        var attr;
     132
     133        if ( event.target.nodeName === 'IMG' && ( attr = editor.dom.getAttrib( event.target, 'data-wp-more' ) ) ) {
     134            event.name = attr;
    136135        }
    137136    });
     
    146145        tag = tag || 'more';
    147146        classname += ' mce-wp-' + tag;
    148         title = tag === 'more' ? 'More...' : 'Next Page';
     147        title = tag === 'more' ? 'Read more...' : 'Next page';
     148        title = editor.editorManager.i18n.translate( title );
    149149        html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
    150             'data-mce-resize="false" data-mce-placeholder="1" />';
     150            'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />';
    151151
    152152        // Most common case
  • trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

    r29245 r29317  
    123123}
    124124
    125 .mce-content-body img.mce-wp-nextpage,
    126 .mce-content-body img.mce-wp-more {
     125.mce-content-body img[data-wp-more] {
    127126    border: 0;
    128127    -webkit-box-shadow: none;
     
    136135}
    137136
    138 .mce-content-body img.mce-wp-nextpage[data-mce-selected],
    139 .mce-content-body img.mce-wp-more[data-mce-selected] {
     137.mce-content-body img[data-wp-more][data-mce-selected] {
    140138    outline: 1px dotted #888;
    141139}
    142140
    143 .mce-content-body img.mce-wp-more {
     141.mce-content-body img[data-wp-more="more"] {
    144142    background: transparent url( images/more.png ) repeat-y scroll center center;
    145143}
    146144
    147 .mce-content-body img.mce-wp-nextpage {
     145.mce-content-body img[data-wp-more="nextpage"] {
    148146    background: transparent url( images/pagebreak.png ) repeat-y scroll center center;
    149147}
Note: See TracChangeset for help on using the changeset viewer.