Changeset 7716
- Timestamp:
- 04/17/2008 07:11:21 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/editor.js
r7513 r7716 14 14 15 15 saveCallback : function(el, content, body) { 16 16 17 17 document.getElementById(el).style.color = '#fff'; 18 18 if ( tinyMCE.activeEditor.isHidden() ) … … 27 27 // We have a TON of cleanup to do. Line breaks are already stripped. 28 28 29 // Protect pre|script tags 30 content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { 31 a = a.replace(/<br ?\/?>[\r\n]*/g, '<wp_temp>'); 32 return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>'); 33 }); 34 29 35 // Pretty it up for the source editor 30 var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p re|p';36 var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p'; 31 37 content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n'); 32 38 content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); … … 47 53 content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div'); 48 54 content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n'); 49 55 50 56 var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; 51 57 content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); … … 65 71 content = content.replace(new RegExp('^\\s*', ''), ''); 66 72 content = content.replace(new RegExp('\\s*$', ''), ''); 73 74 // put back the line breaks in pre|script 75 content = content.replace(/<wp_temp>/g, '\n'); 67 76 68 77 // Hope. … … 110 119 } 111 120 112 121 ta.style.color = ''; 113 122 this.wpSetDefaultEditor('html'); 114 123 } … … 149 158 pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1"); 150 159 pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1"); 151 pee = pee.replace(new RegExp('<p> <blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");152 pee = pee.replace(new RegExp('</blockquote> </p>', 'gi'), '</p></blockquote>');160 pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>"); 161 pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>'); 153 162 pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1"); 154 163 pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1"); … … 156 165 pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1"); 157 166 pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1'); 158 pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); 159 //pee = pee.replace(new RegExp('(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' "); // Hmm... 160 return pee; 167 // pee = pee.replace(new RegExp('^((?: )*)\\s', 'mg'), '$1 '); 168 169 // Fix the pre|script tags 170 pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) { 171 a = a.replace(/<br ?\/?>[\r\n]*/g, '\n'); 172 return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n'); 173 }); 174 175 return pee; 161 176 } 162 177 }
Note: See TracChangeset
for help on using the changeset viewer.