summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--editors/markitup.inc2
-rw-r--r--editors/nicedit.inc2
-rw-r--r--editors/tinymce.inc4
-rw-r--r--editors/wymeditor.inc84
5 files changed, 89 insertions, 4 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a6dd83c..5a96c31 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
---------------------------
+#514912 by Likeless, sun: Added plugin/button handling for WYMeditor.
#538996 by darktygur: Fixed 404 errors for non-existing theme CSS files.
#509570 by Rob Loach, sun: Added forced detaching of editor upon form submit.
#526644 by Darren Oh: Fixed broken editor theme validation.
diff --git a/editors/markitup.inc b/editors/markitup.inc
index 3a0a30d..eb4254e 100644
--- a/editors/markitup.inc
+++ b/editors/markitup.inc
@@ -169,8 +169,8 @@ function wysiwyg_markitup_plugins($editor) {
'buttons' => array(
'bold' => t('Bold'), 'italic' => t('Italic'),
'stroke' => t('Strike-through'),
- 'image' => t('Image'),
'link' => t('Link'),
+ 'image' => t('Image'),
// 'cleanup' => t('Clean-up'),
'preview' => t('Preview'),
),
diff --git a/editors/nicedit.inc b/editors/nicedit.inc
index a03d987..5217297 100644
--- a/editors/nicedit.inc
+++ b/editors/nicedit.inc
@@ -107,7 +107,7 @@ function wysiwyg_nicedit_plugins($editor) {
'outdent' => t('Outdent'), 'indent' => t('Indent'),
'image' => t('Image'),
'forecolor' => t('Forecolor'), 'bgcolor' => t('Backcolor'),
- 'superscript' => t('Sup'), 'subscript' => t('Sub'),
+ 'superscript' => t('Superscript'), 'subscript' => t('Subscript'),
'hr' => t('Horizontal rule'),
// @todo New challenge: Optional internal plugins packaged into editor
// library.
diff --git a/editors/tinymce.inc b/editors/tinymce.inc
index 36ebc52..50fcad4 100644
--- a/editors/tinymce.inc
+++ b/editors/tinymce.inc
@@ -367,7 +367,7 @@ function _wysiwyg_tinymce_plugin_name($op, $name) {
}
/**
- * Return internal plugins for TinyMCE; semi-implementation of hook_wysiwyg_plugin().
+ * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
*/
function wysiwyg_tinymce_plugins($editor) {
$plugins = array(
@@ -384,7 +384,7 @@ function wysiwyg_tinymce_plugins($editor) {
'image' => t('Image'),
'cleanup' => t('Clean-up'),
'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'),
- 'sup' => t('Sup'), 'sub' => t('Sub'),
+ 'sup' => t('Superscript'), 'sub' => t('Subscript'),
'blockquote' => t('Blockquote'), 'code' => t('Source code'),
'hr' => t('Horizontal rule'),
'cut' => t('Cut'), 'copy' => t('Copy'), 'paste' => t('Paste'),
diff --git a/editors/wymeditor.inc b/editors/wymeditor.inc
index 773daa2..34c6f11 100644
--- a/editors/wymeditor.inc
+++ b/editors/wymeditor.inc
@@ -32,6 +32,7 @@ function wysiwyg_wymeditor_editor() {
'version callback' => 'wysiwyg_wymeditor_version',
'themes callback' => 'wysiwyg_wymeditor_themes',
'settings callback' => 'wysiwyg_wymeditor_settings',
+ 'plugin callback' => 'wysiwyg_wymeditor_plugins',
'versions' => array(
'0.5-rc1' => array(
'js files' => array('wymeditor.js'),
@@ -108,6 +109,40 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) {
$settings['lang'] = $config['language'];
}
+ // Add configured buttons.
+ if (!empty($config['buttons'])) {
+ $buttoninfo = _wysiwyg_wymeditor_button_info();
+ $plugins = wysiwyg_get_plugins($editor['name']);
+ $settings['toolsItems'] = array();
+ foreach ($config['buttons'] as $plugin => $buttons) {
+ foreach ($buttons as $button => $enabled) {
+ // Iterate separately over buttons and extensions properties.
+ foreach (array('buttons', 'extensions') as $type) {
+ // Skip unavailable plugins.
+ if (!isset($plugins[$plugin][$type][$button])) {
+ continue;
+ }
+ // Add buttons.
+ if ($type == 'buttons') {
+ // Merge meta-data for internal default buttons.
+ if (isset($buttoninfo[$button])) {
+ $buttoninfo[$button] += array('name' => $button);
+ $settings['toolsItems'][] = $buttoninfo[$button];
+ }
+ // For custom buttons, try to provide a valid button definition.
+ else {
+ $settings['toolsItems'][] = array(
+ 'name' => $button,
+ 'title' => $plugins[$plugin][$type][$button],
+ 'css' => 'wym_tools_' . $button,
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
if (!empty($config['block_formats'])) {
$containers = array(
'p' => 'Paragraph',
@@ -145,3 +180,52 @@ function wysiwyg_wymeditor_settings($editor, $config, $theme) {
return $settings;
}
+/**
+ * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
+ */
+function wysiwyg_wymeditor_plugins($editor) {
+ $plugins = array(
+ 'default' => array(
+ 'buttons' => array(
+ 'Bold' => t('Bold'), 'Italic' => t('Italic'),
+ 'InsertOrderedList' => t('Bullet list'), 'InsertUnorderedList' => t('Numbered list'),
+ 'Outdent' => t('Outdent'), 'Indent' => t('Indent'),
+ 'Undo' => t('Undo'), 'Redo' => t('Redo'),
+ 'CreateLink' => t('Link'), 'Unlink' => t('Unlink'),
+ 'InsertImage' => t('Image'),
+ 'Superscript' => t('Superscript'), 'Subscript' => t('Subscript'),
+ 'ToggleHtml' => t('Source code'),
+ 'Paste' => t('Paste'),
+ 'InsertTable' => t('Table'),
+ 'Preview' => t('Preview'),
+ ),
+ 'internal' => TRUE,
+ ),
+ );
+ return $plugins;
+}
+
+/**
+ * Helper function to provide additional meta-data for internal default buttons.
+ */
+function _wysiwyg_wymeditor_button_info() {
+ return array(
+ 'Bold' => array('title'=> 'Strong', 'css'=> 'wym_tools_strong'),
+ 'Italic' => array('title'=> 'Emphasis', 'css'=> 'wym_tools_emphasis'),
+ 'Superscript' => array('title'=> 'Superscript', 'css'=> 'wym_tools_superscript'),
+ 'Subscript' => array('title'=> 'Subscript', 'css'=> 'wym_tools_subscript'),
+ 'InsertOrderedList' => array('title'=> 'Ordered_List', 'css'=> 'wym_tools_ordered_list'),
+ 'InsertUnorderedList' => array('title'=> 'Unordered_List', 'css'=> 'wym_tools_unordered_list'),
+ 'Indent' => array('title'=> 'Indent', 'css'=> 'wym_tools_indent'),
+ 'Outdent' => array('title'=> 'Outdent', 'css'=> 'wym_tools_outdent'),
+ 'Undo' => array('title'=> 'Undo', 'css'=> 'wym_tools_undo'),
+ 'Redo' => array('title'=> 'Redo', 'css'=> 'wym_tools_redo'),
+ 'CreateLink' => array('title'=> 'Link', 'css'=> 'wym_tools_link'),
+ 'Unlink' => array('title'=> 'Unlink', 'css'=> 'wym_tools_unlink'),
+ 'InsertImage' => array('title'=> 'Image', 'css'=> 'wym_tools_image'),
+ 'InsertTable' => array('title'=> 'Table', 'css'=> 'wym_tools_table'),
+ 'Paste' => array('title'=> 'Paste_From_Word', 'css'=> 'wym_tools_paste'),
+ 'ToggleHtml' => array('title'=> 'HTML', 'css'=> 'wym_tools_html'),
+ 'Preview' => array('title'=> 'Preview', 'css'=> 'wym_tools_preview'),
+ );
+}