diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c0808d7a263dfb941cf2de7298497ddb74d81054..76f3304f49d17b7ea1224003212bb2445231190b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ Wysiwyg x.x-x.x, xxxx-xx-xx Wysiwyg 6.x-3.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 3a0a30d84adbf06ae0109593001b8fd47d735df4..eb4254ed014c6cb28ae2d280e82d2e9b5c65dbff 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 a03d987fcfe34eba3088832bf25526623778121c..52172977aa33ded20a8523bfd06d11ed68e1a67e 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 36ebc52864967d74b0afc225af1072d0d3221337..50fcad49fe6dab5816e1cb381bc9f152cdbbdcb6 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 773daa246e9dc9708f19ad224b6e9a2cf63eda26..34c6f11c6b9ca053d093d179807c73a42989699b 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'), + ); +}