UMeditor百度富文本编辑器的使用

摘要:
noCache=':'&noCache=')+.toString);img.setAttribute;domUtils.addClass;API地址http://fex.baidu.com/ueditor/#server-jsp用起来感觉非常easy。还有经常使用的ToolBar配置,其它的视频上传路径什么的就去看api吧UMeditor为眼下最好用简单的富文本编辑器,当中的各种文件上传等等差点儿不用配置,仅仅须要拷贝样例代码就好了第一部:下载相应语言的源代码包,我的是jsp版。直接执行项目输入地址http://localhost:8080/WebEUEdit/EU/jsp/controller.jsp?

批量上传的图片在线管理没法查看图片 是因为jar包本身的Bug,这里暂时做了个替换展示。就是找到Img.js 然后搜索

img.set 替换下就好了

var url=list[i].url ;
url=url.replace("D:/JavaWorkSpace/.metadata/.me_tcat7/webapps/WebEUEdit","");

//img.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?

') == -1 ? '?

noCache=':'&noCache=') + (+new Date()).toString(36) );
// img.setAttribute('_src', urlPrefix + list[i].url);
img.setAttribute('src', urlPrefix +url + (url.indexOf('?

') == -1 ?

'?

noCache=':'&noCache=') + (+new Date()).toString(36) );
img.setAttribute('_src', urlPrefix +url);
domUtils.addClass(icon, 'icon');

API地址

http://fex.baidu.com/ueditor/#server-jsp

用起来感觉非常easy。主要配置什么的就不多说了。就把环境。这里主要是解说下我怎么搭的环境。还有经常使用的ToolBar配置,其它的视频上传路径什么的就去看api吧

UMeditor为眼下最好用简单的富文本编辑器,当中的各种文件上传等等差点儿不用配置,仅仅须要拷贝样例代码就好了

第一部:下载相应语言的源代码包,我的是jsp版。里面的index.html是最全的完整案例

UMeditor百度富文本编辑器的使用第1张

第二部:新建一个webproject,而且在webroot以下穿件一个目录用来放这个富文本插件,把上面下载的全部东西复制到这个目录里面

UMeditor百度富文本编辑器的使用第2张

第三部:把EU/jsp以下的jar包复制到lib以下,记住必须是拷贝进去,不能引入到项目,否则会报错。

UMeditor百度富文本编辑器的使用第3张

測试是否部署成功。

直接执行项目 输入地址

http://localhost:8080/WebEUEdit/EU/jsp/controller.jsp?action=config,假设以下提示是一个js的。文本显示就说明正确了

页面显示结果Like这样

{"snapscreenInsertAlign":"none","videoPathFormat":"/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}","videoFieldName":"upfile","fileManagerActionName":"listfile","fileUrlPrefix":"","imageUrlPrefix":"","imageAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"videoAllowFiles":[".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".mpg",".ogg",".ogv",".mov",".wmv",".mp4",".webm",".mp3",".wav",".mid"],"filePathFormat":"/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}","fileMaxSize":51200000,"fileManagerListPath":"/ueditor/jsp/upload/file/","catcherUrlPrefix":"","videoActionName":"uploadvideo","scrawlInsertAlign":"none","videoUrlPrefix":"","imageManagerUrlPrefix":"","scrawlUrlPrefix":"","imageFieldName":"upfile","fileManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp",".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".mpg",".ogg",".ogv",".mov",".wmv",".mp4",".webm",".mp3",".wav",".mid",".rar",".zip",".tar",".gz",".7z",".bz2",".cab",".iso",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".txt",".md",".xml"],"imageMaxSize":2048000,"catcherPathFormat":"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","imageManagerInsertAlign":"none","scrawlFieldName":"upfile","imagePathFormat":"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","scrawlActionName":"uploadscrawl","imageManagerActionName":"listimage","imageActionName":"uploadimage","imageManagerListSize":20,"imageManagerAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"fileAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp",".flv",".swf",".mkv",".avi",".rm",".rmvb",".mpeg",".mpg",".ogg",".ogv",".mov",".wmv",".mp4",".webm",".mp3",".wav",".mid",".rar",".zip",".tar",".gz",".7z",".bz2",".cab",".iso",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".txt",".md",".xml"],"snapscreenActionName":"uploadimage","fileFieldName":"upfile","fileActionName":"uploadfile","catcherActionName":"catchimage","fileManagerListSize":20,"catcherAllowFiles":[".png",".jpg",".jpeg",".gif",".bmp"],"snapscreenPathFormat":"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","imageCompressBorder":1600,"snapscreenUrlPrefix":"","imageCompressEnable":true,"catcherLocalDomain":["127.0.0.1","localhost","img.baidu.com"],"imageManagerListPath":"/ueditor/jsp/upload/image/","imageInsertAlign":"none","catcherMaxSize":2048000,"videoMaxSize":102400000,"fileManagerUrlPrefix":"","scrawlPathFormat":"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}","scrawlMaxSize":2048000,"catcherFieldName":"source"}

上面 就是代表代码已经部署上去 以下是使用

在一个jsp页面上这样写代码

引入一下3个

<script type="text/javascript" charset="utf-8" src="http://t.zoukankan.com/EU/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="http://t.zoukankan.com/EU/ueditor.all.min.js"> </script>
<!--建议手动加在语言,避免在ie下有时由于载入语言失败导致编辑器载入失败-->
<!--这里载入的语言文件会覆盖你在配置项目里加入的语言类型。比方你在配置项目里配置的是英文。这里载入的中文,那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="http://t.zoukankan.com/EU/lang/zh-cn/zh-cn.js"></script>

<body>

<script type="text/plain" style="1024px;height:500px;">这个就是富文本的元素</script>

<button onclick="getContent()">获得内容</button>

<script type="text/javascript">

//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例。假设在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');

function getContent() {
var arr = [];
arr.push("使用editor.getContent()方法能够获得编辑器的内容");
arr.push("内容为:");
arr.push(UE.getEditor('editor').getContent());
alert(arr.join(" "));
}
</script>

</body>

经过上面 訪问jsp页面 就好了 当中文件上传什么的 所有不须要配置了,仅仅须要自己去配置相关文件上传路径就好了这个能够去看api 系统默认的上传路径是webroot下的edit文件,里面有img file 等等类型的文件上传

最后效果

UMeditor百度富文本编辑器的使用第4张

关于富文本上面的toolbar可在这里配置

UMeditor百度富文本编辑器的使用第5张

相关上传文件的配置 能够再这里自己去看

UMeditor百度富文本编辑器的使用第6张

免责声明:文章转载自《UMeditor百度富文本编辑器的使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇使用grok exporter 做为log 与prometheus 的桥网络流(二)——最大流最小割定理下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

FTP操作(FTPClient)

//FTP开源封装的类 using System; using System.Collections.Generic; using System.Net; using System.IO; namespace FTP {     /// <summary>     /// FTP客户端操作类     /// </summary>  ...

C#获取URL参数值

在写程序的时候,我们经常需要对页面进行传参数,比如page?id=1234,那么在page这个页面中就直接可以使用string id = Request.QueryString["id"];来获取参数id的值1234了。这是一个人人都知道的基础知识。 上面的方法:Request.QueryString,它会把传入的URL进行分析,并把结果保存在一个键值(...

jsp、javabean、el

JSP三大指令一个jsp页面中,可以有0~N个指令的定义!1. page --> 最复杂:<%@page language="java" info="xxx"...%>* pageEncoding和contentType:> pageEncoding:它指定当前jsp页面的编码,只要不说谎,就不会有乱码!在服务器要把jsp编译成.j...

JS时间转换,url编码,jquery返回类型等问题

1.当时间被转换为json格式后会被转换成  /Date(...)/  这种格式,其中...为时间转换成妙后的一串整数 function changeDateFormat(cellval) { var datetime = new Date(parseInt(cellval.replace("/Date(", "").repla...

Linux下svn常用命令

1、将文件checkout到本地目录 svn checkout path(path是服务器上的目录)   例如:svn checkout svn://192.168.1.1/pro/domain    简写:svn co 2、往版本库中添加新的文件   svn add file   例如:svn add test.php(添加test.php)   s...

Java Web基础 --- Servlet 综述(理论篇)

摘要:   Web 技术成为当今主流的互联网 Web 应用技术之一,而 Servlet 是 Java Web 技术的核心基础。本文首先从请求/响应架构应用的大背景谈起 Servlet 的由来,明确 Servlet 的产生动机,并揭示了 Servlet 的本质以及其在标准MVC模式中所扮演的角色。紧接着,给出了 Servlet族的继承结构,并对族内的接口和抽...