No description or website provided.
JavaScript PHP Other
Latest commit b73518a Sep 27, 2012 @wolfv Update README.md
Permalink
Failed to load latest commit information.
code Added the markdown libraries Aug 7, 2012
css Bugfixes everywhere Jun 30, 2012
images added images Aug 19, 2012
javascript Added the ACE source Aug 7, 2012
scss Bugfixes everywhere Jun 30, 2012
templates Bugfixes everywhere Jun 30, 2012
.gitignore initial commit Jan 29, 2012
README.md Update README.md Sep 26, 2012
_config.php initial commit Jan 29, 2012
config.rb initial commit Jan 29, 2012

README.md

Silverstripe 3.0 MarkdownEditor Field

Requires Silverstripe 3.0 and a modern browser.

A simple, yet versatile field for nice textediting in the Silverstripe CMS. It's based on the ACE Editor.

Features:

  • Suggest Link: [Testlink](: leads to an autosuggest-field.

  • Suggest Image: ![Image Description](! opens an image-autosuggest field.

Getting the markdown editor field as a replacement for TinyMCE is easy:

public function getCMSFields() {
        $fields = parent::getCMSFields();
        $md = new MarkdownField('Content', 'Content');
        $md->addExtraClass('stacked'); // Little different Layout in CMS
        $fields->addFieldToTab('Root.Main', $md);
        return $fields;
}

To use the Markdown-Formatted Content on the website, use e.g. instead of $Content $Content.Parse(MarkdownParser).

To get the same Syntax Highlighting as in the preview pane inside the Editor, include markdown/javascript/lib/highlight/src/highlight.pack.js to your template. Initialization could look like this (with jQuery):

$(document).ready(function() {
  $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});

More examples are on http://softwaremaniacs.org/soft/highlight/en/description/ (All credit to them)


Example for a Page

DataObject with an additional MarkdownText Field, that automatically caches parsed Markdown into the "Content" Field, so you can later add TinyMCE back.

class Page extends SiteTree {

    public static $db = array(
        "MarkdownText" => "Text"
    );  

    public function getCMSFields() {
        $fields = parent::getCMSFields();

        $md = new MarkdownField('MarkdownText', 'Markdown Content');
        $md->addExtraClass('stacked'); // Little different Layout in CMS

        $fields->addFieldToTab('Root.Main', $md, 'Content');
        $fields->removeByName('Content');

        return $fields;
    }

    public function onBeforeWrite() {
        $Parser = new MarkdownParser($this->MarkdownText);
        $this->Content = $Parser->parse();
        parent::onBeforeWrite();
    }
}

The Markdown Logo was made by Dustin Curtis. All other icons were made by Orman Clark Premium Pixels