自訂ckeditor編輯器的工具樣式

來源:互聯網
上載者:User
IT程式員開發必備-各類資源下載清單,史上最全IT資源,個人收藏總結。

//字型. config.font_names = ‘宋體;楷體_GB2312;新宋體;黑體;隸書;幼圓;微軟雅黑;Arial; Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana;’ ; //工具按鈕. config.toolbar= [ ['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.width = 500; //高度 config.height = 400; //皮膚 config.skin=’v2′; //等等… … [/css]

1.在ckeditor\config.js中的CKEDITOR.editorConfig裡加入以下需要自訂的配置代碼

/*Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.For licensing, see LICENSE.html or http://ckeditor.com/license*/CKEDITOR.editorConfig = function( config ){// Define changes to default configuration here. For example:// config.language = 'fr';// config.uiColor = '#AADC6E';//下面的是自己寫的        config.language = 'zh-cn'; // 配置語言       config.uiColor = '#FFF'; // 背景顏色       config.width = 'auto'; // 寬度       config.height = '300px'; // 高度       config.skin = 'office2003';// 介面v2,kama,office2003       config.toolbar = 'MyToolbar';// 工具列風格(基礎'Basic'、全能'Full'、自訂)plugins/toolbar/plugin.js       config.toolbarCanCollapse = false;// 工具列是否可以被收縮       config.resize_enabled = false;// 取消 “拖拽以改變尺寸”功能 plugins/resize/plugin.js              //自訂的工具列           config.toolbar_MyToolbar =       [           ['Source','-','Save','Preview','Print'],           ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],           ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],           ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],           '/',           ['Styles','Format'],           ['Bold','Italic','Strike'],           ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],           ['Link','Unlink','Anchor'],           ['Maximize','-','About']       ];   };
2.在jsp頁面中定義某個ckeditor的樣式

示範<ck:editor>的標籤的作用 <br>    <%    Map<String, String> attr = new HashMap<String, String>();attr.put("rows", "8");attr.put("cols", "50");request.setAttribute("attr",attr);   CKEditorConfig settings = new CKEditorConfig();      settings.addConfigValue("width","200");      settings.addConfigValue("toolbar","[[ 'Source', '-', 'Bold', 'Italic' ]]");      request.setAttribute("settings",settings);%>     <!-- 這裡basePath和editor是必選項,其中          editor   : is the name of the internal textarea element.           basePath : contains the path to the main CKEditor directory.        -->    <ck:editor editor="editor1" config="<%=settings%>"  textareaAttributes="${attr}" basePath="${pageContext.request.contextPath}/ckeditor/" value="please input content here!"></ck:editor>    <ck:editor editor="editor2"   textareaAttributes="${attr}" basePath="${pageContext.request.contextPath}/ckeditor/" value="please input content here!"></ck:editor>    <input type="button" value="editor2" onclick="getData()" >

IT程式員開發必備-各類資源下載清單,史上最全IT資源,個人收藏總結。



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.