百度编辑器UEditor常用设置函数总结

百度编辑器UEditor常用设置函数总结

正在参与的项目有富文本编辑器的需求,于是选择了百度编辑器UEditor。在表单中使用时,对文本编辑器的内容有必填校验以及最大字数校验,由于UEditor本身提供的校验只做提示作用,并不能阻止表单的提交,因此找到了以下这些函数以及设置方便使用。

1、创建编辑器

UE.getEditor(‘editor’, {
initialFrameWidth:“100%” //初始化选项
})
精简版
UE.getEditor(‘editor’)

2、删除编辑器

UE.getEditor(‘editor’).destroy();

3、设置焦点

UE.getEditor(‘editor’).focus();

4、获取编辑器内容

UE.getEditor(‘editor’).getContent()

5、编辑器是否有内容

UE.getEditor(‘editor’).hasContents()

6、获取编辑器内容纯文本格式

UE.getEditor(‘editor’).getContentTxt()

7、获取带格式的纯文本

UE.getEditor(‘editor’).getPlainTxt()

8、启用编辑器

UE.getEditor(‘editor’).setEnabled();

9、禁止编辑

UE.getEditor(‘editor’).setDisabled(‘fullscreen’);

10、获取整个html内容

UE.getEditor(‘editor’).getAllHtml()

11、常用设置

imageUrl:UEDITOR_HOME_URL + “…/yunserver/yunImageUp.php”, //图片上传接口
imagePath:“http://”,

scrawlUrl:UEDITOR_HOME_URL + “…/yunserver/yunScrawlUp.php”,//涂鸦接口
scrawlPath:“http://”,

fileUrl:UEDITOR_HOME_URL + “…/yunserver/yunFileUp.php”,//文件上传接口
filePath:“http://”,

catcherUrl:UEDITOR_HOME_URL + “php/getRemoteImage.php”,//获取远程图片接口
catcherPath:UEDITOR_HOME_URL + “php/”,

imageManagerUrl:UEDITOR_HOME_URL + “…/yunserver/yunImgManage.php”,//图片管理接口
imageManagerPath:“http://”,

snapscreenHost:‘ueditor.baidu.com’,
snapscreenServerUrl:UEDITOR_HOME_URL + “…/yunserver/yunSnapImgUp.php”,//截图接口
snapscreenPath:“http://”,

wordImageUrl:UEDITOR_HOME_URL + “…/yunserver/yunImageUp.php”,//word图片转存接口
wordImagePath:“http://”, //

getMovieUrl:UEDITOR_HOME_URL + “…/yunserver/getMovie.php”,//获取视频接口

lang:/^zh/.test(navigator.language || navigator.browserLanguage || navigator.userLanguage) ? ‘zh-cn’ : ‘en’,
langPath:UEDITOR_HOME_URL + “lang/”,

webAppKey:“9HrmGf2ul4mlyK8ktO2Ziayd”,
initialFrameWidth:860, //初始化宽度
initialFrameHeight:420, //初始化高度
focus:true, //是否焦点
maximumWords:450,//最大字数限制
elementPathEnabled:false,//关闭下方元素路径
wordOverFlowMsg:“字数超出限制”//修改默认提示信息

12、控制toolbars上按钮的屏蔽和显示

不要的按钮直接在UEditor加载时删除toolbars数组中对应的单词,toolbars所有按钮单词对应说明文档地址:http://fex.baidu.com/ueditor/#start-toolbar

//加载文本编辑器
    var ue = UE.getEditor("details", {
	   toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
            'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
            'print', 'preview', 'searchreplace', 'drafts', 'help'
        ]],               

如果还有其他的问题,之后碰到了再更新,仅作为本人的学习笔记

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值