diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc
index 6ff60d5..8b6215a 100644
--- a/editors/ckeditor.inc
+++ b/editors/ckeditor.inc
@@ -135,19 +135,84 @@ 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'];
+ $installed_version = $form_state['wysiwyg']['editor']['installed version'];
+
+ $ckeditor_defaults = array();
+ if (version_compare($installed_version, '3.1.0', '>=')) {
+ // Enabled by default.
+ $ckeditor_defaults['pasteFromWordRemoveFontStyles'] = TRUE;
+ $ckeditor_defaults['pasteFromWordRemoveStyles'] = TRUE;
+ }
+
+ $profile->settings += $ckeditor_defaults;
+
+ $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($profile->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.1.0', '>=')) {
+ $form['paste']['pasteFromWord'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Paste from Word'),
+ );
+
+ $form['paste']['pasteFromWord']['pasteFromWordNumberedHeadingToList'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Numbered heading to list'),
+ '#default_value' => !empty($profile->settings['pasteFromWordNumberedHeadingToList']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, transforms MS Word outline numbered headings into lists.'),
+ );
+
+ $form['paste']['pasteFromWord']['pasteFromWordPromptCleanup'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Promt on cleanup'),
+ '#default_value' => !empty($profile->settings['pasteFromWordPromptCleanup']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, prompts the user about the clean up of content being pasted from MS Word.'),
+ );
- if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.6.0', '>=')) {
+ $form['paste']['pasteFromWord']['pasteFromWordRemoveFontStyles'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove font styles'),
+ '#default_value' => !empty($profile->settings['pasteFromWordRemoveFontStyles']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, removes all font related formatting styles, including font size, font family, font foreground/background color..'),
+ );
+
+ $form['paste']['pasteFromWord']['pasteFromWordRemoveStyles'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove styles'),
+ '#default_value' => !empty($profile->settings['pasteFromWordRemoveStyles']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, removes element styles that can\'t be managed with the editor, other than font specific styles.'),
+ );
+ }
+
+ 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($profile->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]
',
@@ -246,10 +311,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,9 +341,21 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
}
}
- if (isset($config['language'])) {
- $settings['language'] = $config['language'];
+ $check_if_set = array(
+ 'apply_source_formatting',
+ 'forcePasteAsPlainText',
+ 'language',
+ 'pasteFromWordNumberedHeadingToList',
+ 'pasteFromWordPromptCleanup',
+ 'pasteFromWordRemoveFontStyles',
+ 'pasteFromWordRemoveStyles',
+ );
+ foreach ($check_if_set as $setting_name) {
+ if (isset($config[$setting_name])) {
+ $settings[$setting_name] = $config[$setting_name];
+ }
}
+
if (isset($config['resizing'])) {
// CKEditor performs a type-agnostic comparison on this particular setting.
$settings['resize_enabled'] = (bool) $config['resizing'];
@@ -290,9 +363,6 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
if (isset($config['toolbar_loc'])) {
$settings['toolbarLocation'] = $config['toolbar_loc'];
}
- if (isset($config['paste_auto_cleanup_on_paste'])) {
- $settings['forcePasteAsPlainText'] = $config['paste_auto_cleanup_on_paste'];
- }
$settings['toolbar'] = array();
$supports_groups = version_compare($editor['installed version'], '3.6.0', '>=');
diff --git a/editors/fckeditor.inc b/editors/fckeditor.inc
index 27bcb7b..de2f2b6 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,41 @@ 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'];
+ $profile->settings += array(
+ // Enabled by default.
+ 'AutoDetectPasteFromWord' => TRUE,
+ );
+ $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' => $profile->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($profile->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.'),
+ );
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -123,8 +159,11 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) {
if (isset($config['apply_source_formatting'])) {
$settings['FormatOutput'] = $settings['FormatSource'] = $config['apply_source_formatting'];
}
- if (isset($config['paste_auto_cleanup_on_paste'])) {
- $settings['AutoDetectPasteFromWord'] = $config['paste_auto_cleanup_on_paste'];
+ if (isset($config['ForcePasteAsPlainText'])) {
+ $settings['ForcePasteAsPlainText'] = $config['ForcePasteAsPlainText'];
+ }
+ if (isset($config['AutoDetectPasteFromWord'])) {
+ $settings['AutoDetectPasteFromWord'] = $config['AutoDetectPasteFromWord'];
}
if (isset($config['css_setting'])) {
diff --git a/editors/tinymce.inc b/editors/tinymce.inc
index fc48174..f787544 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,148 @@ 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'];
+
+ $profile->settings += array(
+ // Enabled by default.
+ 'paste_auto_cleanup_on_paste' => TRUE,
+ 'paste_retain_style_properties' => 'none',
+ 'paste_remove_styles_if_webkit' => TRUE,
+ 'paste_strip_class_attributes' => 'mso',
+ 'paste_convert_middot_lists' => TRUE,
+ 'paste_max_consecutive_linebreaks' => 2,
+ 'paste_text_linebreaktype' => 'combined',
+ );
+
+ $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($profile->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.'),
+ );
+ $form['output']['paste_block_drop'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Block drag/drop'),
+ '#default_value' => !empty($profile->settings['paste_block_drop']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, blocks drag/drop from/to the editor and inside it.'),
+ );
+ $form['paste']['paste_retain_style_properties'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Retain style properties'),
+ '#default_value' => $profile->settings['paste_retain_style_properties'],
+ '#description' => t('Comma separated list of style properties to retain during the paste operation from Word. For example: "font-size,color". If you want to remove all style properties use an empty string "" or "none". If you want to keep all style properties, use "all" or "*".'),
+ );
+ $form['paste']['paste_strip_class_attributes'] = array(
+ '#type' => 'select',
+ '#title' => t('Strip class attributes'),
+ '#options' => array(
+ 'none' => t('None'),
+ 'all' => t('All'),
+ 'mso' => t('MS Office'),
+ ),
+ '#default_value' => $profile->settings['paste_strip_class_attributes'],
+ '#description' => t('Enables you to strip the class attributes when pasted.'),
+ );
+ $form['paste']['paste_remove_spans'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove spans'),
+ '#default_value' => !empty($profile->settings['paste_remove_spans']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, removes all span elements when pasting.'),
+ );
+ $form['paste']['paste_remove_styles'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove styles'),
+ '#default_value' => !empty($profile->settings['paste_remove_styles']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, removes all style information when pasting, regardless of browser type. Pasting from Word 2000 will cause TinyMCE to error.'),
+ );
+ $form['paste']['paste_remove_styles_if_webkit'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove styles in WebKit'),
+ '#default_value' => !empty($profile->settings['paste_remove_styles_if_webkit']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, removes all style information when pasting in WebKit since it has a serious paste bug.'),
+ );
+ $form['paste']['paste_convert_middot_lists'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Convert Word lists'),
+ '#default_value' => !empty($profile->settings['paste_convert_middot_lists']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, the paste plugin tries to convert Word lists into semantic XHTML list elements.'),
+ );
+ $form['paste']['paste_convert_headers_to_strong'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Convert headers to strong'),
+ '#default_value' => !empty($profile->settings['paste_convert_headers_to_strong']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, the paste plugin tries to convert Word headers to strong tags.'),
+ );
+ $form['paste']['paste_max_consecutive_linebreaks'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Max consecutive linebreaks'),
+ '#size' => 5,
+ '#maxlength' => '10',
+ '#default_value' => !empty($profile->settings['paste_max_consecutive_linebreaks']),
+ '#description' => t('The maximum number of consecutive linebreaks to use.'),
+ );
+ $form['paste']['paste_text_use_dialog'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use dialog'),
+ '#default_value' => !empty($profile->settings['paste_text_use_dialog']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, uses legacy mode for the Paste as Text button. Will use a dialog instead of treating the button as a toggle.'),
+ );
+ $form['paste']['paste_text_sticky'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Sticky "Paste text" button'),
+ '#default_value' => !empty($profile->settings['paste_text_sticky']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, keeps the "Paste text" button selected after pasting. Requires the "Paste text" button and "Process contents on paste" to be enabled.'),
+ );
+ $form['paste']['paste_text_sticky_default'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Paste as plain text by default'),
+ '#default_value' => !empty($profile->settings['paste_text_sticky_default']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, the "Paste text" button is selected when the editor starts. Requires the "Paste text" button and "Process contents on paste" to be enabled.'),
+ );
+ $form['paste']['paste_text_notifyalways'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Always notify when pasting plain text'),
+ '#default_value' => !empty($profile->settings['paste_text_notifyalways']),
+ '#return_value' => 1,
+ '#description' => t('If enabled, users will be notified each time plain text pasting mode is enabled.'),
+ );
+ $form['paste']['paste_text_linebreaktype'] = array(
+ '#type' => 'select',
+ '#title' => t('Linebreak type'),
+ '#options' => array(
+ 'combined' => t('Combined'),
+ 'p' => t('
'),
+ 'br' => t('
'),
+ ),
+ '#default_value' => $profile->settings['paste_text_linebreaktype'],
+ '#description' => t('Converts plain text linebreaks to br or p elements.'),
+ );
+}
+
+/**
* Returns an initialization JavaScript for this editor library.
*
* @param array $editor
@@ -194,23 +337,31 @@ 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',
+ 'paste_block_drop',
+ 'paste_convert_middot_lists',
+ 'paste_convert_headers_to_strong',
+ 'paste_max_consecutive_linebreaks',
+ 'paste_remove_spans',
+ 'paste_remove_styles',
+ 'paste_remove_styles_if_webkit',
+ 'paste_retain_style_properties',
+ 'paste_strip_class_attributes',
+ 'paste_text_use_dialog',
+ 'pste_text_linebreaktype',
+ 'paste_text_sticky',
+ 'paste_text_sticky_default',
+ '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/wysiwyg.admin.inc b/wysiwyg.admin.inc
index 0a37063..5beaaf3 100644
--- a/wysiwyg.admin.inc
+++ b/wysiwyg.admin.inc
@@ -38,7 +38,6 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'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,
@@ -244,14 +243,6 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'#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'),
diff --git a/wysiwyg.install b/wysiwyg.install
index 9832b7d..b19e63e 100644
--- a/wysiwyg.install
+++ b/wysiwyg.install
@@ -340,3 +340,48 @@ 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':
+ // Do nothing.
+ break;
+ case 'ckeditor':
+ if (isset($profile->settings['paste_auto_cleanup_on_paste'])) {
+ $profile->settings['forcePasteAsPlainText'] = $profile->settings['paste_auto_cleanup_on_paste'];
+ unset($profile->settings['paste_auto_cleanup_on_paste']);
+ $changed = TRUE;
+ }
+ break;
+ case 'fckeditor':
+ if (isset($profile->settings['paste_auto_cleanup_on_paste'])) {
+ $profile->settings['ForcePasteAsPlainText'] = $profile->settings['paste_auto_cleanup_on_paste'];
+ unset($profile->settings['paste_auto_cleanup_on_paste']);
+ $changed = TRUE;
+ }
+ break;
+ default:
+ // No other editor supports paste_auto_cleanup_on_paste.
+ if (isset($profile->settings['paste_auto_cleanup_on_paste'])) {
+ unset($profile->settings['paste_auto_cleanup_on_paste']);
+ $changed = TRUE;
+ }
+ }
+ if ($changed) {
+ db_update('wysiwyg')
+ ->condition('format', $profile->format)
+ ->fields(array(
+ 'settings' => serialize($profile->settings),
+ ))
+ ->execute();
+ }
+ }
+}