Commit e16a9972 authored by sun's avatar sun

#337569 by sun: Fixed different profiles for same editor are not respected.

parent 33fd8bc9
......@@ -6,6 +6,7 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-x.x, xxxx-xx-xx
---------------------------
#337569 by sun: Fixed different profiles for same editor are not respected.
#340195 by sun: Fixed #after_build function not invoked on all forms.
#333521 by sun: Fixed TinyMCE version detection to look at the actual script.
#329657 by svendecabooter, sun: Added Whizzywig support.
......
......@@ -6,11 +6,11 @@
* See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
*/
Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) {
var FCKinstance = new FCKeditor(params.field, settings[params.theme]['Width'], settings[params.theme]['Height']);
// Configure settings for this theme.
FCKinstance.BasePath = settings[params.theme].BasePath;
for (var setting in settings[params.theme]) {
FCKinstance.Config[setting] = settings[params.theme][setting];
var FCKinstance = new FCKeditor(params.field, settings['Width'], settings['Height']);
// Configure editor settings for this input format.
FCKinstance.BasePath = settings.BasePath;
for (var setting in settings) {
FCKinstance.Config[setting] = settings[setting];
}
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
......
......@@ -3,7 +3,7 @@
/**
* Attach this editor to a target element.
*/
Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, editorSettings) {
Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, settings) {
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
$('#' + params.field).wysiwyg();
......
......@@ -3,10 +3,10 @@
/**
* Attach this editor to a target element.
*/
Drupal.wysiwyg.editor.attach.nicedit = function(context, params, editorSettings) {
Drupal.wysiwyg.editor.attach.nicedit = function(context, params, settings) {
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
var editor = new nicEditor(editorSettings[params.theme]);
var editor = new nicEditor(settings);
editor.panelInstance(params.field);
}
};
......
......@@ -7,9 +7,9 @@
* calling tinyMCE.init() after the page is loaded breaks IE6.
*
* @param editorSettings
* An object containing editor settings for each enabled editor theme.
* An object containing editor settings for each input format.
*/
Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
Drupal.wysiwyg.editor.init.tinymce = function(settings) {
// If JS compression is enabled, TinyMCE is unable to find its own base path
// and exec mode, hence we need to define it manually.
// @todo Move global library settings somewhere else.
......@@ -18,8 +18,8 @@ Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
tinyMCE.gzipMode = (Drupal.settings.wysiwyg.execMode == 'gzip');
// Initialize editor configurations.
for (var theme in editorSettings) {
tinyMCE.init(editorSettings[theme]);
for (var format in settings) {
tinyMCE.init(settings[format]);
}
for (var plugin in Drupal.settings.wysiwyg.plugins.tinymce) {
tinyMCE.loadPlugin(plugin, Drupal.settings.wysiwyg.plugins.tinymce[plugin]);
......@@ -31,10 +31,10 @@ Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
*
* See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
*/
Drupal.wysiwyg.editor.attach.tinymce = function(context, params, editorSettings) {
// Configure settings for this theme.
for (var setting in editorSettings[params.theme]) {
tinyMCE.settings[setting] = editorSettings[params.theme][setting];
Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
// Configure editor settings for this input format.
for (var setting in settings) {
tinyMCE.settings[setting] = settings[setting];
}
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
......
......@@ -8,9 +8,9 @@
* calling tinyMCE.init() after the page is loaded breaks IE6.
*
* @param editorSettings
* An object containing editor settings for each enabled editor theme.
* An object containing editor settings for each input format.
*/
Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
Drupal.wysiwyg.editor.init.tinymce = function(settings) {
// If JS compression is enabled, TinyMCE is unable to find its own base path
// and exec mode, hence we need to define it manually.
// @todo Move global library settings somewhere else.
......@@ -19,8 +19,8 @@ Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
tinyMCE.gzipMode = (Drupal.settings.wysiwyg.execMode == 'gzip');
// Initialize editor configurations.
for (var theme in editorSettings) {
tinyMCE.init(editorSettings[theme]);
for (var format in settings) {
tinyMCE.init(settings[format]);
}
for (var plugin in Drupal.settings.wysiwyg.plugins.tinymce) {
tinymce.PluginManager.load(plugin, Drupal.settings.wysiwyg.plugins.tinymce[plugin]);
......@@ -32,10 +32,10 @@ Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
*
* See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
*/
Drupal.wysiwyg.editor.attach.tinymce = function(context, params, editorSettings) {
// Configure settings for this theme.
for (var setting in editorSettings[params.theme]) {
tinyMCE.settings[setting] = editorSettings[params.theme][setting];
Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
// Configure editor settings for this input format.
for (var setting in settings) {
tinyMCE.settings[setting] = settings[setting];
}
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
......
......@@ -51,18 +51,18 @@ var o = function (id) {
/**
* Attach this editor to a target element.
*/
Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, editorSettings) {
Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
// Assign button images path, if available.
if (editorSettings[params.theme].buttonPath) {
window.buttonPath = editorSettings[params.theme].buttonPath;
if (settings.buttonPath) {
window.buttonPath = settings.buttonPath;
}
// Create Whizzywig container.
wysiwygWhizzywig.currentField = params.field;
wysiwygWhizzywig.fields[wysiwygWhizzywig.currentField] = '';
// Attach editor.
makeWhizzyWig(params.field, (editorSettings[params.theme].buttons ? editorSettings[params.theme].buttons : 'all'));
makeWhizzyWig(params.field, (settings.buttons ? settings.buttons : 'all'));
// Whizzywig fails to detect and set initial textarea contents.
var instance = $('#whizzy' + params.field).get(0);
if (instance) {
......
......@@ -19,7 +19,7 @@ Drupal.wysiwygInit = function() {
* This behavior searches for input format selectors and formatting guidelines
* that have been preprocessed by Wysiwyg API. All CSS classes of those elements
* with the prefix 'wysiwyg-' are parsed into input format parameters, defining
* the configured editor, editor theme, target element id, and variable other
* the input format, configured editor, target element id, and variable other
* properties, which are passed to the attach/detach hooks of the corresponding
* editor.
*
......@@ -45,6 +45,8 @@ Drupal.behaviors.attachWysiwyg = function(context) {
params[parts[1]] = value;
}
}
// Convert format id to string.
params.format = 'format' + params.format;
$this = $(this);
// Directly attach this editor, if the input format is enabled or there is
// only one input format at all.
......@@ -81,7 +83,7 @@ Drupal.behaviors.attachWysiwyg = function(context) {
Drupal.wysiwygAttach = function(context, params) {
if (typeof Drupal.wysiwyg.editor.attach[params.editor] == 'function') {
// Attach editor.
Drupal.wysiwyg.editor.attach[params.editor](context, params, Drupal.wysiwyg.clone(Drupal.settings.wysiwyg.configs[params.editor]));
Drupal.wysiwyg.editor.attach[params.editor](context, params, (Drupal.settings.wysiwyg.configs[params.editor] ? Drupal.wysiwyg.clone(Drupal.settings.wysiwyg.configs[params.editor][params.format]) : {}));
// Display toggle link.
$('#wysiwyg-toggle-' + params.field).show();
}
......
......@@ -45,23 +45,6 @@ function wysiwyg_help($path, $arg) {
}
}
/**
* Implementation of hook_elements().
*
* @todo Remove #wysiwyg_style; the GUI for an editor should be solely handled
* via profiles, when profiles are attached to an input format. It makes no
* sense to display TinyMCE's simple GUI/theme for the user signature, when
* the input format allows users to use advanced HTML and hence, editor
* plugins. Fix this here, in wysiwyg_process_element(), and lastly
* in wysiwyg_get_editor_config().
*/
function wysiwyg_elements() {
$type = array();
// @todo Derive editor theme from input format.
$type['textarea'] = array('#wysiwyg_style' => 'advanced');
return $type;
}
/**
* Implementation of hook_form_alter().
*
......@@ -132,26 +115,23 @@ function wysiwyg_process_form(&$form) {
foreach ($formats as $format) {
// Default to 'none' editor (Drupal's default behaviors).
$editor = 'none';
$theme = '';
// Fetch the profile associated to this input format.
$profile = wysiwyg_get_profile($format);
if ($profile) {
$editor = $profile->editor;
// Check editor theme (and reset it if not/no longer available).
$theme = wysiwyg_get_editor_themes($profile, (isset($field['#wysiwyg_style']) ? $field['#wysiwyg_style'] : ''));
$theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : ''));
// Add profile settings for this input format.
wysiwyg_add_editor_settings($profile, $theme);
// Add plugin settings for this input format.
wysiwyg_add_plugin_settings($profile);
$theme = ' wysiwyg-theme-'. $theme;
}
// Use a prefix/suffix for a single input format, or attach to input
// format selector radio buttons.
if (isset($element['format']['guidelines'])) {
$element['format']['guidelines']['#prefix'] = '<div class="wysiwyg wysiwyg-editor-'. $editor .' wysiwyg-field-'. $field['#id'] . $theme . $extra_class .'">';
$element['format']['guidelines']['#prefix'] = '<div class="wysiwyg wysiwyg-format-'. $format .' wysiwyg-editor-'. $editor .' wysiwyg-field-'. $field['#id'] . $extra_class .'">';
$element['format']['guidelines']['#suffix'] = '</div>';
// Edge-case: Default format contains no input filters.
if (empty($element['format']['guidelines']['#value'])) {
......@@ -165,7 +145,7 @@ function wysiwyg_process_form(&$form) {
else {
$element[$format]['#attributes']['class'] = '';
}
$element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-editor-'. $editor .' wysiwyg-field-'. $field['#id'] . $theme . $extra_class;
$element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-format-'. $format .' wysiwyg-editor-'. $editor .' wysiwyg-field-'. $field['#id'] . $extra_class;
}
}
}
......@@ -307,15 +287,17 @@ function wysiwyg_load_editor($profile) {
}
/**
* Register a theme.
* Add editor settings for a given input format.
*/
function wysiwyg_add_editor_settings($profile, $theme) {
static $editors = array();
static $formats = array();
if (!isset($editors[$profile->editor][$theme])) {
if (!isset($formats[$profile->format])) {
$config = wysiwyg_get_editor_config($profile, $theme);
drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array($theme => $config)))), 'setting');
$editors[$profile->editor][$theme] = TRUE;
// drupal_to_js() does not properly convert numeric array keys, so we need
// to use a string instead of the format id.
drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format'. $profile->format => $config)))), 'setting');
$formats[$profile->format] = TRUE;
}
}
......@@ -351,10 +333,9 @@ function wysiwyg_add_plugin_settings($profile) {
}
/**
* Grab the themes available to Wysiwyg Editor.
* Retrieve available themes for an editor.
*
* Wysiwyg Editor themes control the functionality and buttons that are available to a
* user. Themes are only looked for within the default Wysiwyg Editor theme directory.
* Editor themes control the visual presentation of an editor.
*
* @param $profile
* A wysiwyg editor profile; passed/altered by reference.
......@@ -417,7 +398,7 @@ function wysiwyg_get_plugins($editor_name) {
}
/**
* Return an array of initial Wysiwyg Editor config options from the current role.
* Return an array of initial editor settings for a Wysiwyg profile.
*/
function wysiwyg_get_editor_config($profile, $theme) {
$editor = wysiwyg_get_editor($profile->editor);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment