diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc index 12949af..d3be165 100644 --- a/editors/ckeditor.inc +++ b/editors/ckeditor.inc @@ -139,7 +139,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 : 'kama', diff --git a/editors/fckeditor.inc b/editors/fckeditor.inc index fba81f6..2ad4c67 100644 --- a/editors/fckeditor.inc +++ b/editors/fckeditor.inc @@ -102,7 +102,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 4ee2cff..ece9f1e 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 42efc32..fee49df 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 40b8c04..ddf11a1 100644 --- a/editors/tinymce.inc +++ b/editors/tinymce.inc @@ -147,6 +147,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 cb04757..d0c28cd 100644 --- a/wysiwyg.js +++ b/wysiwyg.js @@ -126,7 +126,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, (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 8191b5f..31ee4da 100644 --- a/wysiwyg.module +++ b/wysiwyg.module @@ -197,10 +197,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. @@ -386,20 +393,13 @@ 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; - } +function wysiwyg_add_editor_settings($field, $profile, $theme) { + $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'); } /**