diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc
index 6ff60d5..409ecbe 100644
--- a/editors/ckeditor.inc
+++ b/editors/ckeditor.inc
@@ -135,19 +135,59 @@ function wysiwyg_ckeditor_themes($editor, $profile) {
* @see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.stylesSet
*/
function wysiwyg_ckeditor_settings_form(&$form, &$form_state) {
- $form['output']['paste_auto_cleanup_on_paste']['#title'] = t('Force paste as plain text');
- $form['output']['paste_auto_cleanup_on_paste']['#description'] = t('If enabled, all pasting operations insert plain text into the editor, loosing any formatting information possibly available in the source text. Note: Paste from Word is not affected by this setting.');
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+ $installed_version = $form_state['wysiwyg']['editor']['installed version'];
- if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.6.0', '>=')) {
+ $ckeditor_defaults = array(
+ 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
+ );
+
+ $settings += $ckeditor_defaults;
+
+ $form['appearance']['toolbarLocation'] = array(
+ '#type' => 'select',
+ '#title' => t('Toolbar location'),
+ '#default_value' => $settings['toolbarLocation'],
+ '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')),
+ '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.'),
+ );
+
+ $form['appearance']['enable_resize'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable resizing button'),
+ '#default_value' => $settings['enable_resize'],
+ '#return_value' => 1,
+ '#description' => t('This option gives you the ability to enable/disable the editor resizing feature.'),
+ );
+
+ $form['paste'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Paste plugin'),
+ '#description' => t('Settings for the paste plugin.'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'advanced',
+ );
+
+ $form['paste']['forcePasteAsPlainText'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Force paste as plain text'),
+ '#default_value' => !empty($settings['forcePasteAsPlainText']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, all pasting operations insert plain text into the editor, loosing any formatting information possibly available in the source text. Note: Paste from Word is not affected by this setting.'),
+ );
+
+ if (version_compare($installed_version, '3.6.0', '>=')) {
$form['appearance']['default_toolbar_grouping'] = array(
'#type' => 'checkbox',
'#title' => t('Use default toolbar button grouping'),
- '#default_value' => !empty($form_state['wysiwyg_profile']->settings['default_toolbar_grouping']),
+ '#default_value' => !empty($settings['default_toolbar_grouping']),
'#return_value' => 1,
'#description' => t('This option gives you the ability to enable/disable the usage of default groupings for toolbar buttons. If enabled, toolbar buttons will be placed into predetermined groups instead of all in a single group.'),
);
}
- if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.2.1', '>=')) {
+ if (version_compare($installed_version, '3.2.1', '>=')) {
// Replace CSS classes element description to explain the advanced syntax.
$form['css']['css_classes']['#description'] = t('Optionally define CSS classes for the "Font style" dropdown list.
Enter one class on each line in the format: !format. Example: !example
If left blank, CSS classes are automatically imported from loaded stylesheet(s).', array(
'!format' => '[label]=[element].[class]
',
@@ -159,6 +199,16 @@ function wysiwyg_ckeditor_settings_form(&$form, &$form_state) {
// Versions below 3.2.1 do not support Font styles at all.
$form['css']['css_classes']['#access'] = FALSE;
}
+
+ $form['css']['block_formats'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block formats'),
+ '#default_value' => $settings['block_formats'],
+ '#size' => 40,
+ '#maxlength' => 250,
+ '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list
.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')),
+ '#element_validate' => array('wysiwyg_ckeditor_settings_form_validate_block_formats'),
+ );
}
/**
@@ -171,6 +221,15 @@ function wysiwyg_ckeditor_settings_form_validate_css_classes($element, &$form_st
}
/**
+ * #element_validate handler for block_formats element added by wysiwyg_ckeditor_settings_form().
+ */
+function wysiwyg_ckeditor_settings_form_validate_block_formats($element, &$form_state) {
+ // Remove any white-space from 'block_formats' setting, since editor
+ // implementations rely on a comma-separated list to explode().
+ form_set_value($form['css']['block_formats'], preg_replace('@\s+@', '', $element['#value']), $form_state);
+}
+
+/**
* Returns an initialization JavaScript for this editor library.
*
* @param array $editor
@@ -246,10 +305,6 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
$settings['format_tags'] = implode(';', $block_formats);
}
- if (isset($config['apply_source_formatting'])) {
- $settings['apply_source_formatting'] = $config['apply_source_formatting'];
- }
-
if (isset($config['css_setting'])) {
// Versions below 3.0.1 could only handle one stylesheet.
if (version_compare($editor['installed version'], '3.0.1.4391', '<')) {
@@ -280,18 +335,23 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
}
}
- if (isset($config['language'])) {
- $settings['language'] = $config['language'];
+ $check_if_set = array(
+ 'apply_source_formatting',
+ 'forcePasteAsPlainText',
+ 'language',
+ );
+ foreach ($check_if_set as $setting_name) {
+ if (isset($config[$setting_name])) {
+ $settings[$setting_name] = $config[$setting_name];
+ }
}
- if (isset($config['resizing'])) {
+
+ if (isset($config['resize_enabled'])) {
// CKEditor performs a type-agnostic comparison on this particular setting.
- $settings['resize_enabled'] = (bool) $config['resizing'];
- }
- if (isset($config['toolbar_loc'])) {
- $settings['toolbarLocation'] = $config['toolbar_loc'];
+ $settings['resize_enabled'] = (bool) $config['resize_enabled'];
}
- if (isset($config['paste_auto_cleanup_on_paste'])) {
- $settings['forcePasteAsPlainText'] = $config['paste_auto_cleanup_on_paste'];
+ if (isset($config['toolbarLocation'])) {
+ $settings['toolbarLocation'] = $config['toolbarLocation'];
}
$settings['toolbar'] = array();
diff --git a/editors/epiceditor.inc b/editors/epiceditor.inc
index af0a6dc..4d3ecb0 100644
--- a/editors/epiceditor.inc
+++ b/editors/epiceditor.inc
@@ -25,6 +25,7 @@ function wysiwyg_epiceditor_editor() {
),
'version callback' => 'wysiwyg_epiceditor_version',
'themes callback' => 'wysiwyg_epiceditor_themes',
+ 'settings form callback' => 'wysiwyg_epiceditor_settings_form',
'settings callback' => 'wysiwyg_epiceditor_settings',
'versions' => array(
'0.1.1' => array(
@@ -77,6 +78,16 @@ function wysiwyg_epiceditor_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for EpicEditor.
+ *
+ */
+function wysiwyg_epiceditor_settings_form(&$form, &$form_state) {
+ $form['buttons']['#access'] = FALSE;
+ $form['basic']['language']['#access'] = FALSE;
+ $form['css']['#access'] = FALSE;
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
diff --git a/editors/fckeditor.inc b/editors/fckeditor.inc
index 27bcb7b..b262650 100644
--- a/editors/fckeditor.inc
+++ b/editors/fckeditor.inc
@@ -21,6 +21,7 @@ function wysiwyg_fckeditor_editor() {
),
'version callback' => 'wysiwyg_fckeditor_version',
'themes callback' => 'wysiwyg_fckeditor_themes',
+ 'settings form callback' => 'wysiwyg_fckeditor_settings_form',
'settings callback' => 'wysiwyg_fckeditor_settings',
'plugin callback' => 'wysiwyg_fckeditor_plugins',
'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings',
@@ -83,6 +84,77 @@ function wysiwyg_fckeditor_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for FCKeditor.
+ *
+ * @see http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
+ */
+function wysiwyg_fckeditor_settings_form(&$form, &$form_state) {
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+ $settings += array(
+ // Enabled by default.
+ 'AutoDetectPasteFromWord' => TRUE,
+ 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
+ 'FormatOutput' => TRUE,
+ 'FormatSource' => TRUE,
+ );
+ $form['output']['FormatSource'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Apply source formatting'),
+ '#default_value' => $settings['FormatSource'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, the editor will re-format the HTML source code when switching to Source View.'),
+ );
+ $form['output']['FormatOutput'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Apply output formatting'),
+ '#default_value' => $settings['FormatOutput'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, the editor will re-format the HTML source code output. Disabling this option could avoid conflicts with other input filters.'),
+ );
+ $form['css']['block_formats'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block formats'),
+ '#default_value' => $settings['block_formats'],
+ '#size' => 40,
+ '#maxlength' => 250,
+ '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list
.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')),
+ '#element_validate' => array('wysiwyg_fckeditor_settings_form_validate_block_formats'),
+ );
+ $form['paste'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Paste plugin'),
+ '#description' => t('Settings for the paste plugin.'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'advanced',
+ );
+ $form['paste']['AutoDetectPasteFromWord'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Auto detect paste from Word'),
+ '#default_value' => $settings['AutoDetectPasteFromWord'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, FCKeditor checks if pasted text comes from MS Word. If so the editor will launch the "Paste from Word" window. Only works in Internet Explorer.'),
+ );
+ $form['paste']['ForcePasteAsPlainText'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Force paste as plain text'),
+ '#default_value' => !empty($settings['ForcePasteAsPlainText']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, forces the editor to discard all formatting when pasting text. It will also disable the Paste from Word operation.'),
+ );
+}
+
+/**
+ * #element_validate handler for block_formats element added by wysiwyg_fckeditor_settings_form().
+ */
+function wysiwyg_fckeditor_settings_form_validate_block_formats($element, &$form_state) {
+ // Remove any white-space from 'block_formats' setting, since editor
+ // implementations rely on a comma-separated list to explode().
+ form_set_value($form['css']['block_formats'], preg_replace('@\s+@', '', $element['#value']), $form_state);
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -120,11 +192,17 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) {
if (isset($config['block_formats'])) {
$settings['FontFormats'] = strtr($config['block_formats'], array(',' => ';'));
}
- if (isset($config['apply_source_formatting'])) {
- $settings['FormatOutput'] = $settings['FormatSource'] = $config['apply_source_formatting'];
+ if (isset($config['FormatOutput'])) {
+ $settings['FormatOutput'] = $config['FormatOutput'];
+ }
+ if (isset($config['FormatSource'])) {
+ $settings['FormatSource'] = $config['FormatSource'];
+ }
+ if (isset($config['ForcePasteAsPlainText'])) {
+ $settings['ForcePasteAsPlainText'] = $config['ForcePasteAsPlainText'];
}
- if (isset($config['paste_auto_cleanup_on_paste'])) {
- $settings['AutoDetectPasteFromWord'] = $config['paste_auto_cleanup_on_paste'];
+ if (isset($config['AutoDetectPasteFromWord'])) {
+ $settings['AutoDetectPasteFromWord'] = $config['AutoDetectPasteFromWord'];
}
if (isset($config['css_setting'])) {
diff --git a/editors/jwysiwyg.inc b/editors/jwysiwyg.inc
index fa65b74..ae7ebda 100644
--- a/editors/jwysiwyg.inc
+++ b/editors/jwysiwyg.inc
@@ -24,6 +24,7 @@ function wysiwyg_jwysiwyg_editor() {
),
),
'version callback' => 'wysiwyg_jwysiwyg_version',
+ 'settings form callback' => 'wysiwyg_jwysiwyg_settings_form',
// @todo Wrong property; add separate properties for editor requisites.
'css path' => wysiwyg_get_path('jwysiwyg'),
'versions' => array(
@@ -37,6 +38,15 @@ function wysiwyg_jwysiwyg_editor() {
}
/**
+ * Enhances the editor profile settings form for jWYSIWYG.
+ */
+function wysiwyg_jwysiwyg_settings_form(&$form, &$form_state) {
+ $form['buttons']['#access'] = FALSE;
+ $form['basic']['language']['#access'] = FALSE;
+ $form['css']['#access'] = FALSE;
+}
+
+/**
* Detect editor version.
*
* @param $editor
diff --git a/editors/markitup.inc b/editors/markitup.inc
index 57a37e8..72dab5a 100644
--- a/editors/markitup.inc
+++ b/editors/markitup.inc
@@ -26,6 +26,7 @@ function wysiwyg_markitup_editor() {
),
'version callback' => 'wysiwyg_markitup_version',
'themes callback' => 'wysiwyg_markitup_themes',
+ 'settings form callback' => 'wysiwyg_markitup_settings_form',
'settings callback' => 'wysiwyg_markitup_settings',
'plugin callback' => 'wysiwyg_markitup_plugins',
'versions' => array(
@@ -82,6 +83,14 @@ function wysiwyg_markitup_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for markItUp.
+ */
+function wysiwyg_markitup_settings_form(&$form, &$form_state) {
+ $form['basic']['language']['#access'] = FALSE;
+ $form['css']['#access'] = FALSE;
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
diff --git a/editors/nicedit.inc b/editors/nicedit.inc
index 6acc800..8a77564 100644
--- a/editors/nicedit.inc
+++ b/editors/nicedit.inc
@@ -20,6 +20,7 @@ function wysiwyg_nicedit_editor() {
),
),
'version callback' => 'wysiwyg_nicedit_version',
+ 'settings form callback' => 'wysiwyg_nicedit_settings_form',
'settings callback' => 'wysiwyg_nicedit_settings',
'plugin callback' => 'wysiwyg_nicedit_plugins',
'versions' => array(
@@ -46,6 +47,18 @@ function wysiwyg_nicedit_version($editor) {
}
/**
+ * Enhances the editor profile settings form for NicEdit.
+ *
+ * @see http://wiki.nicedit.com/w/page/515/Configuration%20Options
+ */
+function wysiwyg_nicedit_settings_form(&$form, &$form_state) {
+ $form['basic']['language']['#access'] = FALSE;
+ // NicEdit only supports loading a single stylesheet, and only in FF2.
+ // This essentially means we're dropping stylesheet support for NiceEdit.
+ $form['css']['#access'] = FALSE;
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -75,6 +88,7 @@ function wysiwyg_nicedit_settings($editor, $config, $theme) {
}
// Add editor content stylesheet.
+ // @todo Drop stylsheet support since it's only used in FF2.
if (isset($config['css_setting'])) {
if ($config['css_setting'] == 'theme') {
$css = drupal_get_path('theme', variable_get('theme_default', NULL)) . '/style.css';
diff --git a/editors/openwysiwyg.inc b/editors/openwysiwyg.inc
index c135b2c..b876174 100644
--- a/editors/openwysiwyg.inc
+++ b/editors/openwysiwyg.inc
@@ -22,6 +22,7 @@ function wysiwyg_openwysiwyg_editor() {
),
'version callback' => 'wysiwyg_openwysiwyg_version',
'themes callback' => 'wysiwyg_openwysiwyg_themes',
+ 'settings form callback' => 'wysiwyg_openwysiwyg_settings_form',
'settings callback' => 'wysiwyg_openwysiwyg_settings',
'plugin callback' => 'wysiwyg_openwysiwyg_plugins',
'versions' => array(
@@ -75,6 +76,32 @@ function wysiwyg_openwysiwyg_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for openWYSIWYG.
+ */
+function wysiwyg_openwysiwyg_settings_form(&$form, &$form_state) {
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+
+ $settings += array(
+ // Enabled by default.
+ 'StatusBarEnabled' => TRUE,
+ );
+
+ $form['basic']['language']['#access'] = FALSE;
+
+ $form['css']['#description'] = t('Note: openWYSIWYG can only load a single stylesheet into the editor.');
+ $form['css']['css_classes']['#access'] = FALSE;
+
+ $form['appearance']['StatusBarEnabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable statusbar'),
+ '#default_value' => $settings['StatusBarEnabled'],
+ '#return_value' => 1,
+ '#description' => t('When enabled, shows a statusbar.'),
+ );
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -94,8 +121,8 @@ function wysiwyg_openwysiwyg_settings($editor, $config, $theme) {
'Width' => '100%',
);
- if (isset($config['path_loc']) && $config['path_loc'] == 'none') {
- $settings['StatusBarEnabled'] = FALSE;
+ if (isset($config['StatusBarEnabeld'])) {
+ $settings['StatusBarEnabled'] = $config['StatusBarEnabled'];
}
if (isset($config['css_setting'])) {
@@ -127,11 +154,6 @@ function wysiwyg_openwysiwyg_settings($editor, $config, $theme) {
}
}
- // @todo
-// if (isset($config['block_formats'])) {
-// $settings['DropDowns']['headings']['elements'] = explode(',', $config['block_formats']);
-// }
-
return $settings;
}
diff --git a/editors/tinymce.inc b/editors/tinymce.inc
index fc48174..bcf1c48 100644
--- a/editors/tinymce.inc
+++ b/editors/tinymce.inc
@@ -28,6 +28,7 @@ function wysiwyg_tinymce_editor() {
),
'version callback' => 'wysiwyg_tinymce_version',
'themes callback' => 'wysiwyg_tinymce_themes',
+ 'settings form callback' => 'wysiwyg_tinymce_settings_form',
'init callback' => 'wysiwyg_tinymce_init',
'settings callback' => 'wysiwyg_tinymce_settings',
'plugin callback' => 'wysiwyg_tinymce_plugins',
@@ -127,6 +128,138 @@ function wysiwyg_tinymce_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for TinyMCE.
+ *
+ * @see http://www.tinymce.com/wiki.php/Configuration
+ */
+function wysiwyg_tinymce_settings_form(&$form, &$form_state) {
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+ $settings += array(
+ // Enabled by default.
+ 'apply_source_formatting' => FALSE,
+ // Also available, but buggy in TinyMCE 2.x: blockquote,code,dt,dd,samp.
+ 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
+ 'convert_fonts_to_spans' => TRUE,
+ 'paste_auto_cleanup_on_paste' => TRUE,
+ 'path_loc' => 'bottom',
+ 'preformatted' => FALSE,
+ 'remove_linebreaks' => TRUE,
+ 'resizing' => TRUE,
+ 'toolbar_align' => 'left',
+ 'toolbar_loc' => 'top',
+ 'verify_html' => TRUE,
+ );
+
+ $form['appearance']['toolbar_loc'] = array(
+ '#type' => 'select',
+ '#title' => t('Toolbar location'),
+ '#default_value' => $settings['toolbar_loc'],
+ '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')),
+ '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.'),
+ );
+
+ $form['appearance']['toolbar_align'] = array(
+ '#type' => 'select',
+ '#title' => t('Button alignment'),
+ '#default_value' => $settings['toolbar_align'],
+ '#options' => array('center' => t('Center'), 'left' => t('Left'), 'right' => t('Right')),
+ '#description' => t('This option controls the alignment of icons in the editor toolbar.'),
+ );
+
+ $form['appearance']['path_loc'] = array(
+ '#type' => 'select',
+ '#title' => t('Path location'),
+ '#default_value' => $settings['path_loc'],
+ '#options' => array('none' => t('Hide'), 'top' => t('Top'), 'bottom' => t('Bottom')),
+ '#description' => t('Where to display the path to HTML elements (i.e. body > table > tr > td
).'),
+ );
+
+ $form['appearance']['resizing'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable resizing button'),
+ '#default_value' => $settings['resizing'],
+ '#return_value' => 1,
+ '#description' => t('This option gives you the ability to enable/disable the resizing button. If enabled, the Path location toolbar must be set to "Top" or "Bottom" in order to display the resize icon.'),
+ );
+
+ $form['output']['verify_html'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Verify HTML'),
+ '#default_value' => $settings['verify_html'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, potentially malicious code like <HEAD>
tags will be removed from HTML contents.'),
+ );
+
+ $form['output']['preformatted'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Preformatted'),
+ '#default_value' => $settings['preformatted'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE element in HTML does.'),
+ );
+
+ $form['output']['convert_fonts_to_spans'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Convert <font> tags to styles'),
+ '#default_value' => $settings['convert_fonts_to_spans'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, HTML tags declaring the font size, font family, font color and font background color will be replaced by inline CSS styles.'),
+ );
+
+ $form['output']['remove_linebreaks'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove linebreaks'),
+ '#default_value' => $settings['remove_linebreaks'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, the editor will remove most linebreaks from contents. Disabling this option could avoid conflicts with other input filters.'),
+ );
+
+ $form['output']['apply_source_formatting'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Apply source formatting'),
+ '#default_value' => $settings['apply_source_formatting'],
+ '#return_value' => 1,
+ '#description' => t('If enabled, the editor will re-format the HTML source code. Disabling this option could avoid conflicts with other input filters.'),
+ );
+
+ $form['css']['block_formats'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block formats'),
+ '#default_value' => $settings['block_formats'],
+ '#size' => 40,
+ '#maxlength' => 250,
+ '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list
.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')),
+ '#element_validate' => array('wysiwyg_tinymce_settings_form_validate_block_formats'),
+ );
+
+ $form['paste'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Paste plugin'),
+ '#description' => t('Settings for the paste plugin.'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'advanced',
+ );
+ $form['paste']['paste_auto_cleanup_on_paste'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Process contents on paste'),
+ '#default_value' => !empty($settings['paste_auto_cleanup_on_paste']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, contents will be automatically processed when you paste using Ctrl+V or similar methods. Cleaning up contents from MS Word or pasting as plain text will not work without this.'),
+ );
+}
+
+/**
+ * #element_validate handler for block_formats element added by wysiwyg_tinymce_settings_form().
+ */
+function wysiwyg_tinymce_settings_form_validate_block_formats($element, &$form_state) {
+ // Remove any white-space from 'block_formats' setting, since editor
+ // implementations rely on a comma-separated list to explode().
+ form_set_value($form['css']['block_formats'], preg_replace('@\s+@', '', $element['#value']), $form_state);
+}
+
+/**
* Returns an initialization JavaScript for this editor library.
*
* @param array $editor
@@ -194,23 +327,18 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) {
// XML default characters '&', '<', '>'.
'entities' => '160,nbsp,173,shy,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm',
);
- if (isset($config['apply_source_formatting'])) {
- $settings['apply_source_formatting'] = $config['apply_source_formatting'];
- }
- if (isset($config['convert_fonts_to_spans'])) {
- $settings['convert_fonts_to_spans'] = $config['convert_fonts_to_spans'];
- }
- if (isset($config['language'])) {
- $settings['language'] = $config['language'];
- }
- if (isset($config['paste_auto_cleanup_on_paste'])) {
- $settings['paste_auto_cleanup_on_paste'] = $config['paste_auto_cleanup_on_paste'];
- }
- if (isset($config['preformatted'])) {
- $settings['preformatted'] = $config['preformatted'];
- }
- if (isset($config['remove_linebreaks'])) {
- $settings['remove_linebreaks'] = $config['remove_linebreaks'];
+ $check_if_set = array(
+ 'apply_source_formatting',
+ 'convert_fonts_to_spans',
+ 'language',
+ 'paste_auto_cleanup_on_paste',
+ 'preformatted',
+ 'remove_linebreaks',
+ );
+ foreach ($check_if_set as $setting_name) {
+ if (isset($config[$setting_name])) {
+ $settings[$setting_name] = $config[$setting_name];
+ }
}
if (isset($config['verify_html'])) {
// TinyMCE performs a type-agnostic comparison on this particular setting.
diff --git a/editors/whizzywig.inc b/editors/whizzywig.inc
index acfc7de..3c627c4 100644
--- a/editors/whizzywig.inc
+++ b/editors/whizzywig.inc
@@ -20,6 +20,7 @@ function wysiwyg_whizzywig_editor() {
),
),
'version callback' => 'wysiwyg_whizzywig_version',
+ 'settings form callback' => 'wysiwyg_whizzywig_settings_form',
'settings callback' => 'wysiwyg_whizzywig_settings',
'plugin callback' => 'wysiwyg_whizzywig_plugins',
'versions' => array(
@@ -63,6 +64,15 @@ function wysiwyg_whizzywig_version($editor) {
}
/**
+ * Enhances the editor profile settings form for Whizzywig.
+ */
+function wysiwyg_whizzywig_settings_form(&$form, &$form_state) {
+ $form['basic']['language']['#access'] = FALSE;
+ // @todo CSS settings are currently not used.
+ $form['css']['#access'] = FALSE;
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -102,6 +112,7 @@ function wysiwyg_whizzywig_settings($editor, $config, $theme) {
}
// Add editor content stylesheet.
+ // @todo CSS settings are currently not used.
if (isset($config['css_setting'])) {
if ($config['css_setting'] == 'theme') {
$css = drupal_get_path('theme', variable_get('theme_default', NULL)) . '/style.css';
diff --git a/editors/wymeditor.inc b/editors/wymeditor.inc
index 5f44d64..78dd318 100644
--- a/editors/wymeditor.inc
+++ b/editors/wymeditor.inc
@@ -30,6 +30,7 @@ function wysiwyg_wymeditor_editor() {
),
'version callback' => 'wysiwyg_wymeditor_version',
'themes callback' => 'wysiwyg_wymeditor_themes',
+ 'settings form callback' => 'wysiwyg_wymeditor_settings_form',
'settings callback' => 'wysiwyg_wymeditor_settings',
'plugin callback' => 'wysiwyg_wymeditor_plugins',
'versions' => array(
@@ -82,6 +83,42 @@ function wysiwyg_wymeditor_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for WYMeditor.
+ *
+ * @see http://wymeditor.readthedocs.org/en/latest/version_1.0_and_0.5/getting_started/customize.html
+ */
+function wysiwyg_wymeditor_settings_form(&$form, &$form_state) {
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+
+ $settings += array(
+ 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
+ );
+
+ $form['css']['#description'] = t('Note: WYMeditor can only load a single stylesheet into the editor.');
+ $form['css']['css_classes']['#access'] = FALSE;
+
+ $form['css']['block_formats'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block formats'),
+ '#default_value' => $settings['block_formats'],
+ '#size' => 40,
+ '#maxlength' => 250,
+ '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list
.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,blockquote,pre,th')),
+ '#element_validate' => array('wysiwyg_wymeditor_settings_form_validate_block_formats'),
+ );
+}
+
+/**
+ * #element_validate handler for block_formats element added by wysiwyg_wymeditor_settings_form().
+ */
+function wysiwyg_wymeditor_settings_form_validate_block_formats($element, &$form_state) {
+ // Remove any white-space from 'block_formats' setting, since editor
+ // implementations rely on a comma-separated list to explode().
+ form_set_value($form['css']['block_formats'], preg_replace('@\s+@', '', $element['#value']), $form_state);
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -169,6 +206,7 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) {
}
}
+ // Add editor content stylesheet.
if (isset($config['css_setting'])) {
if ($config['css_setting'] == 'theme') {
// WYMeditor only supports one CSS file currently.
diff --git a/editors/yui.inc b/editors/yui.inc
index 36d0a59..c6fbec0 100644
--- a/editors/yui.inc
+++ b/editors/yui.inc
@@ -42,6 +42,7 @@ function wysiwyg_yui_editor() {
),
'version callback' => 'wysiwyg_yui_version',
'themes callback' => 'wysiwyg_yui_themes',
+ 'settings form callback' => 'wysiwyg_yui_settings_form',
'load callback' => 'wysiwyg_yui_load',
'settings callback' => 'wysiwyg_yui_settings',
'plugin callback' => 'wysiwyg_yui_plugins',
@@ -105,6 +106,32 @@ function wysiwyg_yui_themes($editor, $profile) {
}
/**
+ * Enhances the editor profile settings form for YUI.
+ *
+ * @see http://developer.yahoo.com/yui/docs/YAHOO.widget.Editor.html
+ */
+function wysiwyg_yui_settings_form(&$form, &$form_state) {
+ $form['basic']['language']['#access'] = FALSE;
+
+ $form['css']['css_classes']['#access'] = FALSE;
+
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+
+ $settings += array(
+ );
+
+ $form['appearance']['autoHeight'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable automatic height'),
+ '#default_value' => $settings['autoHeight'],
+ '#return_value' => 1,
+ '#description' => t('When enabled, removes the scrollbars from the edit area and resizes it to fit the content.'),
+ );
+
+}
+
+/**
* Perform additional actions upon loading this editor.
*
* @param $editor
@@ -143,11 +170,7 @@ function wysiwyg_yui_settings($editor, $config, $theme) {
'ptags' => TRUE,
);
- if (isset($config['path_loc']) && $config['path_loc'] != 'none') {
- $settings['dompath'] = $config['path_loc'];
- }
- // Enable auto-height feature when editor should be resizable.
- if (!empty($config['resizing'])) {
+ if (!empty($config['autoHeight'])) {
$settings['autoHeight'] = TRUE;
}
diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc
index 0a37063..d61d50e 100644
--- a/wysiwyg.admin.inc
+++ b/wysiwyg.admin.inc
@@ -18,27 +18,14 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
if (empty($profile['settings'])) {
$profile['settings'] = array();
}
- $profile['settings'] += array(
+ $settings = &$profile['settings'];
+ $settings += array(
'default' => TRUE,
'user_choose' => FALSE,
'show_toggle' => TRUE,
- 'theme' => 'advanced',
+ 'theme' => '',
'language' => 'en',
- 'access' => 1,
- 'access_pages' => "node/*\nuser/*\ncomment/*",
'buttons' => array(),
- 'toolbar_loc' => 'top',
- 'toolbar_align' => 'left',
- 'path_loc' => 'bottom',
- 'resizing' => TRUE,
- // Also available, but buggy in TinyMCE 2.x: blockquote,code,dt,dd,samp.
- 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
- 'verify_html' => TRUE,
- 'preformatted' => FALSE,
- 'convert_fonts_to_spans' => TRUE,
- 'remove_linebreaks' => TRUE,
- 'apply_source_formatting' => FALSE,
- 'paste_auto_cleanup_on_paste' => FALSE,
'css_setting' => 'theme',
'css_path' => NULL,
'css_classes' => NULL,
@@ -64,7 +51,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['basic']['default'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled by default'),
- '#default_value' => $profile->settings['default'],
+ '#default_value' => $settings['default'],
'#return_value' => 1,
'#description' => t('The default editor state for users having access to this profile. Users are able to override this state if the next option is enabled.'),
);
@@ -72,7 +59,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['basic']['user_choose'] = array(
'#type' => 'checkbox',
'#title' => t('Allow users to choose default'),
- '#default_value' => $profile->settings['user_choose'],
+ '#default_value' => $settings['user_choose'],
'#return_value' => 1,
'#description' => t('If allowed, users will be able to choose their own editor default state in their user account settings.'),
);
@@ -80,20 +67,20 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['basic']['show_toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Show enable/disable rich text toggle link'),
- '#default_value' => $profile->settings['show_toggle'],
+ '#default_value' => $settings['show_toggle'],
'#return_value' => 1,
'#description' => t('Whether or not to show the enable/disable rich text toggle link below a textarea. If disabled, the user setting or global default is used (see above).'),
);
$form['basic']['theme'] = array(
'#type' => 'hidden',
- '#value' => $profile->settings['theme'],
+ '#value' => $settings['theme'],
);
$form['basic']['language'] = array(
'#type' => 'select',
'#title' => t('Interface language'),
- '#default_value' => $profile->settings['language'],
+ '#default_value' => $settings['language'],
);
// @see _locale_prepare_predefined_list()
require_once DRUPAL_ROOT . '/includes/iso.inc';
@@ -139,7 +126,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['buttons'][$name][$button] = array(
'#type' => 'checkbox',
'#title' => $title,
- '#default_value' => !empty($profile->settings['buttons'][$name][$button]) ? $profile->settings['buttons'][$name][$button] : FALSE,
+ '#default_value' => !empty($settings['buttons'][$name][$button]) ? $settings['buttons'][$name][$button] : FALSE,
'#description' => isset($meta['url']) ? l($meta['url'], $meta['url']) : NULL,
);
}
@@ -149,7 +136,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['buttons'][$name][$extension] = array(
'#type' => 'checkbox',
'#title' => check_plain($title),
- '#default_value' => !empty($profile->settings['buttons'][$name][$extension]) ? $profile->settings['buttons'][$name][$extension] : FALSE,
+ '#default_value' => !empty($settings['buttons'][$name][$extension]) ? $settings['buttons'][$name][$extension] : FALSE,
'#description' => isset($meta['url']) ? l($meta['url'], $meta['url']) : NULL,
);
}
@@ -164,38 +151,6 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'#group' => 'advanced',
);
- $form['appearance']['toolbar_loc'] = array(
- '#type' => 'select',
- '#title' => t('Toolbar location'),
- '#default_value' => $profile->settings['toolbar_loc'],
- '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')),
- '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.'),
- );
-
- $form['appearance']['toolbar_align'] = array(
- '#type' => 'select',
- '#title' => t('Button alignment'),
- '#default_value' => $profile->settings['toolbar_align'],
- '#options' => array('center' => t('Center'), 'left' => t('Left'), 'right' => t('Right')),
- '#description' => t('This option controls the alignment of icons in the editor toolbar.'),
- );
-
- $form['appearance']['path_loc'] = array(
- '#type' => 'select',
- '#title' => t('Path location'),
- '#default_value' => $profile->settings['path_loc'],
- '#options' => array('none' => t('Hide'), 'top' => t('Top'), 'bottom' => t('Bottom')),
- '#description' => t('Where to display the path to HTML elements (i.e. body > table > tr > td
).'),
- );
-
- $form['appearance']['resizing'] = array(
- '#type' => 'checkbox',
- '#title' => t('Enable resizing button'),
- '#default_value' => $profile->settings['resizing'],
- '#return_value' => 1,
- '#description' => t('This option gives you the ability to enable/disable the resizing button. If enabled, the Path location toolbar must be set to "Top" or "Bottom" in order to display the resize icon.'),
- );
-
$form['output'] = array(
'#type' => 'fieldset',
'#title' => t('Cleanup and output'),
@@ -204,54 +159,6 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'#group' => 'advanced',
);
- $form['output']['verify_html'] = array(
- '#type' => 'checkbox',
- '#title' => t('Verify HTML'),
- '#default_value' => $profile->settings['verify_html'],
- '#return_value' => 1,
- '#description' => t('If enabled, potentially malicious code like <HEAD>
tags will be removed from HTML contents.'),
- );
-
- $form['output']['preformatted'] = array(
- '#type' => 'checkbox',
- '#title' => t('Preformatted'),
- '#default_value' => $profile->settings['preformatted'],
- '#return_value' => 1,
- '#description' => t('If enabled, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE element in HTML does.'),
- );
-
- $form['output']['convert_fonts_to_spans'] = array(
- '#type' => 'checkbox',
- '#title' => t('Convert <font> tags to styles'),
- '#default_value' => $profile->settings['convert_fonts_to_spans'],
- '#return_value' => 1,
- '#description' => t('If enabled, HTML tags declaring the font size, font family, font color and font background color will be replaced by inline CSS styles.'),
- );
-
- $form['output']['remove_linebreaks'] = array(
- '#type' => 'checkbox',
- '#title' => t('Remove linebreaks'),
- '#default_value' => $profile->settings['remove_linebreaks'],
- '#return_value' => 1,
- '#description' => t('If enabled, the editor will remove most linebreaks from contents. Disabling this option could avoid conflicts with other input filters.'),
- );
-
- $form['output']['apply_source_formatting'] = array(
- '#type' => 'checkbox',
- '#title' => t('Apply source formatting'),
- '#default_value' => $profile->settings['apply_source_formatting'],
- '#return_value' => 1,
- '#description' => t('If enabled, the editor will re-format the HTML source code. Disabling this option could avoid conflicts with other input filters.'),
- );
-
- $form['output']['paste_auto_cleanup_on_paste'] = array(
- '#type' => 'checkbox',
- '#title' => t('Force cleanup on standard paste'),
- '#default_value' => $profile->settings['paste_auto_cleanup_on_paste'],
- '#return_value' => 1,
- '#description' => t('If enabled, the default paste function (CTRL-V or SHIFT-INS) behaves like the "paste from word" plugin function.'),
- );
-
$form['css'] = array(
'#type' => 'fieldset',
'#title' => t('CSS'),
@@ -260,19 +167,10 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'#group' => 'advanced',
);
- $form['css']['block_formats'] = array(
- '#type' => 'textfield',
- '#title' => t('Block formats'),
- '#default_value' => $profile->settings['block_formats'],
- '#size' => 40,
- '#maxlength' => 250,
- '#description' => t('Comma separated list of HTML block formats. Possible values: @format-list
.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')),
- );
-
$form['css']['css_setting'] = array(
'#type' => 'select',
'#title' => t('Editor CSS'),
- '#default_value' => $profile->settings['css_setting'],
+ '#default_value' => $settings['css_setting'],
'#options' => array('theme' => t('Use theme CSS'), 'self' => t('Define CSS'), 'none' => t('Editor default CSS')),
'#description' => t('Defines the CSS to be used in the editor area.
Use theme CSS - loads stylesheets from current site theme.
Define CSS - enter path for stylesheet files below.
Editor default CSS - uses default stylesheets from editor.'),
);
@@ -280,7 +178,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['css']['css_path'] = array(
'#type' => 'textfield',
'#title' => t('CSS path'),
- '#default_value' => $profile->settings['css_path'],
+ '#default_value' => $settings['css_path'],
'#size' => 40,
'#maxlength' => 255,
'#description' => t('If "Define CSS" was selected above, enter path to a CSS file or a list of CSS files separated by a comma.') . '
' . t('Available tokens: %b
(base path, eg: /
), %t
(path to theme, eg: themes/garland
)') . '
' . t('Example:') . ' css/editor.css,/themes/garland/style.css,%b%t/style.css,http://example.com/external.css',
@@ -289,7 +187,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['css']['css_classes'] = array(
'#type' => 'textarea',
'#title' => t('CSS classes'),
- '#default_value' => $profile->settings['css_classes'],
+ '#default_value' => $settings['css_classes'],
'#description' => t('Optionally define CSS classes for the "Font style" dropdown list.
Enter one class on each line in the format: !format. Example: !example
If left blank, CSS classes are automatically imported from all loaded stylesheet(s).', array('!format' => '[title]=[class]
', '!example' => 'My heading=header1')),
);
@@ -322,6 +220,12 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$editor['settings form callback']($form, $form_state);
}
+ foreach (array('appearance', 'output') as $fieldset) {
+ if (count(element_children($form[$fieldset])) == 0) {
+ $form[$fieldset]['#access'] = FALSE;
+ }
+ }
+
return $form;
}
@@ -340,9 +244,6 @@ function wysiwyg_profile_form_submit($form, &$form_state) {
// Store only enabled plugins.
$values['buttons'] = array_filter($values['buttons']);
}
- // Remove any white-space from 'block_formats' setting, since editor
- // implementations rely on a comma-separated list to explode().
- $values['block_formats'] = preg_replace('@\s+@', '', $values['block_formats']);
// Remove input format name.
$format = $values['format'];
diff --git a/wysiwyg.install b/wysiwyg.install
index 9832b7d..13edb74 100644
--- a/wysiwyg.install
+++ b/wysiwyg.install
@@ -340,3 +340,73 @@ function wysiwyg_update_7201() {
}
}
}
+
+/**
+ * Update internal names of settings.
+ */
+function wysiwyg_update_7202() {
+ $query = db_select('wysiwyg', 'w')
+ ->fields('w', array('format', 'editor', 'settings'));
+ foreach ($query->execute() as $profile) {
+ $settings = unserialize($profile->settings);
+ $changed = FALSE;
+ switch ($profile->editor) {
+ case 'tinymce':
+ // No changes needed.
+ break;
+ case 'ckeditor':
+ if (isset($settings['resizing'])) {
+ $settings['enable_resize'] = $settings['resizing'];
+ unset($settings['resizing']);
+ $changed = TRUE;
+ }
+ if (isset($settings['toolbar_loc'])) {
+ $settings['toolbarLocation'] = $settings['toolbar_loc'];
+ unset($settings['toolbar_loc']);
+ $changed = TRUE;
+ }
+ if (isset($settings['paste_auto_cleanup_on_paste'])) {
+ $settings['forcePasteAsPlainText'] = $settings['paste_auto_cleanup_on_paste'];
+ unset($settings['paste_auto_cleanup_on_paste']);
+ $changed = TRUE;
+ }
+ break;
+ case 'fckeditor':
+ if (isset($settings['apply_source_formatting'])) {
+ $settings['FormatSource'] = $settings['FormatOutput'] = $settings['apply_source_formatting'];
+ unset($settings['apply_source_formatting']);
+ $changed = TRUE;
+ }
+ if (isset($settings['paste_auto_cleanup_on_paste'])) {
+ $settings['ForcePasteAsPlainText'] = $settings['paste_auto_cleanup_on_paste'];
+ unset($settings['paste_auto_cleanup_on_paste']);
+ $changed = TRUE;
+ }
+ break;
+ case 'yui':
+ // The reisizing settin was triggering autoHeight instead of resize.
+ if (isset($settings['resizing'])) {
+ $settings['autoHeight'] = $settings['resizing'];
+ unset($settings['resizing']);
+ $changed = TRUE;
+ }
+ break;
+ case 'openwysiwyg':
+ if (isset($settings['path_loc'])) {
+ $settings['StatusBarEnabled'] = ($settings['path_loc'] != 'none' );
+ unset($settings['path_loc']);
+ $changed = TRUE;
+ }
+ break;
+ default:
+ }
+ if ($changed) {
+ db_update('wysiwyg')
+ ->condition('format', $profile->format)
+ ->fields(array(
+ 'settings' => serialize($settings),
+ ))
+ ->execute();
+ }
+ }
+}