Ckeditor編輯器的配置使用,ckeditor編輯器配置
<span style="font-family:Microsoft YaHei;font-size:12px;"><span style="white-space: pre;"></span> <strong>Ckditor配置使用</strong><span style="white-space: pre;"></span> 【STEP1】:下載Ckeditor3.6.6.2外掛程式包FULL版本(直接官網http://ckeditor.com/):<span style="white-space: pre;"></span> 【STEP2】:將外掛程式解壓之後ctrl+v到WebRoot目錄下(例如:WebRoot/ckeditor3.6.6.2)並精簡 刪除_samples(全部) 、 _source(全部)、lang中的(除了en.js和zh-cn.js的所有)以及非js和css檔案<span style="white-space: pre;"></span> 【STEP3】:在需要引入的jsp分頁檔中添加以下類容<span style="white-space: pre;"></span><form id="detailForm" action="ckeditor_test" method="post"><span style="white-space: pre;"></span> <textarea id="content" name="content"></textarea><span style="white-space: pre;"></span> <input type="submit" value="儲存" id="save" onclick="save()" /><span style="white-space: pre;"></span></form><span style="white-space: pre;"></span><script type="text/javascript" src="ckeditor3.6.6.2/ckeditor.js"></script><span style="white-space: pre;"></span><script type="text/javascript"><span style="white-space: pre;"></span> var editor = null;<span style="white-space: pre;"></span> window.onload = function(){<span style="white-space: pre;"></span> editor = CKEDITOR.replace('content'); //參數‘content’是textarea元素的name屬性值,而非id屬性值<span style="white-space: pre;"></span> }<span style="white-space: pre;"></span></script><span style="white-space: pre;"></span>【STEP4】:在WebRoot/ckeditor3.6.6.2/config.js檔案中可以用覆蓋的方式修改需要的配置資訊<span style="white-space: pre;"></span>【特別提示】:如果需要添加QQ、WangWang或其他的動態gif表徵圖,可以從網上下載 並用匯出工具哦哩哩表情管理器,之後再匯出到相應的檔案夾中<span style="white-space: pre;"></span> 最後,需要修改STEP4中屬性(將相應的圖片名稱逐一添加進去就好了)<span style="white-space: pre;"></span> config.smiley_images = ['broken_heart.gif','kiss.gif','envelope.gif'];</span><span style="font-family:Arial, Helvetica, sans-serif;"></span>
<span style="font-family: Arial, Helvetica, sans-serif;"></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%></span>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>Ckeditor線上編輯器工具的配置使用</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"> </head> <body><form id="detailForm" action="ckeditor_test" method="post"> <textarea id="content" name="content"></textarea> <input type="submit" value="儲存" id="save" onclick="save()" /></form><script type="text/javascript" src="ckeditor3.6.6.2/ckeditor.js"></script><script type="text/javascript"> var editor = null; window.onload = function(){ editor = CKEDITOR.replace('content'); //參數‘content’是textarea元素的name屬性值,而非id屬性值 }</script> </body></html>
CKEDITOR.editorConfig = function( config ){//去掉左下角出現的body和pconfig.removePlugins = 'elementspath';/*//下面的是全部功能配置項,可以更具自己的實際需要進行功能選項進行配置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'], ['Maximize', 'ShowBlocks','-','About']];*//***************************************以下是可以修改的配置項**************************************************//*// config.language = 'zh-cn'; //介面語言,預設為 'en'// 設定寬高 //config.width = 400; //config.height = 400;// config.uiColor = '#AADC6E'; //皮膚背景色設定//config.skin="kama";// 皮膚內建了三種 kama(預設) v2和office2003 (待選) black(來自網路)共四種//config.toolbar = 'Basic'; //對應的表情圖片 plugins/smiley/plugin.jsconfig.smiley_images = [ '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' ]; //重設備選字型.config.font_names = '宋體;楷體_GB2312;新宋體;黑體;隸書;幼圓;微軟雅黑;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana;' ;//工具列是否可以被收縮(即工具列是否可以被隱藏起來) config.toolbarCanCollapse = true; //工具列的位置 config.toolbarLocation ='top';//可選:bottom top(預設) //工具列預設是否展開 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; // 當提交包含有此編輯器的表單時,是否自動更新元素內的資料 config.autoUpdateElement =true; // 設定是使用絕對目錄還是相對目錄,為空白為相對目錄 config.baseHref = '' // 編輯器的z-index值 config.baseFloatZIndex = 10000; //設定快速鍵 config.keystrokes = [ [CKEDITOR.ALT + 121 , 'toolbarFocus' ], //擷取焦點 F10 [CKEDITOR.ALT + 122 , 'elementsPathFocus' ], //元素焦點 F11 [CKEDITOR.SHIFT + 121 ,'contextMenu' ], //文本菜單 F10 [CKEDITOR.CTRL + 90 , 'undo' ], //撤銷 Z [CKEDITOR.CTRL + 89 , 'redo' ], //重做 Y [CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 , 'redo' ], //Z [CKEDITOR.CTRL + 76 , 'link' ], //連結 L [CKEDITOR.CTRL + 66 , 'bold' ], //粗體B [CKEDITOR.CTRL + 73 , 'italic' ], //斜體I [CKEDITOR.CTRL + 85 , 'underline' ], //底線U [CKEDITOR.ALT + 109 ,'toolbarCollapse' ] //- ] //設定快速鍵 可能與瀏覽器快速鍵衝突plugins/keystrokes/plugin.js. config.blockedKeystrokes = [ CKEDITOR.CTRL + 66 //B, CKEDITOR.CTRL + 73 //I, CKEDITOR.CTRL + 85 //U ] //設定編輯內元素的背景色的取值plugins/colorbutton/plugin.js. config.colorButton_backStyle = { element : 'span', styles : { 'background-color' : '#(color)'} } //設定前景色彩的取值 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'; //是否在選擇顏色時顯示“其它顏色”選項plugins/colorbutton/plugin.js config.colorButton_enableMore =false //區塊的前景色彩預設值設定 plugins/colorbutton/plugin.js config.colorButton_foreStyle = { element : 'span', styles : { 'color' : '#(color)' } }; //所需要添加的CSS檔案 在此添加 可使用相對路徑和網站的絕對路徑 config.contentsCss = './contents.css'; //文字方向 config.contentsLangDirection ='rtl'; //從左至右 //CKeditor的設定檔 若不想配置 留空即可 CKEDITOR.replace( 'myfiled', { customConfig : './config.js' } ); //介面編輯框的背景色 plugins/dialog/plugin.js config.dialog_backgroundCoverColor = '#fffefd'; //可設定參考 config.dialog_backgroundCoverColor = 'white' //預設 //背景的不透明度 數值應該在:0.0~1.0 之間plugins/dialog/plugin.js config.dialog_backgroundCoverOpacity =0.5 //移動或者改變元素時 邊框的吸附距離 單位:像素plugins/dialog/plugin.js config.dialog_magnetDistance = 20; //是否拒絕本地拼字檢查和提示 預設為拒絕 目前僅firefox和safari支援plugins/wysiwygarea/plugin.js. config.disableNativeSpellChecker =true //進行表格編輯功能 如:添加行或列 目前僅firefox支援plugins/wysiwygarea/plugin.js config.disableNativeTableHandles =true; //預設為不開啟 //是否開啟 圖片和表格 的改變大小的功能config.disableObjectResizing = true; config.disableObjectResizing= false //預設為開啟 //設定HTML文件類型 config.docType ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22' ; //是否對編輯地區進行渲染plugins/editingblock/plugin.js config.editingBlock = true; //編輯器中斷行符號產生的標籤 config.enterMode =CKEDITOR.ENTER_P; //可選:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV //是否使用HTML實體進行輸出 plugins/entities/plugin.js config.entities = true; //定義更多的實體 plugins/entities/plugin.js config.entities_additional = '#39'; //其中#代替了& //是否轉換一些難以顯示的字元為相應的HTML字元plugins/entities/plugin.js config.entities_greek = true; //是否轉換一些拉丁字元為HTMLplugins/entities/plugin.js config.entities_latin = true; //是否轉換一些特殊字元為ASCII字元 如"This is Chinese:漢語."轉換為"This is Chinese: 漢語."plugins/entities/plugin.js config.entities_processNumerical =false; //添加新組件 config.extraPlugins ='myplugin'; //非預設 僅樣本 //使用搜尋時的高亮色 plugins/find/plugin.js config.find_highlight = { element : 'span', styles: { 'background-color' : '#ff0', 'color' : '#00f' } }; //預設的字型名 plugins/font/plugin.js config.font_defaultLabel = 'Arial'; //字型編輯時的字元集 可以添加常用的中文字元:宋體、楷體、黑體等plugins/font/plugin.js config.font_names = 'Arial;Times NewRoman;Verdana'; //文字的預設式樣 plugins/font/plugin.js config.font_style = { element : 'span', styles : { 'font-family' : '#(family)' }, overrides : [ { element :'font', attributes : { 'face' : null } } ] }; //字型預設大小 plugins/font/plugin.js config.fontSize_defaultLabel = '12px'; //字型編輯時可選的字型大小 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' //設定字型大小時 使用的式樣 plugins/font/plugin.js config.fontSize_style = { element : 'span', styles : { 'font-size' : '#(size)' }, overrides : [ {element : 'font', attributes : { 'size' : null } } ] }; //是否強制複製來的內容去除格式plugins/pastetext/plugin.js config.forcePasteAsPlainText =false//不去除 //是否強制用“&”來代替“&”plugins/htmldataprocessor/plugin.js config.forceSimpleAmpersand = false; //用分號分隔的標籤名字 在工具列上顯示plugins/format/plugin.js config.format_tags ='p;h1;h2;h3;h4;h5;h6;pre;address;div'; //是否使用完整的html編輯模式如使用,其源碼將包含:<html><body></body></html>等標籤 config.fullPage = false; //是否忽略段落中的Null 字元 若不忽略 則字元將以“”表示plugins/wysiwygarea/plugin.js config.ignoreEmptyParagraph = true; //在清除圖片屬性框中的連結屬性時 是否同時清除兩邊的<a>標籤plugins/image/plugin.js config.image_removeLinkByEmptyURL = true; //一組用逗號分隔的標籤名稱,顯示在左下角的層次嵌套中plugins/menu/plugin.js. config.menu_groups='clipboard,form,tablecell,tablecellproperties,tablerow,tablecolumn,table,anchor,link,image,flash,checkbox,radio,textfield,hiddenfield,imagebutton,button,select,textarea'; //顯示子功能表時的延遲,單位:ms plugins/menu/plugin.js config.menu_subMenuDelay = 400; //當執行“建立”命令時,編輯器中的內容plugins/newpage/plugin.js config.newpage_html = ''; //當從word裡複製文字進來時,是否進行文字的格式化去除plugins/pastefromword/plugin.js config.pasteFromWordIgnoreFontFace = true; //預設為忽略格式 //是否使用<h1><h2>等標籤修飾或者代替從word文檔中粘貼過來的內容plugins/pastefromword/plugin.js config.pasteFromWordKeepsStructure = false; //從word中粘貼內容時是否移除格式plugins/pastefromword/plugin.js config.pasteFromWordRemoveStyle =false; //當輸入:shift+Enter時插入的標籤 config.shiftEnterMode = CKEDITOR.ENTER_P; //可選:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV //可選的表情替代字元 plugins/smiley/plugin.js. config.smiley_descriptions = [ ':)', ':(', ';)', ':D', ':/',':P', '', '', '', '', '', '', '', ';(', '', '','', '', '', ':kiss', '' ]; //表情的地址 plugins/smiley/plugin.js config.smiley_path = 'plugins/smiley/images/'; //頁面載入時,編輯框是否立即獲得焦點plugins/editingblock/plugin.js plugins/editingblock/plugin.js. config.startupFocus = false; //載入時,以何種方式編輯 源碼和所見即所得 (WYSIWYG) "source"和"wysiwyg"plugins/editingblock/plugin.js. config.startupMode ='wysiwyg'; //載入時,是否顯示框體的邊框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; //當使用者鍵入TAB時,編輯器走過的空格數,( )當值為0時,焦點將移出編輯框 plugins/tab/plugin.js config.tabSpaces = 0; //預設使用的模板 plugins/templates/plugin.js. config.templates = 'default'; //用逗號分隔的模板檔案plugins/templates/plugin.js. config.templates_files = [ 'plugins/templates/templates/default.js' ] //當使用模板時,“編輯內容將被替換”框是否選中plugins/templates/plugin.js config.templates_replaceContent =true; //主題 config.theme = 'default'; //撤銷的記錄步數 plugins/undo/plugin.js config.undoStackSize =20;// 在 CKEditor 中整合 CKFinder,注意 ckfinder的直接選取要正確。//CKFinder.SetupCKEditor(null, '/ckfinder/'); */};