`
twtmnm1314
  • 浏览: 68968 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
文章分类
社区版块
存档分类
最新评论

FCKeditor的几点重要改进和使用心得,值得分享

阅读更多

以前公司购买过eWebEditor,功能应该还是不错的,但即便到了现在,也还仅是一个IE only的版本,无法满足现在差异化的需求。故前段时间下了最新的FCKeditor2.3.3版本下来(当然了,连带java的integration),demo来看看,发现有几个地方非常不爽:
1、上载的文件,只能放在URL可及的地方(如默认只能放到嵌入应用路径的/UserFiles/下);
2、没有明确的上载视频的按钮;
3、图片、FLASH、附件上载等,步骤多,复杂度高(想想,用户不都是高手)。

怎么办呢,改!

一、第一个就是增加一个FileLocatorServlet,思路很简单:通过这个服务来定位文件,而不是之间产生链接,既是安全的考虑,也是应用集群的一个重要考虑点。而且原来的几个servlet的配置罗嗦且重叠,难以让人产生美感。所谓代码胜千言,通过下面的web.xml大家应该可以看出修理的要点:

  1 <? xml version="1.0" encoding="ISO-8859-1" ?>
  2
  3 <! DOCTYPE web-app
  4   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  5   "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd" >
  6
  7 < web-app >
  8    < display-name > FCKeditor Test Application </ display-name >   
  9      < context-param >
 10          <!--  setting the FCKecitor context based parameters  -->
 11          <!--  baseDir means the root of the uploaded file/image/flash stored 
 12              the prefix of 'file:/' means strore in a file system root that cannot get from webapp url
 13          -->
 14          < param-name > baseDir </ param-name >
 15          < param-value > file:/C:/Temp/FCKeditorUpload/ </ param-value >
 16      </ context-param >  
 17
 18      < context-param >
 19          <!--  
 20              if the baseDir prefix by 'file:/',please set it.
 21          -->
 22          < param-name > fileLocator </ param-name >
 23          < param-value > /editor/filemanager/browser/default/service/jsp/filelocator </ param-value >
 24      </ context-param >  
 25
 26      < context-param >
 27          <!--  
 28              debug setting,true means verbose output to the console.
 29          -->
 30          < param-name > debug </ param-name >
 31          < param-value > true </ param-value >
 32      </ context-param >  
 33
 34      < context-param >
 35          <!--  
 36              enabled setting,true means upload enabled.
 37          -->
 38          < param-name > enabled </ param-name >
 39          < param-value > true </ param-value >
 40      </ context-param >  
 41
 42      < context-param >
 43          <!--  
 44              encoding,the response encoding of the file/image/flash,default is UTF-8
 45          -->
 46          < param-name > encoding </ param-name >
 47          < param-value > UTF-8 </ param-value >
 48      </ context-param >  
 49
 50      < context-param >
 51          <!--  
 52              contentTypeMapping,a map for the response ContentType
 53          -->
 54          < param-name > contentTypeMapping </ param-name >
 55          < param-value > doc=application/vnd.ms-word
 56         |xls=application/vnd.ms-excel
 57         |jpg=image/jpeg
 58         |gif=image/gif
 59         |swf=application/x-shockwave-flash
 60         |avi=video/x-msvideo
 61          </ param-value >
 62      </ context-param >  
 63
 64      < context-param >
 65          <!--  
 66              allowedExtensionsFile,the logic is 'Not allowed means deny.'
 67          -->
 68          < param-name > allowedExtensionsFile </ param-name >
 69          < param-value > doc|xls|pdf|avi </ param-value >
 70      </ context-param >  
 71
 72      < context-param >
 73          <!--  
 74              allowedExtensionsImage,the logic is 'Not allowed means deny.'
 75          -->
 76          < param-name > allowedExtensionsImage </ param-name >
 77          < param-value > jpg|gif|png </ param-value >
 78      </ context-param >  
 79
 80      < context-param >
 81          <!--  
 82              allowedExtensionsFlash,the logic is 'Not allowed means deny.'
 83          -->
 84          < param-name > allowedExtensionsFlash </ param-name >
 85          < param-value > swf|fla </ param-value >
 86      </ context-param >
 87
 88      < servlet >
 89          < servlet-name > Connector </ servlet-name >
 90          < servlet-class > com.fredck.FCKeditor.connector.ConnectorServlet </ servlet-class >
 91          < load-on-startup > 1 </ load-on-startup >
 92      </ servlet >
 93     
 94      < servlet >
 95          < servlet-name > FileLocator </ servlet-name >
 96          < servlet-class > com.fredck.FCKeditor.service.FileLocatorServlet </ servlet-class >
 97          < load-on-startup > 1 </ load-on-startup >
 98      </ servlet >
 99
100      < servlet >
101          < servlet-name > SimpleUploader </ servlet-name >
102          < servlet-class > com.fredck.FCKeditor.uploader.SimpleUploaderServlet </ servlet-class >
103          < load-on-startup > 1 </ load-on-startup >
104      </ servlet >
105
106    < servlet-mapping >
107      < servlet-name > Connector </ servlet-name >
108      < url-pattern > /editor/filemanager/browser/default/connectors/jsp/connector </ url-pattern >
109    </ servlet-mapping >
110   
111    < servlet-mapping >
112      < servlet-name > SimpleUploader </ servlet-name >
113      < url-pattern > /editor/filemanager/upload/simpleuploader </ url-pattern >
114    </ servlet-mapping >   
115   
116    < servlet-mapping >
117      < servlet-name > FileLocator </ servlet-name >
118      < url-pattern > /editor/filemanager/browser/default/service/jsp/filelocator </ url-pattern >
119    </ servlet-mapping >   
120
121 </ web-app >

连带FCKeditorConfigurations.java一并修理,配置统一且singleton。关键代码为:

 1
 2      /** */ /**
 3      * Make the configuration sigleton
 4      *  @param  sc
 5      *  @return  the static configuration map
 6       */

 7      public   static  Map getContextConfigurationsInstance(ServletContext sc) {
 8          if (contextConfigurations == null ) {
 9             initContextConfigurations(sc);
10         }

11          return  contextConfigurations;
12     }

13     
14      /** */ /**
15      * Init all the FCKeditor configuration.
16      * add by zhengxq
17      *  @param  sc
18       */

19      private   static   void  initContextConfigurations(ServletContext sc) {
20          if  (debug)
21             System.out.println( " \r\n---- FCKeditorConfigurations for java initialization started ---- " );
22         
23         String baseDir  =  sc.getInitParameter( " baseDir " );
24         String fileLocator  =  sc.getInitParameter( " fileLocator " );
25         String debugStr  =  sc.getInitParameter( " debug " );
26         String enabledStr  =  sc.getInitParameter( " enabled " );        
27         String encoding  =  sc.getInitParameter( " encoding " );
28         String contentTypeMapping  =  sc.getInitParameter( " contentTypeMapping " );
29         String AllowedExtensionsFile  =  sc.getInitParameter( " allowedExtensionsFile " );
30         String AllowedExtensionsImage  =  sc.getInitParameter( " allowedExtensionsImage " );
31
分享到:
评论

相关推荐

    fckeditor和使用方法

    FCKeditor因其易用性和丰富的功能而广受欢迎,尤其适用于需要创建和编辑内容的网站,如CMS(内容管理系统)、论坛、博客等。 **安装与集成** 1. **下载与解压**:首先,你需要从FCKeditor的官方网站下载最新版本的...

    FCKeditor 2.6.6 可直接使用

    Ckeditor是FCKeditor的后续版本,进行了大量的优化和改进,尤其是在用户体验和性能方面。然而,对于某些项目而言,FCKeditor 2.6.6可能更符合其简洁、低依赖性的需求。开发者可能会选择FCKeditor因为其较低的学习...

    fckeditor源文件和demo

    在使用FCKeditor时,开发者需要注意以下几点: - **兼容性**:FCKeditor支持多种浏览器,包括IE、Firefox、Chrome、Safari和Opera等,但不同版本的浏览器可能存在兼容性问题,需要在实际应用中进行测试。 - **安全...

    fckeditor的MVC版及js使用fckeditor的方法

    FCKeditor的MVC版是专门为ASP.NET MVC设计的集成包,它简化了在MVC项目中引入和使用FCKeditor的过程。要安装FCKeditor,可以下载官方提供的MVC版本包,解压后将内容复制到项目的Scripts或Assets目录下。通常会包含...

    FCKeditor中文使用手册

    在使用FCKeditor时,安全是至关重要的。手册会强调如何过滤用户输入,防止XSS攻击,以及如何设置安全策略来保护服务器不受恶意代码的影响。 **8. 更新与维护** FCKeditor有持续的更新和维护,以修复已知问题和增加...

    FCKeditor.Net_2.6.3.zip和FCKeditor-v2.6.3

    在安装和配置FCKeditor时,需要注意以下几点: 1. **解压和部署**:将下载的zip文件解压缩,然后将相关文件夹复制到服务器或本地开发环境中。 2. **配置文件**:根据实际需求修改配置文件(如fckconfig.js),设置...

    FCKEditor网页编辑器 几点使用心得

    以下是一些关于FCKEditor使用过程中的重要知识点,对于需要使用或已经使用FCKEditor的开发者来说,这些心得可能会有所帮助。 1. **挂接事件** 在FCKEditor中,如果我们需要添加自定义事件处理,例如`onkeydown`...

    fckeditor设置和使用方法

    以下是对FCKeditor设置和使用的详细说明: 1. **安装与准备**: - 首先,你需要下载FCKeditor的最新版本或指定版本,例如FCKeditor_2.5.1。同时,为了在ASP.NET环境中使用,还需要下载FCKeditor_Net。 - 将`...

    FCKeditor2.6.4使用说明

    本文将详细介绍FCKeditor2.6.4的使用方法,帮助开发者和用户更好地理解和操作这个编辑器。 1. **安装与集成** - 下载FCKeditor2.6.4压缩包,解压后将文件夹上传至服务器或本地项目目录。 - 在需要使用编辑器的...

    FCKEDITOR 使用说明

    尽管现在已经被CKEditor所取代,但FCKEditor在许多旧项目中仍然广泛使用,因此理解其工作原理和使用方法仍然很重要。 ### 一、FCKEditor简介 FCKeditor是一款基于JavaScript的WYSIWYG(所见即所得)编辑器,允许...

    fckeditor 编辑器 和使用说明

    - `fckeditor`文件夹可能包含了编辑器的示例代码和资源,通过查看和运行这些示例,可以帮助理解编辑器的运作方式和API的使用。 5. **兼容性** fckeditor兼容多种浏览器,包括Internet Explorer、Firefox、Chrome...

    fckeditor php使用配置

    【标题】:“FCKeditor PHP使用配置” ...不过,FCKeditor已停止更新,当前推荐使用其后续项目CKEditor,它提供了更多功能和更好的兼容性。尽管如此,对于旧项目或简单需求,FCKeditor仍然是一个不错的选择。

    FCKeditor在线文本编辑器使用

    **FCKeditor在线文本编辑器使用** FCKeditor是一款开源的富文本编辑器,它为Web应用程序提供了类似于桌面文本编辑器的功能,用户可以在浏览器中直接编辑、格式化文本,极大地提升了网页内容创建的效率和用户体验。...

    FCKeditor 2.4.3详细使用方法

    FCKeditor 2.4.3详细使用方法

    FCKeditor使用方法详解

    【FCKeditor 使用方法详解】 FCKeditor 是一个基于JavaScript的开源富文本编辑器,它在Web开发领域中被广泛使用,尤其适用于那些需要提供用户友好、可视化的文本编辑功能的网站。FCKeditor 具备强大的功能,包括...

    FckEditor在.net中的使用及配置

    下面将详细介绍FckEditor在.NET中的使用步骤和配置方法。 一、安装FckEditor 首先,你需要从FckEditor的官方网站或者通过NuGet包管理器下载FckEditor的源码或DLL文件。下载完成后,将其解压到你的.NET项目目录下的...

    fckeditor使用心得

    《FCKeditor使用心得与相关技术解析》 FCKeditor是一款功能强大的开源文本编辑器,广泛应用于网页内容编辑,提供类似Microsoft Word的富文本编辑体验。在本文中,我们将深入探讨FCKeditor的使用技巧,以及与其关联...

    fckeditor和级联菜单日历实例

    在IT行业中,富文本编辑器(FCKeditor)是一款广泛使用的在线文本编辑工具,它允许用户在网页上创建、编辑和格式化文本,类似于桌面版的Microsoft Word。FCKeditor以其丰富的功能和易于集成的特点,深受开发者喜爱。...

    FCKEditor使用帮助文档

    **FCKEditor使用帮助文档** FCKEditor是一款开源的HTML编辑器,主要用于网站内容管理系统(CMS)和论坛等在线文本编辑场景。它以其强大的功能、易于集成和自定义而受到开发者的广泛欢迎。本帮助文档将详细介绍...

Global site tag (gtag.js) - Google Analytics