ckeditor+ckfinder使用


http://ckeditor.com/download/ 下載ckeditor  http://ckfinder.com/download下載ckfinder

如果您不願意在官方下載 可以在CSDN上下載http://download.csdn.net/detail/accesszhb/4468438

一.ckeditor 精簡
精簡前:4.52M
精簡后:853K
1.刪除_samples和_source文件夾,分別為示例文件和未壓縮源程序
2.刪除lang文件夾下除zh-cn.js,en.js下的所有語言文件.根據需要刪除
3.刪除根目錄下的changes.html(更新列表),install.html(安裝指向),license.html(使用許可).
4.刪除skins目錄下不需要的皮膚.我一般用V2(簡單.朴素)
//如果只保留V2則必須在config.js中指定皮膚

二.ckeditor 相關文件配置路徑
1./ckeditor.js
核心文件,調用需加載
2./config.js 配置文件,參數配置均在此完成

三.ckeditor應用(.net環境)
1.引用js腳本
<script
type=”text/javascript”
src=”ckeditor/ckeditor.js”></script>

2.將相應的控件替換成編輯器代碼
<textarea ID="Content" Rows="10" ></textarea>
<script type=”text/javascript”>

 if (CKEDITOR.instances['Content']) {
        CKEDITOR.remove(CKEDITOR.instances['Content']);
    }//如果實例已存在
    var editor = CKEDITOR.replace('Content');//實例化
    editor.BasePath = "Scripts/ckfinder/";
    CKFinder.setupCKEditor(editor, "/ckfinder/");//相對路徑

</script>

四.ckeditor配置(config.js配置文件)

以下只是必要的配置 其他更多配置屬性在其它博客上查詢這里就不具體羅列

CKEDITOR.editorConfig = function (config) {
    config.language = 'zh-cn';
    config.toolbar = 'Basic';
    config.toolbar = 'Full';
    config.toolbar_Full = [
    ['Source', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
    ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', ], 
    //['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', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
       '/',
    ['Styles', 'Format', 'Font', 'FontSize'],
    ['TextColor', 'BGColor']
    ];
    
    config.filebrowserBrowseUrl = '/Scripts/ckfinder/ckfinder.html'; //上傳文件時瀏覽服務文件夾
    config.filebrowserImageBrowseUrl = '/Scripts/ckfinder/ckfinder.html?Type=Images'; //上傳圖片時瀏覽服務文件夾
    config.filebrowserFlashBrowseUrl = 'http://www.cnblogs.com/Scripts/ckfinder/ckfinder.html?Type=Flash';  //上傳Flash時瀏覽服務文件夾
    config.filebrowserUploadUrl = '/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files'; //上傳文件按鈕(標簽) 
    config.filebrowserImageUploadUrl = 'http://www.cnblogs.com/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images'; //上傳圖片按鈕(標簽) 
    config.filebrowserFlashUploadUrl = 'http://www.cnblogs.com/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'; //上傳Flash按鈕(標簽)
};

五、如果遇到此報錯:未能加載類型“CKFinder.Connector.Connector”。

在WebSite添加引用CKFinder.dll 在你下載的ckfinder—>bin—>DeBug目錄下

六、CKEditor的取值和賦值

<script type="text/javascript">      CKEDITOR.replace('Content', { toolbar: 'Basic' }); </script>

修改為:

<script type="text/javascript">      var myeditor=CKEDITOR.replace('Content', { toolbar: 'Basic' }); </script>

myeditor.document.getBody().getText(); //取文本形式的值 
myeditor.document.getBody().getHtml(); //取包含html代碼的值 

//賦值

CKEDITOR.instances['Content'].setData('內容');//從此方法可以得出結論CKEDITOR.instances['Content']就是獲取ckeditor的實例

如果要賦值那么就是 myeditor.setData("需要賦值的內容");

http://wenku.baidu.com/view/7c3e98738e9951e79b892757.html 此博文有該控件的使用方法

七、去除上傳圖片功能中的瀏覽服務器按鈕

打開ckeditor\plugins\image\dialogs\image.js文件,搜索browseServer,找到該詞第一次出現的位置,在后面添加,style:'display:none;'。 

第二個browseServer位置是第二菜單:超鏈接的“瀏覽服務器”按鈕,也可按上種辦法去掉

http://www.cnblogs.com/guanhp2013/archive/2012/03/06/2381203.html 圓友此控件.net下使用的博文


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM