{"id":17571247,"url":"https://github.com/netpi/ueditor","last_synced_at":"2025-04-12T15:36:02.104Z","repository":{"id":19965383,"uuid":"23232324","full_name":"netpi/ueditor","owner":"netpi","description":":pencil: UEditor 官方支持的版本有PHP JSP ASP .NET.  ueditor for nodejs 可以让你的UEditor支持node.js ","archived":false,"fork":false,"pushed_at":"2017-08-17T15:53:21.000Z","size":6402,"stargazers_count":503,"open_issues_count":20,"forks_count":163,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-03T16:10:45.654Z","etag":null,"topics":["express","ueditor"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netpi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-22T16:42:45.000Z","updated_at":"2025-02-23T12:03:36.000Z","dependencies_parsed_at":"2022-07-08T01:05:16.965Z","dependency_job_id":null,"html_url":"https://github.com/netpi/ueditor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netpi%2Fueditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netpi%2Fueditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netpi%2Fueditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netpi%2Fueditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netpi","download_url":"https://codeload.github.com/netpi/ueditor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590252,"owners_count":21129772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","ueditor"],"created_at":"2024-10-21T18:23:15.164Z","updated_at":"2025-04-12T15:36:02.080Z","avatar_url":"https://github.com/netpi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js : ueditor\n\n\n[UEditor](https://github.com/fex-team/ueditor) 官方支持的版本有PHP JSP ASP .NET.\n\nueditor for nodejs 可以让你的UEditor支持nodejs\n\n## ueditor@1.0.0 已经全面升级 。\n\n##Installation\n\n```\n npm install ueditor --save\n\n```\n\n\n## Usage\n\n```javascript\n\n\nvar bodyParser = require('body-parser')\nvar ueditor = require(\"ueditor\")\napp.use(bodyParser.urlencoded({\n  extended: true\n}))\napp.use(bodyParser.json());\n\n// /ueditor 入口地址配置 https://github.com/netpi/ueditor/blob/master/example/public/ueditor/ueditor.config.js\n// 官方例子是这样的 serverUrl: URL + \"php/controller.php\"\n// 我们要把它改成 serverUrl: URL + 'ue'\napp.use(\"/ueditor/ue\", ueditor(path.join(__dirname, 'public'), function(req, res, next) {\n\n  // ueditor 客户发起上传图片请求\n\n  if(req.query.action === 'uploadimage'){\n\n    // 这里你可以获得上传图片的信息\n    var foo = req.ueditor;\n    console.log(foo.filename); // exp.png\n    console.log(foo.encoding); // 7bit\n    console.log(foo.mimetype); // image/png\n\n    // 下面填写你要把图片保存到的路径 （ 以 path.join(__dirname, 'public') 作为根路径）\n    var img_url = 'yourpath';\n    res.ue_up(img_url); //你只要输入要保存的地址 。保存操作交给ueditor来做\n  }\n  //  客户端发起图片列表请求\n  else if (req.query.action === 'listimage'){\n    var dir_url = 'your img_dir'; // 要展示给客户端的文件夹路径\n    res.ue_list(dir_url) // 客户端会列出 dir_url 目录下的所有图片\n  }\n  // 客户端发起其它请求\n  else {\n\n    res.setHeader('Content-Type', 'application/json');\n    // 这里填写 ueditor.config.json 这个文件的路径\n    res.redirect('/ueditor/ueditor.config.json')\n}}));\n\n```\n### 七牛上传\n```javascript\n\nvar bodyParser = require('body-parser')\nvar ueditor = require(\"ueditor\")\napp.use(bodyParser.urlencoded({\n  extended: true\n}))\napp.use(bodyParser.json());\n\n// 支持七牛上传，如有需要请配置好qn参数，如果没有qn参数则存储在本地\napp.use(\"/ueditor/ue\", ueditor(path.join(__dirname, 'public'), {\n    qn: {\n        accessKey: 'your access key',\n        secretKey: 'your secret key',\n        bucket: 'your bucket name',\n        origin: 'http://{bucket}.u.qiniudn.com'\n    }\n}, function(req, res, next) {\n  // ueditor 客户发起上传图片请求\n  var imgDir = '/img/ueditor/'\n  if(req.query.action === 'uploadimage'){\n    var foo = req.ueditor;\n\n    var imgname = req.ueditor.filename;\n\n    \n    res.ue_up(imgDir); //你只要输入要保存的地址 。保存操作交给ueditor来做\n  }\n  //  客户端发起图片列表请求\n  else if (req.query.action === 'listimage'){\n    \n    res.ue_list(imgDir);  // 客户端会列出 dir_url 目录下的所有图片\n  }\n  // 客户端发起其它请求\n  else {\n\n    res.setHeader('Content-Type', 'application/json');\n    res.redirect('/ueditor/ueditor.config.json')\n}}));\n\n```\n### FDFS上传\n```javascript\n\nvar bodyParser = require('body-parser')\nvar ueditor = require(\"ueditor\")\napp.use(bodyParser.urlencoded({\n  extended: true\n}))\napp.use(bodyParser.json());\n\n//FDFS config 参数配置\nvar ueditorConfig = {\n  fdfs: {\n    /* Require 必须 */\n    upload: {\n      host: '192.168.0.40', //fdfs 上传服务器 host\n      port: '22122'  // 上传服务器端口(一般默认22122)\n    },\n    download: {\n      host: '192.168.0.82' //fdfs 下载服务器host\n    },\n    /* Require 必须 */\n    /* 可缺省 */\n    defaultExt: 'jpg', //默认后缀为png\n    charset: 'utf8', //默认为utf8\n    timeout: 20 * 1000 //默认超时时间10s\n    /* 可缺省 */\n  }\n};\n\n// 支持FDFS上传，upload跟download字段必填\napp.use(\"/ueditor/ue\", ueditor(path.join(__dirname, 'public'),  ueditorConfig, function(req, res, next) {\n  // ueditor 客户发起上传图片请求\n  var imgDir = '/img/ueditor/'\n  if(req.query.action === 'uploadimage'){\n    var foo = req.ueditor;\n\n    var imgname = req.ueditor.filename;\n\n    \n    res.ue_up(imgDir); //你只要输入要保存的地址 。保存操作交给ueditor来做\n  }\n  //  客户端发起图片列表请求\n  else if (req.query.action === 'listimage'){\n    \n    res.ue_list(imgDir);  // 客户端会列出 dir_url 目录下的所有图片\n  }\n  // 客户端发起其它请求\n  else {\n\n    res.setHeader('Content-Type', 'application/json');\n    res.redirect('/ueditor/ueditor.config.json')\n}}));\n\n```\n\n### 多类型文件上传 （附件 视频 图片）\n```javascript\n\nvar bodyParser = require('body-parser')\nvar ueditor = require(\"ueditor\")\napp.use(bodyParser.urlencoded({\n  extended: true\n}))\napp.use(bodyParser.json());\n\napp.use(\"/ueditor/ue\", ueditor(path.join(__dirname, 'public'), function(req, res, next) {\n  var imgDir = '/img/ueditor/' //默认上传地址为图片\n  var ActionType = req.query.action;\n    if (ActionType === 'uploadimage' || ActionType === 'uploadfile' || ActionType === 'uploadvideo') {\n        var file_url = imgDir;//默认上传地址为图片\n        /*其他上传格式的地址*/\n        if (ActionType === 'uploadfile') {\n            file_url = '/file/ueditor/'; //附件保存地址\n        }\n        if (ActionType === 'uploadvideo') {\n            file_url = '/video/ueditor/'; //视频保存地址\n        }\n        res.ue_up(file_url); //你只要输入要保存的地址 。保存操作交给ueditor来做\n        res.setHeader('Content-Type', 'text/html');\n    }\n  //客户端发起图片列表请求\n  else if (ActionType === 'listimage'){\n    \n    res.ue_list(imgDir);  // 客户端会列出 dir_url 目录下的所有图片\n  }\n  // 客户端发起其它请求\n  else {\n    res.setHeader('Content-Type', 'application/json');\n    res.redirect('/ueditor/ueditor.config.json')\n}}));\n\n```\n\n### 上传配置\n```javascript\napp.use(\"/ueditor/ue\", static_url, config = {}, callback);\n```\n当config为空时，会默认把图片上传到 static_url + '/img/ueditor' 目录下。   \n比如例子“Usage”中图片会上传到项目的 public/img/ueditor 目录。  \n\n当配置了 config.qn 图片则只会上传到七牛服务器而不会上传到项目目录。    \n同时上传到七牛和项目目录，只需配置 config.local 即可\n```javascript\nconfig = {\n  qn: { ... },\n  local: true \n}\n```\n\n你可以来[ueditor:nodejs](http://blog.netpi.me/nodejs/ueditor-nodejs)给作者留言\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetpi%2Fueditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetpi%2Fueditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetpi%2Fueditor/lists"}