Changeset 38039
- Timestamp:
- 07/12/2016 10:08:28 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/editor.js
r35999 r38039 123 123 blocklist2 = blocklist + '|pre', 124 124 preserve_linebreaks = false, 125 preserve_br = false; 125 preserve_br = false, 126 preserve = []; 126 127 127 128 if ( ! html ) { … … 129 130 } 130 131 131 // Protect pre|script tags 132 if ( html.indexOf( '<pre' ) !== -1 || html.indexOf( '<script' ) !== -1 ) { 132 // Preserve script and style tags. 133 if ( html.indexOf( '<script' ) !== -1 || html.indexOf( '<style' ) !== -1 ) { 134 html = html.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match ) { 135 preserve.push( match ); 136 return '<wp-preserve>'; 137 } ); 138 } 139 140 // Protect pre tags. 141 if ( html.indexOf( '<pre' ) !== -1 ) { 133 142 preserve_linebreaks = true; 134 html = html.replace( /< (pre|script)[^>]*>[\s\S]+?<\/\1>/g, function( a ) {143 html = html.replace( /<pre[^>]*>[\s\S]+?<\/pre>/g, function( a ) { 135 144 a = a.replace( /<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>' ); 136 145 a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>' ); … … 204 213 if ( preserve_br ) { 205 214 html = html.replace( /<wp-temp-br([^>]*)>/g, '<br$1>' ); 215 } 216 217 // Put back preserved tags. 218 if ( preserve.length ) { 219 html = html.replace( /<wp-preserve>/g, function() { 220 return preserve.shift(); 221 } ); 206 222 } 207 223 -
trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
r37906 r38039 91 91 }); 92 92 93 // Replace Read More/Next Page tags with images94 93 editor.on( 'BeforeSetContent', function( event ) { 95 94 var title; … … 115 114 if ( event.load && event.format !== 'raw' && hasWpautop ) { 116 115 event.content = wp.editor.autop( event.content ); 116 } 117 118 if ( event.content.indexOf( '<script' ) !== -1 || event.content.indexOf( '<style' ) !== -1 ) { 119 event.content = event.content.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match, tag ) { 120 return '<img ' + 121 'src="' + tinymce.Env.transparentSrc + '" ' + 122 'data-wp-preserve="' + encodeURIComponent( match ) + '" ' + 123 'data-mce-resize="false" ' + 124 'data-mce-placeholder="1" '+ 125 'class="mce-object" ' + 126 'width="20" height="20" '+ 127 'alt="<' + tag + '>" ' + 128 'title="<' + tag + '>" ' + 129 '/>'; 130 } ); 117 131 } 118 132 … … 130 144 }); 131 145 132 // Replace images with tags 133 editor.on( 'PostProcess', function( e ) { 134 if ( e.get ) { 135 e.content = e.content.replace(/<img[^>]+>/g, function( image ) { 136 var match, moretext = ''; 146 editor.on( 'PostProcess', function( event ) { 147 if ( event.get ) { 148 event.content = event.content.replace(/<img[^>]+>/g, function( image ) { 149 var match, 150 string, 151 moretext = ''; 137 152 138 153 if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) { … … 141 156 } 142 157 143 image= '<!--more' + moretext + '-->';158 string = '<!--more' + moretext + '-->'; 144 159 } else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) { 145 image = '<!--nextpage-->'; 146 } 147 148 return image; 160 string = '<!--nextpage-->'; 161 } else if ( image.indexOf( 'data-wp-preserve' ) !== -1 ) { 162 if ( match = image.match( / data-wp-preserve="([^"]+)"/ ) ) { 163 string = decodeURIComponent( match[1] ); 164 } 165 } 166 167 return string || image; 149 168 }); 150 169 }
Note: See TracChangeset
for help on using the changeset viewer.