X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/bf5c68485ef07868ad0a91168ecd0092af7661ae..refs/tags/wordpress-3.4:/wp-admin/js/editor.dev.js diff --git a/wp-admin/js/editor.dev.js b/wp-admin/js/editor.dev.js index 37c79278..93bb6d4f 100644 --- a/wp-admin/js/editor.dev.js +++ b/wp-admin/js/editor.dev.js @@ -62,13 +62,22 @@ var switchEditors = { }, _wp_Nop : function(content) { - var blocklist1, blocklist2; + var blocklist1, blocklist2, preserve_linebreaks = false, preserve_br = false; // Protect pre|script tags if ( content.indexOf(']*>[\s\S]+?<\/\1>/g, function(a) { - a = a.replace(/
(\r\n|\n)?/g, ''); - return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, ''); + a = a.replace(/
(\r\n|\n)?/g, ''); + return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, ''); + }); + } + + // keep
tags inside captions and remove line breaks + if ( content.indexOf('[caption') != -1 ) { + preserve_br = true; + content = content.replace(/\[caption[\s\S]+?\[\/caption\]/g, function(a) { + return a.replace(/]*)>/g, '').replace(/[\r\n\t]+/, ''); }); } @@ -119,13 +128,19 @@ var switchEditors = { content = content.replace(/[\s\u00a0]+$/, ''); // put back the line breaks in pre|script - content = content.replace(//g, '\n'); + if ( preserve_linebreaks ) + content = content.replace(//g, '\n'); + + // and the
tags in captions + if ( preserve_br ) + content = content.replace(/]*)>/g, ''); return content; }, _wp_Autop : function(pee) { - var blocklist = 'table|thead|tfoot|tbody|tr|td|th|caption|col|colgroup|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|fieldset|legend|hr|noscript|menu|samp|header|footer|article|section|hgroup|nav|aside|details|summary'; + var preserve_linebreaks = false, preserve_br = false, + blocklist = 'table|thead|tfoot|tbody|tr|td|th|caption|col|colgroup|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|fieldset|legend|hr|noscript|menu|samp|header|footer|article|section|hgroup|nav|aside|details|summary'; if ( pee.indexOf('/g, function(a){ @@ -139,8 +154,24 @@ var switchEditors = { // Protect pre|script tags if ( pee.indexOf(']*>[\s\S]+?<\/\1>/g, function(a) { - return a.replace(/(\r\n|\n)/g, ''); + return a.replace(/(\r\n|\n)/g, ''); + }); + } + + // keep
tags inside captions and convert line breaks + if ( pee.indexOf('[caption') != -1 ) { + preserve_br = true; + pee = pee.replace(/\[caption[\s\S]+?\[\/caption\]/g, function(a) { + // keep existing
+ a = a.replace(/]*)>/g, ''); + // no line breaks inside HTML tags + a = a.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(b){ + return b.replace(/[\r\n\t]+/, ' '); + }); + // convert remaining line breaks to
+ return a.replace(/\s*\n\s*/g, ''); }); } @@ -172,7 +203,11 @@ var switchEditors = { }); // put back the line breaks in pre|script - pee = pee.replace(//g, '\n'); + if ( preserve_linebreaks ) + pee = pee.replace(//g, '\n'); + + if ( preserve_br ) + pee = pee.replace(/]*)>/g, ''); return pee; }, @@ -203,4 +238,3 @@ var switchEditors = { return o.data; } } -