最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽_javascript技巧

來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 20:52:22
文檔

使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽_javascript技巧

使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽_javascript技巧:流程比較簡(jiǎn)單,主要有以下步驟: 注冊(cè)插件(按鈕、Lang、htmlTags、插件腳本) 基于media插件代碼修改 注冊(cè)插件 首先,全局配置kindeditor參數(shù): KindEditor.lang({ audio : 'MP3' }); KindEditor.options.htmlTags['au
推薦度:
導(dǎo)讀使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽_javascript技巧:流程比較簡(jiǎn)單,主要有以下步驟: 注冊(cè)插件(按鈕、Lang、htmlTags、插件腳本) 基于media插件代碼修改 注冊(cè)插件 首先,全局配置kindeditor參數(shù): KindEditor.lang({ audio : 'MP3' }); KindEditor.options.htmlTags['au

流程比較簡(jiǎn)單,主要有以下步驟:

  • 注冊(cè)插件(按鈕、Lang、htmlTags、插件腳本)
  • 基于media插件代碼修改
  • 注冊(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

    文檔

    使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽_javascript技巧

    使用JavaScript為Kindeditor自定義按鈕增加Audio標(biāo)簽_javascript技巧:流程比較簡(jiǎn)單,主要有以下步驟: 注冊(cè)插件(按鈕、Lang、htmlTags、插件腳本) 基于media插件代碼修改 注冊(cè)插件 首先,全局配置kindeditor參數(shù): KindEditor.lang({ audio : 'MP3' }); KindEditor.options.htmlTags['au
    推薦度:
    標(biāo)簽: 自定義 js audio
    • 熱門(mén)焦點(diǎn)

    最新推薦

    猜你喜歡

    熱門(mén)推薦

    專題
    Top