主流页面编辑器比对:TinyMCE VS FCKeditor

本文对比了FCKeditor与TinyMCE两种富文本编辑器的特点与使用方法。FCKeditor配置简单但界面繁杂;TinyMCE虽需每页初始化,但界面简洁且操作简便。

 

 

  开发中先用的是 FCKeditor 编辑器,感觉页面展示的东西太繁琐,所以换了 TinyMCE 编辑器。 为了方便理解,本文不采用穿插比对

    

    先看 FCKeditor :

    1、jsp :结束标签不能贴着开始标签

  <fck:editor id="content" basePath="${ctx}/scripts/fckeditor/" skinPath="skins/office2003/">                                                 
   </fck:editor>

    

    2、js 取值、赋值

//取值 - id
var oEditor = FCKeditorAPI.GetInstance("content");  
var content = $.trim(oEditor.GetXHTML(true));

//赋值 - id
var oEditor = FCKeditorAPI.GetInstance("content") ;                          
oEditor.SetHTML("值") ;

     

    3、页面

 

    再看 TinyMCE:

    1、tinyMCE 在页面需要初始化

      tinymce.init({
           selector: "textarea",  //填充 textarea 标签
           upload_image_url: '${ctx}/uploadTinyMcePic', //配置的上传图片的路由(servlet 配置)
           height: 300,
           language:'zh_CN',
           plugins: [
             'advlist autolink lists link  charmap print preview hr anchor pagebreak',
             'searchreplace wordcount visualblocks visualchars code fullscreen',
             'insertdatetime media nonbreaking save table contextmenu directionality',
             'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help uploadimage fontselect'
           ],
           toolbar1: 'undo redo | insert | styleselect | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
           toolbar2: 'print preview media uploadimage | removeformat fontselect forecolor backcolor fontsizeselect emoticons | codesample help',
           image_advtab: true,
           templates: [
             { title: 'Test template 1', content: 'Test 1' },
             { title: 'Test template 2', content: 'Test 2' }
           ],
           menubar: false
       });

    PS:当页面有多个textarea 标签是,需要填充指定标签则 将 selector: "textarea" 改为:

mode : "exact",//用特定的模式
elements : "textareaEdit",//容器的id值,将来要在页面中替换的 textarea

 

    2、TinyMCE 取值、赋值:

//取值
var content = tinyMCE.activeEditor.getContent();

//赋值 - id
tinyMCE.get("content").setContent("值");

 

    3、页面

 

 

由上可知:

  FCKeditor:配置简单,但界面繁杂,取值赋值相对复杂。

  TinyMCE: 每个页面都要初始化相对复杂,但界面简洁,取值赋值相对简单。

转载于:https://www.cnblogs.com/linnuo/p/7269894.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值