21

我正在使用最新的CKeditorjQuery 适配器

我已经成功地让它工作并显示。

但是,由于我对CKeditor完全陌生,如何使用jQuery方法传入配置变量?

这就是我所拥有的

$( '#input-content' ).ckeditor('', {
    toolbar: 'basic'
});

我认为从我读过的内容来看,第一个参数是回调,第二个是配置。但是这样做并没有改变编辑器。

如何使用jQuery适配器使用这些配置属性等?

4

7 回答 7

19

我已经使用此代码完成了此操作。希望这会有所帮助。

这是html:

<textarea id="txtMessage" class="editor"></textarea>

这是javascript:

try {
        var config =
            {
                height: 180,
                width: 515,
                linkShowAdvancedTab: false,
                scayt_autoStartup: true,
                enterMode: Number(2),
                toolbar_Full: [['Styles', 'Bold', 'Italic', 'Underline', 'SpellChecker', 'Scayt', '-', 'NumberedList', 'BulletedList'],
                                ['Link', 'Unlink'], ['Undo', 'Redo', '-', 'SelectAll']]

            };

        $('textarea.editor').ckeditor(config);   }
于 2011-03-13T21:33:05.643 回答
12

我传递了一个空函数...

$('textarea#my').ckeditor($.noop, {
    property: 'value'
});
于 2010-02-04T01:29:48.797 回答
8
jQuery(function(){
        var config = {
            toolbar:
            [
                ['Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Undo', 'Redo', '-', 'SelectAll'],
                ['UIColor']
            ]
        };      
        jQuery('#textAreaElement').ckeditor(config);
    });
于 2011-06-28T19:01:23.797 回答
2
var config = {
    toolbar:
    [
        ['Source','-','Save','NewPage','Preview','-','Templates'],
        ['Maximize', 'ShowBlocks','-','About']
    ],
    coreStyles_bold: { element : 'b', overrides : 'strong' }
};

只需添加相应的配置对象,上面我添加了 coreStyles_bold,我所做的只是将 CK API 文档中的“=”更改为“:”

于 2010-06-01T23:31:21.830 回答
2
 $(document).ready(function(){
     $('.reply').click(
     function(event){
         // Event click Off Default
         event.preventDefault();
         // CKEditor
         $(function(){
             var config = {toolbar:[['Bold', 'Italic', '-', 'Link', 'Unlink']]};
            //<?php /*echo"var config = {toolbar:[['Bold', 'Italic', '-', 'Link', 'Unlink']]};" ;*/ ?>
             // DOM class = "cke"
             $('textarea.cke').ckeditor(function(){}, config);                
         });
         return false;
     });
 });
于 2011-01-21T13:47:40.927 回答
1

它有一个官方文档,请参阅jQuery Adapter

ckeditor() 方法接受两个可选参数:

  • 编辑器准备就绪时要执行的回调函数。
  • 特定于创建的编辑器实例的配置选项:
    $('textarea').ckeditor({
        uiColor: '#9AB8F3'
    });
于 2014-01-03T12:56:38.823 回答
0

不确定这是否是 CKEDITOR 的新功能,但只是想分享我的解决方案(以防它帮助现在正在寻找这个的任何人):

$("textarea.youreditor").ckeditor
(
    {
        customConfig: "/path/to/custom/config.js"
    }
);

...我的配置看起来像这样(只是复制了默认的 config.js):

CKEDITOR.editorConfig = function(config)
{
    config.toolbar_Full =
    [
        { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
        { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] },
        { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
        { name: 'colors', items : [ 'TextColor','BGColor' ] }
    ];  
};    
于 2012-10-05T22:49:55.863 回答