sangroya / yii2-ckeditor
CKEditor for Yii
dev-main
2021-07-01 07:40 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-29 05:49:06 UTC
README
带有静态构建的 CKEditor for Yii(https://docs.ckeditor.com/ckeditor4/latest/builds/)
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一
php composer.phar require --prefer-dist sangroya/yii2-ckeditor5 "*"
或
"sangroya/yii2-ckeditor": "*"
将以下内容添加到您的 composer.json
文件的 require 部分。
使用方法
扩展安装后,只需在代码中通过以下方式使用它:
use sangroya\ckeditor\CKEditor; <?= $form->field($model, 'text')->widget(CKEditor::className(), [ 'options' => ['rows' => 6], 'preset'=>'full', ]) ?>``` Upload Url ----- ```php use sangroya\ckeditor\CKEditor; <?= $form->field($model, 'text')->widget(CKEditor::className(), [ 'options' => ['rows' => 6], 'preset'=>'full', 'clientOptions'=>[ 'filebrowserUploadUrl' => '/site/ckeditor-image-upload',//this will be the url where you want to ckeditor send the post request with file data ], ]) ?>``` Custom Toolbar ----- ```php use sangroya\ckeditor\CKEditor; <?= $form->field($model, 'text')->widget(CKEditor::className(), [ 'options' => ['rows' => 6], 'preset'=>'full', 'clientOptions'=>[ 'filebrowserUploadUrl' => '/site/ckeditor-image-upload',//this will be the url where you want to ckeditor send the post request with file data 'toolbarGroups' => [ ['name' => 'document', 'groups' => ['mode', 'document', 'doctools']], ['name' => 'clipboard', 'groups' => ['clipboard', 'undo']], ['name' => 'forms'], ['name' => 'basicstyles', 'groups' => ['basicstyles', 'colors','cleanup']], '/', ['name' => 'paragraph', 'groups' => [ 'list', 'indent', 'blocks', 'align', 'bidi' , 'paragraph' ]], ['name' => 'links'], ['name' => 'insert'], '/',['name'=>'align'], ['name' => 'styles'], ['name' => 'blocks'], ['name' => 'colors'], ['name' => 'tools'], ['name' => 'others'], ['about' => 'about'], ], ], ]) ?>```