robbieaverill/silverstripe-markdowntextareafield

This package is abandoned and no longer maintained. No replacement package was suggested.

Supercharged textarea with markdown preview for Silverstripe CMS

2.0.0-beta.2 2016-08-11 03:33 UTC

README

Packagist Packagist Code quality via Scrutinizer CI Build Status

Features

  • Live preview (toggle)
  • Extendable toolbar with common markdown functions
  • Support for both regular markdown and extra functions

Screenshot

Markdown editor screenshot

Credits and Authors

Requirements

Installation

  • Use composer to install composer require robbieaverill/silverstripe-markdowntextareafield:*
  • Run /dev/build?flush=1

Instructions

You can use the MarkdownText data type for regular markdown or MarkdownTextExtra for added syntax features:

class Page extends SiteTree {

    private static $db = array(
        'MarkdownContent' => 'MarkdownTextExtra',
    );

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

        $markdownfield = MarkdownTextareaField::create('MarkdownContent');
        $markdownfield->enableExtra(); // Enables extra syntax support for fields live preview.

        $fields->addFieldToTab('Root.Main', $markdownfield);        
        return $fields;
    }
}

Template:

It is also possible to override/use markdown syntax in templates:

<div class="content">
    $MarkdownContent    <!-- Depending on data type used -->
</div>

<div class="content">
    $MarkdownContent.MarkdownAsHTML    <!-- Works with both data types, regular markdown -->
</div>

<div class="content">
    $MarkdownContent.MarkdownExtraAsHTML    <!-- Works with both data types, extended syntax -->
</div>

<div class="content">
    <pre>
        // Render JSON content
        $MarkdownContent.MarkdownAsJS
        // or
        $MarkdownContent.MarkdownExtraAsJS
    </pre>
</div>

Notes

  • Bug reports and ideas more than welcome.