最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

最新版CKEditor的配置方法及插件(Plugin)編寫示例

 更新時(shí)間:2017年03月23日 23:10:56   作者:屈偉  
本文記錄配置CKEditor過程,并以文章分頁插件為例,簡(jiǎn)要CKEditor Plugin編寫過程。 從官網(wǎng)http://ckeditor.com/download下載最新版CKEditor,解壓

FCKEditor重寫了js框架,并改名為CKEditor。第一次在CKEditor網(wǎng)站上看到demo界面,就被CKEditor友好的界面和強(qiáng)大的功能所震撼。毫無疑問,CKEditor是當(dāng)前互聯(lián)網(wǎng)上最優(yōu)秀的開源多媒體HTML編輯器。

本文記錄配置CKEditor過程,并以文章分頁插件為例,簡(jiǎn)要CKEditor Plugin編寫過程。 從官網(wǎng)http://ckeditor.com/download下載最新版CKEditor,解壓。

1. 調(diào)用CKEditor方法

在頁面里加載核心js文件:<script type="text/javascript" src="ckeditor/ckeditor.js"></script>,按常規(guī)方式放置textarea,如:< textarea id="editor1″ name="editor1″ rows="10" cols="80">初始化html內(nèi)容</textarea>
然后在textarea后面寫js:<script type="text/javascript">CKEDITOR.replace('editor1');</script>

其他調(diào)用方式可參考 _samples 目錄下的示例。

2. 配置個(gè)性化工具欄

ckeditor默認(rèn)的工具欄中很多不常用,或者相對(duì)中文來說不適用??赏ㄟ^配置默認(rèn)工具欄方式實(shí)現(xiàn),最簡(jiǎn)潔的方法是直接修改配置文件 config.js 我的config.js內(nèi)容如下:

CKEDITOR.editorConfig = function( config )
 {
 // Define changes to default configuration here. For example:
 // config.language = 'fr';
 config.uiColor = '#ddd';
 config.toolbar = 'Cms';
 config.toolbar_Cms =
 [
 ['Source','-'],
 ['Cut','Copy','Paste','PasteText','PasteFromWord','-'],
 ['Undo','Redo','-','Find','Replace','RemoveFormat'],['Link','Unlink','Anchor'],
 ['Image','Flash','Table','HorizontalRule', '-'],['Maximize'],
 '/',
 ['Bold','Italic','Underline','Strike','-'],
 ['FontSize'],['TextColor','BGColor'],
 ['NumberedList','BulletedList','-','Outdent','Indent','pre'],
 ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
 ['PageBreak', 'Page']
 ];
 config.filebrowserUploadUrl = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
 config.fontSize_sizes = '10/10px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;28/28px;32/32px;48/48px;';
 config.extraPlugins = 'apage';
 };

3. 將編輯器內(nèi)文字修改為14px (默認(rèn)12px,對(duì)中文顯示不太好看)

1)可視化編輯里默認(rèn)字體大?。盒薷母夸浵?contents.css,將body中font-size: 12px改為 font-size: 14px

2)源代碼視圖字體大?。盒薷膕kins\kama\editor.css,在最后加一句:.cke_skin_kama textarea.cke_source { font-size:14px; }

4. 插件編寫流程和實(shí)例代碼

1) 在plugins目錄新建文件夾apage,在apage下新建文件:plugin.js 內(nèi)容如下:

CKEDITOR.plugins.add( 'apage',
 {
 init : function( editor )
 {
 // Add the link and unlink buttons.
 editor.addCommand( 'apage', new CKEDITOR.dialogCommand( 'apage' ) );
 editor.ui.addButton( 'Page',
 {
 //label : editor.lang.link.toolbar,
 label : “Page",
 //icon: 'images/anchor.gif',
 command : 'apage'
 } );
 //CKEDITOR.dialog.add( 'link', this.path + 'dialogs/link.js' );
 CKEDITOR.dialog.add( 'apage', function( editor )
 {
 return {
 title : '文章分頁',
 minWidth : 350,
 minHeight : 100,
 contents : [
 {
 id : 'tab1',
 label : 'First Tab',
 title : 'First Tab',
 elements :
 [
 {
 id : 'pagetitle',
 type : 'text',
 label : '請(qǐng)輸入下一頁文章標(biāo)題<br />(不輸入默認(rèn)使用當(dāng)前標(biāo)題+數(shù)字形式)'
 }
 ]
 }
 ],
 onOk : function()
 {
 editor.insertHtml("[page="+this.getValueOf( 'tab1', 'pagetitle' )+"]“);
 }
 };
 } );
 },
 requires : [ 'fakeobjects' ]
 } );

2)在toolbar中加一項(xiàng)Page,并在配置中聲明添加擴(kuò)展插件 config.extraPlugins = 'apage'; 有兩種方法實(shí)現(xiàn),方法一是直接在config.js中添加,示例本文上面的config.js示例代碼; 方法二:在引用CKEditor的地方加配置參數(shù),如:

CKEDITOR.replace( 'editor1', { extraPlugins : 'examenLink', toolbar : [ ['Undo','Redo','-','Cut','Copy','Paste'], ['ExamenLink','Bold','Italic','Underline',], ['Link','Unlink','Anchor','-','Source'],['Page'] ] });

此時(shí)你應(yīng)該看到編輯器里多了一個(gè)空白的按鈕了。

解決空白按鈕的方法有二:

方法1:修改插件代碼,plugin,將icon定義為一個(gè)存在的圖標(biāo)。

方法2:讓編輯顯示Label的文字。需要加在放編輯器的頁面里加css(注意:cke_button_apage的名稱與實(shí)際保持一致。)

<style type="text/css">
 .cke_button_apage .cke_icon { display : none !important; }
 .cke_button_apage .cke_label { display : inline !important; }
 </style>

如果你的分頁只需要插入一個(gè)分頁符,不需要像本文需要填寫標(biāo)題,那更簡(jiǎn)單,只需要修改插件代碼即可。請(qǐng)?jiān)诩t麥軟件團(tuán)隊(duì)wiki上查看本文提到的所有代碼: http://www.teamwiki.cn/js/ckeditor_config_plugin

CKEditor 配置及插件編寫示例

CKEditor 配置

config.js

CKEDITOR.editorConfig = function( config )
{
	// Define changes to default configuration here. For example:
	// config.language = 'fr';
	config.uiColor = '#ddd';
 
	config.toolbar = 'Cms';
 config.toolbar_Cms =
 [
 ['Source','-'],
 ['Cut','Copy','Paste','PasteText','PasteFromWord','-'],
 ['Undo','Redo','-','Find','Replace','RemoveFormat'],['Link','Unlink','Anchor'],
	['Image','Flash','Table','HorizontalRule', '-'],['Maximize'],
 '/',
 ['Bold','Italic','Underline','Strike','-'],
	['FontSize'],['TextColor','BGColor'],
 ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
 ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
 ['PageBreak','-','Page']
 ];
 
	config.filebrowserUploadUrl = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
	config.fontSize_sizes = '10/10px;12/12px;14/14px;16/16px;18/18px;20/20px;22/22px;24/24px;28/28px;32/32px;48/48px;';
 
	config.extraPlugins = 'apage';
};

CKEditor 分頁插件1:到提示輸入下一頁文章標(biāo)題

CKEDITOR.plugins.add( 'apage',
{
	init : function( editor )
	{
		// Add the link and unlink buttons.
		editor.addCommand( 'apage', new CKEDITOR.dialogCommand( 'apage' ) );
		editor.ui.addButton( 'Page',
			{
				//label : editor.lang.link.toolbar,
				label : "Page",
				//icon: 'images/anchor.gif',
				command : 'apage'
			} );
		//CKEDITOR.dialog.add( 'link', this.path + 'dialogs/link.js' );
		CKEDITOR.dialog.add( 'apage', function( editor )
		{		
			return {
				title : '文章分頁',
				minWidth : 350,
				minHeight : 100,
				contents : [
					{
						id : 'tab1',
						label : 'First Tab',
						title : 'First Tab',
						elements :
						[
							{
								id : 'pagetitle',
								type : 'text',
								label : '請(qǐng)輸入下一頁文章標(biāo)題<br />(不輸入默認(rèn)使用當(dāng)前標(biāo)題+數(shù)字形式)'
							}
						]
					}
				],
				onOk : function()
					{
						editor.insertHtml("[page="+this.getValueOf( 'tab1', 'pagetitle' )+"]");
					}
			};
		} );
	},
 
	requires : [ 'fakeobjects' ]
} );

CKEditor 分頁插件2:直接插入分頁符

因?yàn)榫庉嬈鞯哪J(rèn)轉(zhuǎn)碼,使用過程中需要將『page』中的『』去掉。

CKEDITOR.plugins.add( 'apage',
{
	var cmd = {
		exec:function(editor){
			editor.insertHtml("[[『page』]]");
		}
	}
	init : function( editor )
	{
		// Add the link and unlink buttons.
		editor.addCommand( 'apage', cmd );
		editor.ui.addButton( 'Page',
			{
				//label : editor.lang.link.toolbar,
				label : "Page",
				//icon: 'images/anchor.gif',
				command : 'apage'
			} );		
	},
 
	requires : [ 'fakeobjects' ]
} );

相關(guān)文章

  • 免費(fèi)開源百度編輯器(UEditor)使用方法

    免費(fèi)開源百度編輯器(UEditor)使用方法

    UEditor是一個(gè)開源免費(fèi)的編輯器,由百度web前端研發(fā)部開發(fā)所見即所得富文本web編輯器,具有輕量,可定制,注重用戶體驗(yàn)等特點(diǎn),開源基于BSD協(xié)議,允許自由使用和修改代碼
    2014-05-05
  • dedecms ckeditor編輯器添加鏈接默認(rèn)新窗口打開的修改方法

    dedecms ckeditor編輯器添加鏈接默認(rèn)新窗口打開的修改方法

    最近使用了dedecms ckeditor編輯器,發(fā)現(xiàn)每次都是當(dāng)前頁打開,對(duì)用戶瀏覽造成一定的麻煩,所以特改成新窗口打開,這里腳本之家小編為大家分享下
    2014-07-07
  • jsp fckeditor 上傳中文圖片亂碼問題的解決方法

    jsp fckeditor 上傳中文圖片亂碼問題的解決方法

    徹底解決fckeditor(jsp版)上傳中文圖片亂碼問題,我這里用的編碼是utf-8的,這里用的fckeditor 是2.6的,fckeditor.java包是2.3的
    2009-02-02
  • FCKeditor + SyntaxHighlighter 讓代碼高亮著色插件

    FCKeditor + SyntaxHighlighter 讓代碼高亮著色插件

    FCKeditor是現(xiàn)在最為流行的開源編輯器,SyntaxHighlighter是一個(gè)用JS實(shí)現(xiàn)的代碼高亮顯示插件,F(xiàn)CKeditor + SyntaxHighlighter 讓代碼高亮著色,可以最小化修改您的程序?qū)崿F(xiàn)效果
    2014-06-06
  • 百度UEditor修改右下角統(tǒng)計(jì)字?jǐn)?shù)包含html樣式

    百度UEditor修改右下角統(tǒng)計(jì)字?jǐn)?shù)包含html樣式

    百度UEditor修改右下角統(tǒng)計(jì)字?jǐn)?shù)默認(rèn)只統(tǒng)計(jì)前臺(tái)所見的文字個(gè)數(shù),如何讓右下角統(tǒng)計(jì)字?jǐn)?shù)包含html樣式,需要的朋友可以參考下
    2014-07-07
  • KindEditor 編輯器 v3.5.1 修改版

    KindEditor 編輯器 v3.5.1 修改版

    最近剛認(rèn)識(shí)了KindEditor,感覺挺好用,花了點(diǎn)時(shí)間做了些修改。如果您有更好的建議,歡迎大家一起討論。
    2010-09-09
  • xhEditor編輯器入門基礎(chǔ)

    xhEditor編輯器入門基礎(chǔ)

    在線HTML編輯器就是在線編輯HTML代碼的工具,它經(jīng)常被應(yīng)用于留言板留言、論壇發(fā)貼、Blog編寫日志或等需要用戶輸入HTML的地方,是Web應(yīng)用的常用模塊之一。
    2010-12-12
  • asp.net 為FCKeditor開發(fā)代碼高亮插件實(shí)現(xiàn)代碼

    asp.net 為FCKeditor開發(fā)代碼高亮插件實(shí)現(xiàn)代碼

    昨天已經(jīng)將BlogEngine的可視化編輯器換成了FCKeditor,作為一個(gè)程序員,在博客中插入代碼是很重要的一塊。網(wǎng)上現(xiàn)有的都是修改FCKeditor的fckeditorcode_gecko.js和fckeditorcode_ie.js以達(dá)到InsertCode的目的。這個(gè)方法非常麻煩,當(dāng)要使用FCKeditor新版本時(shí)都要重新修改這兩個(gè)文件,非常影響我們的效率。
    2008-08-08
  • fckeditor asp版本的文件重命名

    fckeditor asp版本的文件重命名

    最近不得不研究FCKEDITOR,而且是ASP版本。對(duì)其文件上傳后的重命名,很郁悶。下面記錄我修改的過程,部分函數(shù)來自網(wǎng)絡(luò)。
    2009-08-08
  • FCKeditorAPI 手冊(cè) js操作獲取等

    FCKeditorAPI 手冊(cè) js操作獲取等

    FCKeditorAPI 手冊(cè) js操作控制,獲取等函數(shù)代碼,使用網(wǎng)頁編輯器的朋友可以參考下。
    2011-01-01

最新評(píng)論

额尔古纳市| 周宁县| 万荣县| 铜陵市| 龙川县| 宁夏| 福建省| 上虞市| 淮安市| 宁海县| 卢龙县| 龙江县| 无锡市| 抚州市| 日喀则市| 烟台市| 申扎县| 永昌县| 六枝特区| 宁远县| 武平县| 成都市| 射阳县| 高唐县| 拜城县| 东光县| 米易县| 靖安县| 吴堡县| 裕民县| 沂源县| 河源市| 江安县| 雷山县| 南乐县| 濮阳县| 花莲市| 虞城县| 正蓝旗| 南充市| 庆云县|