Content editor like Medium.com for yii-2
Content editor like Medium.com for yii-2 based on https://github.com/sofish/pen, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist andrew72ru/yii2-pen "*"
or add, (*4)
"andrew72ru/yii2-pen": "*"
to the require section of your composer.json
file., (*5)
Usage
Use this in Active Form., (*6)
There is two cases of usage., (*7)
First, for multiple string text (like textarea)., (*8)
This code add a editable section
element to your form and make a p
tag in there for each paragraph., (*9)
use andrew72ru\pen\Pen;
echo $form->field($model, 'text')->widget(andrew72ru\pen\Pen::className());
Next case add a inline-editing feature – for headers and other one-line texts., (*10)
This code make a h1
tag with page-geader
class an add editablecontent
to there., (*11)
use andrew72ru\pen\Pen;
echo $form->field($model, 'title')->widget(Pen::className(), [
'clientOptions' => [
'inline' => true,
'tag' => 'h1',
'class' => 'page-header'
]
]);