網(wǎng)站制作到了程序階段,一般需要用到網(wǎng)站編輯器,如后臺(tái)可自行更新相關(guān)公司介紹、產(chǎn)品介紹、編輯新聞等。網(wǎng)站編輯器有很多開源的,我們一般直接使用就行了,但如果要做到更加容易編輯,還是需要做一些改進(jìn),下面方維網(wǎng)絡(luò)的程序員給大家介紹如何自定義模板。
百度編輯器(ueditor)是一款功能強(qiáng)大的富文本編輯器,其中有一個(gè)模板功能,能幫助我們方便快捷的編輯一些相似內(nèi)容或者格式一樣的內(nèi)容
下面介紹一下怎么自定義我們所需要的模板。(如圖為編輯器模板功能按鈕位置)

點(diǎn)擊按鈕,編輯器中已經(jīng)內(nèi)置了幾個(gè)案例
找到ueditor\dialogs\template\config.js文件

var templates = [
{
"pre":"pre0.png",
'title':lang.blank,
'preHtml':'<p class="ue_t"> 車輛參數(shù)模板</p>',
"html":''
},
{
1.pre:為模板的樣式圖可以在
ueditor\dialogs\template\images文件夾中修改添加
2.title:模板名稱;可以在ueditor\lang\zh-cn\ 里進(jìn)行添加修改;
3.'preHtml' 模板內(nèi)容標(biāo)題介紹:直接輸入對(duì)應(yīng)文字即可;
4 ."html" 模板的代碼內(nèi)容 將html代碼壓縮一下復(fù)制進(jìn)去即可;
這樣基本完成了模板的設(shè)置,在這個(gè)過(guò)程中編輯器會(huì)將標(biāo)簽替換掉,需要我們?cè)?br />
ueditor\ueditor.all.js 里搜索allowDivTransToP disabledTableInTable 將他們改成false

UE.plugins['defaultfilter'] = function () {
var me = this;
me.setOpt({
'allowDivTransToP':false,
'disabledTableInTable':false
});
在使用過(guò)程中發(fā)現(xiàn)編輯會(huì)將li里面的樣式去掉

搜索li.style.cssText && (li.style.cssText = ''); 將行代碼注釋掉;
這樣基本就完成了模板的自定義;
kindeditor 也是一款比較好用的富文本編輯器,他的模板自定義和百度的有些不一樣;(功能所在位置)

kindeditor\plugins\template\html

添加模板文件,這是個(gè)html頁(yè)面里面可以寫的內(nèi)容比百度要更豐富

在kindeditor\kindeditor.js 文件中 搜索template.fileList
添加模板文件名稱及自定義模板名稱即可;
如沒(méi)特殊注明,文章均為方維網(wǎng)絡(luò)原創(chuàng),轉(zhuǎn)載請(qǐng)注明來(lái)自http://pdcharm.com/news/5356.html