karneds / yii2-redactor
Extension redactor for Yii2 Framework.
Installs: 106
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 87
Open Issues: 0
Type:yii2-extension
Requires
This package is not auto-updated.
Last update: 2025-03-29 18:31:29 UTC
README
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist "karneds/yii2-redactor *"
or add
"karneds/yii2-redactor": "*"
to the require section of your composer.json.
Usage:
in controller
public function actions(){ return [ 'file' => [ 'class'=>'yii\redactor\actions\FileUploadAction', 'uploadDir'=>'@webroot/uploads/files/' ], 'image' => [ 'class'=>'yii\redactor\actions\ImageUploadAction', 'uploadDir'=>'@webroot/uploads/images/' ], 'imagejson' => [ 'class'=>'yii\redactor\actions\ImageGetJsonAction', 'sourcePath'=>'@webroot/uploadsimages/' ], 'clipboard' => [ 'class'=>'yii\redactor\actions\ClipboardUploadAction', 'uploadDir'=>'@webroot/uploads/files/' ], ]; }
in view
use \yii\helpers\Url; ... <?= $form->field($model,'text')->widget(yii\redactor\widgets\Redactor::className(),[ 'clientOptions'=>[ 'lang'=>'ru', 'formattingTags'=>['p', 'blockquote', 'pre', 'h2', 'h3', 'h4'], 'imageTabLink'=>false, 'imageGetJson' => Url::toRoute(['pages/imagejson']), 'imageUpload' => Url::toRoute(['pages/image']), 'clipboardUploadUrl' =>Url::toRoute(['pages/clipboard']), 'fileUpload' => Url::toRoute(['pages/file']), 'plugins' => ['clips', 'fullscreen'] ] ])?>
Advanced application template
in config.php
'components' => [ 'urlManagerFrontend'=>[ 'class' => 'yii\web\UrlManager', 'baseUrl'=>'', 'hostInfo'=>'http://example.com' ], ]
in controller
public function actions(){ return [ 'image' => [ 'class'=>'yii\redactor\actions\ImageUploadAction', 'uploadDir'=>'@frontend/web/uploads/images/', 'baseDir'=>'@frontend/web', 'baseUrl'=>Yii::$app->urlManagerFrontend->hostInfo.Yii::$app->urlManagerFrontend->baseUrl ], 'imagejson' => [ 'class'=>'yii\redactor\actions\ImageGetJsonAction', 'sourcePath'=>'@frontend/web/uploads/images/' 'baseDir'=>'@frontend/web', 'baseUrl'=>Yii::$app->urlManagerFrontend->hostInfo.Yii::$app->urlManagerFrontend->baseUrl ], ]; }
in view
use \yii\helpers\Url; ... <?= $form->field($model,'text')->widget(yii\redactor\widgets\Redactor::className(),[ 'clientOptions'=>[ 'lang'=>'ru', 'imageGetJson' => Url::toRoute(['pages/imagejson']), 'imageUpload' => Url::toRoute(['pages/image']) ] ])?>