kindeditor配置及功能实现详解

发布时间:2025-12-09 11:58:37 浏览次数:1

 1.编辑器修改 (可选)

1.1在 ueditor/config.json 中添加代码块

    /* 上传word配置 */

    "wordActionName": "wordupload", /* 执行上传视频的action名称 */

    "wordFieldName": "upfile", /* 提交的视频表单名称 */

    "wordPathFormat": "/public/uploads/word/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */

    "wordMaxSize": 102400000, /* 上传大小限制,单位B,默认100MB */

"wordAllowFiles": [".docx"] /* 仅支持docx格式的word */

1.2 修改编辑器配置文件

在ueditor\ueditor.config.js文件中,新增按钮名称"wordupload",并添加鼠标悬浮提示

 ,labelMap:{

      'wordupload': '上传word文件',

    }

编辑

1.2.1 对应 /ueditor/lang/**

编辑

en.js

 'wordupload':{

        'exceedSizeError': 'File Size Exceed',

        'exceedTypeError': 'File Type Not Allow',

        'jsonEncodeError': 'Server Return Format Error',

        'loading':"loading...",

        'loadError':"load error",

        'errorLoadConfig': 'Server config not loaded, upload can not work.',

    },

编辑

编辑

zh-cn.js

 'wordupload':{

        'exceedSizeError': '文件大小超出限制',

        'exceedTypeError': '文件格式不允许',

        'jsonEncodeError': '服务器返回格式错误',

        'loading':"正在上传...",

        'loadError':"上传错误",

        'errorLoadConfig': '后端配置项没有正常加载,上传插件不能正常使用!'

    },

编辑

编辑

1.3 在ueditor\themes\default\images\目录下新增按钮图标"word_upload.png":

编辑

在ueditor\themes\default\css\ueditor.css文件中新增按钮样式:

.edui-default .edui-for-wordupload .edui-icon {

    width: 16px;

    height: 16px;

    background: url(../images/word_upload.png) no-repeat 2px 2px !important;

}

编辑

最后在ueditor\ueditor.all.js文件中editorui[“simpleupload”] = function (editor){}后面添加如下代码

  UE.commands['wordupload'] = {

    execCommand : function() {

      var me = this;

      try {

        if(typeof wordupload === "function") {

          wordupload(me.key);//回传富文本所在的元素ID

        } else {

          console.log("wordupload is not full");

        }

      } catch(e) {

        console.log("wordupload:"+e);

      }

    },

    queryCommandState : function() {

      return false;

    }

  };

编辑

编辑

版权声明:本文为CSDN博主「weixin_41949323」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/weixin_41949323/article/details/124841712

kindeditor配置
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477