summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--editors/js/wymeditor.js35
-rw-r--r--editors/wymeditor.inc142
3 files changed, 178 insertions, 0 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8b0de7b..73fd7e9 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -6,6 +6,7 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-2.x, xxxx-xx-xx
---------------------------
+#362137 by jfh: Added WYMeditor support.
#470928 by jfh, sun: Fixed Drupal.wysiwyg.clone turns arrays into objects.
#445826 by TwoD: Fixed FCKeditor: Drupal.wysiwyg.activeId not updated.
#478324 by jeffschuler: Fixed typo in profile configuration form.
diff --git a/editors/js/wymeditor.js b/editors/js/wymeditor.js
new file mode 100644
index 0000000..d9cdf3c
--- /dev/null
+++ b/editors/js/wymeditor.js
@@ -0,0 +1,35 @@
+// $Id$
+
+/**
+ * Attach this editor to a target element.
+ */
+Drupal.wysiwyg.editor.attach.wymeditor = function(context, params, settings) {
+ $('#' + params.field).wymeditor(settings);
+};
+
+/**
+ * Detach a single or all editors.
+ */
+Drupal.wysiwyg.editor.detach.wymeditor = function(context, params) {
+ if (typeof params != 'undefined') {
+ var $field = $('#' + params.field);
+ var index = $field.data(WYMeditor.WYM_INDEX);
+ if (typeof index != 'undefined') {
+ var instance = WYMeditor.INSTANCES[index];
+ instance.update();
+ $(instance._box).remove();
+ $(instance._element).show();
+ delete instance;
+ }
+ $field.show();
+ }
+ else {
+ jQuery.each(WYMeditor.INSTANCES, function() {
+ this.update();
+ $(this._box).remove();
+ $(this._element).show();
+ delete this;
+ });
+ }
+};
+
diff --git a/editors/wymeditor.inc b/editors/wymeditor.inc
new file mode 100644
index 0000000..2d7ec83
--- /dev/null
+++ b/editors/wymeditor.inc
@@ -0,0 +1,142 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Editor integration functions for WYMeditor.
+ */
+
+/**
+ * Plugin implementation of hook_editor().
+ */
+function wysiwyg_wymeditor_editor() {
+ $editor = array();
+ $editor['wymeditor'] = array(
+ 'title' => 'WYMeditor',
+ 'vendor url' => 'http://www.wymeditor.org/',
+ 'download url' => 'http://www.wymeditor.org/download/',
+ 'library path' => wysiwyg_get_path('wymeditor/wymeditor'),
+ 'libraries' => array(
+ 'min' => array(
+ 'title' => 'Minified',
+ 'files' => array('jquery.wymeditor.min.js'),
+ ),
+ 'pack' => array(
+ 'title' => 'Packed',
+ 'files' => array('jquery.wymeditor.pack.js'),
+ ),
+ 'src' => array(
+ 'title' => 'Source',
+ 'files' => array('jquery.wymeditor.js'),
+ ),
+ ),
+ 'version callback' => 'wysiwyg_wymeditor_version',
+ 'settings callback' => 'wysiwyg_wymeditor_settings',
+ 'themes callback' => 'wysiwyg_wymeditor_themes',
+ 'versions' => array(
+ '0.5-rc1' => array(
+ 'js files' => array('wymeditor.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_wymeditor_version($editor) {
+ $script = $editor['library path'] . '/jquery.wymeditor.js';
+ $script = fopen($script, 'r');
+ fgets($script);
+ $line = fgets($script);
+ if (preg_match('@version\s+([0-9a-z\.-]+)@', $line, $version)) {
+ fclose($script);
+ return $version[1];
+ }
+ fclose($script);
+}
+
+/**
+ * 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_wymeditor_settings($editor, $config, $theme) {
+ $settings = array(
+ 'updateSelector' => '.form-submit',
+ 'skin' => $theme,
+ );
+
+ if (isset($config['language'])) {
+ $settings['lang'] = $config['language'];
+ }
+
+ if (isset($config['block_formats'])) {
+ $containers = array(
+ 'p' => 'Paragraph',
+ 'h1' => 'Heading_1',
+ 'h2' => 'Heading_2',
+ 'h3' => 'Heading_3',
+ 'h4' => 'Heading_4',
+ 'h5' => 'Heading_5',
+ 'h6' => 'Heading_6',
+ 'pre' => 'Preformatted',
+ 'blockquote' => 'Blockquote',
+ 'th' => 'Table_Header',
+ );
+ foreach (explode(',', $config['block_formats']) as $tag) {
+ if (isset($containers[$tag])) {
+ $settings['containersItems'][] = array(
+ 'name' => strtoupper($tag),
+ 'title' => $containers[$tag],
+ 'css' => 'wym_containers_' . $tag,
+ );
+ }
+ }
+ }
+
+ if (isset($config['css_setting'])) {
+ if ($config['css_setting'] == 'theme') {
+ // WYMeditor only supports one CSS file currently.
+ $settings['stylesheet'] = reset(wysiwyg_get_css());
+ }
+ else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
+ $settings['stylesheet'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
+ }
+ }
+
+ return $settings;
+}
+
+/**
+ * Determine available editor themes or check/reset a given one.
+ *
+ * @param $editor
+ * A processed hook_editor() array of editor properties.
+ * @param $profile
+ * A wysiwyg editor profile.
+ *
+ * @return
+ * An array of theme names. The first returned name should be the default
+ * theme name.
+ */
+function wysiwyg_wymeditor_themes($editor, $profile) {
+ return array('compact', 'default', 'minimal', 'silver', 'twopanels');
+}
+