pjkui 2015-03-04 20:28:24 19543次浏览 15条评论 24 6 0

install / 安装

Either run

$ php composer.phar require pjkui/kindeditor "dev-master"

or add

"pjkui/kindeditor": "dev-master"

to the require section of your composer.json file.

Usage example / 应用方法

controller / 控制器:

public function actions()
{
    return [
        'Kupload' => [
            'class' => 'pjkui\kindeditor\KindEditorAction',
        ]
    ];
}

view / 视图:

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

or / 或者:

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

or / 或者:

<?= $form->field($model, 'content')->widget('pjkui\kindeditor\Kindeditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true']]) ?>

configure / 配置相关

you can configure clientOption and editorType to change the kindeditor's preference, the detail configure see the official websiteKindEditor website. / 编辑器相关配置,请在view 中配置,参数为clientOptions,比如定制菜单,编辑器大小等等,具体参数请查看KindEditor官网文档

editorType configure / editorType配置

1 editor work as editor,default configure./配置为富文本编辑器,默认配置

usage:

<?= $form->field($model, 'content')->widget('pjkui\kindeditor\Kindeditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true']]) ?>

2 uploadButtonKindediotr work as a upload file button ,can upload file/picture to the server automatic /这时候配置kindeditor为上传文件按钮,可以自动上传文件到服务器

usage:

<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\Kindeditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true'],'editorType'=>'uploadButton]) ?>

3 colorpickerkindeditor work as color picker / 配置kindeditor为取色器

usage:

<?= $form->field($model, 'content')->widget('pjkui\kindeditor\Kindeditor','editorType'=>'colorpicker']) ?>

4 file-managerkindeditor work as file manager,can view and select the file which uploaded by it . / 配置kindeditor为文件管理器,可以查看和选着其上传的文件。

usage:

<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\Kindeditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true'],'editorType'=>'file-manager']) ?>

5 image-dialog kindeditor work as image upload dialog. / 配置kindeditor为图片上传对话框。

usage:

<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\Kindeditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true'],'editorType'=>'image-dialog']) ?>

6 file-dialog kindeditor work as file upload dialog. / 配置kindeditor为文件上传对话框。

usage:

<?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\Kindeditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true'],'editorType'=>'file-dialog']) ?>

简单实例:

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'
        ],
]);

下载地址:

这里!---->>>>>>github

觉得很赞
  • 评论于 2015-06-19 16:44 举报

    看到最后萌萌哒~

    2 条回复
    评论于 2016-11-18 16:24 回复

    这些问题已经修复,使用中的问题随时联系我。

    评论于 2017-08-06 23:23 回复

    怎么设置,才能把数据库里kindeditor提交的数据显示到视图kindeditor编辑器里,重新编辑提交。编辑器编辑文字时,一敲enter键换行然后保存,用JS 对象的innerHTML()方法,编辑器里显示不出来。

  • 评论于 2015-07-01 16:08 举报

    图片和文件上传出错是怎么回事呢?

    5 条回复
    评论于 2015-07-23 17:33 回复

    我的也是,图片上传错误,你的解决了吗?

    评论于 2015-09-12 12:28 回复

    上传出错,已经解决了吗

    评论于 2016-03-03 10:20 回复

    在web目录里创建一个upload文件夹

    评论于 2016-03-03 10:21 回复

    在linux需要将目录权限修改为777

    评论于 2016-12-03 13:17 回复

    想把文件上传在模块里,但是最后却读取不到了

  • 评论于 2015-07-23 17:35 举报

    楼主,跪求解答为什么上传图片错误

  • 评论于 2015-09-26 20:25 举报

    Invalid Configuration – yii\base\InvalidConfigException
    Either 'name', or 'model' and 'attribute' properties must be specified.

    按照你给的例子,最后的那个简单例子,貌似有问题啊。如上。

  • 评论于 2015-12-21 11:30 举报

    你这个上传的地址不让配置

        $fileManagerJson = Url::to(['Kupload', 'action' => 'fileManagerJson']);
        $uploadJson = Url::to(['Kupload', 'action' => 'uploadJson']);
    
  • 评论于 2016-01-13 11:22 举报

    kindeditor 是没有上传功能,要自己加进去

  • 评论于 2016-01-19 19:17 举报

    可以删除图片吗?

  • 评论于 2016-04-18 10:50 举报

    在KinEditor.php 最后default分支里增加以下代码可解决 内容不同步的问题(后台拿不到数据)

    $clientOptions = Json::decode($clientOptions);
    $clientOptions['afterChange'] = "function(){this.sync();}";
    $clientOptions = Json::encode($clientOptions);
    $clientOptions = str_replace('"function(){this.sync();}"','function(){this.sync();}',$clientOptions);
    

    有更好的方法可以晒出来

  • 评论于 2016-09-06 15:19 举报

    KindEditorAsset.php 里面语言包的大小写不规范,将导致在 linux 下面无法加载语言包。
    zh_cn.js => zh_CN.js

    1 条回复
    评论于 2016-11-18 16:28 回复

    多谢提示,由于初期开发在windows下,有很多大小写的问题,已经修复!

  • 评论于 2016-11-18 16:29 举报

    KindEditor 2016年11月18日16:29:12

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

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

    install

    Either run

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

    or add

    "pjkui/kindeditor": "*"

    to the require section of your composer.json file.

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

    Usage example

    add an actions() method in controller

    public function actions()
    {
        return [
            'Kupload' => [
                'class' => 'pjkui\kindeditor\KindEditorAction',
            ]
        ];
    }
    

    used in view :

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

    or :

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

    or :

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

    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:

     <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
            ['clientOptions'=>['allowFileManager'=>'true',
                                'allowUpload'=>'true'
                                ]
            ]) ?>
    
    1. uploadButtonKindediotr work as a upload file button ,can upload file/picture to the server automatic
      usage:
      <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
                       ['clientOptions'=>[
                                           'allowFileManager'=>'true',
                                           'allowUpload'=>'true'
                                           ],
                       'editorType'=>'uploadButton
                       ]) 
      ?>
      
    2. colorpickerkindeditor work as color picker
      usage:
      <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',
                                                       'editorType'=>'colorpicker'])
           ?>
      
    3. file-managerkindeditor work as file manager,can view and select the file which uploaded by it .
      usage:
      <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
                       ['clientOptions'=>[
                                   'allowFileManager'=>'true',
                                   'allowUpload'=>'true'
                                       ],
                           'editorType'=>'file-manager'
                           ]) 
           ?>
      
    4. image-dialogkindeditor work as image upload dialog.
      usage:
      <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
                           ['clientOptions'=>['allowFileManager'=>'true',
                                               'allowUpload'=>'true'
                                               ],
                           'editorType'=>'image-dialog'
                           ]) 
      ?>
      
    5. file-dialogkindeditor work as file upload dialog.
      usage:
      <?= $form->field($model, 'article_pic')->widget('pjkui\kindeditor\KindEditor',
                                   ['clientOptions'=>['allowFileManager'=>'true',
                                                       'allowUpload'=>'true'],
                                   'editorType'=>'file-dialog'
                                   ])
       ?>
      

    simple demo:

    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'
            ]
    ]);
    

    KindEditor中文手册

    如何安装

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

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

    第二种方法:

    "pjkui/kindeditor": "*"
    

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

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

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

    使用方法

    控制器:

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

    public function actions()
    {
        return [
            'Kupload' => [
                'class' => 'pjkui\kindeditor\KindEditorAction',
            ]
        ];
    }
    

    视图:

    先在视图中加入

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

    或者:

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

    或者:

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

    具体相关功能配置

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

    editorType配置

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

    示例:

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

    简单 示例:

    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'
            ]
    ]);
    
  • 评论于 2016-12-23 14:07 举报

    如果该字段为必填项的话,第一次提交会报错(提示不能为空),这是为什么

    1 条回复
    评论于 2017-10-31 14:51 回复

    我也是这个问题

  • 评论于 2017-05-17 00:58 举报

    上传到了backend\web\upload目录里后,在frontend的web下怎么显示图片和文件

  • 评论于 2017-06-05 15:14 举报

    这个好像上传视频无法播放啊 怎么解决这个问题 求大神

  • 评论于 2017-08-08 11:52 举报

    在视图里,怎么获取kindeditor的对象?

  • 评论于 2017-10-31 14:50 举报

    提交内容不能为空,我后台判断内容了,这个要怎么处理
    `
    <?= $form->field($textform, 'content')->widget('pjkui\kindeditor\KindEditor', [

            'id' => 'editor_id',
            'clientOptions' => [
                'allowFileManager' => 'true',
                'allowUpload' => 'true',
                'items' => [
                    'source', '|', 'formatblock', 'fontsize', '|', 'forecolor', 'bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image', 'table', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'anchor', 'link', 'unlink', '|', 'fullscreen', 'about'
                ]
            ]
        ]); ?>
        `
    
您需要登录后才可以评论。登录 | 立即注册