worstinme/yii2-jodit

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Yii2 jodit editor Extension

Installs: 301

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

v1.0.2 2016-07-24 00:13 UTC

This package is not auto-updated.

Last update: 2019-11-11 02:55:41 UTC


README

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,
            ],
        ],
    ],
]);?>