Ticket #21718: 21718.diff
File 21718.diff, 4.0 KB (added by , 12 years ago) |
---|
-
wp-includes/class-wp-editor.php
28 28 private function __construct() {} 29 29 30 30 public static function parse_settings($editor_id, $settings) { 31 $set = wp_parse_args( $settings, array( 31 if ( isset( $settings['textarea_rows'] ) && ! isset( $settings['editor_height'] ) ) 32 $settings['editor_height'] = $settings['textarea_rows'] * 19; // Convert rows="" to pixels. 33 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' => 380, // editor height in px (380px is about 20 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 ) { 59 // A cookie (set when a user resizes the editor) overrides the default height. 60 $cookie = (int) get_user_setting( 'ed_s_' . $editor_id ); 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['cw']; 66 } 67 68 if ( $cookie ) 69 $set['editor_height'] = $cookie; 70 } 71 72 // 50px is the minimum height for TinyMCE and all things reasonable. 73 if ( $set['editor_height'] < 50 ) 74 $set['editor_height'] = 50; 75 76 var_dump( $set ); 55 77 return $set; 56 78 } 57 79 … … 67 89 $set = self::parse_settings($editor_id, $settings); 68 90 $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"'; 69 91 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; 70 $ rows = ' rows="' . (int) $set['textarea_rows'] . '"';92 $editor_height = ' style="height: ' . $set['editor_height'] . 'px;"'; 71 93 $switch_class = 'html-active'; 72 94 $toolbar = $buttons = ''; 73 95 … … 116 138 echo "</div>\n"; 117 139 } 118 140 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>');141 $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 142 $content = apply_filters('the_editor_content', $content); 121 143 122 144 printf($the_editor, $content); … … 403 425 'body_class' => $body_class 404 426 ); 405 427 428 $mceInit['theme_advanced_resizing_use_cookie'] = 'content' !== $editor_id; 429 406 430 if ( $first_run ) 407 431 $mceInit = array_merge(self::$first_init, $mceInit); 408 432 -
wp-admin/js/editor.js
1 1 2 (function($,win){ 3 if ( typeof win.setUserSetting === 'undefined' ) 4 return; 5 6 $(document).ready( function() { 7 var container = $('#wp-content-editor-container'); 8 if ( ! container.length ) 9 return; 10 $(win).unload( function() { 11 var height = container.height() - ( $('#content').height() ? 35 : 34 ); 12 if ( height < 50 ) 13 return; 14 win.setUserSetting( 'ed_s_content', height ); 15 }); 16 }); 17 })(jQuery, window); 18 2 19 var switchEditors = { 3 20 4 21 switchto: function(el) {