大裤衩子 2015-01-31 20:33:32 48521次浏览 50条评论 62 14 0

百度UEditor

GitHub地址 https://github.com/BigKuCha/yii2-ueditor-widget

安装

Either run

$ php composer.phar require kucha/ueditor "*"

or add

"kucha/ueditor": "*"

to the require section of your composer.json file.

应用

controller:

public function actions()
{
    return [
        'upload' => [
            'class' => 'kucha\ueditor\UEditorAction',
        ]
    ];
}

view:

echo \kucha\ueditor\UEditor::widget([]);

或者:

echo $form->field($model,'colum')->widget('kucha\ueditor\UEditor',[]);

说明

ueditor只支持2种语言,en-uszh-cn,默认跟随系统语言 Yii::$app->language,可以通过2种方式设置,1.修改系统语言,在main.php(高级版) 或者web.php(基础版)添加'language' => 'zh-CN',。2.实例化的时候配置语言选项,见下边配置

配置相关

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

简单实例:

use \kucha\ueditor\UEditor;
echo UEditor::widget([
    'clientOptions' => [
        //编辑区域大小
        'initialFrameHeight' => '200',
        //设置语言
        'lang' =>'en', //中文为 zh-cn
        //定制菜单
        'toolbars' => [
            [
                'fullscreen', 'source', 'undo', 'redo', '|',
                'fontsize',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat',
                'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|',
                'forecolor', 'backcolor', '|',
                'lineheight', '|',
                'indent', '|'
            ],
        ]
]);

文件上传相关配置,请在controller中配置,参数为config,例如文件上传路径等;更多参数请参照 config.php (跟UEditor提供的config.json一样)

简单实例:

public function actions()
{
    return [
        'upload' => [
            'class' => 'kucha\ueditor\UEditorAction',
            'config' => [
                "imageUrlPrefix"  => "http://www.baidu.com",//图片访问路径前缀
                "imagePathFormat" => "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}" //上传保存路径
            ],
        ]
    ];
}
觉得很赞
  • 评论于 2020-08-20 16:42 举报

    yii2 UEditor 提示无法找到类 这个怎么解决啊。重新安装了框架,重新安装了Ueditor也不行!

  • 评论于 2020-02-25 13:27 举报

    求教页面加载的时候报错:Cannot read property 'init' of undefined,是什么原因?

  • 评论于 2018-08-16 17:31 举报

    请问这个问题怎么解决啊 后端配置项没有正常加载,上传插件不能正常使用

  • 评论于 2018-06-09 07:48 举报

    楼主好。
    遇到个问题,使用admin做了用户权限管理,结果只有管理员身份可以使用ueditor发图,其他用户编辑器上发图的按钮就灰色了,这是哪里出了问题呢?

  • 评论于 2018-05-28 16:58 举报

    今天下午突然就不兼容IE10以及以下版本了,这是怎么回事啊?

  • 评论于 2018-04-13 15:02 举报

    Missing required parameter "id" when instantiating "kucha\ueditor\UEditorAction". 大佬 这个错误 是需要传递什么参数吗

  • 评论于 2018-03-27 11:29 举报

    PHP Fatal error: Class 'kucha\ueditor\UEditor' not found in D:\tzjhYII\views\library\send.php on line 54
    在IE7、8下面都正常,在IE9以上或者其他浏览器就会提示这个,这是因为啥?

  • 评论于 2018-01-25 15:30 举报

    请问,编辑器配置成功了,也能把图片上传到本地,怎么点击提交的时候,获取编辑器里文本内容的时候,提示“请求后台配置项http错误,上传功能将不能正常使用!”

    showErrorMsg  ueditor.all.js:8111
    onerror  ueditor.all.js:8102
    xhr.onreadystatechange  ueditor.all.js:8239
    XMLHttpRequest.send (async)
    doAjax  ueditor.all.js:8247
    request  ueditor.all.js:8391
    (anonymous)  ueditor.all.js:8088
    setTimeout (async)
    UE.Editor.loadServerConfig  ueditor.all.js:8078
    UE.Editor  ueditor.all.js:6751
    UE.ui.Editor  ueditor.all.js:29333
    UE.getEditor  ueditor.all.js:29457
    (anonymous)  posted.js:66
    dispatch  jquery.js:5206
    elemData.handle  jquery.js:5014
    
  • 评论于 2017-11-30 17:15 举报

    'upload'=>[
                'class' => 'common\widgets\file_upload\UploadAction',     //这里扩展地址别写错
                'config' => [
                    'imagePathFormat' => "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
                ]
            ],
    

    我已经有个upload,我想改成

    'ueditor'=>[
                'class' => 'common\widgets\ueditor\UEditorAction',
                'config' => [
                    "imageUrlPrefix"  => "http://web.blog.com",
                    "imagePathFormat" => "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
                    "imageRoot" => Yii::getAlias("@webroot"),
                ]
            ],
            
    

    写ueditor提示后台没配置,该怎么办了

    觉得很赞
  • 评论于 2017-10-31 16:58 举报

    为什么 每一个实力在生成的时候都会去访问后台的action来获得配置,能否有办法初始时不用访问后台来获得配置而是自己来配置

  • 评论于 2017-09-25 19:01 举报

    hi

    我对你的插件加了一点点改动,就是我不想用yii根据model生成的name(比如Test[content]),自定义name(content),看你的源码貌似不能自定义就自己稍加修改了下,也建议你对这里做一下修改,毕竟不是每个人都想用这个,只是一个建议~~~,改动如下,我会在配置中根据textarea_name这个参数去修改name

    333.png
    33.png

  • 评论于 2017-09-22 17:48 举报

    xiexie

  • 评论于 2017-08-31 11:38 举报

    请问为什么我的不显示 显示依旧是文本框

  • 评论于 2017-08-21 10:19 举报

    大裤衩子这个编辑器可以上传图片到OSS吗?

  • 评论于 2017-08-14 07:42 举报

    actions方法配置以后被AccessControl 限制了访问,怎么解决呢?

  • 评论于 2017-07-18 22:05 举报

    手动添加该怎么添加?

  • 评论于 2017-06-20 11:29 举报

    Either 'name', or 'model' and 'attribute' properties must be specified.

    为什么我报这个错误啊

  • 评论于 2017-05-31 16:56 举报

    第一个简单实例UEditor::widget(),少了一个 末尾 ‘ ] ’ 。name和id最好配置,否则报错attribute,name ... ...

  • 评论于 2017-03-23 16:46 举报

    把那个saveUrl改成属性可以设置吧,别写死成upload。。

  • 评论于 2017-03-05 19:52 举报

    求教 配置完成后上传图片功能时好时不好怎么回事, 出现跨域问题
    但是都是在本机啊
    附上链接

您需要登录后才可以评论。登录 | 立即注册