您好,登錄后才能下訂單哦!
ckeditor編輯器很強(qiáng)大
下載地址:Ckeditor下載地址:http://ckeditor.com/download
在頁(yè)面<head>中引入ckeditor核心文件ckeditor.js
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
如果是ASP.NET環(huán)境,也可用服務(wù)器端控件<TextBox>
<asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" class="ckeditor"></asp:TextBox>
注意在控件中加上 class="ckeditor" 。
將相應(yīng)的控件替換成編輯器代碼
<script type="text/javascript"> CKEDITOR.replace('TextArea1'); //如果是在ASP.NET環(huán)境下用的服務(wù)器端控 件<TextBox> CKEDITOR.replace('tbContent'); //如 果<TextBox>控件在母版頁(yè)中,要這樣寫 CKEDITOR.replace('<%=tbContent.ClientID.Replace("_","$") %>');</script>
ckeditor的配置都集中在 ckeditor/config.js 文件中,下面是一些常用的配置參數(shù):
// 界面語(yǔ)言,默認(rèn)為 'en' config.language = 'zh-cn'; // 設(shè)置寬高 config.width = 400; config.height = 400; // 編輯器樣式,有三種:'kama'(默認(rèn))、'office2003'、'v2' config.skin = 'v2'; // 背景顏色 config.uiColor = '#FFF'; // 工具欄(基礎(chǔ)'Basic'、全能'Full'、自定義)plugins/toolbar/plugin.js config.toolbar = 'Basic'; config.toolbar = 'Full'; 這將配合: 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'] ]; //工具欄是否可以被收縮 config.toolbarCanCollapse = true; //工具欄的位置 config.toolbarLocation = 'top';//可選:bottom //工具欄默認(rèn)是否展開(kāi) config.toolbarStartupExpanded = true; // 取消 “拖拽以改變尺寸”功能 plugins/resize/plugin.js config.resize_enabled = false; //改變大小的最大高度 config.resize_maxHeight = 3000; //改變大小的最大寬度 config.resize_maxWidth = 3000; //改變大小的最小高度 config.resize_minHeight = 250; //改變大小的最小寬度 config.resize_minWidth = 750; // 當(dāng)提交包含有此編輯器的表單時(shí),是否自動(dòng)更新元素內(nèi)的數(shù)據(jù) config.autoUpdateElement = true; // 設(shè)置是使用絕對(duì)目錄還是相對(duì)目錄,為空為相對(duì)目錄 config.baseHref = '' // 編輯器的z-index值 config.baseFloatZIndex = 10000; //設(shè)置快捷鍵 config.keystrokes = [ [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], //獲取焦點(diǎn) [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ], //元素焦點(diǎn) [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ], //文本菜單 [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], //撤銷 [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], //重做 [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], // [ CKEDITOR.CTRL + 76 /*L*/, 'link' ], //鏈接 [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ], //粗體 [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ], //斜體 [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ], //下劃線 [ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ] ] //設(shè)置快捷鍵 可能與瀏覽器快捷鍵沖突 plugins/keystrokes/plugin.js. config.blockedKeystrokes = [ CKEDITOR.CTRL + 66 /*B*/, CKEDITOR.CTRL + 73 /*I*/, CKEDITOR.CTRL + 85 /*U*/ ] //設(shè)置編輯內(nèi)元素的背景色的取值 plugins/colorbutton/plugin.js. config.colorButton_backStyle = { element : 'span', styles : { 'background-color' : '#(color)' } } //設(shè)置前景色的取值 plugins/colorbutton/plugin.js config.colorButton_colors = '000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF’ //是否在選擇顏色時(shí)顯示“其它顏色”選項(xiàng) plugins/colorbutton/plugin.js config.colorButton_enableMore = false //區(qū)塊的前景色默認(rèn)值設(shè)置 plugins/colorbutton/plugin.js config.colorButton_foreStyle = { element : 'span', styles : { 'color' : '#(color)' } }; //所需要添加的CSS文件 在此添加 可使用相對(duì)路徑和網(wǎng)站的絕對(duì)路徑 config.contentsCss = './contents.css'; //文字方向 config.contentsLangDirection = 'rtl'; //從左到右 //CKeditor的配置文件 若不想配置 留空即可 CKEDITOR.replace( 'myfiled', { customConfig : './config.js' } ); //界面編輯框的背景色 plugins/dialog/plugin.js config.dialog_backgroundCoverColor = '#fffefd'; //可設(shè)置參考 config.dialog_backgroundCoverColor = 'white' //默認(rèn) //背景的不透明度 數(shù)值應(yīng)該在:0.0~1.0 之間 plugins/dialog/plugin.js config.dialog_backgroundCoverOpacity = 0.5 //移動(dòng)或者改變?cè)貢r(shí) 邊框的吸附距離 單位:像素 plugins/dialog/plugin.js config.dialog_magnetDistance = 20; //是否拒絕本地拼寫檢查和提示 默認(rèn)為拒絕 目前僅firefox和safari支持 plugins/wysiwygarea/plugin.js. config.disableNativeSpellChecker = true //進(jìn)行表格編輯功能 如:添加行或列 目前僅firefox支持 plugins/wysiwygarea/plugin.js config.disableNativeTableHandles = true; //默認(rèn)為不開(kāi)啟 //是否開(kāi)啟 圖片和表格 的改變大小的功能 config.disableObjectResizing = true; config.disableObjectResizing = false //默認(rèn)為開(kāi)啟 //設(shè)置HTML文檔類型 config.docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22' ; //是否對(duì)編輯區(qū)域進(jìn)行渲染 plugins/editingblock/plugin.js config.editingBlock = true; //編輯器中回車產(chǎn)生的標(biāo)簽 config.enterMode = CKEDITOR.ENTER_P; //可選:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV //是否使用HTML實(shí)體進(jìn)行輸出 plugins/entities/plugin.js config.entities = true; //定義更多的實(shí)體 plugins/entities/plugin.js config.entities_additional = '#39'; //其中#代替了& //是否轉(zhuǎn)換一些難以顯示的字符為相應(yīng)的HTML字符 plugins/entities/plugin.js config.entities_greek = true; //是否轉(zhuǎn)換一些拉丁字符為HTML plugins/entities/plugin.js config.entities_latin = true; //是否轉(zhuǎn)換一些特殊字符為ASCII字符 如"This is Chinese: 漢語(yǔ)."轉(zhuǎn)換為"This is Chinese: 漢語(yǔ)." plugins/entities/plugin.js config.entities_processNumerical = false; //添加新組件 config.extraPlugins = 'myplugin'; //非默認(rèn) 僅示例 //使用搜索時(shí)的高亮色 plugins/find/plugin.js config.find_highlight = { element : 'span', styles : { 'background-color' : '#ff0', 'color' : '#00f' } }; //默認(rèn)的字體名 plugins/font/plugin.js config.font_defaultLabel = 'Arial'; //字體編輯時(shí)的字符集 可以添加常用的中文字符:宋體、楷體、黑體等 plugins/font/plugin.js config.font_names = 'Arial;Times New Roman;Verdana'; //文字的默認(rèn)式樣 plugins/font/plugin.js config.font_style = { element : 'span', styles : { 'font-family' : '#(family)' }, overrides : [ { element : 'font', attributes : { 'face' : null } } ] }; //字體默認(rèn)大小 plugins/font/plugin.js config.fontSize_defaultLabel = '12px'; //字體編輯時(shí)可選的字體大小 plugins/font/plugin.js config.fontSize_sizes ='8/8px;9/9px;10/10px;11/11px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;26/26px;28/28px;36/36px;48/48px;72/72px' //設(shè)置字體大小時(shí) 使用的式樣 plugins/font/plugin.js config.fontSize_style = { element : 'span', styles : { 'font-size' : '#(size)' }, overrides : [ { element : 'font', attributes : { 'size' : null } } ] }; //是否強(qiáng)制復(fù)制來(lái)的內(nèi)容去除格式 plugins/pastetext/plugin.js config.forcePasteAsPlainText =false //不去除 //是否強(qiáng)制用“&”來(lái)代替“&”plugins/htmldataprocessor/plugin.js config.forceSimpleAmpersand = false; //對(duì)address標(biāo)簽進(jìn)行格式化 plugins/format/plugin.js config.format_address = { element : 'address', attributes : { class : 'styledAddress' } }; //對(duì)DIV標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_div = { element : 'div', attributes : { class : 'normalDiv' } }; //對(duì)H1標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_h2 = { element : 'h2', attributes : { class : 'contentTitle1' } }; //對(duì)H2標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_h3 = { element : 'h3', attributes : { class : 'contentTitle2' } }; //對(duì)H3標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_h2 = { element : 'h4', attributes : { class : 'contentTitle3' } }; //對(duì)H4標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_h2 = { element : 'h5', attributes : { class : 'contentTitle4' } }; //對(duì)H5標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_h2 = { element : 'h6', attributes : { class : 'contentTitle5' } }; //對(duì)H6標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_h2 = { element : 'h7', attributes : { class : 'contentTitle6' } }; //對(duì)P標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_p = { element : 'p', attributes : { class : 'normalPara' } }; //對(duì)PRE標(biāo)簽自動(dòng)進(jìn)行格式化 plugins/format/plugin.js config.format_pre = { element : 'pre', attributes : { class : 'code' } }; //用分號(hào)分隔的標(biāo)簽名字 在工具欄上顯示 plugins/format/plugin.js config.format_tags = 'p;h2;h3;h4;h5;h6;h7;pre;address;div'; //是否使用完整的html編輯模式 如使用,其源碼將包含:<html><body></body></html>等標(biāo)簽 config.fullPage = false; //是否忽略段落中的空字符 若不忽略 則字符將以“”表示 plugins/wysiwygarea/plugin.js config.ignoreEmptyParagraph = true; //在清除圖片屬性框中的鏈接屬性時(shí) 是否同時(shí)清除兩邊的<a>標(biāo)簽 plugins/p_w_picpath/plugin.js config.p_w_picpath_removeLinkByEmptyURL = true; //一組用逗號(hào)分隔的標(biāo)簽名稱,顯示在左下角的層次嵌套中 plugins/menu/plugin.js. config.menu_groups ='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,p_w_picpath,flash,checkbox,radio,textfield,hiddenfield,p_w_picpathbutton,button,select,textarea'; //顯示子菜單時(shí)的延遲,單位:ms plugins/menu/plugin.js config.menu_subMenuDelay = 400; //當(dāng)執(zhí)行“新建”命令時(shí),編輯器中的內(nèi)容 plugins/newpage/plugin.js config.newpage_html = ''; //當(dāng)從word里復(fù)制文字進(jìn)來(lái)時(shí),是否進(jìn)行文字的格式化去除 plugins/pastefromword/plugin.js config.pasteFromWordIgnoreFontFace = true; //默認(rèn)為忽略格式 //是否使用<h2><h3>等標(biāo)簽修飾或者代替從word文檔中粘貼過(guò)來(lái)的內(nèi)容 plugins/pastefromword/plugin.js config.pasteFromWordKeepsStructure = false; //從word中粘貼內(nèi)容時(shí)是否移除格式 plugins/pastefromword/plugin.js config.pasteFromWordRemoveStyle = false; //對(duì)應(yīng)后臺(tái)語(yǔ)言的類型來(lái)對(duì)輸出的HTML內(nèi)容進(jìn)行格式化,默認(rèn)為空 config.protectedSource.push( /<"?["s"S]*?"?>/g ); // PHP Code config.protectedSource.push( //g ); // ASP Code config.protectedSource.push( /(]+>["s|"S]*?<"/asp:[^">]+>)|(]+"/>)/gi ); // ASP.Net Code //當(dāng)輸入:shift+Enter時(shí)插入的標(biāo)簽 config.shiftEnterMode = CKEDITOR.ENTER_P; //可選:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV //可選的表情替代字符 plugins/smiley/plugin.js. config.smiley_descriptions = [ ':)', ':(', ';)', ':D', ':/', ':P', '', '', '', '', '', '', '', ';(', '', '', '', '', '', ':kiss', '' ]; //對(duì)應(yīng)的表情圖片 plugins/smiley/plugin.js config.smiley_p_w_picpaths = [ 'regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif', 'embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif', 'devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif', 'broken_heart.gif','kiss.gif','envelope.gif']; //表情的地址 plugins/smiley/plugin.js config.smiley_path = 'plugins/smiley/p_w_picpaths/'; //頁(yè)面載入時(shí),編輯框是否立即獲得焦點(diǎn) plugins/editingblock/plugin.js plugins/editingblock/plugin.js. config.startupFocus = false; //載入時(shí),以何種方式編輯 源碼和所見(jiàn)即所得 "source"和"wysiwyg" plugins/editingblock/plugin.js. config.startupMode ='wysiwyg'; //載入時(shí),是否顯示框體的邊框 plugins/showblocks/plugin.js config.startupOutlineBlocks = false; //是否載入樣式文件 plugins/stylescombo/plugin.js. config.stylesCombo_stylesSet = 'default'; //以下為可選 config.stylesCombo_stylesSet = 'mystyles'; config.stylesCombo_stylesSet = 'mystyles:/editorstyles/styles.js'; config.stylesCombo_stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js'; //起始的索引值 config.tabIndex = 0; //當(dāng)用戶鍵入TAB時(shí),編輯器走過(guò)的空格數(shù),( ) 當(dāng)值為0時(shí),焦點(diǎn)將移出編輯框 plugins/tab/plugin.js config.tabSpaces = 0; //默認(rèn)使用的模板 plugins/templates/plugin.js. config.templates = 'default'; //用逗號(hào)分隔的模板文件plugins/templates/plugin.js. config.templates_files = [ 'plugins/templates/templates/default.js' ] //當(dāng)使用模板時(shí),“編輯內(nèi)容將被替換”框是否選中 plugins/templates/plugin.js config.templates_replaceContent = true; //主題 config.theme = 'default'; //撤銷的記錄步數(shù) plugins/undo/plugin.js config.undoStackSize =20; // 在 CKEditor 中集成 CKFinder,注意 ckfinder 的路徑選擇要正確。 //CKFinder.SetupCKEditor(null, '/ckfinder/');
要注意為安全考慮默認(rèn)情況下是不允許上傳圖片的,在自己的源代碼中要設(shè)置可以上傳,代碼如下
session_start();if(!empty($_SESSION['USERNAME'])&&!empty($_SESSION['PASSWORD'])){ $_SESSION['KCFINDER']['disabled'] = false; }else{ echo "<script>top.location.> }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。