2017 © Pedro Peláez
 

silverstripe-vendormodule markdown

Markdown DB field and form field for SilverStripe

image

silverstripers/markdown

Markdown DB field and form field for SilverStripe

  • Tuesday, June 5, 2018
  • by silverstripers
  • Repository
  • 3 Watchers
  • 6 Stars
  • 189 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 226 % Grown

The README.md

MarkdownField

CircleCI codecov, (*1)

This module introduces a new DB field type Markdown & Markdown Editor. It uses github style Markdown style. And uses the simple markdown editor., (*2)

https://github.com/sparksuite/simplemde-markdown-editor, (*3)

https://github.com/cebe/markdown, (*4)

The module is still under development, but soon will be ready, with link popups and image selectors., (*5)

Installation

Use composer, (*6)

composer require silverstripers/markdown dev-master

Basic Usage

To use the markdown DB field in your data objects the basic code would look like, (*7)


class MyDataClass extends DataObject { private static $db = [ 'MarkdownContent' => 'MarkdownText' ]; }

MarkdownText knows to add a markdown editor for your fields, but if you need to manually specify the type of field use, (*8)

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

    $fields->addFieldsToTab('Root.Sidebar', [
        \SilverStripers\markdown\forms\MarkdownEditorField::create('MarkdownContent', 'Content'),
    ]);

    return $fields;
}

Force all the fields to use Markdown

If you are looking to replace all the fields of HTMLText to markdown use the following configs in the config.yml., (*9)

This should override any instances of the HTMLText replacements with MarkdownText, (*10)

---
Name: myconfigs
After:
  - '#corefieldtypes'
---
SilverStripe\Core\Injector\Injector:
  HTMLText:
    class: SilverStripers\markdown\db\MarkdownText

Add preview styles

You can add your own CSS styles to the editor previews. This would let the users to check how their content will be displayed before they save in., (*11)

To achived this create a css file in mysite/css/ and name it as editor.css., (*12)

Your CSS rules have to be nested in a class so it wont affect other areas of the CMS., (*13)

.markdown-preview {
    background-color: white;
    padding: 20px;
    font-size: 20px;
}

.markdown-preview h1 {
    font-size: 30px;
}
````

If you are using a separate config and wanting to add styles to that EditorConfig you just add a new class name. This is possible because the fields adds
the EditorConfig's identifier on to the preview pane. The below is an example for the default configs.

.markdown-preview.default { background-color: white; padding: 20px; font-size: 14px; line-height: 20px; }, (*14)

.markdown-preview.default h1 { font-size: 24px; line-height: 30px; } ````, (*15)

The Versions

05/06 2018

dev-master

9999999-dev

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

22/12 2017

2.0.0

2.0.0.0

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

22/12 2017

dev-hotfix/media-embed-fixes

dev-hotfix/media-embed-fixes

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

02/11 2017

2.0.0-beta4

2.0.0.0-beta4

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

02/11 2017

2.0.0-beta3

2.0.0.0-beta3

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

27/10 2017

dev-feature/injector-class

dev-feature/injector-class

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

26/10 2017

dev-hotfix/type-errors-on-get_active

dev-hotfix/type-errors-on-get_active

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

24/10 2017

2.0.0-beta2

2.0.0.0-beta2

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

15/10 2017

2.0.0-beta1

2.0.0.0-beta1

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe

29/08 2017

1.0.0

1.0.0.0

Markdown DB field and form field for SilverStripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Nivanka Fonseka

module markdown silverstripe