Ticket #6812: img_captions4.patch
File img_captions4.patch, 14.2 KB (added by , 16 years ago) |
---|
-
wp-admin/js/editor.js
53 53 content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div'); 54 54 content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n'); 55 55 content = content.replace(new RegExp('\\s*\\[wp_caption([^\\[]+)\\[/wp_caption\\]\\s*', 'gi'), '\n\n[wp_caption$1[/wp_caption]\n\n'); 56 content = content.replace(new RegExp('wp_caption\\]\\n\\n+\\[wp_caption', 'g'), 'wp_caption]\n\n[wp_caption'); 56 57 57 58 var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; 58 59 content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); -
wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
127 127 }); 128 128 129 129 // Add Media buttons to fullscreen 130 131 130 ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { 131 if ( 'mceFullScreen' != cmd ) return; 132 132 if ( 'mce_fullscreen' != ed.id ) 133 133 ed.settings.theme_advanced_buttons1 += ',|,add_image,add_video,add_audio,add_media'; 134 134 }); 135 135 136 136 // Add class "alignleft", "alignright" and "aligncenter" when selecting align for images. 137 ed. onExecCommand.add(function( ed, cmd) {138 var n , bl, dom = ed.dom;137 ed.addCommand('JustifyLeft', function() { 138 var n = ed.selection.getNode(); 139 139 140 if ( 'JustifyCenter' == cmd ) { 141 tinymce.each(dom.select('img'), function(n) { 142 var v = n.className; 140 if ( n.nodeName != 'IMG' ) 141 ed.editorCommands.mceJustify('JustifyLeft', 'left'); 142 else ed.plugins.wordpress.do_align(n, 'alignleft'); 143 }); 143 144 144 if (v.indexOf('aligncenter') == -1) { 145 dom.getParent(n, function(P) { 146 if (P && P.style && P.style.textAlign == 'center') 147 dom.setStyle(P, 'textAlign', ''); 148 }); 149 } 150 }); 145 ed.addCommand('JustifyRight', function() { 146 var n = ed.selection.getNode(); 151 147 152 ed.execCommand('mceRepaint'); 153 } 148 if ( n.nodeName != 'IMG' ) 149 ed.editorCommands.mceJustify('JustifyRight', 'right'); 150 else ed.plugins.wordpress.do_align(n, 'alignright'); 154 151 }); 155 152 156 ed. onBeforeExecCommand.add(function( ed, cmd) {157 var n , dir, xdir, bl, dom = ed.dom;153 ed.addCommand('JustifyCenter', function() { 154 var n = ed.selection.getNode(), P = ed.dom.getParent(n, 'p'), DL = ed.dom.getParent(n, 'dl'); 158 155 159 if ( ( cmd.indexOf('Justify') != -1 ) && ( n = ed.selection.getNode() ) ) { 160 if ( 'JustifyFull' == cmd || n.nodeName !== 'IMG' ) return; 161 dir = cmd.substring(7).toLowerCase(); 162 163 if ( ed.queryCommandState( cmd ) ) { 164 n.className = n.className.replace(/align[^ '"]+\s?/g, ''); 165 dom.addClass( n, "alignnone" ); 166 } else if ( 'JustifyCenter' == cmd ) { 167 n.className = n.className.replace(/alignleft\s?|alignright\s?|alignnone\s?/g, ''); 168 if ( dom.hasClass( n, "aligncenter" ) ) { 169 dom.removeClass( n, "aligncenter" ); 170 dom.addClass( n, "alignnone" ); 171 } else 172 dom.addClass( n, "aligncenter" ); 173 174 } else { 175 n.className = n.className.replace(/align[^ '"]+\s?/g, ''); 176 dom.addClass( n, "align"+dir ); 177 } 178 } 156 if ( n.nodeName == 'IMG' && ( P || DL ) ) 157 ed.plugins.wordpress.do_align(n, 'aligncenter'); 158 else ed.editorCommands.mceJustify('JustifyCenter', 'center'); 179 159 }); 180 160 181 182 183 184 185 186 187 188 189 161 // Word count if script is loaded 162 if ( 'undefined' != typeof wpWordCount ) { 163 var last = 0; 164 ed.onKeyUp.add(function(ed, e) { 165 if ( e.keyCode == last ) return; 166 if ( 13 == e.keyCode || 8 == last || 46 == last ) wpWordCount.wc( ed.getContent({format : 'raw'}) ); 167 last = e.keyCode; 168 }); 169 }; 190 170 191 171 // Add listeners to handle more break 192 172 t._handleMoreBreak(ed, url); 193 173 194 174 // Add custom shortcuts … … 227 207 }, 228 208 229 209 // Internal functions 210 do_align : function(n, a) { 211 var P, DL, DIV, cls, c, ed = tinyMCE.activeEditor; 230 212 213 P = ed.dom.getParent(n, 'p'); 214 DL = ed.dom.getParent(n, 'dl'); 215 DIV = ed.dom.getParent(n, 'div'); 216 217 if ( DL && DIV ) { 218 cls = ed.dom.hasClass(DL, a) ? 'alignnone' : a; 219 DL.className = DL.className.replace(/align[^ '"]+\s?/g, ''); 220 ed.dom.addClass(DL, cls); 221 c = (cls == 'aligncenter') ? ed.dom.addClass(DIV, 'mceIEcenter') : ed.dom.removeClass(DIV, 'mceIEcenter'); 222 } else if ( P ) { 223 cls = ed.dom.hasClass(n, a) ? 'alignnone' : a; 224 n.className = n.className.replace(/align[^ '"]+\s?/g, ''); 225 ed.dom.addClass(n, cls); 226 if ( cls == 'aligncenter' ) 227 ed.dom.setStyle(P, 'textAlign', 'center'); 228 else if (P.style && P.style.textAlign == 'center') 229 ed.dom.setStyle(P, 'textAlign', ''); 230 } 231 232 ed.execCommand('mceRepaint'); 233 }, 234 231 235 // Resizes the iframe by a relative height value 232 236 _resizeIframe : function(ed, tb_id, dy) { 233 237 var ifr = ed.getContentAreaContainer().firstChild; -
wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js
21 21 22 22 ed.onInit.add(function(ed) { 23 23 tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) { 24 24 ed.plugins.wpeditimage.hideButtons(); 25 25 }); 26 26 }); 27 27 28 28 ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { 29 29 ed.plugins.wpeditimage.hideButtons(); 30 30 }); 31 31 32 32 ed.onSaveContent.add(function(ed, o) { 33 33 ed.plugins.wpeditimage.hideButtons(); 34 34 }); 35 35 36 36 ed.onMouseUp.add(function(ed, e) { … … 63 63 }); 64 64 65 65 ed.onBeforeSetContent.add(function(ed, o) { 66 67 66 o.content = t._do_shcode(o.content); 67 }); 68 68 69 69 ed.onPostProcess.add(function(ed, o) { 70 70 if (o.get) … … 74 74 75 75 _do_shcode : function(co) { 76 76 return co.replace(/\[wp_caption([^\]]+)\]([\s\S]+?)\[\/wp_caption\][\s\u00a0]*/g, function(a,b,c){ 77 var id = b.match(/id=['"]([^'"]+)/ ), cls = b.match(/align=['"]([^'"]+)/);78 var w = b.match(/width=['"]([0-9]+)/), cap = b.match(/caption=['"]([^'"]+)/ );77 var id = b.match(/id=['"]([^'"]+)/i), cls = b.match(/align=['"]([^'"]+)/i); 78 var w = b.match(/width=['"]([0-9]+)/), cap = b.match(/caption=['"]([^'"]+)/i); 79 79 80 80 id = ( id && id[1] ) ? id[1] : ''; 81 81 cls = ( cls && cls[1] ) ? cls[1] : 'alignnone'; … … 91 91 }, 92 92 93 93 _get_shcode : function(co) { 94 return co.replace(/<div class="mceTemp[^"]*">\s*<dl([^>]+)>\s*<dt[^>]+>([\s\S]+?)<\/dt>\s*<dd[^>]+>([^<]+)<\/dd>\s*<\/dl>\s*<\/div>\s*/g , function(a,b,c,cap){95 var id = b.match(/id=['"]([^'"]+)/ ), cls = b.match(/class=['"]([^'"]+)/);94 return co.replace(/<div class="mceTemp[^"]*">\s*<dl([^>]+)>\s*<dt[^>]+>([\s\S]+?)<\/dt>\s*<dd[^>]+>([^<]+)<\/dd>\s*<\/dl>\s*<\/div>\s*/gi, function(a,b,c,cap){ 95 var id = b.match(/id=['"]([^'"]+)/i), cls = b.match(/class=['"]([^'"]+)/i); 96 96 var w = c.match(/width=['"]([0-9]+)/); 97 97 98 98 id = ( id && id[1] ) ? id[1] : ''; … … 100 100 w = ( w && w[1] ) ? w[1] : ''; 101 101 102 102 if ( ! w || ! cap ) return c; 103 cls = cls ? cls.match(/align[^ '"]+/) : '';103 cls = cls.match(/align[^ '"]+/) || 'alignnone'; 104 104 105 105 return '[wp_caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/wp_caption]'; 106 106 }); 107 107 }, 108 108 109 _fixCenter : function(c) {110 var ed = tinyMCE.activeEditor;111 112 tinymce.each(ed.dom.select('img', c), function(n) {113 if ( ed.dom.hasClass(n, 'aligncenter') ) {114 var P = ed.dom.getParent(n, 'p');115 if ( tinymce.isIE )116 ed.dom.addClass(P, 'mce_iecenter');117 if ( P.style && P.style.textAlign == 'center' )118 ed.dom.setStyle(P, 'textAlign', '');119 }120 });121 },122 123 109 showButtons : function(n) { 124 110 var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y; 125 111 … … 172 158 ed.windowManager.bookmark = ed.selection.getBookmark('simple'); 173 159 ed.execCommand("WP_EditImage"); 174 160 this.parentNode.style.display = 'none'; 175 } 161 }; 176 162 177 163 var wp_delimgbtn = DOM.add('wp_editbtns', 'img', { 178 164 src : t.url+'/img/delete.png', … … 196 182 ed.execCommand('mceRepaint'); 197 183 return false; 198 184 } 199 } 185 }; 200 186 }, 201 187 202 188 getInfo : function() { -
wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js
260 260 if ( DL = dom.getParent(el, 'dl') ) { 261 261 var dlc = ed.dom.getAttrib(DL, 'class'); 262 262 dlc = dlc.match(/align[^ "']+/i); 263 if ( ! dom.hasClass(el, dlc) )263 if ( dlc && ! dom.hasClass(el, dlc) ) 264 264 c += ' '+dlc; 265 265 266 266 tinymce.each(DL.childNodes, function(e) { 267 if ( e.nodeName == 'DD' ) {267 if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp_caption_dd') ) { 268 268 caption = e.innerHTML; 269 269 return; 270 270 } … … 377 377 'class' : img_class 378 378 }); 379 379 380 if ( ! f.link_href.value ) { 381 if ( A ) { 382 b = ed.selection.getBookmark(); 383 ed.dom.remove(A, 1); 384 ed.selection.moveToBookmark(b); 385 } 386 } else { 380 if ( f.link_href.value ) { 387 381 // Create new anchor elements 388 382 if ( A == null ) { 389 if ( ! f.link_href.value.match(/https?:\/\// ) )383 if ( ! f.link_href.value.match(/https?:\/\//i) ) 390 384 f.link_href.value = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.link_href.value); 391 385 392 386 if ( tinymce.isWebKit && ed.dom.hasClass(el, 'aligncenter') ) { … … 431 425 style : 'width: '+cap_width+'px;' 432 426 }); 433 427 434 if ( DIV ) 428 if ( DIV ) 435 429 ed.dom.setAttrib(DIV, 'class', div_cls); 436 430 437 431 if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp_caption_dd') ) 438 432 ed.dom.setHTML(DD, f.img_alt.value); 439 433 440 434 } else { 435 var lnk = '', pa; 441 436 if ( (id = f.img_classes.value.match( /wp-image-([0-9]{1,6})/ )) && id[1] ) 442 437 cap_id = 'attachment_'+id[1]; 443 438 444 if ( f.link_href.value ) html = ed.dom.getOuterHTML(ed.dom.getParent(el, 'a')); 445 else html = ed.dom.getOuterHTML(el); 439 if ( f.link_href.value && (lnk = ed.dom.getParent(el, 'a')) ) { 440 if ( lnk.childNodes.length == 1 ) 441 html = ed.dom.getOuterHTML(lnk); 442 else { 443 html = ed.dom.getOuterHTML(lnk); 444 html = html.match(/<a[^>]+>/i); 445 html = html+ed.dom.getOuterHTML(el)+'</a>'; 446 } 447 } else html = ed.dom.getOuterHTML(el); 446 448 447 449 html = '<dl id="'+cap_id+'" class="wp_caption '+t.align+'" style="width: '+cap_width+ 448 450 'px"><dt class="wp_caption_dt">'+html+'</dt><dd class="wp_caption_dd">'+f.img_alt.value+'</dd></dl>'; … … 451 453 452 454 if ( P ) { 453 455 P.parentNode.insertBefore(cap, P); 454 ed.dom.remove(P); 456 if ( P.childNodes.length == 1 ) 457 ed.dom.remove(P); 458 else if ( lnk && lnk.childNodes.length == 1 ) 459 ed.dom.remove(lnk); 460 else ed.dom.remove(el); 461 } else if ( pa = ed.dom.getParent(el, 'TD,TH,LI') ) { 462 pa.appendChild(cap); 463 if ( lnk && lnk.childNodes.length == 1 ) 464 ed.dom.remove(lnk); 465 else ed.dom.remove(el); 455 466 } 456 467 } 457 468 458 tinyMCEPopup.execCommand("mceEndUndoLevel");459 ed.execCommand('mceRepaint');460 tinyMCEPopup.close();461 return;462 469 } else { 463 470 if ( DL && DIV ) { 464 if ( f.link_href.value ) html = ed.dom.getOuterHTML(ed.dom.getParent(el, 'a')); 471 var aa; 472 if ( f.link_href.value && (aa = ed.dom.getParent(el, 'a')) ) html = ed.dom.getOuterHTML(aa); 465 473 else html = ed.dom.getOuterHTML(el); 466 474 467 475 P = ed.dom.create('p', {}, html); 468 476 DIV.parentNode.insertBefore(P, DIV); 469 477 ed.dom.remove(DIV); … … 478 486 ed.dom.setStyle(P, 'textAlign', ''); 479 487 } 480 488 489 if ( ! f.link_href.value && A ) { 490 b = ed.selection.getBookmark(); 491 ed.dom.remove(A, 1); 492 ed.selection.moveToBookmark(b); 493 } 494 481 495 tinyMCEPopup.execCommand("mceEndUndoLevel"); 482 496 ed.execCommand('mceRepaint'); 483 497 tinyMCEPopup.close(); -
wp-includes/js/tinymce/tiny_mce_config.php
222 222 // Setup cache info 223 223 if ( $disk_cache ) { 224 224 225 $cacheKey = apply_filters('tiny_mce_version', '2008070 3');225 $cacheKey = apply_filters('tiny_mce_version', '20080706'); 226 226 227 227 foreach ( $initArray as $v ) 228 228 $cacheKey .= $v; -
wp-includes/script-loader.php
34 34 $visual_editor = apply_filters('visual_editor', array('tiny_mce')); 35 35 $scripts->add( 'editor', false, $visual_editor, '20080321' ); 36 36 37 $scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '2008070 2' );37 $scripts->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080706' ); 38 38 39 39 // Modify this version when tinyMCE plugins are changed. 40 $mce_version = apply_filters('tiny_mce_version', '2008070 3');40 $mce_version = apply_filters('tiny_mce_version', '20080706'); 41 41 $scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version ); 42 42 43 43 $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');