summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsun2008-10-30 10:15:20 (GMT)
committer sun2008-10-30 10:15:20 (GMT)
commit4c552b903415fdd1339503056ad169c6c5dc39b0 (patch)
treeb56992c704c8b9134851d7624593476ad0e9ff1a
parent7623c9ce77967697fb0487fe28eb86a48c6d4fdb (diff)
#327710 by sun: Added nicEdit support.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--editors/js/nicedit.js39
-rw-r--r--editors/nicedit.inc123
-rw-r--r--editors/tinymce.inc10
-rw-r--r--wysiwyg.module10
5 files changed, 173 insertions, 10 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 132a5ae..7a4dd9a 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -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.
diff --git a/editors/js/nicedit.js b/editors/js/nicedit.js
new file mode 100644
index 0000000..8492545
--- /dev/null
+++ b/editors/js/nicedit.js
@@ -0,0 +1,39 @@
+// $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 = [];
+ }
+ }
+};
+
diff --git a/editors/nicedit.inc b/editors/nicedit.inc
new file mode 100644
index 0000000..616d5fe
--- /dev/null
+++ b/editors/nicedit.inc
@@ -0,0 +1,123 @@
+<?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,
+ ),
+ );
+}
+
diff --git a/editors/tinymce.inc b/editors/tinymce.inc
index 8fb29c4..69968d7 100644
--- a/editors/tinymce.inc
+++ b/editors/tinymce.inc
@@ -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;
}
diff --git a/wysiwyg.module b/wysiwyg.module
index b2df3d1..97aa430 100644
--- a/wysiwyg.module
+++ b/wysiwyg.module
@@ -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;
}