Ticket #21718: 21718-3.patch
File 21718-3.patch, 10.3 KB (added by , 13 years ago) |
---|
-
wp-admin/js/editor.js
49 49 if ( ed && ed.isHidden() ) 50 50 return false; 51 51 52 if ( ed ) { 53 txtarea_el.style.height = ed.getContentAreaContainer().offsetHeight + 20 + 'px'; 52 if ( ed ) 54 53 ed.hide(); 55 }56 54 57 55 dom.removeClass(wrap_id, 'tmce-active'); 58 56 dom.addClass(wrap_id, 'html-active'); -
wp-includes/class-wp-editor.php
28 28 private function __construct() {} 29 29 30 30 public static function parse_settings($editor_id, $settings) { 31 if ( isset( $settings['textarea_rows'] ) && ! isset( $settings['editor_height'] ) ) 32 $settings['editor_height'] = $settings['textarea_rows'] * 18; // Convert rows="" to pixels. 33 31 34 $set = wp_parse_args( $settings, array( 32 35 'wpautop' => true, // use wpautop? 33 36 'media_buttons' => true, // show insert/upload button(s) 34 37 'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here 35 ' textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."38 'editor_height' => '', // editor height in px (replaces textarea rows) 36 39 'tabindex' => '', 37 40 'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE 38 41 'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped". … … 52 55 if ( self::$this_quicktags ) 53 56 self::$has_quicktags = true; 54 57 58 if ( 'content' === $editor_id && self::$has_tinymce ) { 59 // A cookie (set when a user resizes the editor) overrides the height. 60 $cookie = (int) get_user_setting( $editor_id . '_ed_size' ); 61 62 // Upgrade an old TinyMCE cookie if it is still around, and the new one isn't. 63 if ( ! $cookie && isset( $_COOKIE['TinyMCE_' . $editor_id . '_size'] ) ) { 64 parse_str( $_COOKIE['TinyMCE_' . $editor_id . '_size'], $cookie ); 65 $cookie = $cookie['ch']; 66 } 67 68 if ( $cookie ) 69 $set['editor_height'] = $cookie; 70 else 71 $set['editor_height'] = 360; // 360px is about 20 textarea rows. the old default val for the main editor 72 } 73 74 // 50px is the minimum height for TinyMCE and all things reasonable. 75 if ( $set['editor_height'] < 50 ) 76 $set['editor_height'] = 50; 77 55 78 return $set; 56 79 } 57 80 … … 67 90 $set = self::parse_settings($editor_id, $settings); 68 91 $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"'; 69 92 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; 70 $ rows = ' rows="' . (int) $set['textarea_rows'] . '"';93 $editor_height = $set['editor_height'] ? ' style="height: ' . $set['editor_height'] . 'px;"' : ''; 71 94 $switch_class = 'html-active'; 72 95 $toolbar = $buttons = ''; 73 96 … … 116 139 echo "</div>\n"; 117 140 } 118 141 119 $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $ rows. $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>');142 $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $editor_height . $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>'); 120 143 $content = apply_filters('the_editor_content', $content); 121 144 122 145 printf($the_editor, $content); … … 403 426 'body_class' => $body_class 404 427 ); 405 428 429 $mceInit['theme_advanced_resizing_use_cookie'] = 'content' !== $editor_id; 430 406 431 if ( $first_run ) 407 432 $mceInit = array_merge(self::$first_init, $mceInit); 408 433 … … 553 578 ?> 554 579 555 580 <script type="text/javascript"> 581 var wpActiveEditor; 582 556 583 (function(){ 557 var init, ed, qt, first_init, mce = <?php echo wp_default_editor() == 'tinymce' ? 'true' : 'false'; ?>;584 var init, ed, qt, first_init, DOM, el, i, mce = <?php 558 585 586 if ( ( self::$has_tinymce && wp_default_editor() == 'tinymce' ) || !self::$has_quicktags ) 587 echo 'true'; 588 else 589 echo 'false'; 590 591 ?>; 592 559 593 if ( typeof(tinymce) == 'object' ) { 594 DOM = tinymce.DOM; 560 595 // mark wp_theme/ui.css as loaded 561 tinymce.DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/wp_theme/ui.css'] = true;596 DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/wp_theme/ui.css'] = true; 562 597 598 DOM.events.add( DOM.select('.wp-editor-wrap'), 'mousedown', function(e){ 599 if ( this.id ) 600 wpActiveEditor = this.id.slice(3, -5); 601 }); 602 563 603 for ( ed in tinyMCEPreInit.mceInit ) { 564 604 if ( first_init ) { 565 605 init = tinyMCEPreInit.mceInit[ed] = tinymce.extend( {}, first_init, tinyMCEPreInit.mceInit[ed] ); … … 570 610 if ( mce ) 571 611 try { tinymce.init(init); } catch(e){} 572 612 } 613 } else { 614 el = document.getElementsByClassName('wp-editor-wrap'); 615 for ( i in el ) { 616 if ( typeof(el[i]) == 'object' ) 617 el[i].onmousedown = function(){ wpActiveEditor = this.id.slice(3, -5); } 618 } 573 619 } 574 620 575 621 if ( typeof(QTags) == 'function' ) { … … 578 624 } 579 625 } 580 626 })(); 627 <?php 581 628 582 var wpActiveEditor;583 584 jQuery('.wp-editor-wrap').mousedown(function(e){585 wpActiveEditor = this.id.slice(3, -5);586 });587 588 <?php589 590 629 if ( self::$ext_plugins ) 591 630 echo self::$ext_plugins . "\n"; 592 631 593 632 if ( ! $compressed && $tmce_on ) { 594 ?>595 (function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();596 <?php633 ?> 634 (function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})(); 635 <?php 597 636 } 598 637 599 if ( !is_admin() ) 638 if ( !is_admin() ) { 600 639 echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; 601 ?> 602 </script> 603 <?php 640 } else { 641 ?> 642 (function($){ 643 if ( typeof($) == 'undefiend' || !$.browser.webkit ) 644 return; 645 // convert textarea height from px to rows 646 var txt = $('textarea#content'), height = txt.css('height'); 647 648 if ( !height ) // not the main editor or no height in inline css 649 return; 604 650 651 txt.css('height', '').attr('rows', ( parseInt(height, 10) - 20 ) / 18); 652 653 654 655 console.log( 'rows in jQuery = '+ txt.attr('rows') ); 656 console.log( 'css height in jQuery = '+ txt[0].style.height ); 657 658 })(jQuery) 659 <?php 660 } 661 662 ?> 663 </script> 664 <?php 665 605 666 if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) 606 667 self::wp_link_dialog(); 607 668 -
wp-includes/css/editor.css
1024 1024 line-height: 150%; 1025 1025 border: 0 none; 1026 1026 outline: none; 1027 display: block; 1027 1028 resize: vertical; 1028 1029 -moz-box-sizing: border-box; 1029 1030 -webkit-box-sizing: border-box; -
wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js
3 3 */ 4 4 5 5 (function() { 6 var DOM = tinymce.DOM ;6 var DOM = tinymce.DOM, win = window; 7 7 8 8 tinymce.create('tinymce.plugins.WordPress', { 9 9 mceTout : 0, … … 234 234 } 235 235 }); 236 236 237 // resize TinyMCE to match the textarea height when switching Text -> Visual 238 ed.onLoadContent.add( function(ed, o) { 239 var height, tb_height, ifr_height, txt = ed.getElement(), 240 ed_toolbar = DOM.select('#'+ed.id + '_tbl tr.mceFirst'); 241 242 if ( txt && txt.style && txt.style.height ) 243 height = parseInt( txt.style.height, 10 ); 244 else if ( txt && ed.dom.getAttrib(txt, 'rows') ) 245 height = ( ed.dom.getAttrib(txt, 'rows') * 18 ) + 20; 246 247 if ( ed_toolbar && ed_toolbar[0] ) 248 tb_height = ed_toolbar[0].clientHeight; 249 250 if ( height && tb_height ) { 251 ifr_height = height - tb_height + 13; // compensate for the 10px padding in the textarea 252 253 DOM.setStyle( DOM.get(ed.id + '_tbl'), 'height', '' ); 254 DOM.setStyle( DOM.get(ed.id + '_ifr'), 'height', ifr_height ); 255 if ( win.setUserSetting ) 256 win.setUserSetting( ed.id + '_ed_size', height ); 257 } 258 }); 259 260 // resize the textarea to match TinyMCE's height when switching Visual -> Text 261 ed.onSaveContent.add( function(ed, o) { 262 var height = DOM.get(ed.id+'_tbl').clientHeight, txt = ed.getElement(); 263 264 if ( height && height > 84 ) { 265 height -= 34; 266 267 if ( tinymce.isWebKit ) { 268 DOM.setStyle( txt, 'height', '' ); 269 DOM.setAttrib( txt, 'rows', ( height - 20 ) / 18 ); 270 } else { 271 DOM.setStyle( txt, 'height', height ); 272 } 273 274 if ( win.setUserSetting ) 275 win.setUserSetting( ed.id + '_ed_size', height ); 276 } 277 }); 278 279 // save on uoload 280 DOM.bind(win, 'unload', function(e){ 281 var height = document.getElementById('wp-'+ed.id+'-editor-container').clientHeight; 282 283 if ( document.getElementById(ed.id).clientHeight ) 284 height -= 35; 285 else 286 height -= 34; 287 288 if ( !win.setUserSetting || height < 50 ) 289 return; 290 291 win.setUserSetting( ed.id + '_ed_size', height ); 292 }); 293 237 294 /* disable for now 238 295 ed.onBeforeSetContent.add(function(ed, o) { 239 296 o.content = t._setEmbed(o.content);