'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'),
$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',
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'),
+ );
+}