troon-markdown / yii2-troon-markdown
editor.md for Yii2 by Troon Technologies
dev-master
2020-03-06 12:39 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-06-06 19:45:28 UTC
README
Troon Markdown editor
Markdown editor powered by Troon Technologies
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist troon-markdown/yii2-troon-markdown "*"
or add
"troon-markdown/yii2-troon-markdown": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
<?php
use troon\markdown\EditorMdWidget;
echo $form->field($model, 'content')->widget(EditorMdWidget::className(), [
'options'=>[
'id'=>'content'
],
'clientOptions' => [
'height' => '640',
// 'previewTheme' => 'dark',
// 'editorTheme' => 'pastel-on-dark',
'markdown' => '',
'codeFold' => true,
'syncScrolling' => false,
'saveHTMLToTextarea' => true,
'searchReplace' => true,
'htmlDecode' => 'style,script,iframe|on*',
'toolbar ' => false,
'previewCodeHighlight' => false,
'emoji' => true,
'taskList' => true,
'tocm' => true,
'tex' => true,
'flowChart' => true,
'sequenceDiagram' => true,
'imageUpload' => true,
'imageFormats' => ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'],
'imageUploadURL' => '/file/blog-upload?type=default&filekey=editormd-image-file',
]
]);
?>
To display Markdown on web view
<?php
use troon\markdown\ViewMdWidget;
echo ViewMdWidget::widget([
'markdown'=>$model->content,
'options'=>[// html attributes
'id'=>'content'
]
]);
?>