百度 UEditor 绑定插入图片、插入文件事件
来源:互联网 发布:centos7图形网络配置 编辑:程序博客网 时间:2024/06/04 18:56
1、在 Editor render 之后增加侦听器,绑定 beforeexeccommand 或 afterexeccommand 事件;
2、事件绑定后可以截获 insertimage 事件,但是截获后的事件只有两个参数,分别为 : beforeexeccommand 或 insertimage 信息,但是缺少事件的参数信息;
3、修正 editor_all.js 脚本中关于事件绑定的设置,查找 beforeexeccommand 关键字,可以找到以下代码区:
execCommand : function ( cmdName ) {
cmdName = cmdName.toLowerCase();
var me = this,
result,
cmd = me.commands[cmdName] || UE.commands[cmdName];
if ( !cmd || !cmd.execCommand ) {
return;
}
if ( !cmd.notNeedUndo && !me.__hasEnterExecCommand ) {
me.__hasEnterExecCommand = true;
if(me.queryCommandState(cmdName) !=-1){
me.fireEvent( 'beforeexeccommand', cmdName);
result = this._callCmdFn( 'execCommand', arguments );
me.fireEvent( 'afterexeccommand', cmdName);
}
me.__hasEnterExecCommand = false;
} else {
result = this._callCmdFn( 'execCommand', arguments );
}
me._selectionChange();
return result;
},
4、修正 2 个 fireEvent 方法为:
me.fireEvent( 'beforeexeccommand', cmdName,arguments);
result = this._callCmdFn( 'execCommand', arguments );
me.fireEvent( 'afterexeccommand', cmdName ,arguments);
5、修正后在 render 之后的使用如下的方法:
var editor_a = new baidu.editor.ui.Editor(editorOption);
editor_a.render('editor');
editor_a.addListener("afterexeccommand", function (t, e, arg) {
alert(e);
});
这样就可以截获: e 就为 "insertImage" , arg 为插入图片的参数信息,多幅图片为数组模式。解析方法:opt = utils.isArray(opt) ? opt : [opt];
6 、修正 editor_all.js 脚本 增加 "insertfile" 命令方法,如下:
// --> 附加上传附件
UE.commands['insertfile'] = {
execCommand : function (cmd, ci){
var me = this;
var inf = "(" + cmd + ")-> src=[" +ci.url + "]<br> origin=[" + ci.original + "]<br>"; // 这里以后修正为插入 HTML 的信息
me.execCommand("inserthtml", inf);
}
};
7、修正 Ueditor\dialogs\attachment\attachment.html (上传文件对话框) 中的 dialog.onok 脚本,如下:
dialog.onok = function () {
// var map = fileTypeMaps,
// str="";
// for(var i=0,ci;ci=filesList[i++];){
// var src = editor.options.UEDITOR_HOME_URL + "dialogs/attachment/fileTypeImages/"+(map[ci.type]||"icon_default.png");
// str += "<p style='line-height: 16px;'><img src='"+ src + "' data_ue_src='"+src+"' />" +
// "<a href='"+editor.options.filePath + ci.url+"'>" + ci.original + "</a></p>";
// }
// editor.execCommand("insertHTML",str);
for (var i = 0, ci; ci = filesList[i++]; ) {
editor.execCommand("insertfile", ci);
}
swfupload.destroy();
};
8、这样就可以在 beforeexeccommand 或 afterexeccommand 时截获 "insertfile" 事件并获取相关文件信息了。
9、修正弹出对话框 的 zIndex ,在 editor_all.js 中查找:Dialog = baidu.editor.ui.Dialog = function (options) 方法,修正一下 1 个地方
//this.editor.container.style.zIndex && (this.getDom().style.zIndex = this.editor.container.style.zIndex * 1 + 10);
this.editor.container.style.zIndex && (this.getDom().style.zIndex = this.editor.container.style.zIndex * 1 + 500);
并在 config.js 中增加
, zIndex: 75 //编辑器层级的基数,默认是900
, zIndex_DialogOver: 500 // 弹出对话框 高于 zIndex 的层数 ( zIndex + zIndex_DialogOver 应高于所有层)
- 百度 UEditor 绑定插入图片、插入文件事件
- Ueditor插入图片后换行
- bootstrap3模态框里有个百度编辑器ueditor,当点击插入图片时,插入图片界面被模态框遮住了解决办法
- UEditor插入视频、图片显示问题解决
- [easyui+ueditor]ueditor插入图片对话框被遮盖问题
- 百度UEditor插入图片尺寸自动适应编辑框大小问题
- 百度ueditor富文本编辑器插入html代码问题
- 百度编辑器ueditor插入表格没有边框颜色的解决方法
- ueditor插入flv视频
- oracle图片及文件插入
- 向PDF文件插入图片
- JSP文件中插入图片
- 向ueditor中插入内容
- 百度编辑器ueditor上传图片及文件路径配置
- 如何调用百度编辑器ueditor的上传图片、上传文件
- 百度编辑器ueditor修改文件图片上传路径的方法
- 百度ueditor踩坑,ueditor图片上传
- 插入图片
- ArcEngine数据删除几种方法和性能比较
- 选择框控制文本框是否可用
- poj 1269 Intersecting Lines--直线相交
- 如何用随机函数rand5来构造随机函数rand7 一道经典的算法题
- HDU-2141(二分查找_创新)
- 百度 UEditor 绑定插入图片、插入文件事件
- u盘安装64位win7及误删恢复
- asp.Net_图片上传的一个类库的源码
- Java关键字
- OpenGL几个 函数
- C++ 并发编程的一种思维
- 直接转换网站data的内容
- ArcEngine利用C#反射获取事件列表
- SCN、ORA-19706错误和_external_scn_rejection_threshold_hours参数