markdown编辑器

Yii2 2017-12-04 浏览(5730 评论(0

图片描述

下载链接:https://github.com/yidashi/yii2-bootstrap-markdown

1.安装

composer require yidashi/yii2-bootstrap-markdown:"*"

2.使用

直接使用

<?= \yidashi\markdown\Markdown::widget(['name' => 'desc', 'language' => 'zh'])?>

在activeForm里使用

      <?= $form->field($model,'desc')->widget('yidashi\markdown\Markdown',['language' => 'zh']); ?>

twig使用

{{weight('\\yidashi\\markdown\\Markdown',{'name':'desc'})}}
{{ form.field(model,'desc').widget('\\yidashi\\markdown\\Markdown',{'name':'desc'})|raw }}

如果需要上传图片功能,加useUploadImage => true,此功能依赖 yidashi/yii2-webuploader,见https://github.com/yidashi/yii2-webuploader

{{ form.field(model,'desc').widget('\\yidashi\\markdown\\Markdown',{'name':'desc','options':{'url':'/upload'}})|raw}}

3.解析时候可以用

yii\helpers\Markdown::process($model->desc, 'gfm)

打赏

如果此文对你有所帮助,请随意打赏鼓励作者^_^

黄信强博客