修改ueditor.config.js文件
在ueditor.config.js文件中,找到toolbars参数,增加一个“audio”字符串,对应着添加一个labelMap,用于鼠标移上按钮时的提示。
//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的从新定义
, 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','audio', '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', 'help', 'drafts'
]]
//当鼠标放在工具栏上时显示的tooltip提示,留空支持自动多语言配置,否则以配置值为准
,labelMap:{
audio:'音频'
}2.修改ueditor.all.js文件
找到iframeUrlMap增加一行:
'audio': '~/dialogs/audio/audio.html',
找到btnCmds、dialogBtns增加一个元素:audio
接下来在dialogs文件夹下创建audio文件夹并新建audio.html
音频地址:
" + "" +
"" +
"Your browser does not support the audio tag" +
"" + "");
dialog.close();
} else {
alert("不支持该音频格式");
return false;
}
} else {
alert("请输入音频地址");
return false;
}
}
dialog.onok = handleDialogOk;
$G('href').onkeydown = function(evt) {
evt = evt || window.event;
if (evt.keyCode == 13) {
handleDialogOk();
return false;
}
}" _ue_custom_node_="true">相关的操作js也写在该html里面。
到这里,运行编辑器 新加的按钮已经出来啦,但是点击弹出的窗口样式不对 乱了;
这时候,修改themes/default/css/ueditor.css文件,增加一条样式:
.edui-default .edui-for-audio .edui-icon {
background-position: -18px -40px
}至此,弹窗可以正常显示了,并能插入相应的代码。