desc
**修复了linux下的一些bug,由于Yii China 无法更新这些信息,抱歉。使用方法务必参考本文,YiiChina上的方法有拼写问题,因为无法修改,所以一定要看这个!!!***, (*1)
中文的使用说明在页面下部, (*2)
Either run, (*3)
$ php composer.phar require pjkui/kindeditor "*"
or add, (*4)
"pjkui/kindeditor": "*"
to the require
section of your composer.json
file., (*5)
'pjkui\\kindeditor\\'=>array($vendorDir . '/pjkui/kindeditor')
public function actions() { return [ 'Kupload' => [ 'class' => 'pjkui\kindeditor\KindEditorAction', ] ]; }
echo \pjkui\kindeditor\KindEditor::widget([]);
or :, (*6)
echo $form->field($model,'colum')->widget('pjkui\kindeditor\KindEditor',[]);
or :, (*7)
<?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ] ]) ?>
you can configure clientOption
and editorType
to change the kindeditor's preference, the detail configure see the official websiteKindEditor website, (*8)
editorType
configureusage:, (*9)
<?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ] ]) ?>
uploadButton
Kindediotr work as a upload file button ,can upload file/picture to the server automatic usage:, (*10)
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'uploadButton ]) ?>
colorpicker
kindeditor work as color picker usage:, (*11)
<?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor', 'editorType'=>'colorpicker']) ?>
file-manager
kindeditor work as file manager,can view and select the file which uploaded by it . usage:, (*12)
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'file-manager' ]) ?>
image-dialog
kindeditor work as image upload dialog. usage:, (*13)
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'image-dialog' ]) ?>
file-dialog
kindeditor work as file upload dialog. usage:, (*14)
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'file-dialog' ]) ?>
simple demo:, (*15)
use \pjkui\kindeditor\KindEditor; echo KindEditor::widget([ 'clientOptions' => [ //editor size 'height' => '500', //custom menu 'items' => [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about' ] ]);
第一种方法: 如果装了composer,可以运行这个命令, (*16)
$ php composer.phar require pjkui/kindeditor "*"
第二种方法: 将, (*17)
"pjkui/kindeditor": "*"
加入到项目 composer.json
文件的require
部分。, (*18)
第三种方法:
直接将程序文件放到系统的vendor下面,其实建议用compaser,这个是比较方便和规范的安装方法,如果是拷贝的话,有一个文件需要修改,以保证这个kindeditor类被加载。
这个文件是/vendor/composer/autoload_psr4.php
.添加一行, (*19)
'pjkui\\kindeditor\\'=>array($vendorDir . '/pjkui/kindeditor'),
在控制器中加入这个方法:, (*20)
public function actions() { return [ 'Kupload' => [ 'class' => 'pjkui\kindeditor\KindEditorAction', ] ]; }
先在视图中加入, (*21)
echo \pjkui\kindeditor\KindEditor::widget([]);
或者:, (*22)
echo $form->field($model,'colum')->widget('pjkui\kindeditor\KindEditor',[]);
或者:, (*23)
<?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor', ['clientOptions'=>['allowFileManager'=>'true', 'allowUpload'=>'true']]) ?>
编辑器相关配置,请在view 中配置,参数为
clientOptions,比如定制菜单,编辑器大小等等,具体参数请查看KindEditor官网文档。, (*24)
editorType
配置配置为富文本编辑器,默认配置, (*25)
示例:, (*26)
<?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ] ]) ?>
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'uploadButton ]) ?>
<?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor', 'editorType'=>'colorpicker') ?>
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'file-manager' ]) ?>
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'image-dialog' ]) ?>
<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor', [ 'clientOptions'=>[ 'allowFileManager'=>'true', 'allowUpload'=>'true' ], 'editorType'=>'file-dialog' ]) ?>
简单 示例:, (*27)
use \pjkui\kindeditor\KindEditor; echo KindEditor::widget([ 'clientOptions' => [ //编辑区域大小 'height' => '500', //定制菜单 'items' => [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about' ], 'id'=>'thisID',//填写你想给textarea的id ]);