Commit 1a7c5997 authored by sun's avatar sun

#282717 by sun: Added (basic) FCKeditor support.

parent 85de4b26
......@@ -6,6 +6,7 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-x.x, xxxx-xx-xx
---------------------------
#282717 by sun: Added (basic) FCKeditor support.
#316507 by sun: Added Drupal.wysiwyg function stacks to execute editor library
specific actions upon initializing, attaching, detaching, and toggling an
editor. Editor specific JavaScript resides in separate files now, as specified
......
......@@ -17,7 +17,6 @@ function wysiwyg_fckeditor_editor() {
'title' => 'FCKeditor',
'vendor url' => 'http://www.fckeditor.net',
'download url' => 'http://www.fckeditor.net/download',
'editor path' => wysiwyg_get_path('fckeditor'),
'library path' => wysiwyg_get_path('fckeditor'),
'libraries' => array( // We cannot assume that all editors need just one js library.
'' => array( // Key may be used in wysiwyg_fckeditor_settings() for exec mode.
......@@ -25,7 +24,6 @@ function wysiwyg_fckeditor_editor() {
'files' => array('fckeditor.js'),
),
),
'js path' => wysiwyg_get_path('js'),
'version callback' => 'wysiwyg_fckeditor_version',
'themes callback' => 'wysiwyg_fckeditor_themes',
'settings callback' => 'wysiwyg_fckeditor_settings',
......@@ -33,13 +31,16 @@ function wysiwyg_fckeditor_editor() {
'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings',
'versions' => array( // Each version can override global editor properties.
2.6 => array(
'include files' => array('fckeditor-2.inc'),
'js files' => array('fckeditor-2.js'),
// 'include files' => array('fckeditor-2.inc'),
'js files' => array('fckeditor-2.6.js'),
),
),
// Optional properties
'css path' => wysiwyg_get_path('css'),
'css files' => array('fckeditor.css'),
// 'editor path' => wysiwyg_get_path('fckeditor'),
// 'js path' => wysiwyg_get_path('js'),
// 'css path' => wysiwyg_get_path('css'),
// @todo Not yet implemented.
// 'css files' => array('fckeditor.css'),
);
return $editor;
}
......@@ -79,6 +80,38 @@ function wysiwyg_fckeditor_version($editor) {
* Drupal.settings.wysiwygEditor.configs.{editor}
*/
function wysiwyg_fckeditor_settings($editor, $config, $theme) {
$init = array(
'BasePath' => base_path() . $editor['editor path'] .'/',
'SkinPath' => base_path() . $editor['editor path'] .'/editor/skins/default/',
'DefaultLanguage' => 'en',
'AutoDetectLanguage' => TRUE,
'Height' => 420,
'ToolbarStartExpanded' => TRUE,
'Width' => '100%',
'EnterMode' => 'p',
'ShiftEnterMode' => 'br',
'FontFormats' => strtr($config['block_formats'], array(',' => ';')),
'FormatSource' => $config['apply_source_formatting'],
'FormatOutput' => $config['preformatted'],
'LinkBrowser' => FALSE,
'ImageBrowser' => FALSE,
'FlashBrowser' => FALSE,
'LinkUpload' => FALSE,
'ImageUpload' => FALSE,
'FlashUpload' => FALSE,
);
if ($config['css_setting'] == 'theme') {
$css = path_to_theme() .'/style.css';
if (file_exists($css)) {
$init['EditorAreaCSS'] = base_path() . $css;
}
}
else if ($config['css_setting'] == 'self') {
$init['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
}
return $init;
}
/**
......
// $Id$
Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {}, 'toggle': {} };
/**
* Attach FCKeditor to textareas, using the theme specified in CSS class names.
*
* @param editorSettings
* An object containing editor settings for each enabled editor theme.
*/
Drupal.wysiwyg.attach.fckeditor = function(context, editorSettings) {
for (var theme in editorSettings) {
$('textarea.wysiwyg-' + theme + ':not(.wysiwyg-processed)', context).each(function() {
// @todo Convert string into variable name w/o overwriting string?
// workaround: build object via editors[this.id] = new ...
var oFCK_1 = new FCKeditor(this.id);
// Clone, so original settings are not overwritten.
var config = Drupal.wysiwyg.clone(editorSettings[theme]);
// Configure settings for this theme.
oFCK_1.BasePath = config.BasePath;
for (var setting in config) {
oFCK_1.Config[setting] = config[setting];
}
// Attach Wysiwyg Editor control if default is on.
if (Drupal.settings.wysiwygEditor.status) {
oFCK_1.ReplaceTextarea();
}
$(this).addClass('wysiwyg-processed');
});
}
}
/**
* Detach all FCKeditor editors.
*
* @todo Context support required to remove only certain editors (think AHAH/AJAX).
*/
Drupal.wysiwyg.detach.fckeditor = function(context) {
if (tinyMCE.activeEditor) {
tinyMCE.triggerSave();
tinyMCE.activeEditor.remove();
}
}
/**
* Toggle editor and return new state.
*
* @param element
* The DOM element to toggle the editor for.
* @param theme
* The editor theme assigned to the element.
*
* @return
* A boolean value indicating whether the editor has been enabled.
*/
Drupal.wysiwyg.toggle.fckeditor = function(element, theme) {
var instance = FCKeditorAPI.GetInstance(element.id);
if ($(element).css('display') != 'none' || instance == null) {
instance.SetHTML($(element).hide().val());
$('#' + element.id + '___Frame').show();
return true;
}
else {
$('#' + element.id).val(instance.GetXHTML()).show();
$('#' + element.id + '___Frame').hide();
return false;
}
}
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