jodit wysiwyg
PHP
Latest commit 33ede62 Jul 24, 2016 @worstinme fix

README.md

Yii2 Jodit WYSIWIG editor Extension

Jodit

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist worstinme/yii2-jodit "*"

or

composer require --prefer-dist worstinme/yii2-jodit

or add

"worstinme/yii2-jodit": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?=$form->field($model, 'content')->widget(\worstinme\jodit\Editor::className(), [
    'settings' => [
        'buttons'=>[
            'bold', 'italic', 'underline', '|', 'ul', 'ol', '|', 'image', '|', 'hr',
        ],
    ],
]);?>

Image uploader

add uploader action to controller:

public function actions()
{
    return [
        'upload-image' => [
            'class' => 'worstinme\jodit\UploadAction',
            'folder'=>Yii::getAlias('@webroot/uploads'),
            'webroot'=>Yii::getAlias('@webroot'),
        ],
    ];
}

editors config:

<?=$form->field($model, 'content')->widget(\worstinme\jodit\Editor::className(), [
    'settings' => [
        'height'=>'250px',
        'enableDragAndDropFileToEditor'=>new \yii\web\JsExpression("true"),
        'uploader'=>[
            'url'=>\yii\helpers\Url::to(['upload-image']),
            'data'=> [
                '_csrf'=> Yii::$app->request->csrfToken,
            ],
        ],
    ],
]);?>