Ticket #29804: 29804.patch
File 29804.patch, 6.2 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-editor.php
946 946 'Keyboard Shortcuts' => __( 'Keyboard Shortcuts' ), 947 947 'Toolbar Toggle' => __( 'Toolbar Toggle' ), 948 948 'Insert Read More tag' => __( 'Insert Read More tag' ), 949 ' Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor949 '(more…)' => __( '(more…)' ), // Title on the placeholder inside the editor 950 950 'Distraction Free Writing' => __( 'Distraction Free Writing' ), 951 951 ); 952 952 -
src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
82 82 }); 83 83 84 84 // Replace Read More/Next Page tags with images 85 editor.on( 'BeforeSetContent', function( e ) {85 editor.on( 'BeforeSetContent', function( event ) { 86 86 var title; 87 87 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…)' ); 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 ) + '" />'; 95 94 }); 96 95 } 97 96 98 if ( e .content.indexOf( '<!--nextpage-->' ) !== -1 ) {97 if ( event.content.indexOf( '<!--nextpage-->' ) !== -1 ) { 99 98 title = editor.editorManager.i18n.translate( 'Page break' ); 100 99 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' ) + '" />' ); 104 101 } 105 102 } 106 103 }); … … 108 105 // Replace images with tags 109 106 editor.on( 'PostProcess', function( e ) { 110 107 if ( e.get ) { 111 e.content = e.content.replace(/< img[^>]+>/g, function( image ) {108 e.content = e.content.replace(/<hr[^>]+>/g, function( image ) { 112 109 var match, moretext = ''; 113 110 114 111 if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) { … … 130 127 editor.on( 'ResolveName', function( event ) { 131 128 var attr; 132 129 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' ) ) ) { 134 131 event.name = attr; 135 132 } 136 133 }); … … 138 135 // Register commands 139 136 editor.addCommand( 'WP_More', function( tag ) { 140 137 var parent, html, title, 141 classname = 'wp-more-tag',142 138 dom = editor.dom, 143 139 node = editor.selection.getNode(); 144 140 145 141 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…)' : 'Page break' ); 143 html = '<hr title="' + title + '" data-wp-more="' + tag + '" />'; 151 144 152 145 // 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' ) ) ) { 154 147 editor.insertContent( html ); 155 148 return; 156 149 } 157 150 158 151 // Get the top level parent node 159 152 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'; 165 154 }, editor.getBody() ); 166 155 167 156 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 ); 174 158 editor.nodeChanged(); 175 159 } 176 160 }); -
src/wp-includes/js/tinymce/skins/wordpress/wp-content.css
131 131 padding: 0; 132 132 } 133 133 134 .mce-content-body img[data-wp-more] { 134 hr[data-wp-more] { 135 background: none; 135 136 border: 0; 136 137 -webkit-box-shadow: none; 137 138 box-shadow: none; 138 width: 96%; 139 height: 16px; 139 width: 100%; 140 height: 22px; 141 font-size: 14px; 142 line-height: 20px; 140 143 display: block; 141 margin: 15px auto0;144 margin: 20px 0; 142 145 outline: 0; 143 cursor: default; 146 cursor: pointer; 147 position: relative; 144 148 } 145 149 146 .mce-content-body img[data-wp-more][data-mce-selected] {147 outline: 1px dotted #888;150 hr[data-wp-more][data-mce-selected] { 151 outline: 1px dotted currentColor; 148 152 } 149 153 150 .mce-content-body img[data-wp-more="more"] { 151 background: transparent url( images/more.png ) repeat-y scroll center center; 154 hr[data-wp-more]:after { 155 content: ''; 156 position: absolute; 157 top: 20px; 158 border-bottom: 2px dashed currentColor; 159 width: 100%; 152 160 } 153 161 154 .mce-content-body img[data-wp-more="nextpage"] { 155 background: transparent url( images/pagebreak.png ) repeat-y scroll center center; 162 hr[data-wp-more]:before { 163 content: attr( title ); 164 position: absolute; 156 165 } 157 166 158 167 /* Gallery, audio, video placeholders */