Make WordPress Core

Ticket #29804: 29804.patch

File 29804.patch, 6.2 KB (added by iseulde, 9 years ago)
  • src/wp-includes/class-wp-editor.php

     
    946946                        'Keyboard Shortcuts' => __( 'Keyboard Shortcuts' ),
    947947                        'Toolbar Toggle' => __( 'Toolbar Toggle' ),
    948948                        'Insert Read More tag' => __( 'Insert Read More tag' ),
    949                         'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor
     949                        '(more…)' => __( '(more…)' ), // Title on the placeholder inside the editor
    950950                        'Distraction Free Writing' => __( 'Distraction Free Writing' ),
    951951                );
    952952
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    8282    });
    8383
    8484        // Replace Read More/Next Page tags with images
    85         editor.on( 'BeforeSetContent', function( e ) {
     85        editor.on( 'BeforeSetContent', function( event ) {
    8686                var title;
    8787
    88                 if ( e.content ) {
    89                         if ( e.content.indexOf( '<!--more' ) !== -1 ) {
    90                                 title = editor.editorManager.i18n.translate( 'Read more...' );
    91 
    92                                 e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
    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" />';
     88                if ( event.content ) {
     89                        if ( event.content.indexOf( '<!--more' ) !== -1 ) {
     90                                title = editor.editorManager.i18n.translate( '(more&hellip;)' );
     91
     92                                event.content = event.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
     93                                        return '<hr data-wp-more="more" data-wp-more-text="' + moretext + '" title="' + ( tinymce.trim( moretext ) || title ) + '" />';
    9594                                });
    9695                        }
    9796
    98                         if ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
     97                        if ( event.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
    9998                                title = editor.editorManager.i18n.translate( 'Page break' );
    10099
    101                                 e.content = e.content.replace( /<!--nextpage-->/g,
    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" />' );
     100                                event.content = event.content.replace( /<!--nextpage-->/g, '<hr data-wp-more="nextpage" title="' + editor.editorManager.i18n.translate( 'Page break' ) + '" />' );
    104101                        }
    105102                }
    106103        });
     
    108105        // Replace images with tags
    109106        editor.on( 'PostProcess', function( e ) {
    110107                if ( e.get ) {
    111                         e.content = e.content.replace(/<img[^>]+>/g, function( image ) {
     108                        e.content = e.content.replace(/<hr[^>]+>/g, function( image ) {
    112109                                var match, moretext = '';
    113110
    114111                                if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) {
     
    130127        editor.on( 'ResolveName', function( event ) {
    131128                var attr;
    132129
    133                 if ( event.target.nodeName === 'IMG' && ( attr = editor.dom.getAttrib( event.target, 'data-wp-more' ) ) ) {
     130                if ( event.target.nodeName === 'HR' && ( attr = editor.dom.getAttrib( event.target, 'data-wp-more' ) ) ) {
    134131                        event.name = attr;
    135132                }
    136133        });
     
    138135        // Register commands
    139136        editor.addCommand( 'WP_More', function( tag ) {
    140137                var parent, html, title,
    141                         classname = 'wp-more-tag',
    142138                        dom = editor.dom,
    143139                        node = editor.selection.getNode();
    144140
    145141                tag = tag || 'more';
    146                 classname += ' mce-wp-' + tag;
    147                 title = tag === 'more' ? 'Read more...' : 'Next page';
    148                 title = editor.editorManager.i18n.translate( title );
    149                 html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
    150                         'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />';
     142                title = editor.editorManager.i18n.translate( tag === 'more' ? '(more&hellip;)' : 'Page break' );
     143                html = '<hr title="' + title + '" data-wp-more="' + tag + '" />';
    151144
    152145                // Most common case
    153                 if ( node.nodeName === 'BODY' || ( node.nodeName === 'P' && node.parentNode.nodeName === 'BODY' ) ) {
     146                if ( node.nodeName === 'BODY' || ( node.parentNode.nodeName === 'BODY' && ( node.nodeName === 'P' ) ) ) {
    154147                        editor.insertContent( html );
    155148                        return;
    156149                }
    157150
    158151                // Get the top level parent node
    159152                parent = dom.getParent( node, function( found ) {
    160                         if ( found.parentNode && found.parentNode.nodeName === 'BODY' ) {
    161                                 return true;
    162                         }
    163 
    164                         return false;
     153                        return found.parentNode && found.parentNode.nodeName === 'BODY';
    165154                }, editor.getBody() );
    166155
    167156                if ( parent ) {
    168                         if ( parent.nodeName === 'P' ) {
    169                                 parent.appendChild( dom.create( 'p', null, html ).firstChild );
    170                         } else {
    171                                 dom.insertAfter( dom.create( 'p', null, html ), parent );
    172                         }
    173 
     157                        editor.$( parent ).after( html );
    174158                        editor.nodeChanged();
    175159                }
    176160        });
  • src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

     
    131131        padding: 0;
    132132}
    133133
    134 .mce-content-body img[data-wp-more] {
     134hr[data-wp-more] {
     135        background: none;
    135136        border: 0;
    136137        -webkit-box-shadow: none;
    137138        box-shadow: none;
    138         width: 96%;
    139         height: 16px;
     139        width: 100%;
     140        height: 22px;
     141        font-size: 14px;
     142        line-height: 20px;
    140143        display: block;
    141         margin: 15px auto 0;
     144        margin: 20px 0;
    142145        outline: 0;
    143         cursor: default;
     146        cursor: pointer;
     147        position: relative;
    144148}
    145149
    146 .mce-content-body img[data-wp-more][data-mce-selected] {
    147         outline: 1px dotted #888;
     150hr[data-wp-more][data-mce-selected] {
     151        outline: 1px dotted currentColor;
    148152}
    149153
    150 .mce-content-body img[data-wp-more="more"] {
    151         background: transparent url( images/more.png ) repeat-y scroll center center;
     154hr[data-wp-more]:after {
     155        content: '';
     156        position: absolute;
     157        top: 20px;
     158        border-bottom: 2px dashed currentColor;
     159        width: 100%;
    152160}
    153161
    154 .mce-content-body img[data-wp-more="nextpage"] {
    155     background: transparent url( images/pagebreak.png ) repeat-y scroll center center;
     162hr[data-wp-more]:before {
     163        content: attr( title );
     164        position: absolute;
    156165}
    157166
    158167/* Gallery, audio, video placeholders */