Commit 4c552b90 authored by sun's avatar sun

#327710 by sun: Added nicEdit support.

parent 7623c9ce
......@@ -6,6 +6,7 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-x.x, xxxx-xx-xx
---------------------------
#327710 by sun: Added nicEdit support.
#323855 by sun: Increased supported version of jWYSIWYG to 0.5.
#323671 by sun: Fixed TinyMCE editor not resized when browser is resized.
#327152 by sun: Fixed breadcrumbs for profile configuration pages.
......
// $Id$
/**
* Attach this editor to a target element.
*/
Drupal.wysiwyg.editor.attach.nicedit = function(context, params, editorSettings) {
// Attach editor control if default is on.
if (Drupal.settings.wysiwyg.status) {
var editor = new nicEditor(editorSettings[params.theme]);
editor.panelInstance(params.field);
}
};
/**
* Detach a single or all editors.
*
* See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
*/
Drupal.wysiwyg.editor.detach.nicedit = function(context, params) {
if (typeof params != 'undefined') {
var instance = nicEditors.findEditor(params.field);
if (instance) {
instance.ne.removeInstance(params.field);
instance.ne.removePanel();
}
}
else {
for (var e in nicEditors.editors) {
// Save contents of all editors back into textareas.
var instances = nicEditors.editors[e].nicInstances;
for (var i = 0; i < instances.length; i++) {
instances[i].remove();
}
// Remove all editor instances.
nicEditors.editors[e].nicInstances = [];
}
}
};
<?php
// $Id$
/**
* Plugin implementation of hook_editor().
*/
function wysiwyg_nicedit_editor() {
$editor = array();
$editor['nicedit'] = array(
'title' => 'NicEdit',
'vendor url' => 'http://nicedit.com',
'download url' => 'http://nicedit.com/download.php',
'library path' => wysiwyg_get_path('nicedit'),
'libraries' => array(
'' => array(
'title' => 'Source',
'files' => array('nicedit.js'),
),
),
'version callback' => 'wysiwyg_nicedit_version',
'settings callback' => 'wysiwyg_nicedit_settings',
'plugin callback' => 'wysiwyg_nicedit_plugins',
'versions' => array(
'0.9' => array(
'js files' => array('nicedit.js'),
),
),
);
return $editor;
}
/**
* Detect editor version.
*
* @param $editor
* An array containing editor properties as returned from hook_editor().
*
* @return
* The installed editor version.
*/
function wysiwyg_nicedit_version($editor) {
$script = wysiwyg_get_path('nicedit') . '/nicedit.js';
// Note: This is 100% lame. nicEdit developers: Please add version info.
$size = (filesize($script) / 1000);
if ($size > 41) {
return '0.9';
}
}
/**
* Return runtime editor settings for a given wysiwyg profile.
*
* @param $editor
* A processed hook_editor() array of editor properties.
* @param $config
* An array containing wysiwyg editor profile settings.
* @param $theme
* The name of a theme/GUI/skin to use.
*
* @return
* A settings array to be populated in
* Drupal.settings.wysiwyg.configs.{editor}
*/
function wysiwyg_nicedit_settings($editor, $config, $theme) {
$settings = array(
'iconsPath' => wysiwyg_get_path('nicedit', TRUE) . '/nicEditorIcons.gif',
);
// Add configured buttons or all available.
if (!empty($config['buttons'])) {
$buttons = array();
foreach ($config['buttons'] as $plugin) {
$buttons = array_merge($buttons, $plugin);
}
$settings['buttonList'] = array_keys($buttons);
}
else {
$settings['fullPanel'] = TRUE;
}
// Add editor content stylesheet.
if ($config['css_setting'] == 'theme') {
$css = path_to_theme() .'/style.css';
if (file_exists($css)) {
$settings['externalCSS'] = base_path() . $css;
}
}
else if ($config['css_setting'] == 'self') {
$settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
}
return $settings;
}
/**
* Return internal plugins for nicEdit; semi-implementation of hook_wysiwyg_plugin().
*/
function wysiwyg_nicedit_plugins($editor) {
return array(
'default' => array(
#'path' => $editor['library path'] .'/themes/advanced',
'buttons' => array(
'bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'),
'strikethrough' => t('Strike-through'),
'left' => t('Align left'), 'center' => t('Align center'), 'right' => t('Align right'),
'ul' => t('Bullet list'), 'ol' => t('Numbered list'),
'outdent' => t('Outdent'), 'indent' => t('Indent'),
'image' => t('Image'),
'forecolor' => t('Forecolor'), 'bgcolor' => t('Backcolor'),
'superscript' => t('Sup'), 'subscript' => t('Sub'),
'hr' => t('Horizontal rule'),
// @todo New challenge: Optional internal plugins packaged into editor
// library.
'link' => t('Link'), 'unlink' => t('Unlink'),
'fontFormat' => t('HTML block format'), 'fontFamily' => t('Font'), 'fontSize' => t('Font size'),
'xhtml' => t('Source code'),
),
'internal' => TRUE,
),
);
}
......@@ -225,6 +225,16 @@ function wysiwyg_tinymce_settings($editor, $config, $theme) {
}
unset($init['buttons']);
// Convert the config values into the form expected by TinyMCE.
foreach ($init as $key => $value) {
if (is_bool($value)) {
continue;
}
if (is_array($value)) {
$init[$key] = implode(',', $init[$key]);
}
}
return $init;
}
......
......@@ -308,16 +308,6 @@ function wysiwyg_add_editor_settings($profile, $theme) {
if (!isset($editors[$profile->editor][$theme])) {
$config = wysiwyg_get_editor_config($profile, $theme);
// @todo Move into tinymce.inc
// Convert the config values into the form expected by editor.
foreach ($config as $key => $value) {
if (is_bool($value)) {
continue;
}
if (is_array($value)) {
$config[$key] = implode(',', $config[$key]);
}
}
drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array($theme => $config)))), 'setting');
$editors[$profile->editor][$theme] = TRUE;
}
......
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