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' => '', + 'placeHolder' => 'Your title here...', + ), + 'h2' => array( + 'name' => t('Heading 2'), + 'className' => 'markitup-h2', + 'key' => '2', + 'openWith' => '', + 'closeWith' => '', + 'placeHolder' => 'Your title here...', + ), + 'h3' => array( + 'name' => t('Heading 3'), + 'className' => 'markitup-h3', + 'key' => '3', + 'openWith' => '', + 'closeWith' => '', + 'placeHolder' => 'Your title here...', + ), + 'h4' => array( + 'name' => t('Heading 4'), + 'className' => 'markitup-h4', + 'key' => '4', + 'openWith' => '', + 'closeWith' => '', + 'placeHolder' => 'Your title here...', + ), + 'paragraph' => array( + 'name' => t('Paragraph'), + 'className' => 'markitup-paragraph', + 'key' => 'p', + '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' => "
    \n", + 'closeWith' => '
', + ), + 'list-numeric' => array( + 'name' => t('Ordered List'), + 'className' => 'markitup-list-numeric', + 'openWith' => "
    \n", + 'closeWith' => '
', + ), + 'list-item' => array( + 'name' => t('List Item'), + 'className' => 'markitup-list-item', + 'openWith' => '
  • ', + 'closeWith' => '
  • ', + ), // @todo // 'cleanup' => array('name' => t('Clean-up'), 'className' => 'markitup-cleanup', 'replaceWith' => 'function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") }'), 'preview' => array( @@ -171,36 +275,5 @@ function wysiwyg_markitup_settings($editor, $config, $theme) { 'call' => 'preview', ), ); - $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]; - } - } - } - } - - return $settings; -} - -/** - * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin(). - */ -function wysiwyg_markitup_plugins($editor) { - return array( - 'default' => array( - 'buttons' => array( - 'bold' => t('Bold'), 'italic' => t('Italic'), - 'stroke' => t('Strike-through'), - 'link' => t('Link'), - 'image' => t('Image'), - // 'cleanup' => t('Clean-up'), - 'preview' => t('Preview'), - ), - 'internal' => TRUE, - ), - ); }