注冊(cè)插件
首先,全局配置kindeditor參數(shù):
KindEditor.lang({ audio : 'MP3' }); KindEditor.options.htmlTags['audio'] = ['src','controls','autoplay','type']; KindEditor.options.htmlTags['source'] = ['src','controls','autoplay','type'];
在初始化編輯器的地方,配置按鈕列表items參數(shù),把
'audio'
放在合適的位置:
KindEditor.ready(function(K) { editor = K.create('#info,#spread_info', { //其他配置省略... items : [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', '|' ,'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about','audio' ] });
為了便于閱讀,我把a(bǔ)udio按鈕放在最后,在 "幫助" 標(biāo)簽的后面。
為了讓按鈕能夠顯示,我們還需要指定一下css樣式:
這里我圖方便,直接用了自帶的音視頻按鈕的圖標(biāo),自定義圖標(biāo)請(qǐng)手動(dòng)指定 background 樣式屬性。
最后,創(chuàng)建腳本
kindeditor/plugins/audio/audio.js
audio目錄手動(dòng)建立。
我們把
plugins/media/media.js
中的代碼復(fù)制到audio.js里,然后著手修改。
修改media插件
主要是去掉一些無(wú)用的屬性,如 寬、高、自動(dòng)播放等,并修改插入代碼的部分,手動(dòng)構(gòu)建 "audio" 標(biāo)簽的html代碼。
至此,整個(gè)插件基本結(jié)束。
需要注意的是,上傳文件用的是通用的配置uploadJson參數(shù),但會(huì)在上傳的時(shí)候自動(dòng)添加一個(gè)get參數(shù) "dir=audio" ,以便后臺(tái)識(shí)別:
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com