diff --git a/editors/ckeditor.inc b/editors/ckeditor.inc
index 6ff60d5..28e0a8c 100644
--- a/editors/ckeditor.inc
+++ b/editors/ckeditor.inc
@@ -135,36 +135,91 @@ 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'];
+
+ $ckeditor_defaults = array(
+ 'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
+ 'toolbarLocation' => 'top',
+ 'resize_enabled' => TRUE,
+ 'stylesSet' => '',
+ );
+
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'toolbarLocation', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-toolbarLocation'))),
+ );
+
+ $form['appearance']['resize_enabled'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable resizing button'),
+ '#default_value' => $settings['resize_enabled'],
+ '#return_value' => 1,
+ '#description' => t('This option gives you the ability to enable/disable the editor resizing feature.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'resize_enabled', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-resize_enabled'))),
+ );
- if (version_compare($form_state['wysiwyg']['editor']['installed version'], '3.6.0', '>=')) {
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'forcePasteAsPlainText', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-forcePasteAsPlainText'))),
+ );
+
+ 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', '>=')) {
- // 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]
',
- '!example' => 'Title=h1.title
',
- ));
- $form['css']['css_classes']['#element_validate'][] = 'wysiwyg_ckeditor_settings_form_validate_css_classes';
- }
- else {
+ if (version_compare($installed_version, '3.2.1', '>=')) {
// Versions below 3.2.1 do not support Font styles at all.
- $form['css']['css_classes']['#access'] = FALSE;
+ $form['css']['stylesSet'] = array(
+ '#type' => 'textarea',
+ '#title' => t('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(
+ '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.stylesSet'),
+ '!format' => '[label]=[element].[class]
',
+ '!example' => 'Title=h1.title
',
+ )) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'stylesSet', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-stylesSet'))),
+ '#default_value' => $settings['stylesSet'],
+ '#element_validate' => array('wysiwyg_ckeditor_settings_form_validate_stylessets'),
+ );
+
}
+
+ $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 and other block elements')) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'block_formats', '@url' => url('http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-format_tags'))),
+ );
}
/**
* #element_validate handler for CSS classes element altered by wysiwyg_ckeditor_settings_form().
*/
-function wysiwyg_ckeditor_settings_form_validate_css_classes($element, &$form_state) {
+function wysiwyg_ckeditor_settings_form_validate_stylessets($element, &$form_state) {
if (wysiwyg_ckeditor_settings_parse_styles($element['#value']) === FALSE) {
form_error($element, t('The specified CSS classes are syntactically incorrect.'));
}
@@ -237,7 +292,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
// Add HTML block format settings; common block formats are already predefined
// by CKEditor.
if (isset($config['block_formats'])) {
- $block_formats = explode(',', drupal_strtolower($config['block_formats']));
+ $block_formats = explode(',', drupal_strtolower(preg_replace('@\s+@', '', $config['block_formats'])));
$predefined_formats = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'address', 'div');
foreach (array_diff($block_formats, $predefined_formats) as $tag) {
$tag = trim($tag);
@@ -246,10 +301,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', '<')) {
@@ -275,23 +326,28 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
// @todo This should be a plugin setting, but Wysiwyg does not support
// plugin-specific settings yet.
if (!empty($config['buttons']['default']['Styles']) && version_compare($editor['installed version'], '3.2.1', '>=')) {
- if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['css_classes'])) {
+ if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['stylesSet'])) {
$settings['stylesSet'] = $styles;
}
}
- 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();
@@ -367,7 +423,7 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
}
/**
- * Parses CSS classes settings string into a stylesSet JavaScript settings array.
+ * Parses stylesSet settings string into a stylesSet JavaScript settings array.
*
* @param string $css_classes
* A string containing CSS class definitions to add to the Style dropdown
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..ef0c5d3 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,67 @@ 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,
+ 'FontFormats' => '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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'FormatSource', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/FormatSource'))),
+ );
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'FormatOutput', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/FormatOutput'))),
+ );
+ $form['css']['FontFormats'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block formats'),
+ '#default_value' => $settings['FontFormats'],
+ '#size' => 40,
+ '#maxlength' => 250,
+ '#description' => t('Semicolon separated list of HTML block formats. Possible values: @format-list
.', array('@format-list' => 'p;h1;h2;h3;h4;h5;h6;div;address;pre')) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'FontFormats', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/FontFormats'))),
+ );
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'AutoDetectPasteFromWord', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/AutoDetectPasteFromWord'))),
+ );
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'ForcePasteAsPlainText', '@url' => url('http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/ForcePasteAsPlainText'))),
+ );
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -117,14 +179,20 @@ function wysiwyg_fckeditor_settings($editor, $config, $theme) {
'IncludeLatinEntities' => FALSE,
'IncludeGreekEntities' => FALSE,
);
- if (isset($config['block_formats'])) {
- $settings['FontFormats'] = strtr($config['block_formats'], array(',' => ';'));
+ if (isset($config['FontFormats'])) {
+ $settings['FontFormats'] = preg_replace('@\s+@', '', $config['FontFormats']);
+ }
+ if (isset($config['FormatOutput'])) {
+ $settings['FormatOutput'] = $config['FormatOutput'];
+ }
+ if (isset($config['FormatSource'])) {
+ $settings['FormatSource'] = $config['FormatSource'];
}
- if (isset($config['apply_source_formatting'])) {
- $settings['FormatOutput'] = $settings['FormatSource'] = $config['apply_source_formatting'];
+ 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/js/tinymce-4.js b/editors/js/tinymce-4.js
new file mode 100644
index 0000000..45e95b6
--- /dev/null
+++ b/editors/js/tinymce-4.js
@@ -0,0 +1,234 @@
+(function($) {
+
+/**
+ * Initialize editor instances.
+ *
+ * @todo Is the following note still valid for 3.x?
+ * This function needs to be called before the page is fully loaded, as
+ * calling tinymce.init() after the page is loaded breaks IE6.
+ *
+ * @param editorSettings
+ * An object containing editor settings for each input format.
+ */
+Drupal.wysiwyg.editor.init.tinymce = function(settings) {
+ tinymce.on('active focus', function(e) {
+ Drupal.wysiwyg.activeId = e.editor.id;
+ });
+ // Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
+ var $drupalToolbars = $('#toolbar, #admin-menu', Drupal.overlayChild ? window.parent.document : document);
+ tinymce.on('AddEditor', function (e) {
+ e.editor.on('FullscreenStateChanged', function (e) {
+ if (e.state) {
+ $drupalToolbars.hide();
+ }
+ else {
+ $drupalToolbars.show();
+ }
+ });
+ });
+
+ // Initialize editor configurations.
+ for (var format in settings) {
+ if (Drupal.settings.wysiwyg.plugins[format]) {
+ // Load native external plugins.
+ // Array syntax required; 'native' is a predefined token in JavaScript.
+ for (var plugin in Drupal.settings.wysiwyg.plugins[format]['native']) {
+ tinymce.PluginManager.load(plugin, Drupal.settings.wysiwyg.plugins[format]['native'][plugin]);
+ }
+ // Load Drupal plugins.
+ for (var plugin in Drupal.settings.wysiwyg.plugins[format].drupal) {
+ Drupal.wysiwyg.editor.instance.tinymce.addPlugin(plugin, Drupal.settings.wysiwyg.plugins[format].drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin]);
+ }
+ }
+ }
+};
+
+/**
+ * Attach this editor to a target element.
+ *
+ * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
+ */
+Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
+ // Configure editor settings for this input format.
+// var ed = new tinymce.Editor(params.field, settings);
+
+ // Remove TinyMCE's internal mceItem class, which was incorrectly added to
+ // submitted content by Wysiwyg <2.1. TinyMCE only temporarily adds the class
+ // for placeholder elements. If preemptively set, the class prevents (native)
+ // editor plugins from gaining an active state, so we have to manually remove
+ // it prior to attaching the editor. This is done on the client-side instead
+ // of the server-side, as Wysiwyg has no way to figure out where content is
+ // stored, and the class only affects editing.
+ $field = $('#' + params.field);
+ $field.val($field.val().replace(/(<.+?\s+class=['"][\w\s]*?)\bmceItem\b([\w\s]*?['"].*?>)/ig, '$1$2'));
+
+ // Attach editor.
+ // ed.render();
+ settings.selector = '#' + params.field;
+ tinymce.init(settings);
+};
+
+/**
+ * Detach a single or all editors.
+ *
+ * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
+ */
+Drupal.wysiwyg.editor.detach.tinymce = function (context, params, trigger) {
+ if (typeof params != 'undefined') {
+ var instance = tinymce.get(params.field);
+ if (instance) {
+ instance.save();
+ if (trigger != 'serialize') {
+ instance.remove();
+ }
+ }
+ }
+ else {
+ // Save contents of all editors back into textareas.
+ tinymce.triggerSave();
+ if (trigger != 'serialize') {
+ // Remove all editor instances.
+ for (var instance in tinymce.editors) {
+ tinymce.editors[instance].remove();
+ }
+ }
+ }
+};
+
+Drupal.wysiwyg.editor.instance.tinymce = {
+ addPlugin: function(plugin, settings, pluginSettings) {
+ if (typeof Drupal.wysiwyg.plugins[plugin] != 'object') {
+ return;
+ }
+
+ // Register plugin.
+ tinymce.PluginManager.add('drupal_' + plugin, function (editor) {
+ var button = {
+ title : settings.iconTitle,
+ image : settings.icon,
+ onPostRender : function() {
+ var self = this;
+ editor.on('nodeChange', function (e) {
+ // isNode: Return whether the plugin button should be enabled for the
+ // current selection.
+ if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
+ self.active(Drupal.wysiwyg.plugins[plugin].isNode(e.element));
+ }
+ });
+ }
+ }
+ if (typeof Drupal.wysiwyg.plugins[plugin].invoke == 'function') {
+ button.onclick = function() {
+ var data = { format: 'html', node: editor.selection.getNode(), content: editor.selection.getContent() };
+ // TinyMCE creates a completely new instance for fullscreen mode.
+ Drupal.wysiwyg.plugins[plugin].invoke(data, pluginSettings, editor.id);
+ }
+ }
+
+ // Register the plugin button.
+ editor.addButton('drupal_' + plugin, button);
+ /**
+ * Initialize the plugin, executed after the plugin has been created.
+ *
+ * @param ed
+ * The tinymce.Editor instance the plugin is initialized in.
+ * @param url
+ * The absolute URL of the plugin location.
+ var editorId = (e.target.id == 'mce_fullscreen' ? e.target.getParam('fullscreen_editor_id') : e.target.id);
+ */
+ editor.on('init', function(e) {
+ // Load custom CSS for editor contents on startup.
+ if (settings.css) {
+ editor.dom.loadCSS(settings.css);
+ }
+
+ });
+
+ // Attach: Replace plain text with HTML representations.
+ editor.on('beforeSetContent', function(e) {
+ if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
+ e.content = Drupal.wysiwyg.plugins[plugin].attach(e.content, pluginSettings, e.target.id);
+ e.content = Drupal.wysiwyg.editor.instance.tinymce.prepareContent(e.content);
+ }
+ });
+
+ // Detach: Replace HTML representations with plain text.
+ editor.on('getContent', function(e) {
+ var editorId = (e.target.id == 'mce_fullscreen' ? e.target.getParam('fullscreen_editor_id') : e.target.id);
+ if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
+ e.content = Drupal.wysiwyg.plugins[plugin].detach(e.content, pluginSettings, editorId);
+ }
+ });
+ });
+ },
+
+ openDialog: function(dialog, params) {
+ var instanceId = this.getInstanceId();
+ var editor = tinymce.get(instanceId);
+ editor.windowManager.open({
+ file: dialog.url + '/' + instanceId,
+ width: dialog.width,
+ height: dialog.height,
+ inline: 1
+ }, params);
+ },
+
+ closeDialog: function(dialog) {
+ var editor = tinymce.get(this.getInstanceId());
+ editor.windowManager.close(dialog);
+ },
+
+ prepareContent: function(content) {
+ // Certain content elements need to have additional DOM properties applied
+ // to prevent this editor from highlighting an internal button in addition
+ // to the button of a Drupal plugin.
+ var specialProperties = {
+ img: { 'class': 'mceItem' }
+ };
+ var $content = $('
body > table > tr > td
).') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_statusbar_location', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_statusbar_location'))),
+ );
+
+ $form['appearance']['theme_advanced_resizing'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable resizing button'),
+ '#default_value' => $settings['theme_advanced_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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_resizing', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_resizing'))),
+ );
+
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'verify_html', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:preformatted'))),
+ );
+
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'preformatted', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:preformatted'))),
+ );
+
+ $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.') . ' ' . t('Uses the @setting setting internally.', array(
+ '@setting' => 'convert_fonts_to_spans', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:convert_fonts_to_spans'))),
+ );
+
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'remove_linebreaks', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:remove_linebreaks'))),
+ );
+
+ $form['css']['theme_advanced_styles'] = array(
+ '#type' => 'textarea',
+ '#title' => t('CSS classes'),
+ '#default_value' => $settings['theme_advanced_styles'],
+ '#description' => t('Optionally define CSS classes for the "Font style" dropdown list.[title]=[class]
',
+ '!example' => 'My heading=header1',
+ )
+ ) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_styles', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_styles'))),
+ );
+ if (version_compare($version, '4', '<')) {
+ $form['css']['theme_advanced_blockformats'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block formats'),
+ '#default_value' => $settings['theme_advanced_blockformats'],
+ '#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')) . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'theme_advanced_blockformats', '@url' => url('http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_blockformats'))),
+ '#element_validate' => array('wysiwyg_tinymce_settings_form_validate_blockformats'),
+ );
+ }
+ if (version_compare($version, '3.3', '>=')) {
+ $link_url = url('http://www.tinymce.com/wiki.php/Configuration3x:style_formats');
+ if (version_compare($version, '4', '>=')) {
+ $form['css']['theme_advanced_styles']['#access'] = FALSE;
+ $link_url = url('http://www.tinymce.com/wiki.php/Configuration:style_formats');
+ }
+ else {
+ $form['css']['theme_advanced_styles']['#description'] .= '@format-list
.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,blockquote,pre,th')),
+ );
+}
+
+/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
@@ -158,7 +184,7 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) {
'blockquote' => 'Blockquote',
'th' => 'Table_Header',
);
- foreach (explode(',', $config['block_formats']) as $tag) {
+ foreach (explode(',', preg_replace('@\s+@', '', $config['block_formats'])) as $tag) {
if (isset($containers[$tag])) {
$settings['containersItems'][] = array(
'name' => strtoupper($tag),
@@ -169,6 +195,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..a29fb66 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,46 @@ 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) {
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+ $settings += array(
+ 'block_formats' => 'p,h1,h2,h3,h4,h5,h6',
+ );
+
+ $form['basic']['language']['#access'] = FALSE;
+
+ $profile = $form_state['wysiwyg_profile'];
+ $settings = $profile->settings;
+
+ $settings += array(
+ 'autoHeight' => FALSE,
+ 'block_formats' => 'p,h2,h3,h4,h5,h6',
+ );
+
+ $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.') . ' ' . t('Uses the @setting setting internally.', array('@setting' => 'autoHeight', '@url' => url('http://developer.yahoo.com/yui/docs/YAHOO.widget.SimpleEditor.html#config_autoHeight'))),
+ );
+
+ $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,')),
+ );
+}
+
+/**
* Perform additional actions upon loading this editor.
*
* @param $editor
@@ -143,11 +184,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;
}
@@ -178,7 +215,7 @@ function wysiwyg_yui_settings($editor, $config, $theme) {
'h5' => array('text' => 'Heading 5', 'value' => 'h5'),
'h6' => array('text' => 'Heading 6', 'value' => 'h6'),
);
- foreach (explode(',', $config['block_formats']) as $tag) {
+ foreach (explode(',', preg_replace('@\s+@', '', $config['block_formats'])) as $tag) {
if (isset($headings[$tag])) {
$extra['menu'][] = $headings[$tag];
}
diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc
index 0a37063..77e6fdf 100644
--- a/wysiwyg.admin.inc
+++ b/wysiwyg.admin.inc
@@ -18,30 +18,16 @@ 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,
);
$profile = (object) $profile;
@@ -64,7 +50,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 +58,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 +66,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 +125,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 +135,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 +150,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 +158,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 +166,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.%b
(base path, eg: /
), %t
(path to theme, eg: themes/garland
)') . '[title]=[class]
', '!example' => 'My heading=header1')),
- );
-
$form['advanced'] = array(
'#type' => 'vertical_tabs',
'#weight' => 50,
@@ -322,6 +212,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 +236,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..87fc86f 100644
--- a/wysiwyg.install
+++ b/wysiwyg.install
@@ -340,3 +340,113 @@ 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':
+ if (isset($settings['path_loc'])) {
+ $settings['theme_advanced_statusbar_location'] = $settings['path_loc'];
+ unset($settings['path_loc']);
+ $changed = TRUE;
+ }
+ if (isset($settings['toolbar_loc'])) {
+ $settings['theme_advanced_toolbar_location'] = $settings['toolbar_loc'];
+ unset($settings['toolbar_loc']);
+ $changed = TRUE;
+ }
+ if (isset($settings['toolbar_align'])) {
+ $settings['theme_advanced_toolbar_align'] = $settings['toolbar_align'];
+ unset($settings['toolbar_align']);
+ $changed = TRUE;
+ }
+ if (isset($settings['block_formats'])) {
+ $settings['theme_advanced_blockformats'] = $settings['block_formats'];
+ unset($settings['block_formats']);
+ $changed = TRUE;
+ }
+ if (isset($settings['css_classes'])) {
+ $settings['theme_advanced_styles'] = $settings['css_classes'];
+ unset($settings['css_classes']);
+ $changed = TRUE;
+ }
+ if (isset($settings['resizing'])) {
+ $settings['theme_advanced_resizing'] = $settings['resizing'];
+ unset($settings['resizing']);
+ $changed = TRUE;
+ }
+ break;
+ case 'ckeditor':
+ if (isset($settings['resizing'])) {
+ $settings['resize_enabled'] = $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;
+ }
+ if (isset($settings['css_classes'])) {
+ $settings['stylesSet'] = $settings['css_classes'];
+ unset($settings['css_classes']);
+ $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;
+ }
+ if (isset($settings['block_formats'])) {
+ $settings['FontFormats'] = strtr($settings['block_formats'], array(',' => ';'));
+ unset($settings['block_formats']);
+ $changed = TRUE;
+ }
+ break;
+ case 'yui':
+ // The resizing setting is 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:
+ // Do not touch any other profiles since the extra settings won't hurt.
+ }
+ if ($changed) {
+ db_update('wysiwyg')
+ ->condition('format', $profile->format)
+ ->fields(array(
+ 'settings' => serialize($settings),
+ ))
+ ->execute();
+ }
+ }
+}