text-decoration:line-through;">');
}else{
cmd.wrap('');
cmd.select();
self.hideMenu();
varmenu=self.createMenu({
name:name,
width:150
menu.addItem({
title:'红底白字',
click:function(){
click('red');
title:'绿底白字',
click('green');
title:'黄底白字',
click('yellow');
title:'自定义删除线',
click('adv_strikethrough');
cssPath:['../plugins/code/prettify.css','index.css'],
items:['source','removeformat','example1','example2','code']
单独调用组件
上传图片弹出框
vareditor=K.editor({
allowFileManager:true
K('#image').click(function(){
editor.loadPlugin('image',function(){
editor.plugin.imageDialog({
imageUrl:K('#url').val(),
clickFn:function(url,title,width,height,border,align){
K('#url').val(url);
editor.hideDialog();
取色器
varcolorpicker;
K('#colorpicker').bind('click',function(e){
if(colorpicker){
colorpicker.remove();
colorpicker=null;
varcolorpickerPos=K('#colorpicker').pos();
colorpicker=K.colorpicker({
x:colorpickerPos.x,
y:colorpickerPos.y+K('#colorpicker').height(),
z:19811214,
selectedColor:'default',
noColor:'无颜色',
click:function(color){
K('#color').val(color);
四.jsp基本编辑器
使用步骤:
1.把edit.htm修改为edit.jsp
2.把想要使用的地方包含edit.jsp就行了
代码:
<%@includefile="edit.jsp"%>
注意事项:
在需要引入编辑器的页面中的onload事件,要结合edit.jsp中的事件
五.Xheditor
(1)解压压缩文件,将其中的xheditor-zh-cn.min.js以及xheditor_emot、xheditor_plugins和xheditor_skin三个文件夹上传到网站相应目录
注:如果您网站中没有使用jQuery框架,也请一并上传jquery文件夹中的jquery-1.4.4.min.js
(2)在相应html文件的之前添加
注:如果jQuery之前已经在项目页面中使用,请勿重复添加引用代码
(3).
方法1:在textarea上添加属性:class="xheditor"
例如:test
方法2:在您的页面初始JS代码里加上:$('#elm1').xheditor();
$('#elm1').xheditor();
例如:
$({
相应的卸载编辑器的代码为
$('#elm1').xheditor(false);
自定义按钮
$(pageInit);
functionpageInit()
$.extend(xheditor.settings,{shortcuts:{'ctrl+enter':submitForm}});
$('#elm1').xheditor({tools:'full'});
$('#elm2').xheditor({tools:'mfull'});
$('#elm3').xheditor({tools:'simple'});
$('#elm4').xheditor({tools:'mini'});
$('#elm5').xheditor({tools:'Cut,Copy,Paste,Pastetext,|,Source,Fullscreen,About'});
$('#elm6').xheditor({tools:'Cut,Copy,Paste,Pastetext,/,Source,Fullscreen,About'});
functionsubmitForm(){$('#frmDemo').submit();}
1,full(完全):
当前实例调用的Javascript源代码为:
2,mfull(多行完全):
3,simple(简单):
4,mini(迷你):
5,custom(自定义):
6,自定义多行模式:
当前实例调用的Javascript源代码为
皮肤选择
注:为了保持项目精简,同一个页面只能调用一个皮肤,当同一界面同时调用多个皮肤时,最后一个皮肤的按钮面板样式会影响之前的
$('#elm1').xheditor({skin:'default'});
$('#elm2').xheditor({skin:'o2007blue'});
$('#elm3').xheditor({skin:'o2007silver'});
$('#elm4').xheditor({skin:'vista'});
$('#elm5').xheditor({skin:'nostyle'});
1,默认皮肤:
2,Office2007蓝色:
3,Office2007银白色:
4,Vista:
5,NoStyle:
六.Tinymce
使用:
tinyMCE.init({
mode:"textareas",
theme:"simple"//模式
skin:"o2k7",//word
theme:"simple"
ThisissomeexampletextthatyoucaneditinsidetheTinyMCEeditor
皮肤设置
//Generaloptions
mode:"exact",
elements:"elm1",
theme:"advanced",
plugins:"autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,
advlink,emotions,iespell,insertdatetime,preview,media,searchreple,print,contextmenu,paste,directionality,fullscreen,noneditable,
visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosa",
//Themeoptions
theme_advanced_buttons1:"save,newdocument,|,bold,italic,underline,strikethrough,|,
justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,
fontselect,fontsizeselect",
theme_advanced_buttons2:"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,
numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,prevw,|,forecolor,backcolor",
theme_advanced_buttons3:"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,
charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullsc",
theme_advanced_buttons4:"insertlayer,moveforward,movebackward,absolute,|,
styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,no,
template,pagebreak,restoredraft",
theme_advanced_toolbar_location:"top",//工具栏位置
theme_advanced_toolbar_align:"left",//工具栏对齐方式
theme_advanced_statusbar_location:"bottom",//状态显示栏的位置
theme_advanced_resizing:true,
//ExamplecontentCSS(shouldbeyoursiteCSS)
content_css:"css/content.css",
//Droplistsforlink/image/media/templatedialogs
template_external_list_url:"lists/template_list.js",
external_link_list_url:"lists/link_list.js",
external_image_list_url:"lists/image_list.js",
media_external_list_url:"lists/media_list.js",
//Replacevaluesforthetemplateplugin
template_replace_values:{
username:"SomeUser",
staffid:"991234"
//O2k7skin
elements:"elm2",
skin:"o2k7",
plugins:"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,
emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreg,xhtmlxtras,template,inlinepopups,autosave",
justifyleft,justifycenter,justifyright,justifyfull,styleselect,
formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2:"cut,copy,paste,pastetext,pasteword,|,search,replace,|,
bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,
nonbreaking,template,pagebreak,restoredraft",
theme_advanced_toolbar_location:"top",
theme_advanced_toolbar_align:"left",
theme_advanced_statusbar_location:"bottom",
ThisissomeexampletextthatyoucaneditinsidetheTinyMCEeditor;.
//O2k7skin(silver)
elements:"elm3",
skin_variant:"silver",
plugins:"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,
iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,
paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,
xhtmlxtras,template,inlinepopups,autosave",
theme_advanced_buttons1:"save,newdocument,|,bold,italic,underline,strikethrough
,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,
inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3:"tablecontrols,|,hr,removeformat,visualaid,|,
sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchas,nonbreaking,template,pagebreak,restoredraft",
ThisissomeexampletextthatyoucaneditinsidetheTinyMCE
elements:"elm4",
skin_variant:"black",
theme_advanced_buttons2:"cut,copy,paste,pastetext,pasteword,|,search,replace
,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,
redo,|,link,unlink,anchor,image,cleanup,help,code,|,
insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons4:"insertlayer,moveforward,movebackward,absolute
,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
Thisissomeexampletextthatyoucaneditinsidethe;
七.ueditor1
1.避免了重复加载源码高亮的核心代码
2.修复了word粘贴table过滤出错问题
3.修复插入地图会出现style="undefined"的问题
4.优化了list,多个相邻的属性一直的list会合并
5.可以在列表中的一行里产生多行的效果(通过回车再回退操作),类似office的效果
6.添加自定义样式功能
7.修了在chrome下右键删除td里的图片会把整个td删除的问题
8.改进了不同的页面调用一个editor,URL问题
9.增加了颜色选择器的颜色
10.改进了提供的后台程序的安全性
11.代码高亮支持折行
12.改进了源码编辑模式下的性能(ie下),并且支持自动换行
13.修改了在destroy之后会在ie下报错的问题
14.给初始化容器name值,那么在后台取值的键值就是name给定的值,方便多实例在一个form下提交
15.支持插入script/style这样的标签
16.修复了列表里插入浮动图片,图片不占位问题
17.源码模式下,去掉了pre中的
18.完善了_example下的demo例子
19.base64的图片被过滤掉了
使用方法:vareditorOption={
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
toolbars:[['FullScreen','Source','Undo','Redo','Bold']],
//focus时自动清空初始化时的内容
autoClearinitialContent:true,
//关闭字数统计
wordCount:false,
//关闭elementPath
elementPathEnabled:false
//更多其他参数,请参考editor_config.js中的配置项
};
vareditor_a=newbaidu.editor.ui.Editor(editorOption);
editor_a.render('textarea的Id');
简单应用
varUEDITOR_HOME_URL="../";//指向dialogs,themes等目录的父目录,推荐使用/开头的绝对路径
paths=[
'editor.js',
'core/browser.js',
'core/utils.js',
'core/EventBase.js',
'core/dom/dom.js',
'core/dom/dtd.js',
'core/dom/domUtils.js',
'core/dom/Range.js',
'core/dom/Selection.js',
'core/Editor.js',
'commands/inserthtml.js',
'commands/image.js',
'commands/justify.js',
'commands/font.js',
'commands/link.js',
'commands/map.js',
'commands/iframe.js',
'commands/removeformat.js',
'commands/blockquote.js',
'commands/indent.js',
'commands/print.js',
'commands/preview.js',
'commands/spechars.js',
'commands/emotion.js',
'commands/selectall.js',
'commands/paragraph.js',
'commands/directionality.js',
'commands/horizontal.js',
'commands/time.js',
'commands/rowspacing.js',
'commands/lineheight.js',
'commands/cleardoc.js',
'commands/anchor.js',
'commands/delete.js',
'commands/wordcount.js',
'plugins/pagebreak/pagebreak.js',
'plugins/checkimage/checkimage.js',
'plugins/undo/undo.js',
'plugins/paste/paste.js',//粘贴时候的提示依赖了UI
'plugins/list/list.js',
'plugins/source/source.js',
'plugins/shortcutkeys/shortcutkeys.js',
'plugins/enterkey/enterkey.js',
'plugins/keystrokes/keystrokes.js',
'plugins/fiximgclick/fiximgclick.js',
'plugins/autolink/autolink.js',
'plugins/autoheight/autoheight.js',
'plugins/autofloat/autofloat.js',//依赖UEditorUI,在IE6中,会覆盖掉body的背景图属性
'plugins/highlight/highlight.js',
'plugins/serialize/serialize.js',
'plugins/video/video.js',
'plugins/table/table.js',
'plugins/contextmenu/contextmenu.js',
'plugins/basestyle/basestyle.js',
'plugins/elementpath/elementpath.js',
'plugins/formatmatch/formatmatch.js',
'plugins/searchreplace/searchreplace.js',
'plugins/customstyle/customstyle.js',
'ui/ui.js',
'ui/uiutils.js',
'ui/uibase.js',
'ui/separator.js',
'ui/mask.js',
'ui/popup.js',
'ui/colorpicker.js',
'ui/tablepicker.js',
'ui/stateful.js',
'ui/button.js',
'ui/splitbutton.js',
'ui/colorbutton.js',
'ui/tablebutton.js',
'ui/toolbar.js',
'ui/menu.js',
'ui/combox.js',
'ui/dialog.js',
'ui/menubutton.js',
'ui/datebutton.js',
'ui/editorui.js',
'ui/editor.js',
'ui/multiMenu.js'
];
//自定义的编辑器配置项,此处定义的配置项将覆盖editor_config.js中的同名配置
vareditorOption={
editor_a.render('myEditor');