myzero1/yii2-ckeditor

CKEditor widget for Yii 2

Maintainers

👁 myzero1

Package info

github.com/myzero1/yii2-ckeditor

Type:yii2-extension

pkg:composer/myzero1/yii2-ckeditor

Statistics

Installs: 181

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

4.11.2 2019-03-04 04:29 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 18ea19d14b7d41c3ace67ad3617c66f2c3320f04

  • myzero1 <myzero1.woop@sina.com>

wysiwygeditorCKEditorwidgetyii2

This package is not auto-updated.

Last update: 2026-06-17 01:34:41 UTC


README

This extension renders a CKEditor widget for Yii framework 2.0.

👁 License

Installation

Install extension through composer:

Either run

php composer.phar require "myzero1/yii2-ckeditor" "*"

or add

"myzero1/yii2-ckeditor" : "*"

to the require section of your application's composer.json file.

Config the action for upload

Add the section of your application's main.json file, as flowing:


return [
 ......
 'controllerNamespace' => 'backend\controllers',
 'controllerMap' => [
 'ckeditor' => [
 'class' => 'myzero1\ckeditor\CKditorController',
 'config' => [
 'imageFieldName' => 'upload',
 'imageMaxSize' => 1024*1024*2, // 2M = 1024*1024*2
 'imageAllowFiles' => ['.jpg', '.jpeg', '.png', '.gif'],
 'imagePathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}',
 ],
 ]
 ],
 'bootstrap' => ['log'],
 ......

Usage

The following code in a view file would render a CKEditor widget:

<?= myzero1\ckeditor\CKEditor::widget(['name' => 'attributeName']) ?>

Configuring the CKEditor options should be done using the clientOptions attribute:

<?= myzero1\ckeditor\CKEditor::widget([
 'name' => 'attributeName',
 'clientOptions' => [
 'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,preview,image2',
 // 'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,preview,easyimage',
 'removePlugins' => 'resize,image',
 'autoGrow_maxHeight' => 900,
 'stylesSet' => [
 ['name' => 'Subscript', 'element' => 'sub'],
 ['name' => 'Superscript', 'element' => 'sup'],
 ],
 ],
]) ?>

If you want to use the CKEditor widget in an ActiveForm, it can be done like this:

<?= $form->field($model, 'attributeName')->widget(myzero1\ckeditor\CKEditor::className()) ?>

If you want to use the CKEditor widget in an ActiveForm,and to configuring the CKEditor options, it can be done like this:

<?= $form->field($model, 'attributeName')->widget(myzero1\ckeditor\CKEditor::className(), [
 'clientOptions' => [
 'selectMultiple' => true,
 'filebrowserImageUploadUrl' => '/ckeditor/upload-image',
 'imageUploadUrl' => '/ckeditor/upload-image',
 'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,preview,image2',
 // 'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,image2,preview,easyimage',
 'removePlugins' => 'resize,image',
 'autoGrow_maxHeight' => 900,
 'stylesSet' => [
 ['name' => 'Subscript', 'element' => 'sub'],
 ['name' => 'Superscript', 'element' => 'sup'],
 ],
 ],
 ]) ?>