如何在.Net版本UEditor中添加一個普通按鈕
第一步:找到ueditor.config.js文件中的toolbars數(shù)組,增加一個“hougelou”字符串,然后找到labelMap數(shù)組,對應(yīng)著添加一個labelMap,用于鼠標(biāo)移上按鈕時的提示。
//工具欄上的所有的功能按鈕和下拉框,可以在new編輯器的實例時選擇自己需要的從新定義
, toolbars:[
['fullscreen', 'source', '|', 'undo', 'redo', '|',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'hougelou', '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', '|',
'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', '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', '|',
'print', 'preview', 'searchreplace', 'help']
]
//當(dāng)鼠標(biāo)放在工具欄上時顯示的tooltip提示,留空支持自動多語言配置,否則以配置值為準(zhǔn)
,labelMap:{
'hougelou': 'hello,后閣樓'
}
第二步:找到你所引用的ueditor.all.js文件中的btnCmds數(shù)組,在其中同樣增加一個“hougelou”字符串。
第三步:清空緩存刷新下頁面吧!工具欄的對應(yīng)位置是否出現(xiàn)了一個自己定義的按鈕呢?如下圖所示:
由于此時未設(shè)置對應(yīng)按鈕的圖片樣式,所以會顯示默認(rèn)的“B”字符。要想讓其顯示成自己需要的圖標(biāo)樣式,接著按照下面的步驟動手吧。
第四步:找到themes/default/css/ueditor.css文件,增加一條樣式定義:
.edui-for-hougelou .edui-icon {
background-position: -700px -40px;
}
此處的樣式定義了showmsg圖標(biāo)在UEditor默認(rèn)的精靈Icon圖片(themes/default/images/icons.png)中的位置偏移。如需更改成另外圖標(biāo),只需添加圖標(biāo)到該圖片文件中,然后設(shè)置偏移值即可。
第五步:到此為止,在UI層面已經(jīng)完成了一個工具欄圖標(biāo)的顯示和各種狀態(tài)變化的邏輯,但是我們發(fā)現(xiàn)點擊按鈕之后毫無反應(yīng)。那是必然的,我們還必須為該按鈕綁定屬于它自己的事件處理方法。
實質(zhì)上,此時一個默認(rèn)的事件處理方法已經(jīng)被UEditor綁定到按鈕上了,只不過由于我們還沒有定義該方法的具體內(nèi)容,所以點擊之后無任何變化。
下面我們就來定義該方法的具體內(nèi)容:
在初始化編輯器的時候,加上自己的事件處理(插入一張圖片),如下代碼:
ueditor = UE.getEditor('txtContent', {
"initialFrameHeight": "200",
toolbars: [['fullscreen', 'source', 'hougelou', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|', 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|', 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 'insertimage', 'emotion', 'insertvideo', 'music', 'insertcode', 'background', '|', 'horizontal', 'date', 'time', 'spechars', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|', 'preview', 'searchreplace', 'help']],
enterTag: " "
}); //回車的時候用換行不用段落標(biāo)簽
//實現(xiàn)插件的功能代碼
baidu.editor.commands['hougelou'] = { execCommand: function() { this.execCommand('insertHtml', "<img src='http://www.xxx.com/images/logo.png' />"); return true; }, queryCommandState: function() { } };
End
-------------------------------------------------------------------------------
在images.ashx里發(fā)現(xiàn)百度編輯器返回圖片路徑是用分隔符“ue_separate_ue”連起來的。
相關(guān)文章
asp.net mvc4 mysql制作簡單分頁組件(部分視圖)
這篇文章主要介紹了asp.net mvc4 mysql制作簡單分頁組件,附部分視圖,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-10-10詳解mvc使用JsonResult返回Json數(shù)據(jù)
這篇文章主要介紹了詳解mvc使用JsonResult返回Json數(shù)據(jù),具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-01-01ASP.NET下母版頁和內(nèi)容頁中的事件發(fā)生順序整理
母版頁與內(nèi)容頁合并后事件的發(fā)生順序,有需要區(qū)別的朋友能用的到2009-03-03MVC+EasyUI+三層新聞網(wǎng)站建立 分頁查詢數(shù)據(jù)功能(七)
這篇文章主要為大家詳細(xì)介紹了MVC+EasyUI+三層新聞網(wǎng)站建立的第七篇,教大家如何分頁查詢出數(shù)據(jù),具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07.NET Core創(chuàng)建一個控制臺(Console)程序
這篇文章主要為大家詳細(xì)介紹了.NET Core如何創(chuàng)建一個控制臺程序,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04C#/.NET讀取或修改文件的創(chuàng)建時間及修改時間詳解
這篇文章主要給大家介紹了關(guān)于C#/.NET讀取或修改文件的創(chuàng)建時間及修改時間的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-08-08Asp.Net如何將多個RadioButton指定在一個組中
將多個RadioButton指定在一個組中,實現(xiàn)其實很簡單,一句代碼即可,具體如下,希望對大家有所幫助2013-12-12