国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

CKeditor富文本編輯器使用技巧之添加自定義插件的方法

來源:懂視網(wǎng) 責編:小采 時間:2020-11-27 21:55:03
文檔

CKeditor富文本編輯器使用技巧之添加自定義插件的方法

CKeditor富文本編輯器使用技巧之添加自定義插件的方法:本文實例講述了CKeditor富文本編輯器使用技巧之添加自定義插件的方法。分享給大家供大家參考,具體如下: 首先就是在CKeditor的plugins目錄下新建一個目錄qchoice: qchoice目錄下的結(jié)構(gòu)如下: 然后, images中如下: dialogs中如下: 我們
推薦度:
導讀CKeditor富文本編輯器使用技巧之添加自定義插件的方法:本文實例講述了CKeditor富文本編輯器使用技巧之添加自定義插件的方法。分享給大家供大家參考,具體如下: 首先就是在CKeditor的plugins目錄下新建一個目錄qchoice: qchoice目錄下的結(jié)構(gòu)如下: 然后, images中如下: dialogs中如下: 我們

本文實例講述了CKeditor富文本編輯器使用技巧之添加自定義插件的方法。分享給大家供大家參考,具體如下:

首先就是在CKeditor的plugins目錄下新建一個目錄qchoice:

qchoice目錄下的結(jié)構(gòu)如下:

然后, images中如下:

dialogs中如下:

我們先來看plugins.js文件的內(nèi)容:

(function() {
 CKEDITOR.plugins.add("qchoice", {
 requires: ["dialog"],
 init: function(a) {
 a.addCommand("qchoice", new CKEDITOR.dialogCommand("qchoice"));
 a.ui.addButton("qchoice", {
 label: "qchoice",//調(diào)用dialog時顯示的名稱
 command: "qchoice",
 icon: this.path + "images/qchoice.jpg"http://在toolbar中的圖標
 });
 CKEDITOR.dialog.add("qchoice", this.path + "dialogs/qchoice.js")
 }
 })
})();

再來看qchoice.js文件的內(nèi)容:

CKEDITOR.dialog.add('qchoice', function (editor) { //要和plugin.js 中的command 一致
 var escape = function (value) {
 return value;
 };
 return {
 title: '', //對話框標題
 minWidth: 500, //對話框?qū)挾? minHeight: 600,//對話框高度
 contents: [{ //對話框內(nèi)容
 id: 'choice',
 name: 'choice',
 label: '插入選擇題答案',
 title: '插入選擇題答案',
 elements: [{
 id: 'rdType_1',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['中國贊','[中國贊]'],['廣告','[廣告]'],['doge','[doge]'],['喵喵','[喵喵]'],['二哈','[二哈]'],['抱抱','[抱抱]'],['哼','[哼]'],['思考','[思考]'],['生病','[生病]'],['偷樂','[偷樂]']]
 },
 {
 id: 'rdType_2',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['笑cry','[笑cry]'],['饞嘴','[饞嘴]'],['拜拜','[拜拜]'],['右哼哼','[右哼哼]'],['左哼哼','[左哼哼]'],['怒罵','[怒罵]'],['鄙視','[鄙視]'],['笑而不語','[笑而不語]']]
 },
 {
 id: 'rdType_3',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['害羞','[害羞]'],['費解','[費解]'],['挖鼻','[挖鼻]'],['悲傷','[悲傷]'],['打臉','[打臉]'],['抓狂','[抓狂]'],['哈哈','[哈哈]'],['傻眼','[傻眼]'],['好喜歡','[好喜歡]'],['好愛哦','[好愛哦]']]
 },
 {
 id: 'rdType_4',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['失望','[失望]'],['good','[good]'],['弱','[弱]'],['耶','[耶]'],['來','[來]'],['握手','[握手]'],['加油','[加油]'],['haha','[haha]'],['拳頭','[拳頭]'],['男孩兒','[男孩兒]']]
 },
 {
 id: 'rdType_5',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['話筒','[話筒]'],['禮物','[禮物]'],['飛機','[飛機]'],['干杯','[干杯]'],['圍脖','[圍脖]'],['鐘','[鐘]'],['肥皂','[肥皂]'],['浪','[浪]'],['女孩兒','[女孩兒]'],['照相機','[照相機]']]
 },
 {
 id: 'rdType_6',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['熊貓','[熊貓]'],['喜','[喜]'],['綠絲帶','[綠絲帶]'],['威武','[威武]'],['弗萊見錢眼開','[弗萊見錢眼開]'],['看漲','[看漲]'],['看跌','[看跌]'],['奧特曼','[奧特曼]'],['兔子','[兔子]']]
 }
 ,
 {
 id: 'rdType_7',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['頂','[頂]'],['米奇喜歡','[米奇喜歡]'],['米奇飛吻','[米奇飛吻]'],['米奇大哭','[米奇大哭]'],['米奇比心','[米奇比心]'],['笑哈哈','[笑哈哈]'],['羞嗒嗒','[羞嗒嗒]'],['憧憬','[憧憬]'],['酷','[酷]']]
 }
 ,
 {
 id: 'rdType_8',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['月亮','[月亮]'],['圍觀','[圍觀]'],['蛋糕','[蛋糕]'],['微風','[微風]'],['音樂','[音樂]'],['豬頭','[豬頭]'],['鮮花','[鮮花]'],['太陽','[太陽]'],['Aloha','[Aloha]'],['贊啊','[贊啊]'],['求關注','[求關注]']]
 }
 ,
 {
 id: 'rdType_9',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['哈欠','[哈欠]'],['淚','[淚]'],['怒','[怒]'],['閉嘴','[閉嘴]'],['疑問','[疑問]'],['白眼','[白眼]'],['吐','[吐]'],['黑線','[黑線]'],['委屈','[委屈]'],['下雨','[下雨]'],['傷心','[傷心]']]
 }
 ,
 {
 id: 'rdType_10',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['作揖','[作揖]'],['星星','[星星]'],['半星','[半星]'],['空星','[空星]'],['草泥馬','[草泥馬]'],['浮云','[浮云]'],['沙塵暴','[沙塵暴]'],['給力','[給力]'],['骷髏','[骷髏]'],['最右','[最右]']]
 }
 ,
 {
 id: 'rdType_11',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['太開心','[太開心]'],['擠眼','[擠眼]'],['衰','[衰]'],['感冒','[感冒]'],['可憐','[可憐]'],['汗','[汗]'],['色','[色]'],['可愛','[可愛]'],['錢','[錢]'],['ok','[ok]'],['NO','[NO]'],['蠟燭','[蠟燭]']]
 }
 ,
 {
 id: 'rdType_12',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['吃狗糧','[吃狗糧]'],['蟻人','[蟻人]'],['黃蜂女','[黃蜂女]'],['吃瓜','[吃瓜]'],['允悲','[允悲]'],['壞笑','[壞笑]'],['困','[困]'],['互粉','[互粉]'],['睡','[睡]'],['并不簡單','[并不簡單]']]
 }
 ,
 {
 id: 'rdType_13',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['陰險','[陰險]'],['噓','[噓]'],['嘻嘻','[嘻嘻]'],['愛你','[愛你]'],['吃驚','[吃驚]'],['污','[污]'],['鼓掌','[鼓掌]'],['給你小心心','[給你小心心]'],['心','[心]'],['贊','[贊]']]
 }
 ,
 {
 id: 'rdType_14',
 type: 'radio', //表單元素類型:單選按鈕
 items: [['微笑','[微笑]'],['偷笑','[偷笑]'],['舔屏','[舔屏]'],['親親','[親親]'],['攤手','[攤手]'],['跪了','[跪了]'],['暈','[暈]'],['米奇愛你','[米奇愛你]'],['帶著微博去旅行','[帶著微博去旅行]']]
 }]
 }],
 onOk: function () { //點擊確定按鈕出發(fā)onOK事件。以下代碼主要目的是構(gòu)造一個select下拉框
 qtype_1 = this.getValueOf('choice', 'rdType_1');
 qtype_2 = this.getValueOf('choice', 'rdType_2');
 qtype_3 = this.getValueOf('choice', 'rdType_3');
 qtype_4 = this.getValueOf('choice', 'rdType_4');
 qtype_5 = this.getValueOf('choice', 'rdType_5');
 qtype_6 = this.getValueOf('choice', 'rdType_6');
 qtype_7 = this.getValueOf('choice', 'rdType_7');
 qtype_8 = this.getValueOf('choice', 'rdType_8');
 qtype_9 = this.getValueOf('choice', 'rdType_9');
 qtype_10 = this.getValueOf('choice', 'rdType_10');
 qtype_11 = this.getValueOf('choice', 'rdType_11');
 qtype_12 = this.getValueOf('choice', 'rdType_12');
 qtype_13 = this.getValueOf('choice', 'rdType_13');
 qtype_14 = this.getValueOf('choice', 'rdType_14');
 rtn = "";
 if(qtype_1 != null){
 rtn += qtype_1;
 }
 if(qtype_2 != null){
 rtn += qtype_2;
 }
 if(qtype_3 != null){
 rtn += qtype_3;
 }
 if(qtype_4 != null){
 rtn += qtype_4;
 }
 if(qtype_5 != null){
 rtn += qtype_5;
 }
 if(qtype_6 != null){
 rtn += qtype_6;
 }
 if(qtype_7 != null){
 rtn += qtype_7;
 }
 if(qtype_8 != null){
 rtn += qtype_8;
 }
 if(qtype_9 != null){
 rtn += qtype_9;
 }
 if(qtype_10 != null){
 rtn += qtype_10;
 }
 if(qtype_11 != null){
 rtn += qtype_11;
 }
 if(qtype_12 != null){
 rtn += qtype_12;
 }
 if(qtype_13 != null){
 rtn += qtype_13;
 }
 if(qtype_14 != null){
 rtn += qtype_14;
 }
 if (rtn != "") {
 rtns = "<span>"+rtn+"</span>";
 editor.insertHtml(rtns);
 }
 else {
 return false;
 }
 }
 };
});
function htmlEncode(str) {
 var temp = document.createElement("div");
 (temp.textContent != null) ? (temp.textContent = str) : (temp.innerText = str);
 var output = temp.innerHTML;
 temp = null;
 return output;
}

之后就是config.js配置文件的內(nèi)容了:

/**
 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */
CKEDITOR.editorConfig = function( config ) {
 config.toolbarGroups = [
 { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
 { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
 { name: 'links' },
 { name: 'insert' },
 { name: 'forms' },
 { name: 'tools' },
 { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
 { name: 'others' },
 '/',
 { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
 { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
 { name: 'styles' },
 { name: 'colors' },
 { name: 'about' },
 { name: 'extent', items: ["qchoice"] }
 ];
 config.toolbar_Full = [
 ['Source','-','Save','NewPage','Preview','-','Templates'],
 ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker', 'Scayt'],
 ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
 ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select','Button', 'ImageButton', 'HiddenField'],
 '/',
 ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
 ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
 ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
 ['Link','Unlink','Anchor'],
 ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
 '/',
 ['Styles','Format','Font','FontSize'],
 ['TextColor','BGColor'],
 ["qchoice"]
 ];
 config.image_previewText=' ';
 config.filebrowserImageUploadUrl = 'uploadFiles';
 // config.extraPlugins = 'justify';
 config.extraPlugins += (config.extraPlugins ? ',justify' : 'justify');
 config.extraPlugins += (config.extraPlugins ? ',qchoice' : 'qchoice');
 // config.extraPlugins="linkbutton";
 //
 // config.extraPlugins="ilink";
 //
 // config.extraPlugins="ijuzi";
 // config.extraPlugins="iti";
 config.removeButtons = 'Underline,Subscript,Superscript';
 // Set the most common block elements.
 config.format_tags = 'p;h1;h2;h3;pre';
 // Simplify the dialog windows.
 config.removeDialogTabs = 'image:advanced;link:advanced';
 config.image_previewText=' ';
 config.entities = false;
};

好啦,到這里,自定義插件就算是放入成功了。咱們自定義的插件主要的邏輯結(jié)構(gòu)就是在qchoice.js文件中,可以改變它的內(nèi)容,來實現(xiàn)不同的功能。

好啦,本次記錄就到這里了。

更多關于JavaScript相關內(nèi)容感興趣的讀者可查看本站專題:《JavaScript錯誤與調(diào)試技巧總結(jié)》、《JavaScript操作XML文件技巧總結(jié)》、《JavaScript中json操作技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學運算用法總結(jié)》

希望本文所述對大家JavaScript程序設計有所幫助。

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

CKeditor富文本編輯器使用技巧之添加自定義插件的方法

CKeditor富文本編輯器使用技巧之添加自定義插件的方法:本文實例講述了CKeditor富文本編輯器使用技巧之添加自定義插件的方法。分享給大家供大家參考,具體如下: 首先就是在CKeditor的plugins目錄下新建一個目錄qchoice: qchoice目錄下的結(jié)構(gòu)如下: 然后, images中如下: dialogs中如下: 我們
推薦度:
標簽: 自己的 方法 定義
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 日韩欧美高清在线 | 免费看欧美日韩一区二区三区 | 国产精品久久久久999 | 成人亚洲国产综合精品91 | 全免费a级毛片免费毛视频 情侣国产在线 | 亚洲综合欧美综合 | 欧美精品第一页 | 欧美在线免费播放 | 中文字幕无线码一区 | 欧美精品亚洲网站 | 亚洲 欧美 综合 | 国产精品久久久久久一级毛片 | xxx色| 婷婷综合在线 | 成人欧美精品久久久久影院 | 久久精品国产亚洲 | 国内精品一区二区三区αv 国产最新进精品视频 | 欧美亚洲日本国产 | 天美传媒精品一区 | 欧美日韩国 | 免费精品在线观看 | 国产成人精品一区二三区2022 | 欧美一级久久久久久久大片 | 欧美一区二区在线观看 | 曰韩在线| 亚洲欧美国产精品专区久久 | 久操电影网 | 欧美人与禽x0x0牲伦交 | 在线播放五十路乱中文 | 欧美国产日韩在线 | 国产精品网站在线进入 | 亚洲第一导航 | 在线一区观看 | 亚洲一区二区在线成人 | 久久精品无码一区二区日韩av | 在线观看亚洲一区二区 | 欧日韩视频 | 91久久国产 | 欧美激情综合亚洲一二区 | 精品久久久久久久中文字幕 | 国内自拍视频网站 |