项目作者: pjkui

项目描述 :
rich editor for yii2 framework
高级语言: JavaScript
项目地址: git://github.com/pjkui/kindeditor.git
创建时间: 2015-03-04T10:22:41Z
项目社区:https://github.com/pjkui/kindeditor

开源协议:GNU Lesser General Public License v2.1

下载


KindEditor

修复了linux下的一些bug,由于Yii China 无法更新这些信息,抱歉。使用方法务必参考本文,YiiChina上的方法有拼写问题,因为无法修改,所以一定要看这个!!!*

中文的使用说明在页面下部

install

Either run

  1. $ php composer.phar require pjkui/kindeditor "*"

or add

  1. "pjkui/kindeditor": "*"

to the require section of your composer.json file.

  1. 'pjkui\\kindeditor\\'=>array($vendorDir . '/pjkui/kindeditor')

Usage example

add an actions() method in controller

  1. public function actions()
  2. {
  3. return [
  4. 'Kupload' => [
  5. 'class' => 'pjkui\kindeditor\KindEditorAction',
  6. ]
  7. ];
  8. }

used in view :

  1. echo \pjkui\kindeditor\KindEditor::widget([]);

or :

  1. echo $form->field($model,'colum')->widget('pjkui\kindeditor\KindEditor',[]);

or :

  1. <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ]
  7. ])
  8. ?>

configure

you can configure clientOption and editorType to change the kindeditor’s preference, the detail configure see the official websiteKindEditor website

editorType configure

  1. Work as text editor,default configure.

usage:

  1. <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ]
  7. ])
  8. ?>
  1. uploadButton Kindediotr work as a upload file button ,can upload file/picture to the server automatic

usage:

  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'uploadButton
  8. ])
  9. ?>
  1. colorpickerkindeditor work as color picker

usage:

  1. <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
  2. 'editorType'=>'colorpicker'])
  3. ?>
  1. file-managerkindeditor work as file manager,can view and select the file which uploaded by it .

usage:

  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'file-manager'
  8. ])
  9. ?>
  1. image-dialogkindeditor work as image upload dialog.

usage:

  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'image-dialog'
  8. ])
  9. ?>
  1. file-dialogkindeditor work as file upload dialog.

usage:

  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'file-dialog'
  8. ])
  9. ?>

simple demo:

  1. use \pjkui\kindeditor\KindEditor;
  2. echo KindEditor::widget([
  3. 'clientOptions' => [
  4. //editor size
  5. 'height' => '500',
  6. //custom menu
  7. 'items' => [
  8. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  9. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  10. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  11. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  12. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  13. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
  14. 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  15. 'anchor', 'link', 'unlink', '|', 'about'
  16. ]
  17. ]);

KindEditor中文手册

如何安装

第一种方法:
如果装了composer,可以运行这个命令

  1. $ php composer.phar require pjkui/kindeditor "*"

第二种方法:

  1. "pjkui/kindeditor": "*"

加入到项目 composer.json 文件的require 部分。

第三种方法:
直接将程序文件放到系统的vendor下面,其实建议用compaser,这个是比较方便和规范的安装方法,如果是拷贝的话,有一个文件需要修改,以保证这个kindeditor类被加载。
这个文件是/vendor/composer/autoload_psr4.php.添加一行

  1. 'pjkui\\kindeditor\\'=>array($vendorDir . '/pjkui/kindeditor'),

使用方法

控制器:

在控制器中加入这个方法:

  1. public function actions()
  2. {
  3. return [
  4. 'Kupload' => [
  5. 'class' => 'pjkui\kindeditor\KindEditorAction',
  6. ]
  7. ];
  8. }

视图:

先在视图中加入

  1. echo \pjkui\kindeditor\KindEditor::widget([]);

或者:

  1. echo $form->field($model,'colum')->widget('pjkui\kindeditor\KindEditor',[]);

或者:

  1. <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
  2. ['clientOptions'=>['allowFileManager'=>'true',
  3. 'allowUpload'=>'true']])
  4. ?>

具体相关功能配置

编辑器相关配置,请在view 中配置,参数为clientOptions,比如定制菜单,编辑器大小等等,具体参数请查看KindEditor官网文档

editorType配置

  1. 配置为富文本编辑器,默认配置

    示例:

  1. <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ]
  7. ])
  8. ?>
  1. 这时候配置kindeditor为上传文件按钮,可以自动上传文件到服务器
    示例:
  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'uploadButton
  8. ])
  9. ?>
  1. 配置kindeditor为取色器
    示例:
  1. <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
  2. 'editorType'=>'colorpicker')
  3. ?>
  1. 配置kindeditor为文件管理器,可以查看和选着其上传的文件。
    示例:
  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'file-manager'
  8. ])
  9. ?>
  1. 配置kindeditor为图片上传对话框。
    示例:
  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'image-dialog'
  8. ])
  9. ?>
  1. 配置kindeditor为文件上传对话框。
    示例:
  1. <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
  2. [
  3. 'clientOptions'=>[
  4. 'allowFileManager'=>'true',
  5. 'allowUpload'=>'true'
  6. ],
  7. 'editorType'=>'file-dialog'
  8. ])
  9. ?>

简单 示例:

  1. use \pjkui\kindeditor\KindEditor;
  2. echo KindEditor::widget([
  3. 'clientOptions' => [
  4. //编辑区域大小
  5. 'height' => '500',
  6. //定制菜单
  7. 'items' => [
  8. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  9. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  10. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  11. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  12. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  13. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
  14. 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  15. 'anchor', 'link', 'unlink', '|', 'about'
  16. ],
  17. 'id'=>'thisID',//填写你想给textarea的id
  18. ]);