/yii2-bootstrap-markdown-editor

Yii2 Markdown Editor based on Bootstrap Markdown.

Primary LanguagePHPMIT LicenseMIT

Yii2 Bootstrap Markdown Editor

Yii2 Markdown Editor based on Bootstrap Markdown.

This component use folowing libraries:

  • Marked -- a full-featured markdown parser and compiler, written in JavaScript.
  • To markdown -- an HTML to Markdown converter written in javascript.
  • Bootstrap Markdown -- JSimple Markdown editing tools that works!

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require uran1980/yii2-bootstrap-markdown-editor "dev-master"

or add

"uran1980/yii2-bootstrap-markdown-editor": "dev-master"

to the require section of your composer.json

Usage

Active widget

In view in active form:

<?php

use yii\widgets\ActiveForm;
use uran1980\yii\widgets\markdown\MarkdownEditor;
?>

<div class="active-form">
    <?php $form = ActiveForm::begin(); ?>
    <?php echo $form->field($model, 'content')->widget(MarkdownEditor::className(), [
        'clientOptions' => ['language' => Yii::$app->language],
        'options'       => ['data-provider' => 'markdown'],
    ]); ?>
    <?php ActiveForm::end(); ?>
</div>

Simple widget

In view:

<?php
use uran1980\yii\widgets\markdown\MarkdownEditor;

echo MarkdownEditor::widget([
    'name'          => 'md-editor',
    'value'         => '# test message',
    'clientOptions' => ['language' => Yii::$app->language],
    'options'       => ['data-provider' => 'markdown'],
]);

See also

Author

Ivan Yakovlev, e-mail: uran1980@gmail.com