| 热度: |
什么是CKEditor?
CKEditor即大名鼎鼎的FCKeditor终于在最近发布新版本了,与增加版本号不同,这次完全把它改名了,更名为CKeditor。这 应该是和它的开发公司CKSource的名字有关吧,该公司的另一个产品为CKFinder(一个Ajax文件管理器),这次可能为了保持一致,将FCK 更改为CK,但是版本号继承了下来,为CKeditor3.0版。
FCKeditor项目已转向下一代版本命名CKEditor的产品开发,基本上采用Fckeditor并对部分进行了重新设计和采用新技术以改善 结构。最新版本是ckeditor 3.0 beta 2,这是一个全功能的测试版,它包含了我们按预期准备发布的第一个ckeditor 3.0正式版的所有功能。你现在就可以享受它令人吃惊的性能、充分无障碍和强大而可扩展的javascript API,有着你过去常常使用的fckeditor的大部分功能。
好了言归正传,我们看看CKEditor在PHP中如何安装和配置,非常简单。
1.从我们的网站http://ckeditor.com.cn上下载CKEditor的最新版本。CKEditor 3.0.1, released on 16 October 2009。
2.将下载的文件解压, 然后将4M多的文件减肥:可以删掉_samples、_source、_tests这三个无用的文件夹;打开lang文件夹,干掉除 _languages.js、en.js、zh-cn.js以外的所有文件;如果你不用office2003和v2两种皮肤,可以把skin目录下的这两 个目录也都干掉。这样下来就1M都不到了。
3.将整理好的下载文件上传到你网站根目录下的“ckeditor”文件夹里。
注意:你也可以 将这些文件放在你网站的其他任何一个地方,默认为“ckeditor”。
例如:
http://www.example.com/ckeditor/_samples/index.html
…
<script type=”text/javascript” src=”/ckeditor/ckeditor.js”></script>
</head>
但是,实际上,CKEditor仍然是使用一个文本区域来传递它的数据到服务 器上,这个文本区域对使用者来说是不可见的,所以,你必需创建并编辑一个实例,首先创建一个实例:
CKEDITOR.replace( ’editor1’ );
</script>
window.onload = function()
{
CKEDITOR.replace( ’editor1’ );
};
</script>
$editor_data = $_POST[ ’editor1’ ];
?>
var editor_data = CKEDITOR.instances.editor1.getData();
</script>
<head>
<title>Sample – CKEditor</title>
<script type=”text/javascript” src=”/ckeditor/ckeditor.js”></script>
</head>
<body>
<form method=”post”>
<p>
My Editor:<br />
<textarea name=”editor1″><p>Initial value.</p></textarea>
<script type=”text/javascript”>
CKEDITOR.replace( ’editor1’ );
</script>
</p>
<p>
<input type=”submit” />
</p>
</form>
</body>
</html>这里主要介绍了CKEditor安装与配置的 基础的步骤(在PHP中),让我们初步体验了FCKEditor在线编辑器的下一代的优良表现。
config.js 的配置, 可以修改textarea大小和编辑器所包含的功能
/*
Copyright (c) 2003-2010, 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.width =’80%’; //宽度
config.height = 300; //高度
config.toolbar = ‘Full’;
//工具栏
config.skin = ‘v2′;
config.toolbar_Full =
[
['Source','-','Bold','Italic','Underline','Strike'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink'],
['Image','Table','HorizontalRule','SpecialChar'],
['Format','Font','FontSize'],
['TextColor','BGColor'],
['RemoveFormat']
];
};
/*
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']
];
*/