Ticket #21812: 21812.patch
File 21812.patch, 9.3 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 wpPreview, 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 if ( typeof(jQuery) != 'undefined' ) 326 jQuery(document).trigger( 'wp_add_mce_previews', ed ); 327 }); 328 /* 329 // runs on paste and on inserting nodes/html, doube/triple runs?? 330 ed.onInit.add(function(ed) { 331 ed.selection.onSetContent.add(function(ed, o) { 332 if ( o.context && t.reg_previews.length ) { 333 each( ed.dom.select(o.context), function(el) { 334 each( t.reg_previews, function(args){ 335 el.textContent = wpPreview(el.textContent, args); 336 }); 337 }); 338 } 339 }); 340 }); 341 */ 342 // runs every time content is loaded in the editor 343 ed.onBeforeSetContent.add(function(ed, o) { 344 if ( t.reg_previews.length && o.content ) { 345 each( t.reg_previews, function(args){ 346 o.content = wpPreview(o.content, args); 347 }); 348 } 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){ 354 // can identify the registered preview and fire a callback here 355 return '<p>'+decodeURIComponent(b)+'</p>'; 356 }); 357 } 358 }); 359 360 // register all previews 361 ed.wpPreviewRegister = function(args) { 362 363 console.log( 'wpPreviewRegister' ); 364 365 t.reg_previews.push(args); 366 }; 367 368 ed.onSetContent.add(function(ed){ 369 // go through the added previews and fire callbacks 370 371 console.log( t.previews ); 372 373 each(t.previews, function(args, div_id){ 374 var node = args ? ed.dom.select('#'+div_id) : null; 375 376 console.log( 'onSetContent' ); 377 console.log( args ); 378 379 380 if ( !args || !node ) 381 return; 382 383 if ( args.node_callback ) { 384 args.node_callback.call( t, { node: node[0], div_id: div_id } ); 385 } 386 if ( args.onmousedown ) { 387 ed.dom.events.add( node, 'mousedown', args.onmousedown ); 388 } 389 if ( args.onmouseup ) { 390 ed.dom.events.add( node, 'mouseup', args.onmouseup ); 391 } 392 if ( args.onclick ) { 393 ed.dom.events.add( node, 'click', args.onclick ); 394 } 395 }); 396 }); 397 398 /* 399 args = { 400 preview_regexp: /\[gallery[^\]]*\]/, 401 str_callback: function(obj){ console.log('str_callback'); console.log(obj); return obj.original+' 123 ' }, 402 node_callback: function(obj){ console.log('node_callback'); console.log(obj) }, 403 onmousedown: function(e){ console.log('onmousedown'); console.log(e) }, 404 onmouseup: function(e){ console.log('onmouseup'); console.log(e) }, 405 onclick: function(e){ console.log('onclick'); console.log(e) } 406 } 407 */ 408 wpPreview = function(content, args) { 409 var self = t, previews = self.previews, div_id, regex; 410 411 if ( args.preview_regexp ) { 412 regex = new RegExp( '(?:<p>\\s*)?(' + args.preview_regexp.source + ')(?:\s*<\/p>)?', 'g' ); 413 414 return content.replace(regex, function(a, orig_str){ 415 var html, div_id; 416 417 previews.i++; 418 div_id = 'wp_mce_preview_' + previews.i; 419 // ed, self or this? 420 orig_str = args.str_callback.call( self, { original: orig_str, div_id: div_id } ); 421 previews[div_id] = args; 422 423 html = '<div id="'+ div_id +'" data-wp-preview="'+ encodeURIComponent(orig_str) +'" class="wp-preview-wrap" contenteditable="false">' + 424 '<div class="wp-preview-blocker"><br></div>' + 425 '<div class="wp-preview">'+ orig_str +'</div>' + // add inner wrapper so the preview node(s) can be appended there without disturbing the blocker and end divs? 426 '<div data-wp-preview-end="1">\uFEFF</div></div>'; 427 428 return html; 429 }); 430 } 431 }; 316 432 }, 317 433 318 434 getInfo : function() { … … 418 534 419 535 // Replace images with morebreak 420 536 ed.onPostProcess.add(function(ed, o) { 421 if ( o.get)537 if ( o.get ) { 422 538 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] : '';539 if ( im.indexOf('class="mceWPmore') !== -1 ) { 540 var m, moretext = ( m = im.match(/alt="(.*?)"/) ) ? m[1] : ''; 425 541 im = '<!--more'+moretext+'-->'; 426 542 } 427 if ( im.indexOf('class="mceWPnextpage') !== -1)543 if ( im.indexOf('class="mceWPnextpage') !== -1 ) 428 544 im = '<!--nextpage-->'; 429 545 430 546 return im; 431 547 }); 548 } 432 549 }); 433 550 434 551 // 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