diff --git a/editors/js/markitup.js b/editors/js/markitup.js index 00e10b9..26c0de5 100644 --- a/editors/js/markitup.js +++ b/editors/js/markitup.js @@ -9,7 +9,7 @@ Drupal.wysiwyg.editor.attach.markitup = function(context, params, settings) { // Adjust CSS for editor buttons. $.each(settings.markupSet, function (button) { $('.' + settings.nameSpace + ' .' + this.className + ' a') - .css({ backgroundImage: 'url(' + settings.root + 'sets/default/images/' + button + '.png' + ')' }) + .css({ backgroundImage: 'url(' + settings.markupSet[button].iconPath + ')' }) .parents('li').css({ backgroundImage: 'none' }); }); }; diff --git a/editors/markitup.inc b/editors/markitup.inc index faa35b4..b3be75c 100644 --- a/editors/markitup.inc +++ b/editors/markitup.inc @@ -127,7 +127,93 @@ function wysiwyg_markitup_settings($editor, $config, $theme) { ); // Add configured buttons or all available. - $default_buttons = array( + $default_buttons = _wysiwyg_markitup_default_buttons(); + + // Get information from button plugins to add their markitup settings. + $plugins_info = wysiwyg_get_plugins('markitup'); + + $settings['markupSet'] = array(); + if (!empty($config['buttons'])) { + foreach ($config['buttons'] as $plugin) { + foreach ($plugin as $button => $enabled) { + if (isset($default_buttons[$button])) { + $settings['markupSet'][$button] = $default_buttons[$button]; + } + else { + $settings['markupSet'][$button] = $plugins_info[$button]['markitup']; + } + + // If iconPath isn't specified fallback to the icons from the library. + if (empty($settings['markupSet'][$button]['iconPath'])) { + $settings['markupSet'][$button]['iconPath'] = $settings['root'] . 'sets/default/images/' . $button . '.png'; + } + } + } + } + + return $settings; +} + +/** + * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin(). + */ +function wysiwyg_markitup_plugins($editor) { + $default_buttons = _wysiwyg_markitup_default_buttons(); + + $buttons = array(); + foreach ($default_buttons as $button => $info) { + $buttons[$button] = $info['name']; + } + + return array( + 'default' => array( + 'buttons' => $buttons, + 'internal' => TRUE, + ), + ); +} + +function _wysiwyg_markitup_default_buttons() { + return array( + 'h1' => array( + 'name' => t('Heading 1'), + 'className' => 'markitup-h1', + 'key' => '1', + 'openWith' => '
', + 'closeWith' => '
', + ), 'bold' => array( 'name' => t('Bold'), 'className' => 'markitup-bold', @@ -163,6 +249,24 @@ function wysiwyg_markitup_settings($editor, $config, $theme) { 'closeWith' => '', 'placeHolder' => 'Your text to link...', ), + 'list-bullet' => array( + 'name' => t('Unordered List'), + 'className' => 'markitup-list-bullet', + 'openWith' => "