Ticket #21812: 21812-2.patch
File 21812-2.patch, 10.1 KB (added by , 12 years ago) |
---|
-
wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js
7 7 8 8 tinymce.create('tinymce.plugins.WordPress', { 9 9 mceTout : 0, 10 previews : {i: 0}, 11 reg_previews : [], 10 12 11 13 init : function(ed, url) { 12 var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML, closeOnClick, mod_key; 14 var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML, closeOnClick, mod_key, 15 _step_2, each = tinymce.each; 16 13 17 moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />'; 14 18 nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />'; 15 19 16 if ( getUserSetting('hidetb', '0') == '1' ) 20 t.ed = ed; 21 22 if ( typeof(getUserSetting) == 'function' && getUserSetting('hidetb', '0') == '1' ) 17 23 ed.settings.wordpress_adv_hidden = 0; 18 24 19 25 // Hides the specified toolbar and resizes the iframe … … 251 257 // Add custom shortcuts 252 258 mod_key = 'alt+shift'; 253 259 254 // if ( tinymce.isGecko ) // disable for mow, too many shortcuts conflicts255 // mod_key = 'ctrl+alt';256 257 260 ed.addShortcut(mod_key + '+c', 'justifycenter_desc', 'JustifyCenter'); 258 261 ed.addShortcut(mod_key + '+r', 'justifyright_desc', 'JustifyRight'); 259 262 ed.addShortcut(mod_key + '+l', 'justifyleft_desc', 'JustifyLeft'); … … 313 316 // close popups when clicking on the background 314 317 tinymce.dom.Event.remove(document.body, 'click', closeOnClick); 315 318 tinymce.dom.Event.add(document.body, 'click', closeOnClick); 319 320 321 /* testing */ 322 ed.onPreInit.add( function(ed){ 323 ed.schema.addValidElements('div[*]'); // so we can set contenteditable=false 324 325 // add custom jQuery event so plugins can do: 326 // jQuery(document).on( 'wp_add_mce_previews', function(e, ed){ ed.wpPreviewRegister(args) } ); 327 if ( typeof(jQuery) != 'undefined' ) 328 jQuery(document).trigger( 'wp_add_mce_previews', ed ); 329 }); 330 331 // runs on paste and on inserting nodes/html (on send_to_editor) 332 ed.onInit.add(function(ed) { 333 ed.selection.onSetContent.add(function(sel, o) { 334 var node; 335 336 if ( o.context && t.reg_previews.length ) { 337 node = sel.getNode(); 338 339 if ( node.innerHTML ) 340 node.innerHTML = ed.wpPreviewAdd(node.innerHTML); 341 } 342 }); 343 }); 344 345 // runs every time content is loaded in the editor 346 ed.onBeforeSetContent.add(function(ed, o) { 347 if ( o.content ) 348 o.content = ed.wpPreviewAdd(o.content); 349 }); 350 351 ed.onPostProcess.add(function(ed, o) { 352 if ( ( o.get || o.save ) && o.content.indexOf('data-wp-preview="') > -1 ) { 353 o.content = o.content.replace(/(<div[^>]+data-wp-preview="([^"]+)"[^>]*>)[\s\S]+?<\/div><div data-wp-preview-end[^<]+<\/div><\/div>/g, function(a, b, c){ 354 var previews = t.previews, str = '<p>'+ decodeURIComponent(c) +'</p>', div_id = b.replace(/.+id="([^"]+)".+/, '$1'); 355 356 if ( previews[div_id] && previews[div_id].cleanup_callback ) 357 str = previews[div_id].cleanup_callback.call( t, { ed: ed, original: str } ); 358 359 return str; 360 }); 361 } 362 }); 363 364 _step_2 = function() { 365 var _previews = {}; 366 367 // go through the added previews and fire callbacks 368 each(t.previews, function(args, div_id){ 369 var node = typeof(args) == 'object' && div_id != 'i' ? ed.dom.select('#'+div_id) : null, wrap; 370 371 if ( !node || !node.length ) 372 return; 373 374 // reset the previews references 375 _previews[div_id] = args; 376 wrap = ed.dom.select('.wp-preview', node[0]); 377 378 if ( args.node_callback ) { // use the inner wrapper as node in the callback 379 args.node_callback.call( t, { ed: ed, node: wrap[0], div_id: div_id } ); 380 } 381 if ( args.onmousedown ) { 382 ed.dom.events.add( node, 'mousedown', args.onmousedown ); 383 } 384 if ( args.onmouseup ) { 385 ed.dom.events.add( node, 'mouseup', args.onmouseup ); 386 } 387 if ( args.onclick ) { 388 ed.dom.events.add( node, 'click', args.onclick ); 389 } 390 }); 391 392 _previews.i = t.previews.i; 393 t.previews = _previews; 394 } 395 396 // register all previews 397 ed.wpPreviewRegister = function(args) { 398 t.reg_previews.push(args); 399 }; 400 401 /* 402 args = { 403 preview_regexp: /\[gallery[^\]]*\]/, 404 str_callback: function(obj){ console.log('str_callback'); console.log(obj); return obj.original+' 123 ' }, 405 node_callback: function(obj){ console.log('node_callback'); console.log(obj) }, 406 cleanup_callback: function(obj){ console.log('cleanup_callback'); console.log(obj); return obj.original }, 407 onmousedown: function(e){ console.log('onmousedown'); console.log(e) }, 408 onmouseup: function(e){ console.log('onmouseup'); console.log(e) }, 409 onclick: function(e){ console.log('onclick'); console.log(e) } 410 } 411 */ 412 ed.wpPreviewAdd = function(content) { 413 var previews = t.previews; 414 415 if ( t.reg_previews.length ) { 416 each( t.reg_previews, function(args){ 417 if ( !args.preview_regexp ) 418 return; 419 420 var regex = new RegExp( '(?:<p>\\s*)?(' + args.preview_regexp.source + ')(?:\\s*</p>)?', 'g' ); 421 422 content = content.replace(regex, function(a, orig_str){ 423 var html, div_id, new_str; 424 425 previews.i++; 426 div_id = 'wp_mce_preview_' + previews.i; 427 // ed, self or this? 428 new_str = args.str_callback.call( t, { ed: ed, original: orig_str, div_id: div_id } ); 429 previews[div_id] = args; 430 431 html = '<div id="'+ div_id +'" data-wp-preview="'+ encodeURIComponent(orig_str) +'" class="wp-preview-wrap" contenteditable="false">' + 432 '<div class="wp-preview-blocker"><br></div>' + 433 '<div class="wp-preview">'+ new_str +'</div>' + // add inner wrapper so the preview node(s) can be appended there without disturbing the blocker and end divs? 434 '<div data-wp-preview-end="1">\uFEFF</div></div>'; 435 436 return html; 437 }); 438 }); 439 } 440 441 if ( t.step2timeout ) 442 clearTimeout(t.step2timeout); 443 // run the callback after the node has been created in the editor 444 t.step2timeout = setTimeout( function(){ 445 _step_2(); 446 }, 200 ); 447 448 return content; 449 }; 316 450 }, 317 451 318 452 getInfo : function() { … … 418 552 419 553 // Replace images with morebreak 420 554 ed.onPostProcess.add(function(ed, o) { 421 if ( o.get)555 if ( o.get ) { 422 556 o.content = o.content.replace(/<img[^>]+>/g, function(im) { 423 if ( im.indexOf('class="mceWPmore') !== -1) {424 var m, moretext = ( m = im.match(/alt="(.*?)"/)) ? m[1] : '';557 if ( im.indexOf('class="mceWPmore') !== -1 ) { 558 var m, moretext = ( m = im.match(/alt="(.*?)"/) ) ? m[1] : ''; 425 559 im = '<!--more'+moretext+'-->'; 426 560 } 427 if ( im.indexOf('class="mceWPnextpage') !== -1)561 if ( im.indexOf('class="mceWPnextpage') !== -1 ) 428 562 im = '<!--nextpage-->'; 429 563 430 564 return im; 431 565 }); 566 } 432 567 }); 433 568 434 569 // Set active buttons if user selected pagebreak or more break -
wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js
26 26 if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') ) 27 27 ed.plugins.wordpress._showButtons(e.target, 'wp_gallerybtns'); 28 28 }); 29 29 /* 30 30 ed.onBeforeSetContent.add(function(ed, o) { 31 31 o.content = t._do_gallery(o.content); 32 32 }); … … 35 35 if (o.get) 36 36 o.content = t._get_gallery(o.content); 37 37 }); 38 */ 38 39 }, 39 40 40 41 _do_gallery : function(co) { -
wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css
141 141 height: 250px; 142 142 } 143 143 144 /* Previews */ 145 146 div.wp-preview-blocker { 147 height: 100%; 148 width: 100%; 149 position: absolute; 150 background: #fff; 151 opacity: 0.01; 152 filter: alpha(opacity=1); 153 top: 0; 154 left: 0; 155 bottom: 0; 156 right: 0; 157 z-index: 5; 158 } 159 160 div.wp-preview-blocker.focused { 161 background-color: #000; 162 filter: alpha(opacity=25); 163 opacity: 0.25; 164 } 165 166 div.wp-preview-wrap { 167 margin: 10px auto; 168 position: relative; 169 -ms-user-select: none; 170 -moz-user-select: none; /* doesn't work */ 171 -webkit-user-select: none; 172 user-select: none; 173 } 174 175 div.wp-preview-wrap div[data-wp-preview-end] { 176 height: 1em; 177 margin-top: -1em; 178 } 179 180 div.wp-preview-wrap .gallery-icon { 181 margin: 0; 182 } 183 184 div.wp-preview-wrap .gallery-icon img { 185 display: block; 186 margin: 0 auto; 187 padding: 0; 188 max-width: 90%; 189 height: auto; 190 border: 0; 191 } 192 193 div.wp-preview-wrap dd.gallery-caption { 194 margin: 0 6%; 195 font-size: 12px; 196 } 197 198 div.wp-preview-wrap div.gallery { 199 clear: both; 200 } 201 202 div.wp-preview-wrap div.gallery dl.gallery-item { 203 float: left; 204 margin: 10px 0; 205 padding: 0; 206 } 207 208 div.wp-preview-wrap div.gallery-columns-1 dl.gallery-item { 209 width: 99%; 210 } 211 212 div.wp-preview-wrap div.gallery-columns-2 dl.gallery-item { 213 width: 49.5%; 214 } 215 216 div.wp-preview-wrap div.gallery-columns-3 dl.gallery-item { 217 width: 33%; 218 } 219 220 div.wp-preview-wrap div.gallery-columns-4 dl.gallery-item { 221 width: 24.75%; 222 } 223 224 div.wp-preview-wrap div.gallery-columns-5 dl.gallery-item { 225 width: 19.8%; 226 } 227 228 div.wp-preview-wrap div.gallery-columns-6 dl.gallery-item { 229 width: 16.5%; 230 } 231 232 div.wp-preview-wrap div.gallery-columns-7 dl.gallery-item { 233 width: 14.2%; 234 } 235 236 div.wp-preview-wrap div.gallery-columns-8 dl.gallery-item { 237 width: 12.45%; 238 } 239 240 div.wp-preview-wrap div.gallery-columns-9 dl.gallery-item { 241 width: 11.1%; 242 } 243 244 div.wp-preview-wrap div.gallery-columns-10 dl.gallery-item { 245 width: 9.99%; 246 } 247 248 249