You are here

function wysiwyg_markitup_settings in Wysiwyg 7.2

Same name and namespace in other branches
  1. 5.2 editors/markitup.inc \wysiwyg_markitup_settings()
  2. 5 editors/markitup.inc \wysiwyg_markitup_settings()
  3. 6.2 editors/markitup.inc \wysiwyg_markitup_settings()
  4. 6 editors/markitup.inc \wysiwyg_markitup_settings()

Return runtime editor settings for a given wysiwyg profile.

Parameters

$editor: A processed hook_editor() array of editor properties.

$config: An array containing wysiwyg editor profile settings.

$theme: The name of a theme/GUI/skin to use.

Return value

A settings array to be populated in Drupal.settings.wysiwyg.configs.{editor}

1 string reference to 'wysiwyg_markitup_settings'
wysiwyg_markitup_editor in editors/markitup.inc
Plugin implementation of hook_editor().

File

editors/markitup.inc, line 116
Editor integration functions for markItUp.

Code

function wysiwyg_markitup_settings($editor, $config, $theme) {
  drupal_add_css($editor['library path'] . '/markitup/skins/' . $theme . '/style.css', array(
    // Specify an alternate basename; otherwise, style.css would override a
    // commonly used style.css file of the theme.
    'basename' => 'markitup.' . $theme . '.style.css',
    'group' => CSS_THEME,
  ));
  $settings = array(
    'root' => base_path() . $editor['library path'] . '/markitup/',
    'nameSpace' => $theme,
    'markupSet' => array(),
  );

  // Add configured buttons or all available.
  $default_buttons = array(
    'bold' => array(
      'name' => t('Bold'),
      'className' => 'markitup-bold',
      'key' => 'B',
      'openWith' => '(!(<strong>|!|<b>)!)',
      'closeWith' => '(!(</strong>|!|</b>)!)',
    ),
    'italic' => array(
      'name' => t('Italic'),
      'className' => 'markitup-italic',
      'key' => 'I',
      'openWith' => '(!(<em>|!|<i>)!)',
      'closeWith' => '(!(</em>|!|</i>)!)',
    ),
    'stroke' => array(
      'name' => t('Strike-through'),
      'className' => 'markitup-stroke',
      'key' => 'S',
      'openWith' => '<del>',
      'closeWith' => '</del>',
    ),
    'image' => array(
      'name' => t('Image'),
      'className' => 'markitup-image',
      'key' => 'P',
      'replaceWith' => '<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />',
    ),
    'link' => array(
      'name' => t('Link'),
      'className' => 'markitup-link',
      'key' => 'K',
      'openWith' => '<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>',
      'closeWith' => '</a>',
      'placeHolder' => 'Your text to link...',
    ),
    // @todo
    // 'cleanup' => array('name' => t('Clean-up'), 'className' => 'markitup-cleanup', 'replaceWith' => 'function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") }'),
    'preview' => array(
      'name' => t('Preview'),
      'className' => 'markitup-preview',
      '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;
}