Index: editors/markitup_markdown.inc
===================================================================
--- editors/markitup_markdown.inc	(revision 0)
+++ editors/markitup_markdown.inc	(revision 0)
@@ -0,0 +1,163 @@
+<?php
+// $Id: markitup.inc,v 1.2 2009/03/06 02:48:30 sun Exp $
+
+/**
+ * @file
+ * Editor integration functions for markItUp.
+ */
+
+
+/**
+ * Plugin implementation of hook_editor().
+ */
+function wysiwyg_markitup_markdown_editor() {
+  $editor = array();
+  $editor['markitup_markdown'] = array(
+    'title' => 'markItUp (markdown)',
+    'vendor url' => 'http://markitup.jaysalvat.com',
+    'download url' => 'http://markitup.jaysalvat.com/downloads',
+    'library path' => wysiwyg_get_path('markitup/markitup'),
+    'libraries' => array(
+      '' => array(
+        'title' => 'Source',
+        'files' => array('jquery.markitup.js'),
+      ),
+      'pack' => array(
+        'title' => 'Packed',
+        'files' => array('jquery.markitup.pack.js'),
+      ),
+    ),
+    'version callback' => 'wysiwyg_markitup_markdown_version',
+    'settings callback' => 'wysiwyg_markitup_markdown_settings',
+    'themes callback' => 'wysiwyg_markitup_markdown_themes',
+    'plugin callback' => 'wysiwyg_markitup_markdown_plugins',
+    'versions' => array(
+      '1.1.5' => array(
+        'js files' => array('markitup_markdown.js'),
+      ),
+    ),
+    'css files' => array('markitup_markdown-1.css'),
+  );
+  return $editor;
+}
+
+/**
+ * Detect editor version.
+ *
+ * @param $editor
+ *   An array containing editor properties as returned from hook_editor().
+ *
+ * @return
+ *   The installed editor version.
+ */
+function wysiwyg_markitup_markdown_version($editor) {
+  $changelog = wysiwyg_get_path('markitup/markitup') . '/readme.txt';
+  $changelog = fopen($changelog, 'r');
+  $line = fgets($changelog);
+  if (preg_match('@([0-9\.]+)@', $line, $version)) {
+    fclose($changelog);
+    return $version[1];
+  }
+  fclose($changelog);
+}
+
+/**
+ * Return runtime editor settings for a given wysiwyg profile.
+ *
+ * @param $editor
+ *   A processed hook_editor() array of editor properties.
+ * @param $config
+ *   An array containing wysiwyg editor profile settings.
+ * @param $theme
+ *   The name of a theme/GUI/skin to use.
+ *
+ * @return
+ *   A settings array to be populated in
+ *   Drupal.settings.wysiwyg.configs.{editor}
+ */
+function wysiwyg_markitup_markdown_settings($editor, $config, $theme) {
+  // Whoever is guilty for adding this horrible CSS-file-without-filepath
+  // override "feature" to Drupal core... stand in the corner!
+  drupal_add_css($editor['library path'] . '/skins/' . $theme . '/style.css', 'theme');
+  
+  $settings = array(
+    'root' => wysiwyg_get_path('markitup/markitup', TRUE) . '/',
+    'nameSpace' => $theme,
+    'markupSet' => array(),
+  );
+
+  // Add configured buttons or all available.
+  $default_buttons = array(
+    'h1' => array('name' => t('First Level Heading'), 'placeHolder' => 'Your title here...', 'className' => 'markitup-h1', 'key' => '1', 'closeWith' => 'function(markItUp) { return miu.markdownTitle(markItUp, "=") }'),
+    'h2' => array('name' => t('Second Level Heading'), 'placeHolder' => 'Your title here...', 'className' => 'markitup-h2', 'key' => '2', 'closeWith' => 'function(markItUp) { return miu.markdownTitle(markItUp, "-") }'),
+    'h3' => array('name' => t('Heading 3'), 'placeHolder' => 'Your title here...', 'className' => 'markitup-h3', 'key' => '3', 'openWith' => '### '),
+    'h4' => array('name' => t('Heading 4'), 'placeHolder' => 'Your title here...', 'className' => 'markitup-h4', 'key' => '4', 'openWith' => '#### '),
+    'h5' => array('name' => t('Heading 5'), 'placeHolder' => 'Your title here...', 'className' => 'markitup-h5', 'key' => '5', 'openWith' => '##### '),
+    'h6' => array('name' => t('Heading 6'), 'placeHolder' => 'Your title here...', 'className' => 'markitup-h6', 'key' => '6', 'openWith' => '###### '),
+    'bold' => array('name' => t('Bold'), 'className' => 'markitup-bold', 'key' => 'B', 'openWith' => '**', 'closeWith' => '**'),
+    'italic' => array('name' => t('Italic'), 'className' => 'markitup-italic', 'key' => 'I', 'openWith' => '_', 'closeWith' => '_'),
+    'link' => array('name' => t('Link'), 'className' => 'markitup-link', 'key' => 'L', 'openWith' => '[', 'closeWith' => ']([![Url:!:http://]!] "[![Title]!]")', 'placeHolder' => 'Your text to link here...'),
+    'bullet' => array('name' => t('Bulleted List'), 'className' => 'markitup-bullet', 'openWith' => '- '),
+    'numeric' => array('name' => t('Numeric List'), 'className' => 'markitup-numeric', 'openWith' => 'function(markItUp) { return markItUp.line+'. '; }'),
+    'quote' => array('name' => t('Quotes'), 'className' => 'markitup-quote', 'openWith' => '> '),
+    'code' => array('name' => t('Code Block / Code'), 'className' => 'markitup-code', 'openWith' => '(!(    |!|`)!)', 'closeWith' => '(!(`)!)'),
+    // @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'),
+  );
+      
+  if (!empty($config['buttons'])) {
+    foreach ($config['buttons'] as $plugin) {
+      foreach ($plugin as $button => $enabled) {
+        if (isset($default_buttons[$button])) {
+          $settings['markupSet'][] = $default_buttons[$button];
+        }
+      }
+    }
+  }
+  else {
+    $settings['markupSet'] = $default_buttons;
+  }
+
+  return $settings;
+}
+
+/**
+ * Determine available editor themes or check/reset a given one.
+ *
+ * @param $editor
+ *   A processed hook_editor() array of editor properties.
+ * @param $profile
+ *   A wysiwyg editor profile.
+ *
+ * @return
+ *   An array of theme names. The first returned name should be the default
+ *   theme name.
+ */
+function wysiwyg_markitup_markdown_themes($editor, $profile) {
+  return array('simple', 'markitup');
+}
+
+/**
+ * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
+ */
+function wysiwyg_markitup_markdown_plugins($editor) {
+  return array(
+    'default' => array(
+      'buttons' => array(
+        'h1' => t('First Level Heading'),
+        'h2' => t('Second Level Heading'), 
+        'h3' => t('Heading 3'), 
+        'h4' => t('Heading 4'), 
+        'h5' => t('Heading 5'), 
+        'h6' => t('Heading 6'), 
+        'bold' => t('Bold'), 'italic' => t('Italic'),
+        'link' => t('Link'),
+        // 'cleanup' => t('Clean-up'),
+        'preview' => t('Preview'),
+      ),
+      'internal' => TRUE,
+    ),
+  );
+}
+

Property changes on: editors/markitup_markdown.inc
___________________________________________________________________
Added: svn:executable
   + *

Index: editors/css/markitup_markdown-1.css
===================================================================
--- editors/css/markitup_markdown-1.css	(revision 0)
+++ editors/css/markitup_markdown-1.css	(revision 0)
@@ -0,0 +1,54 @@
+/* -------------------------------------------------------------------
+// markItUp!
+// By Jay Salvat - http://markitup.jaysalvat.com/
+// ------------------------------------------------------------------*/
+.markItUp .markitup-h1 a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/h1.png); 
+}
+.markItUp .markitup-h2 a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/h2.png); 
+}
+.markItUp .markitup-h3 a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/h3.png); 
+}
+.markItUp .markitup-h4 a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/h4.png); 
+}
+.markItUp .markitup-h5 a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/h5.png); 
+}
+.markItUp .markitup-h6 a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/h6.png); 
+}
+
+.markItUp .markitup-bold a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/bold.png);
+}
+.markItUp .markitup-italic a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/italic.png);
+}
+
+.markItUp .markitup-bullet a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/list-bullet.png);
+}
+.markItUp .markitup-numeric a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/list-numeric.png);
+}
+
+.markItUp .markitup-image a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/picture.png); 
+}
+.markItUp .markitup-link a {
+	background-image:url(../../markitup/markitup/sets/markdown/images/link.png);
+}
+
+.markItUp .markitup-quote a	{
+	background-image:url(../../markitup/markitup/sets/markdown/images/quotes.png);
+}
+.markItUp .markitup-code a	{
+	background-image:url(../../markitup/markitup/sets/markdown/images/code.png);
+}
+
+.markItUp .markitup-preview a {
+	background-image:url(../../markitup/markitup/sets/default/images/preview.png);
+}

Property changes on: editors/css/markitup_markdown-1.css
___________________________________________________________________
Added: svn:executable
   + *

Index: editors/js/markitup_markdown.js
===================================================================
--- editors/js/markitup_markdown.js	(revision 0)
+++ editors/js/markitup_markdown.js	(revision 0)
@@ -0,0 +1,35 @@
+// $Id: markitup.js,v 1.1 2009/01/06 01:40:31 sun Exp $
+
+/**
+ * Attach this editor to a target element.
+ */
+Drupal.wysiwyg.editor.attach.markitup_markdown = function(context, params, settings) {
+  // If a string start with function()
+  for (var ms in settings['markupSet']) {
+    if (typeof(settings['markupSet'][ms].openWith) != 'undefined' && settings['markupSet'][ms].openWith.indexOf("function") == 0) {
+      settings['markupSet'][ms].openWith = function() {
+        return eval(settings['markupSet'][ms].openWith);
+      };
+    }
+    if (typeof(settings['markupSet'][ms].closeWith) != 'undefined' && settings['markupSet'][ms].closeWith.indexOf("function") == 0) {
+      settings['markupSet'][ms].closeWith = function() {
+        return eval(settings['markupSet'][ms].closeWith);
+      };
+    }
+  }
+  $('#' + params.field, context).markItUp(settings);
+};
+
+/**
+ * Detach a single or all editors.
+ *
+ * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
+ */
+Drupal.wysiwyg.editor.detach.markitup_markdown = function(context, params) {
+  if (typeof params != 'undefined') {
+    $('#' + params.field, context).markItUpRemove();
+  }
+  else {
+    $('.markItUpEditor', context).markItUpRemove();
+  }
+};

Property changes on: editors/js/markitup_markdown.js
___________________________________________________________________
Added: svn:executable
   + *

