firemail

标题: UEditor用于nodejs [打印本页]

作者: jimu    时间: 2016-1-23 21:57
标题: UEditor用于nodejs
本帖最后由 jimu 于 2016-1-30 11:02 编辑

http://ueditor.baidu.com/website/index.html

GitHub 源码


Node.js:ueditor

贡献者: netpi
可你让您的UEditor 兼容nodejs。Node.js:ueditor@0.0.4以及更高版本,支持图片上传,图片批量管理等。您可以通过npm install ueditor 直接安装此插件。项目代码已经发放到github上,欢迎关注此项目。
文 档 源 码




作者: jimu    时间: 2016-1-30 11:01
本帖最后由 jimu 于 2016-1-30 11:15 编辑

Node.js:ueditor 使用方法:
到自己的工程目录(如:qiDiJiaoYu)下
npm install ueditor --save
安装完毕显示
  1. qiDiJiaoYu@0.0.0 E:\github\qidijiaoyu_github\qidijiaoyu\qiDiJiaoYu
  2. └─┬ ueditor@1.1.1
  3.   ├─┬ busboy@0.2.12
  4.   │ ├─┬ dicer@0.2.5
  5.   │ │ ├── readable-stream@1.1.13
  6.   │ │ └── streamsearch@0.1.2
  7.   │ └── readable-stream@1.1.13
  8.   ├─┬ fs-extra@0.11.1
  9.   │ ├── jsonfile@2.2.3
  10.   │ ├─┬ mkdirp@0.5.1
  11.   │ │ └── minimist@0.0.8
  12.   │ ├── ncp@0.6.0
  13.   │ └─┬ rimraf@2.5.1
  14.   │   └─┬ glob@6.0.4
  15.   │     ├─┬ inflight@1.0.4
  16.   │     │ └── wrappy@1.0.1
  17.   │     ├─┬ minimatch@3.0.0
  18.   │     │ └─┬ brace-expansion@1.1.2
  19.   │     │   ├── balanced-match@0.3.0
  20.   │     │   └── concat-map@0.0.1
  21.   │     ├── once@1.3.3
  22.   │     └── path-is-absolute@1.0.0
  23.   └── node-snowflake@0.0.1
复制代码
安装完后,package.json文件中增加了  "ueditor": "^1.1.1"

node_modules文件夹下增加了



其中bin文件下增加了





作者: jimu    时间: 2016-1-30 23:15
本帖最后由 jimu 于 2016-1-31 17:34 编辑

关于html标签字符及转义字符遇到的问题
  1. 字符串str的内容为 {"user":"test","conent":"<p><span style="color: rgb(192, 80, 77);">33</span></p>"}

  2. 如何用JSON.parse(str) 这会报错 Uncaught SyntaxError: Unexpected token c  
  3. 到 http://www.bejson.com/ 校验字符串str是不合法的多了双引号

  4. 把content对应的内容中的"改为'
复制代码
  1. var post = JSON.parse("{"user":"test","conent":"<p><span style='color: rgb(192, 80, 77);'>33</span></p>"}");
  2. Uncaught SyntaxError: missing ) after argument list

  3. 这里要注意,要转换的字符串本身已经是字符串了,没必要再转一次,即:
  4. 原写法:  var post = '<%- JSON.stringify(locals.post) %>';
  5. 改为 var post = <%- JSON.stringify(locals.post) %>;    -------------即把外面的单引号去掉
复制代码
  1. var contentTrans =  doc.content.replace(/\"/g,"\'")

  2. 正则写法上面没有双引号

  3. record.content.replace(/\\/g,"\\\\")%>
复制代码

作者: jimu    时间: 2016-1-31 00:11
上传图片,登录状态不在了?
  1. ---use:[object Object]
  2. ---ueditor:[object Object]
  3. POST /ueditor/ue?action=uploadimage 200 35.317 ms - 100
  4. GET /images/ueditor/2016-01-31/693465420044308480.png 200 5.325 ms - 22035
  5. crashing child
  6. Starting child process with 'node ./bin/www'
  7. ---use:undefined
  8. --------------currentUser:undefined
复制代码





欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3