天天看點

php中如何使用KindEditor編輯器

前不久做了一個小網站,釋出新聞的時候,同僚推薦了一個好的富文本編輯器kindeditor,覺得用的挺友善,今天在這總結一下,簡單的介紹一下kindeidtor使用,這裡隻将核心的一些配置說明列在下面,首先說一下準備工作:

1.下載下傳:Kindeditor編輯器(是一個檔案夾,在這重命名為eidtor)将其放在網站根目錄下面,

2.引用:在同一級目錄中建立一個news.php檔案,用來引用該編輯器,下面是news.php中的内容

<html>
<head>
<script type="text/javascript" charset="utf-8" src="./editor/kindeditor.js"></script>  
		<script type="text/javascript">
			KE.show({
				id : 'content_1',
				items:['source', '|', 'fullscreen', 'undo', 'redo',  'copy', 'paste',
				'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				'superscript', '|', 'selectall', '-',
				'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
				'italic', 'underline', 'strikethrough',  '|', 'image',
				'advtable', '|', 'about']
				
			});
		</script>		
</head>
<body>
 <textarea id='content_1' name="content" style="width:727px;height:350px;"> </textarea>	
</body>
</html>
           

該段代碼中第一段js腳本主要是用來引用editor編輯器js檔案(必須的),第二段js代碼主要設定編輯器的樣式,裡面的東西大家可以根據需要增減,每一項的具體含義我在這不多說,大家可以參考網上的一些說明

3.配置eidtor編輯器,富文本編輯器有一個重要的功能是可以上傳一些圖檔,使用之前需要進行配置,打開eidtor檔案夾下

php檔案夾下的upload_json.php檔案,進行配置

php中如何使用KindEditor編輯器

editor預設的将圖檔放到了editor檔案夾下的attached檔案夾下,大家可以根據需要更改,同時也可以限制上傳檔案的大小,和檔案類型.

經過上面的設定,就可以使用圖文并茂的編輯器了。