2017 © Pedro Peláez
 

silverstripe-module silverstripe-simplemde-markdown

SimpleMDE editor & markdown support for SilverStripe 3

image

axllent/silverstripe-simplemde-markdown

SimpleMDE editor & markdown support for SilverStripe 3

  • Tuesday, February 6, 2018
  • by axllent
  • Repository
  • 0 Watchers
  • 1 Stars
  • 256 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

SimpleMDE Editor & Markdown for SilverStripe 3

This module adds a field and a data type that allows for Markdown editing in the CMS, and HTML template rendering using the Github Flavoured Markdown parser Parsedown., (*1)

It is integrated with the SimpleMDE Markdown Editor for CMS editing (see "Editor limitations" below)., (*2)

Requirements

  • SilverStripe 3.x

Usage

Use the Markdown data type as your fields data type, then use the SimpleMDEEditor field in the CMS for editing., (*3)

Page class:

class MyMarkdownPage extends Page
{
    public static $db = array(
        'MarkdownContent'=>'Markdown'
    );

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

        $editor = SimpleMDEEditor::create('MarkdownContent', 'Page Content (Markdown)');
        $fields->addFieldToTab('Root.Main', $editor);

        return $fields;
    }
}

Template:

<div class="content">
    $MarkdownContent  <!-- Will show as rendered html -->
</div>

.htaccess:

The JavaScript and CSS resources needed to show the editor is unfortunately installed in the vendor folder. By default, SilverStripe blocks all HTTP requests to it (note that we do not want to include the dependencies directly because we want Composer to handle those dependencies). In order to get this to work, we'll need to allow access to those resources., (*4)

Add the following line:, (*5)

RewriteCond %{REQUEST_FILENAME} !\.(js|css)$

above this line:, (*6)

RewriteRule ^vendor(/|$) - [F,L,NC]

so that the .htaccess file would look similar to the following:, (*7)

# Deny access to potentially sensitive files and folders
RewriteCond %{REQUEST_FILENAME} !\.(js|css)$
RewriteRule ^vendor(/|$) - [F,L,NC]

RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]

Editor limitations:

SimpleMDE has some nice features such as full-page editing/preview, as well as "Side by Side" editing see demo. Unfortunately this doesn't play nice with SilverStripe's CMS as the fullscreen elements are positioned statically. Rather than some ugly hacking, and until someone hopefully finds an elegant solution (pull requests please), fullscreen & side-by-side functionality has been hidden from the toolbar., (*8)

The Versions

06/02 2018

dev-master

9999999-dev https://github.com/axllent/silverstripe-simplemde-markdown

SimpleMDE editor & markdown support for SilverStripe 3

  Sources   Download

MIT The MIT License (MIT)

The Requires

 

markdown silverstripe

29/08 2017

1.0.1

1.0.1.0 https://github.com/axllent/silverstripe-simplemde-markdown

SimpleMDE editor & markdown support for SilverStripe 3

  Sources   Download

The MIT License (MIT)

The Requires

 

markdown silverstripe

20/01 2016

1.0.0

1.0.0.0 https://github.com/axllent/silverstripe-simplemde-markdown

SimpleMDE editor & markdown support for SilverStripe 3

  Sources   Download

The MIT License (MIT)

The Requires

 

markdown silverstripe