百度Ueditor编辑器

百度的Ueditor编辑器出于安全性考虑,用户在html模式下粘贴进去的html文档会自动被去除样式和转义。虽然安全的,但是非常不方便。

1. ueditor.config.js 做出如下修改即可:

xssFilterRules: false ,// xss 过滤是否开启,inserthtml等操作
inputXssFilter: false ,//input xss过滤
outputXssFilter: false,//output xss过滤

自定义按钮、图标、事件

 ueditor.config.js

//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
toolbars  :[['help','camnpr']]
//当鼠标放在工具栏上时显示的tooltip提示,留空支持自动多语言配置,否则以配置值为准
labelMap  :{'anchor':'', 'undo':'','camnpr':'郑州网建' ]
 
ueditor.all.js
// 自己写的ui也要在这里配置,放到baidu.editor.ui下边,当编辑器实例化的时候会根据ueditor.config中的toolbars找到相应的进行实例化
var iframeUrlMap = { 'camnpr': '~/dialogs/camnpr/camnpr.html' };
 
    // 表情
editorui["emotion"] = function (editor, iframeUrl) {};
editorui["camnpr"] = function (editor, iframeUrl) { var cmd = "camnpr"; var ui = new editorui.MultiMenuPop({ title:editor.options.labelMap[cmd] || editor.getLang("labelMap."+ cmd + "") || '', editor:editor, className:'edui-for-' + cmd, iframeUrl:editor.ui.mapUrl(iframeUrl || (editor.options.iframeUrlMap || {})[cmd] || iframeUrlMap[cmd]) }); editorui.buttons[cmd] = ui; editor.addListener('selectionchange', function () { ui.setDisabled(editor.queryCommandState(cmd) == -1) }); return ui; };

//让其显示成自己需要的图标样式

themes/default/ueditor.css

.edui-for-camnpr .edui-icon {  background-position: -640px -40px; }

自定义按钮、图标、窗口页面

 ueditor.config.js

//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
toolbars  :[['help','camnpr']]
//当鼠标放在工具栏上时显示的tooltip提示,留空支持自动多语言配置,否则以配置值为准
labelMap  :{'anchor':'', 'undo':'','camnpr':'郑州网建' ]
ueditor.all.js
//为工具栏添加按钮,以下都是统一的按钮触发命令,所以写在一起
var btnCmds = [ 'camnpr'];
UE.commands['camnpr'] = {
    execCommand : function(){
        console.log("你好,这是自定义按钮的事件",this.body.innerHTML);
    }
};

 

转载于:https://www.cnblogs.com/techliang666/p/10523388.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值