• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >网页编辑器 > ckeditor和ueditor那个好 CKEditor和UEditor使用比较

ckeditor和ueditor那个好 CKEditor和UEditor使用比较

作者: 字体:[增加 减小] 来源:互联网 时间:2017-06-05

本文主要包含ueditor ckeditor,ckeditor使用教程,ckeditor使用,ckeditor使用手册,ckeditor使用方法等相关知识,希望在学习及工作中可以帮助到您

CKEditor和UEditor使用比较

本来项目中使用CKEditor已经做好了的富文本编辑器的功能,但是业务考虑到美观性要求换成UEditor,所以就在这里总结下

先说下使用这两个不同插件的感想,我用的ueditor是1.4.3的版本:(ueditor API)

UEditor:ueditor更注重用户体验,而且使用起来较ckeditor简单,但是ueditor在处理前后台交互时相比于ckeditor稍显麻烦
ckeditor:ckeditor不像ueditor,更多的方法需要自己去实现,但是毕竟是老牌富文本编辑器,如果之前有写过这些方法的话,集成ckeditor个人觉得还是比ueditor更方便简单。

CKEditor的使用

在jsp页面下引入ckeditor下的ckeditor.js(当然首先要引入jQuery.js,引入插件类库ckeditor-Java-core-3.5.3.jar)

<script type="text/javascript" src="${basePath}/js/ckeditor/ckeditor.js"></script>
</div>

//引入js后在textarea标签上添加一个richText=”true”这个属性即可

<textarea name="wxChoiceInfo.infoTextConte" id="wxChoiceInfoInfoTextConte" richText="true" cols="110" rows="15"></textarea>
</div>

获取ckeditor中的内容

Var content = CKEDITOR.instances.wxChoiceInfoInfoTextConte.getData(content);

//初始化
 $(function() {
//富文本字段初始化
$("[richText]").each(function (e) {	
	CKEDITOR.replace($(this).attr("id"),{	
	 height : 400,
	skin : 'kama',
	language : 'zh-cn',
filebrowserImageUploadUrl:'${basePath}/wxdate/ck_upload.action?fileType=1',
	toolbar: 'ToolbarCommon',
	 resize_enabled: false
	});
});
});
</div>

Action配置

<!-- FckEdit上传-->
<action name="ck_upload" class="com.ccxe.wxdate.action.CkeditorUploadAction">
	<param name="fileSize">5120000</param> <!-- 上传文件大小 -->
</action>
</div>

CkeditorUploadAction类源码

//CkeditorUploadAction类源码
public class CkeditorUploadAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private File upload;
	private String uploadContentType;
	private String uploadFileName;
	//文件大小
	private long fileSize;
	//取文件路径
	private String fileType;
	
	public String getFileType() {
		return fileType;
	}

	public void setFileType(String fileType) {
		this.fileType = fileType;
	}

	public long getFileSize() {
		return fileSize;
	}

	public void setFileSize(long fileSize) {
		this.fileSize = fileSize;
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		
		this.upload = upload;
	}

	public String getUploadContentType() {
		return uploadContentType;
	}

	public void setUploadContentType(String uploadContentType) {
		this.uploadContentType = uploadContentType;
	}

	public String getUploadFileName() {
		return uploadFileName;
	}

	public void setUploadFileName(String uploadFileName) {
		this.uploadFileName = uploadFileName;	}

	public String execute() throws Exception {
		try {
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter out = response.getWriter();
			
			String callback = ServletActionContext.getRequest().getParameter("CKEditorFuncNum"); 
			//对文件进行校验
			if(upload==null || uploadContentType==null || uploadFileName==null){
				//out.print("<font color=\"red\" size=\"2\">*请选择上传文件</font>");
				String path = "";  
			  String alt_msg = "*请选择上传文件";  
			  out.print("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" 
			      + callback  
			      + ", '" 
			      + path  
			      + "' , '" 
			      + alt_msg  
			      + "');</script>"); 
				return null;
			}
			if ((uploadContentType.equals("image/pjpeg") || uploadContentType.equals("image/jpeg")) && (uploadFileName.substring(uploadFileName.length() - 4).toLowerCase().equals(".jpg")||uploadFileName.substring(uploadFileName.length() - 5).toLowerCase().equals(".jpeg"))) {
				//IE6上传jpg图片的headimageContentType是image/pjpeg,而IE9以及火狐上传的jpg图片是image/jpeg
			}else if((uploadContentType.equals("image/x-png") || uploadContentType.equals("image/png")) && uploadFileName.substring(uploadFileName.length() - 4).toLowerCase().equals(".png")){
				
			}else if(uploadContentType.equals("image/gif") && uploadFileName.substring(uploadFileName.length() - 4).toLowerCase().equals(".gif")){
				
			}else if(uploadContentType.equals("image/bmp") && uploadFileName.substring(uploadFileName.length() - 4).toLowerCase().equals(".bmp")){
				
			}else{
				//out.print("<script language=\"javascript\">alert(\"*文件格式不正确(必须为.jpg/.gif/.bmp/.png文件)\");return false;</script>");
				 String path = "";  
			   String alt_msg = "*请选择图片文件格式(必须为.jpg/.jpeg/.gif/.bmp/.png文件)";  
			   out.print("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" 
			       + callback  
			       + ", '" 
			       + path  
			       + "' , '" 
			       + alt_msg  
			       + "');</script>");  

				return null;
			}
			
			if(upload.length() > this.getFileSize()){
				//out.print("<font color=\"red\" size=\"2\">*文件大小不得大于"+this.getFileSize()/(1000*1024)+"m</font>");
				 String path = "";  
			   String alt_msg = "*请选择上传"+this.getFileSize()/(1000*1024)+"M以内的图片文件";  
			   out.print("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" 
			       + callback  
			       + ", '" 
			       + path  
			       + "' , '" 
			       + alt_msg
			       + "');</script>");
				return null;
			}
			String imagePath = "";
			
			//imagePath路径的设置
			WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
			WxConfig wxConfig = (WxConfig)wac.getBean("wxConfig");
			//if(fileType.equals(PubParaConstants.DC_CK_UPLOAD_PATTH_PARAM.DC_CK_UPLOAD_PATTH_PARAM_PROSELECT)) {
				imagePath = wxConfig.getFilePath();
			//}
			//WxConfig wxConfig;
			File directory = new File(imagePath);
			if(!directory.isDirectory()) {
				directory.mkdirs();
			}
			//将文件保存到项目目录下
			InputStream is = new FileInputStream(upload);
			Date date = new Date(); // 获得系统时间,用于生成文件名
			long lTime = date.getTime();
			String fileName = DateUtil.toStringNoInterval(date, 8)+"_"+lTime; 
			fileName += FileUtil.getFileSuffix(uploadFileName);
			File toFile = new File(imagePath, fileName);
			OutputStream os = new FileOutputStream(toFile);  
			byte[] buffer = new byte[1024];  
			int length = 0;
			while ((length = is.read(buffer)) > 0) {  
			  os.write(buffer, 0, length);  
			}  
			is.close();
			os.close();
			
			//设置返回“图像”选项卡
			
			String callbackUrl = ServletActionContext.getRequest().getContextPath() +"/fckImageReader.servlet?fold="+this.getFileType()+"&imageName="+fileName;
			out.println("<script type=\"text/javascript\">"); 
			out.println("window.parent.CKEDITOR.tools.callFunction(" + callback + ",'"+ callbackUrl + "','')"); 
			out.println("</script>");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
</div>

图片回显到编辑器的servlet代码

/**
 * 文件流方式读取本地图片文件(图片回显处理)
 * FckImageReaderServlet
 */
public class FckImageReaderServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	public void init() throws ServletException {
	}
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) {
		this.doPost(request, response);
	}
	
	public void
  


 

您可能想查找下面的文章:

  • Ueditor和CKeditor 两款编辑器的使用与配置方法
  • ckeditor和ueditor那个好 CKEditor和UEditor使用比较

相关文章

  • 2017-06-05百度编辑器 如何获取光标位置与不同帧内的节点
  • 2017-06-05百度编辑器 ueditor 内容编辑自动套P标签,及p标签 替换
  • 2017-06-05XHEditor编辑器使用文档
  • 2017-06-05SyntaxHighlighter配合CKEditor插件轻松打造代码语法着色
  • 2017-06-05FCKeditor 在chrome中不显示问题
  • 2017-06-05ie9后浏览器fckeditor无法上传图片、弹出浮层内容不显示的解决方法
  • 2017-06-05CKEditor 取消转义的两种方法
  • 2017-06-05CKEditor 附插入代码的插件
  • 2017-06-05Fckeditor编辑器内容长度限制统计实现方法
  • 2017-06-05FCKeditor 2.6 编码错误导致修改的内容出现乱码的解决方法

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • 免费开源百度编辑器(UEditor)使用方法
    • 最新版CKEditor的配置方法及插件(Plugin)编写示例
    • FCKeditor 网页在线编辑器的使用方法
    • 页面嵌入Windows Media Player播放器代码需要注意的
    • autogrow 让FCKeditor高度随内容增加的插件
    • dedecms ckeditor编辑器添加链接默认新窗口打开的修改方法
    • FCKeidtor 清除编辑器内容的代码
    • asp.net+FCKeditor上传图片显示叉叉图片无法显示的问题的解决方法
    • CKEditor/FCKEditor 使用 CKeditor 3.0.1 快速使用教程(含插入图片)
    • javascript fckeditor编辑器取值与赋值实现代码

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有