如何在使用jquery版本时设置ckeditor配置?

时间:2011-05-24 23:49:10

标签: javascript jquery

我正在使用cqueditor的jquery版本,如下所示:

$(".textarea").ckeditor();

我需要指定工具栏按钮,但我不知道如何。我在stackoverflow或使用谷歌找到的所有帮助都是旧的javascript ckeditor版本,或者我不知道如何使用它与jquery(上面的代码)。

另外,如何指定css文件位置,以便ckeditor加载我的css并以与在网站上显示相同的方式显示数据?

任何人都可以帮忙解决这个问题?

3 个答案:

答案 0 :(得分:3)

$(".textarea").ckeditor(function() { 
   // Instance loaded callback.
}, {
   // Config here.
});

答案 1 :(得分:1)

不确定这是否是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' ] }
    ];  
};    

**我在这里交叉发布我的解决方案:How do I pass in config info to CKEditor using the jQuery adapter?

答案 2 :(得分:0)

这就是我使用jQuery设置配置的方法....

var config = {
              toolbar: [ /* Whatever toolbars you wish go here. */ ],
              height: 250,
              width: 500,
              align: "left",
              contentsCss: ["body { /* Style your body any way you like */ } otherCSSStuff { /* Style away. */} "]
              /*and whatever other options you wish to config... */
             };

$( 'textarea.editor' ).ckeditor( config, function() { /* Your callback function. */ } );