
一、使用方法:
1、在页面<head>中引入ckeditor核心文件ckeditorjs
<script type="text/javascript" src="ckeditor/ckeditorjs"></script>
<textarea id="TextArea1" cols="20" rows="2" class="ckeditor"></textarea>
如果是ASPNET环境,也可用服务器端控件<TextBox>
<asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" class="ckeditor"></asp:TextBox>
注意在控件中加上 class="ckeditor" 。
3、将相应的控件替换成编辑器代码
<script type="text/javascript">
CKEDITORreplace('TextArea1');
//如果是在ASPNET环境下用的服务器端控 件<TextBox>
CKEDITORreplace('tbContent');
//如 果<TextBox>控件在母版页中,要这样写
CKEDITORreplace('<%=tbContentClientIDReplace("_","$") %>');
</script>
4、配置编辑器
ckeditor的配置都集中在 ckeditor/configjs 文件中,下面是一些常用的配置参数:
// 界面语言,默认为 'en'
configlanguage = 'zh-cn';
// 设置宽高
configwidth = 400;
configheight = 400;
// 编辑器样式,有三种:'kama'(默认)、'office2003'、'v2'
configskin = 'v2';
// 背景颜色
configuiColor = '#FFF';
// 工具栏(基础'Basic'、全能'Full'、自定义)plugins/toolbar/pluginjs
configtoolbar = 'Basic';
configtoolbar = 'Full';
这将配合:
configtoolbar_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']
];
//工具栏是否可以被收缩
configtoolbarCanCollapse = true;
//工具栏的位置
configtoolbarLocation = 'top';//可选:bottom
//工具栏默认是否展开
configtoolbarStartupExpanded = true;
// 取消 “拖拽以改变尺寸”功能 plugins/resize/pluginjs
configresize_enabled = false;
//改变大小的最大高度
configresize_maxHeight = 3000;
//改变大小的最大宽度
configresize_maxWidth = 3000;
//改变大小的最小高度
configresize_minHeight = 250;
//改变大小的最小宽度
configresize_minWidth = 750;
// 当提交包含有此编辑器的表单时,是否自动更新元素内的数据
configautoUpdateElement = true;
// 设置是使用绝对目录还是相对目录,为空为相对目录
configbaseHref = ''
// 编辑器的z-index值
configbaseFloatZIndex = 10000;
//设置快捷键
configkeystrokes = [
[ CKEDITORALT + 121 /F10/, 'toolbarFocus' ], //获取焦点
[ CKEDITORALT + 122 /F11/, 'elementsPathFocus' ], //元素焦点
[ CKEDITORSHIFT + 121 /F10/, 'contextMenu' ], //文本菜单
[ CKEDITORCTRL + 90 /Z/, 'undo' ], //撤销
[ CKEDITORCTRL + 89 /Y/, 'redo' ], //重做
[ CKEDITORCTRL + CKEDITORSHIFT + 90 /Z/, 'redo' ], //
[ CKEDITORCTRL + 76 /L/, 'link' ], //链接
[ CKEDITORCTRL + 66 /B/, 'bold' ], //粗体
[ CKEDITORCTRL + 73 /I/, 'italic' ], //斜体
[ CKEDITORCTRL + 85 /U/, 'underline' ], //下划线
[ CKEDITORALT + 109 /-/, 'toolbarCollapse' ]
]
//设置快捷键 可能与浏览器快捷键冲突 plugins/keystrokes/pluginjs
configblockedKeystrokes = [
CKEDITORCTRL + 66 /B/,
CKEDITORCTRL + 73 /I/,
CKEDITORCTRL + 85 /U/
]
//设置编辑内元素的背景色的取值 plugins/colorbutton/pluginjs
configcolorButton_backStyle = {
element : 'span',
styles : { 'background-color' : '#(color)' }
}
//设置前景色的取值 plugins/colorbutton/pluginjs
configcolorButton_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/pluginjs
configcolorButton_enableMore = false
//区块的前景色默认值设置 plugins/colorbutton/pluginjs
configcolorButton_foreStyle = {
element : 'span',
styles : { 'color' : '#(color)' }
};
//所需要添加的CSS文件 在此添加 可使用相对路径和网站的绝对路径
configcontentsCss = '/contentscss';
//文字方向
configcontentsLangDirection = 'rtl'; //从左到右
//CKeditor的配置文件 若不想配置 留空即可
CKEDITORreplace( 'myfiled', { customConfig : '/configjs' } );
//界面编辑框的背景色 plugins/dialog/pluginjs
configdialog_backgroundCoverColor = '#fffefd'; //可设置参考
configdialog_backgroundCoverColor = 'white' //默认
//背景的不透明度 数值应该在:00~10 之间 plugins/dialog/pluginjs
configdialog_backgroundCoverOpacity = 05
//移动或者改变元素时 边框的吸附距离 单位:像素 plugins/dialog/pluginjs
configdialog_magnetDistance = 20;
//是否拒绝本地拼写检查和提示 默认为拒绝 目前仅firefox和safari支持 plugins/wysiwygarea/pluginjs
configdisableNativeSpellChecker = true
//进行表格编辑功能 如:添加行或列 目前仅firefox支持 plugins/wysiwygarea/pluginjs
configdisableNativeTableHandles = true; //默认为不开启
//是否开启 和表格 的改变大小的功能 configdisableObjectResizing = true;
configdisableObjectResizing = false //默认为开启
//设置HTML文档类型
configdocType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 10 Transitional//EN" ">
cheditor与ckfinder的集成使用
1,将ckeditor解压打开,打开_Samples,将ckeditor文件夹拷贝项目中的根目录下,把bin放在根目录下
2,将ckfinder解压,ckfinder文件夹拷贝项目中的根目录下,把bin放在根目录下,把_sample,_source,help文件夹删除掉,(注:没有用)
3,在ckeditor文件下找到configjs 打开,找到
在CKEDITOReditorCongig=function(config)
{
//填写以下内容,,flash路径
configuiColor = '#F7F8F9'
configscayt_autoStartup = false
configlanguage = 'zh-cn'; //中文
configfilebrowserBrowseUrl = 'ckfinder/ckfinderhtml';
configfilebrowserImageBrowseUrl = 'ckfinder/ckfinderhtmlType=Images';
configfilebrowserFlashBrowseUrl = 'ckfinder/ckfinderhtmlType=Flash';
configfilebrowserUploadUrl = 'ckfinder/core/connector/aspx/connectoraspxcommand=QuickUpload&type=Files';
configfilebrowserImageUploadUrl = 'ckfinder/core/connector/aspx/connectoraspxcommand=QuickUpload&type=Images';
configfilebrowserFlashUploadUrl = 'ckfinder/core/connector/aspx/connectoraspxcommand=QuickUpload&type=Flash';
};
4,在ckfinder文件下找到configascx文件,打开
1)把public overrider bool ChekcAuthentication(){return false;改为:return true;}
2)public overrider void SetConfig(){BaseUrl = "~/ckfinder/userfiles/";}
5,在页面中head标签内写入:
<script type="text/javascript" src="ckeditor/ckeditorjs" ></script>
<script type="text/javascript" src="ckfinder/ckfinderjs"></script>
如果有母版页,在母版页中写
--注:单纯的配置,6,7可以不要,但是一旦要入数据库中,就要配置67步骤
6,在Defaultaspx页面中,写入<%@Page ValidateRequest="false"%>
7,在webconfig文件中,在systemweb下写 <>
用php把数据库查询出来,放在fck编辑器里的模板内容文件里就OK了
include("fckeditorphp");
$sBasePath="editor/";//编辑器所在目录
$oFCKeditor=new FCKeditor('content'); // 创建一个fckeditor对象
$oFCKeditor->BasePath=$BasePath;
$oFCKeditor->Height='700px';
$oFCKeditor->Width='80%';
$oFCKeditor->Value=$arr['zp_content']; // 设定表单初始值 在这里显示数据库内容
$oFCKeditor->Create(); // 调用方法
《Flask Web开发》这本书中用于博客文章编辑使用的是十分简单的Markdown编辑器。为了让搭建的博客更加User Friendly。我运用了 Flask-ckeditor 来作为博客网站的文章编辑器。
在文章的编辑页面中,发觉一直无法在 edit_posthtml 页面加载得到 flask-ckeditor 。
经过一番的检查,后来发现是在 html 文件中没有加入上述的导入 JavaScript 语句,所以导致 flask-editor 无法加载显示出来。将上述语句加入到 edit_posthtml 文件后就可以加载显示了:
京东在电脑端获取CK需要浏览器进开发者模式抓取ck,方法如下:
1、下载Alook浏览器,各大应用商店有且免费。
2、Alook浏览器地址栏输入mjdcom,进入京东网站。
3、登录自己的账号,建议用手机验证码方式,进入浏览器菜单,选择开发者工具。
4、选择cookies并拷贝值,发送到对应的服务即可。
一、使用方法:
1、在页面<head>中引入ckeditor核心文件ckeditorjs
<script type="text/javascript" src="ckeditor/ckeditorjs"></script>
2、在使用编辑器的地方插入HTML控件<textarea>
<textarea id="TextArea1" cols="20" rows="2" class="ckeditor"></textarea>
如果是ASPNET环境,也可用服务器端控件<TextBox>
<asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" class="ckeditor"></asp:TextBox>
注意在控件中加上 class="ckeditor" 。
3、将相应的控件替换成编辑器代码
<script type="text/javascript">
CKEDITORreplace('TextArea1');
//如果是在ASPNET环境下用的服务器端控 件<TextBox>
CKEDITORreplace('tbContent');
//如 果<TextBox>控件在母版页中,要这样写
CKEDITORreplace('<%=tbContentClientIDReplace("_","$") %>');
</script>
以上就是关于如何设置ckeditor的编辑器,在哪里设置全部的内容,包括:如何设置ckeditor的编辑器,在哪里设置、TextArea使用了ckeditor编辑器后,怎么用JS在Textarea中自动追加值、ckeditor 使用方法等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)