2017 © Pedro Peláez
 

yii2-extension yii2-editor-md

Markdown editor.md for Yii2

image

nikitakls/yii2-editor-md

Markdown editor.md for Yii2

  • Wednesday, February 21, 2018
  • by nikitakls
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

nikitakls/yii2-editor-md

editor.md for Yii2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

composer require nikitakls/yii2-editor-md

or add, (*4)

"nikitakls/yii2-editor-md": "*"

to the require section of your composer.json file., (*5)

Usage

Once the extension is installed, simply use it in your code by:, (*6)


field($model, 'info_md')->widget(EditorMdWidget::className(), [
                'options' => [// html attributes
                    'id' => 'editor-markdown',
                ],
                'language' => 'ru',
                'clientOptions' => [
                    'height' => '300',
                    // 'previewTheme' => 'dark',
                    // 'editorTheme' => 'pastel-on-dark',
                    'markdown' => '',
                    //'codeFold' => true,
                    'syncScrolling' => true,
                    'saveHTMLToTextarea' => true,
                    'searchReplace' => true,
                    'watch' => true, 
                    'htmlDecode' => 'style,script,iframe|on*',
                    //'toolbar' => false,             
                    'placeholder' => 'MarkDown',
                    'previewCodeHighlight' => false,  
                    'emoji' => true,
                    'taskList' => true,
                    'tocm' => true, 
                    'tex' => true,   
                    'flowChart' => true,            
                    'sequenceDiagram' => true,     
                    'imageUpload' => true,
                    'imageFormats' => ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'],
                    'imageUploadURL' => Url::to(['file-upload', 'type' => 'md']),
                    'toolbarIcons' => [
                        "undo", "redo", "|",
                        "bold", "del", "italic", "list-ul", "list-ol", "hr", "|",
                        "code", "code-block", "|",
                        "image", "table", "link", "|",
                        "html-entities", "|",
                        "preview", "watch","|",
                        "help"
                    ],
                ]
            ]
) ?>

See more options [https://pandao.github.io/editor.md/en.html], (*7)

Markdown behavior

This behavior save html render markdown in active record model attribute. You can use markdown behavior for ActiveRecord Model next:, (*8)

use nikitakls\markdown\behaviors\MarkdownModelBehavior

class Content extents ActiveRecord{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            [
                'class' => MarkdownModelBehavior::className(),
                'sourceAttribute' => 'content',
                'destinationAttribute' => 'clean_content',
            ],
        ];
    }

}

Markdown action for upload files

Configure you controller if you want to have upload image functionality:, (*9)

use nikitakls\markdown\actions\UploadFileAction; 

class ContentController extends Controller
{

    /**
     * @inheritdoc
     */
    public function actions()
    {

        return [
            'upload-image' => [
                'class' => UploadFileAction::class,
                'url' => '@fileUrl/origin/puzzle/',
                'path' => '@filePath/origin/puzzle/',
                'thumbPath' => '@filePath/thumb/puzzle/',
                'thumbUrl' => '@fileUrl/thumb/puzzle/',
                'thumbs' => [
                    'puzzle' => [
                        'width' => 480,
                        'height' => 320,
                        'main' => true
                    ],
                ],
                'unique' => true,
                'validatorOptions' => [
                    'maxWidth' => 1600,
                    'maxHeight' => 1200
                ]
            ],
        ];
    }

The Versions

21/02 2018

dev-master

9999999-dev

Markdown editor.md for Yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar nikitakls

extension yii2 editor markdown

21/02 2018

v0.1.1

0.1.1.0

Markdown editor.md for Yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar nikitakls

extension yii2 editor markdown

31/01 2018

v0.1

0.1.0.0

Markdown editor.md for Yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar nikitakls

extension yii2 editor markdown