mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Add support for line breaks to the caption textareas, see #18311
git-svn-id: https://develop.svn.wordpress.org/trunk@20174 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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('<pre') != -1 || content.indexOf('<script') != -1 ) {
|
||||
preserve_linebreaks = true;
|
||||
content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
|
||||
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp_temp>');
|
||||
return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp_temp>');
|
||||
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-temp-lb>');
|
||||
return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-temp-lb>');
|
||||
});
|
||||
}
|
||||
|
||||
// keep <br> tags inside captions
|
||||
if ( content.indexOf('[caption') != -1 ) {
|
||||
preserve_br = true;
|
||||
content = content.replace(/\[caption[^\]]+\]/g, function(a) {
|
||||
return a.replace(/<br([^>]*)>[\r\n]*/g, '<wp-temp-br$1>');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,7 +128,12 @@ var switchEditors = {
|
||||
content = content.replace(/[\s\u00a0]+$/, '');
|
||||
|
||||
// put back the line breaks in pre|script
|
||||
content = content.replace(/<wp_temp>/g, '\n');
|
||||
if ( preserve_linebreaks )
|
||||
content = content.replace(/<wp-temp-lb>/g, '\n');
|
||||
|
||||
// and the <br> tags in captions
|
||||
if ( preserve_br )
|
||||
content = content.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
|
||||
|
||||
return content;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user