ckeditor+ckfinder配置及使用(asp,asp.net环境)

ckeditor+ckfinder配置及使用(asp,asp.net环境)

首先到CKEditor.com/download 和CkFinder.com/download下载文件

将压缩文件解压得到ckeditor和ckfinder两个文件

将两个文件夹复制到项目根目录下

1、在页面<head>中引入ckeditor核心文件ckeditor.js

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>

2、在使用编辑器的地方插入HTML控件<textarea>

<textarea id="TextArea1" cols="20" rows="2" class="ckeditor"></textarea>

如果是ASP.NET环境,也可用服务器端控件<TextBox>

<asp:TextBox ID="tbContent" runat="server" TextMode="MultiLine" class="ckeditor"></asp:TextBox>

注意在控件中加上 class="ckeditor" 。

3、将相应的控件替换成编辑器代码

<script type="text/javascript">
    CKEDITOR.replace('TextArea1');
//如果是在ASP.NET环境下用的服务器端控件<TextBox>
    CKEDITOR.replace('tbContent');
//如果<TextBox>控件在母版页中,要这样写
    CKEDITOR.replace('<%=tbContent.ClientID.Replace("_","$") %>');
</script>

4、配置编辑器

    ckeditor的配置都集中在 ckeditor/config.js 文件中,下面是一些常用的配置参数:

// 界面语言,默认为 'en'

    config.language = 'zh-cn';

// 设置宽高

    config.width = 400;

    config.height = 400;

// 编辑器样式,有三种:'kama'(默认)、'office2003'、'v2'

    config.skin = 'v2';

// 背景颜色

    config.uiColor = '#FFF';

// 工具栏(基础'Basic'、全能'Full'、自定义)plugins/toolbar/plugin.js

    config.toolbar = 'Basic';

    config.toolbar = 'Full';

    这将配合:
    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']
    ];

    //工具栏是否可以被收缩
    config.toolbarCanCollapse = true;

    //工具栏的位置
    config.toolbarLocation = 'top';//可选:bottom

    //工具栏默认是否展开
    config.toolbarStartupExpanded = true;

// 取消 “拖拽以改变尺寸”功能 plugins/resize/plugin.js
    config.resize_enabled = false;

    //改变大小的最大高度

    config.resize_maxHeight = 3000;

    //改变大小的最大宽度
    config.resize_maxWidth = 3000;

    //改变大小的最小高度
    config.resize_minHeight = 250;

    //改变大小的最小宽度
    config.resize_minWidth = 750;
// 当提交包含有此编辑器的表单时,是否自动更新元素内的数据
    config.autoUpdateElement = true;

    //设置编辑内元素的背景色的取值 plugins/colorbutton/plugin.js.
    config.colorButton_backStyle = {
        element : 'span',
        styles : { 'background-color' : '#(color)' }
    }

     //界面编辑框的背景色 plugins/dialog/plugin.js
    config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; //可设置参考
    config.dialog_backgroundCoverColor = 'white' //默认

    //背景的不透明度 数值应该在:0.0~1.0 之间 plugins/dialog/plugin.js
    config.dialog_backgroundCoverOpacity = 0.5

     //编辑器中回车产生的标签
    config.enterMode = CKEDITOR.ENTER_P; //可选:CKEDITOR.ENTER_BR或CKEDITOR.ENTER_DIV

       //是否转换一些特殊字符为ASCII字符 如"This is Chinese: 汉语."转换为"This is Chinese: &#27721;&#35821;." plugins/entities/plugin.js
    config.entities_processNumerical = false;

       //默认的字体名 plugins/font/plugin.js
    config.font_defaultLabel = 'Arial';

     //文字的默认式样 plugins/font/plugin.js
    config.font_style = {
        element   : 'span',
        styles   : { 'font-family' : '#(family)' },
        overrides : [ { element : 'font', attributes : { 'face' : null } } ]
    };

    //字体默认大小 plugins/font/plugin.js
    config.fontSize_defaultLabel = '12px';

        //是否强制复制来的内容去除格式 plugins/pastetext/plugin.js
    config.forcePasteAsPlainText =false //不去除

      //对address标签进行格式化 plugins/format/plugin.js
    config.format_address = { element : 'address', attributes : { class : 'styledAddress' } };

    //是否使用完整的html编辑模式 如使用,其源码将包含:<html><body></body></html>等标签
    config.fullPage = false;

       //从word中粘贴内容时是否移除格式 plugins/pastefromword/plugin.js
    config.pasteFromWordRemoveStyle = false;

    //对应后台语言的类型来对输出的HTML内容进行格式化,默认为空
    config.protectedSource.push( /<\?[\s\S]*?\?>/g );   // PHP Code
    config.protectedSource.push( //g );   // ASP Code
    config.protectedSource.push( /(]+>[\s|\S]*?<\/asp:[^\>]+>)|(]+\/>)/gi );   // ASP.Net Code

     //可选的表情替代字符 plugins/smiley/plugin.js.
    config.smiley_descriptions = [
        ':)', ':(', ';)', ':D', ':/', ':P',
        '', '', '', '', '', '',
        '', ';(', '', '', '', '',
        '', ':kiss', '' ];

    //对应的表情图片 plugins/smiley/plugin.js
    config.smiley_images = [
        'regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif',
        'embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif',
        'devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif',
        'broken_heart.gif','kiss.gif','envelope.gif'];

    //表情的地址 plugins/smiley/plugin.js
    config.smiley_path = 'plugins/smiley/images/';

    //页面载入时,编辑框是否立即获得焦点 plugins/editingblock/plugin.js plugins/editingblock/plugin.js.
    config.startupFocus = false;

    //载入时,以何种方式编辑 源码和所见即所得 "source"和"wysiwyg" plugins/editingblock/plugin.js.
    config.startupMode ='wysiwyg';

    //载入时,是否显示框体的边框 plugins/showblocks/plugin.js
    config.startupOutlineBlocks = false;

    //是否载入样式文件 plugins/stylescombo/plugin.js.
    config.stylesCombo_stylesSet = 'default';
    //以下为可选
    config.stylesCombo_stylesSet = 'mystyles';
    config.stylesCombo_stylesSet = 'mystyles:/editorstyles/styles.js';
    config.stylesCombo_stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js';

      //默认使用的模板 plugins/templates/plugin.js.
    config.templates = 'default';

    //用逗号分隔的模板文件plugins/templates/plugin.js.
    config.templates_files = [ 'plugins/templates/templates/default.js' ]

    //当使用模板时,“编辑内容将被替换”框是否选中 plugins/templates/plugin.js
    config.templates_replaceContent = true;

    //主题
    config.theme = 'default';

    //撤销的记录步数 plugins/undo/plugin.js
    config.undoStackSize =20;

// 在 CKEditor 中集成 CKFinder,注意 ckfinder 的路径选择要正确。
//CKFinder.SetupCKEditor(null, '/ckfinder/');

二、 一些使用技巧

1、在页面中即时设置编辑器

<script type="text/javascript">
//示例1:设置工具栏为基本工具栏,高度为70
    CKEDITOR.replace('<%=tbLink.ClientID.Replace("_","$") %>',
        { toolbar:'Basic', height:70 });
//示例2:工具栏为自定义类型
    CKEDITOR.replace( 'editor1',
         {
             toolbar :
             [
//加粗     斜体,     下划线      穿过线      下标字        上标字
                ['Bold','Italic','Underline','Strike','Subscript','Superscript'],
//数字列表          实体列表            减小缩进    增大缩进
                ['NumberedList','BulletedList','-','Outdent','Indent'],
//左对齐             居中对齐          右对齐          两端对齐
                ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
//超链接 取消超链接 锚点
                ['Link','Unlink','Anchor'],
//图片    flash    表格       水平线            表情       特殊字符        分页符
                ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/',
//样式       格式      字体    字体大小
                ['Styles','Format','Font','FontSize'],
//文本颜色     背景颜色
                ['TextColor','BGColor'],
//全屏           显示区块
                ['Maximize', 'ShowBlocks','-']
             ]
         }
    );
</script>

=================

精简CKeditor

在部署到Web服务器上时,下列文件夹和文件都可以删除:

    /_samples :示例文件夹;

    /_source :未压缩源程序;

    /lang文件夹下除 zh-cn.js、en.js 以外的文件(也可以根据需要保留其他语言文件);

    根目录下的 changes.html(更新列表),install.html(安装指向),license.html(使用许可);

    /skins 目录下不需要的皮肤,一般用V2(简单,朴素) ,如果只保留V2则必须在config.js中指定皮肤。

注意:ASP中使用ckfinder上传图片功能必须安装ASPJpeg组件,并将组件给everyone赋所有权限。

把 function CheckAuthentication() { return false; }

修改成 function CheckAuthentication() { return true; }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ext-2.3.0+CKEditor 3.0.1+ckfinder_asp_1.4配置详解 一、去http://cksource.com/下载这两个东西 二、去http://www.extjs.com/下载ext-2.3.0 三、将ext-2.3.0、CKEditor 3.0.1、ckfinder_asp_1.4,取出解压后的文件夹,真接放到站点根目录,目录结构为: WEBROOT |--ckeditor |--finder |--ext-2.3.0 |--js |--css 修改ckeditor目录下的config.js如下: CKEDITOR.editorConfig = function( config ) { config.language = 'zh-cn'; //配置语言 config.uiColor = 'DFE8F6'; config.skin = 'office2003'; config.height = 320; config.width = '100%'; config.font_names = '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;'+ config.font_names ; config.filebrowserUploadUrl = 'ckfinder/core/connector/asp/connector.asp?command=QuickUpload&type=Files'; config.filebrowserImageUploadUrl = 'ckfinder/core/connector/asp/connector.asp?command=QuickUpload&type=Images'; config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/asp/connector.asp?command=QuickUpload&type=Flash'; config.filebrowserWindowWidth = '1000'; config.filebrowserWindowHeight = '700' }; 在js目录中加入ExtCkeditor.js: /**************************************************** * CKEditor Extension *****************************************************/ Ext.form.CKEditor = function(config){ this.config = config; Ext.form.CKEditor.superclass.constructor.call(this, config); }; Ext.extend(Ext.form.CKEditor, Ext.form.TextArea, { onRender : function(ct, position){ if(!this.el){ this.defaultAutoCreate = { tag: "textarea", autocomplete: "off" }; } Ext.form.TextArea.superclass.onRender.call(this, ct, position); CKEDITOR.replace(this.id, this.config.CKConfig); }, setValue : function(value){ Ext.form.TextArea.superclass.setValue.apply(this,[value]); CKEDITOR.instances[this.id].setData( value ); }, getValue : function(){ CKEDITOR.instances[this.id].updateElement(); return Ext.form.TextArea.superclass.getValue(this); }, getRawValue : function(){ CKEDITOR.instances[this.id].updateElement();

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值