【问题标题】:How to set ckeditor config when using the jquery version?使用jquery版本时如何设置ckeditor config?
【发布时间】:2011-05-24 23:49:10
【问题描述】:

我用的是ckeditor的jquery版本,像这样:

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

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

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

谁能帮忙解决这个问题?

【问题讨论】:

    标签: javascript jquery


    【解决方案1】:
    $(".textarea").ckeditor(function() { 
       // Instance loaded callback.
    }, {
       // Config here.
    });
    

    【讨论】:

    • +1,尽管将回调作为第一个参数是一个相当糟糕的设计选择。但这不是你的错。 ;)
    • 谢谢,工作,3分钟后将接受答案,当倒计时冷却时:))
    【解决方案2】:

    不确定这是否是 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?

    【讨论】:

      【解决方案3】:

      这就是我使用 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. */ } );
      

      【讨论】:

      • 你确定吗?在大多数其他地方,它说回调是第一个参数,配置对象是第二个参数。然而,我也看到了根本不包含回调的示例。那么哪个是正确的呢?现在,我正在传递一个配置对象,它根本不会影响编辑器(基本上,CKEditor 忽略了我所有的配置选项)。
      猜你喜欢
      • 1970-01-01
      • 2011-10-03
      • 2017-01-08
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多