diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc index a5a506c..989136d 100644 --- a/editors/ckeditor.inc +++ b/editors/ckeditor.inc @@ -336,7 +336,9 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) { 'width' => 'auto', // For better compatibility with smaller textareas. 'resize_minWidth' => 450, - 'height' => 420, + // Rough estimate of editor height in pixels: + // 40 for the toolbar, 29 for the first row, and 15 for the rest. + 'height' => isset($config['rows']) ? 40 + 29 + 15 * ($config['rows'] - 1) : 400, // @todo Do not use skins as themes and add separate skin handling. 'theme' => 'default', 'skin' => !empty($theme) ? $theme : $default_skin, diff --git a/editors/fckeditor.inc b/editors/fckeditor.inc index 68c2f98..a9382d6 100644 --- a/editors/fckeditor.inc +++ b/editors/fckeditor.inc @@ -164,7 +164,9 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) { 'SkinPath' => base_path() . $editor['library path'] . '/editor/skins/' . $theme . '/', 'CustomConfigurationsPath' => base_path() . drupal_get_path('module', 'wysiwyg') . '/editors/js/fckeditor.config.js', 'Width' => '100%', - 'Height' => 420, + // Rough estimate of editor height in pixels: + // 40 for the toolbar, 29 for the first row, and 15 for the rest. + 'Height' => isset($config['rows']) ? 40 + 29 + 15 * ($config['rows'] - 1) : 400, 'LinkBrowser' => FALSE, 'LinkUpload' => FALSE, 'ImageBrowser' => FALSE, diff --git a/editors/js/fckeditor-2.6.js b/editors/js/fckeditor-2.6.js index fd915e3..9b77237 100644 --- a/editors/js/fckeditor-2.6.js +++ b/editors/js/fckeditor-2.6.js @@ -8,6 +8,7 @@ Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) { // Apply editor instance settings. FCKinstance.BasePath = settings.EditorPath; FCKinstance.Config.wysiwygFormat = params.format; + FCKinstance.Config.wysiwygField = params.field; FCKinstance.Config.CustomConfigurationsPath = settings.CustomConfigurationsPath; // Load Drupal plugins and apply format specific settings. diff --git a/editors/js/fckeditor.config.js b/editors/js/fckeditor.config.js index d441055..82759e9 100644 --- a/editors/js/fckeditor.config.js +++ b/editors/js/fckeditor.config.js @@ -9,7 +9,8 @@ Drupal = window.parent.Drupal; * FCKConfig.PageConfig. */ var wysiwygFormat = FCKConfig.PageConfig.wysiwygFormat; -var wysiwygSettings = Drupal.settings.wysiwyg.configs.fckeditor[wysiwygFormat]; +var wysiwygField = FCKConfig.PageConfig.wysiwygField; +var wysiwygSettings = Drupal.settings.wysiwyg.configs.fckeditor[wysiwygFormat][wysiwygField]; var pluginSettings = (Drupal.settings.wysiwyg.plugins[wysiwygFormat] ? Drupal.settings.wysiwyg.plugins[wysiwygFormat] : { 'native': {}, 'drupal': {} }); /** diff --git a/editors/tinymce.inc b/editors/tinymce.inc index 81bc2b6..df04a1c 100644 --- a/editors/tinymce.inc +++ b/editors/tinymce.inc @@ -330,6 +330,9 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) { 'plugins' => array(), 'theme' => $theme, 'width' => '100%', + // Rough estimate of editor height in pixels: + // 40 for the toolbar, 29 for the first row, and 15 for the rest. + 'height' => isset($config['rows']) ? 40 + 29 + 15 * ($config['rows'] - 1) : 400, // Strict loading mode must be enabled; otherwise TinyMCE would use // document.write() in IE and Chrome. 'strict_loading_mode' => TRUE, diff --git a/wysiwyg.js b/wysiwyg.js index c0c76e9..d6a81f5 100644 --- a/wysiwyg.js +++ b/wysiwyg.js @@ -136,7 +136,7 @@ Drupal.wysiwygAttach = function(context, params) { } // Attach editor, if enabled by default or last state was enabled. if (params.status) { - Drupal.wysiwyg.editor.attach[params.editor](context, params, processObjectTypes(Drupal.settings.wysiwyg.configs[params.editor] ? jQuery.extend(true, {}, Drupal.settings.wysiwyg.configs[params.editor][params.format]) : {})); + Drupal.wysiwyg.editor.attach[params.editor](context, params, (Drupal.settings.wysiwyg.configs[params.editor] ? jQuery.extend(true, {}, Drupal.settings.wysiwyg.configs[params.editor][params.format][params.field]) : {})); } // Otherwise, attach default behaviors. else { diff --git a/wysiwyg.module b/wysiwyg.module index 69c1e45..67fe1cf 100644 --- a/wysiwyg.module +++ b/wysiwyg.module @@ -254,10 +254,17 @@ function wysiwyg_pre_render_text_format($element) { // Check editor theme (and reset it if not/no longer available). $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : '')); + if (!empty($field['#rows'])) { + $profile->settings['rows'] = $field['#rows']; + } + elseif ($field['#type'] == 'textfield') { + $profile->settings['rows'] = 1; + } + // Add plugin settings (first) for this text format. wysiwyg_add_plugin_settings($profile); // Add profile settings for this text format. - wysiwyg_add_editor_settings($profile, $theme); + wysiwyg_add_editor_settings($field, $profile, $theme); } } // Use a hidden element for a single text format. @@ -464,20 +471,14 @@ function wysiwyg_load_editor($profile) { } /** - * Add editor settings for a given input format. + * Add editor settings for a given field and input format. */ function wysiwyg_add_editor_settings($profile, $theme) { - static $formats = array(); - - if (!isset($formats[$profile->format])) { - $config = wysiwyg_get_editor_config($profile, $theme); - // drupal_to_js() does not properly convert numeric array keys, so we need - // to use a string instead of the format id. - if ($config) { - drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting'); - } - $formats[$profile->format] = TRUE; - } + $config = wysiwyg_get_editor_config($profile, $theme); + // drupal_to_js() does not properly convert numeric array keys, so we need + // to use a string instead of the format id. + + drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => array($field['#id'] => $config))))), 'setting'); } /**