diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js index bde22255cc..c42611bb2d 100644 --- a/src/wp-admin/js/editor.js +++ b/src/wp-admin/js/editor.js @@ -122,16 +122,25 @@ blocklist1 = blocklist + '|div|p', blocklist2 = blocklist + '|pre', preserve_linebreaks = false, - preserve_br = false; + preserve_br = false, + preserve = []; if ( ! html ) { return ''; } - // Protect pre|script tags - if ( html.indexOf( '
]*>[\s\S]*?<\/\1>/g, function( match ) {
+ preserve.push( match );
+ return '';
+ } );
+ }
+
+ // Protect pre tags.
+ if ( html.indexOf( ']*>[\s\S]+?<\/\1>/g, function( a ) {
+ html = html.replace( /]*>[\s\S]+?<\/pre>/g, function( a ) {
a = a.replace( /
(\r\n|\n)?/g, '' );
a = a.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '' );
return a.replace( /\r?\n/g, '' );
@@ -205,6 +214,13 @@
html = html.replace( /]*)>/g, '
' );
}
+ // Put back preserved tags.
+ if ( preserve.length ) {
+ html = html.replace( //g, function() {
+ return preserve.shift();
+ } );
+ }
+
return html;
}
diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
index cc95622e48..46fe40594f 100644
--- a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
+++ b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
@@ -90,7 +90,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
window.wpActiveEditor = editor.id;
});
- // Replace Read More/Next Page tags with images
editor.on( 'BeforeSetContent', function( event ) {
var title;
@@ -116,6 +115,21 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
event.content = wp.editor.autop( event.content );
}
+ if ( event.content.indexOf( '