DDEditor Yii Extension
This extension contains a widget to render an activeTextarea to enter Markdown text.
The rendered widget contains some buttons to add markdown tags for
It is also capable of displaying dropdown lists with additional text snippets for insertion.
protected/extensionsIn your config/main.php file, add
// autoloading model and component classes
'import'=>array(
...
'application.extensions.ddeditor.*',
...
),
In e.g. views/post/_form.php, include the following code:
<?php $this->widget(
'application.extensions.ddeditor.DDEditor',
array(
'model'=>$model,
'attribute'=>'content',
'htmlOptions'=>array('rows'=>10, 'cols'=>70),
'previewRequest'=>'post/preview')); ?>
If you want to display an extra dropdown list with snippets, you may add the additionalSnippets parameter:
<?php $mySnippets = array(
'Users' => array(
'id1' => 'John',
'id2' => 'Paul',
),
'Phrases' => array(
'Text Foo' => 'foo',
'Text Bar' => 'bar'
)
); ?>
<?php $this->widget(
'application.extensions.ddeditor.DDEditor',
array(
'model'=>$model,
'attribute'=>'content',
'htmlOptions'=>array('rows'=>10, 'cols'=>70),
'previewRequest'=>'post/preview',
'additionalSnippets'=>array('My Snippets'=>$mySnippets),
); ?>
In order to receive a rendered preview of the textarea Markdown, add an action method to a controller:
public function actionPreview()
{
$parser=new CMarkdownParser;
echo $parser->safeTransform($_POST['Post'][$_GET['attribute']]);
}
$previewReaquest
Total 1 comment
When h* is inline with others marks, h3 tag is not rendered.
Leave a comment
Please login to leave your comment.