如何使用 jQuery 适配器将配置信息传递到 CKEditor?

发布于 2024-08-19 17:44:57 字数 576 浏览 2 评论 0原文

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

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

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

这就是我从我所读到的内容中得到的

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

,第一个参数是回调,第二个参数是配置。但这样做并没有改变编辑器。

如何使用jQuery<使用这些配置属性等/strong> 适配器?

I'm using the latest CKeditor with jQuery adapter.

I have successfully got it to work, and display.

However, as I am completely new to CKeditor, how do I pass in config variables using the jQuery method?

This is what I've got

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

I think from what I've read, the first argument is meant to be a callback, and the 2nd the config. But doing this has not changed the editor at all.

How do I use these config properties etc using the jQuery adapter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

醉殇 2024-08-26 17:44:57

我已经使用这段代码完成了这一点。希望这有帮助。

这是 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);   }

I have accomplished this using this code. Hopefully this helps.

Here is the html:

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

and here is the 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);   }
平安喜乐 2024-08-26 17:44:57

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

$('textarea#my').ckeditor($.noop, {
    property: 'value'
});

I passed an empty function...

$('textarea#my').ckeditor($.noop, {
    property: 'value'
});
放赐 2024-08-26 17:44:57
jQuery(function(){
        var config = {
            toolbar:
            [
                ['Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Undo', 'Redo', '-', 'SelectAll'],
                ['UIColor']
            ]
        };      
        jQuery('#textAreaElement').ckeditor(config);
    });
jQuery(function(){
        var config = {
            toolbar:
            [
                ['Bold', 'Italic', 'Underline', '-', 'NumberedList', 'BulletedList', '-', 'Undo', 'Redo', '-', 'SelectAll'],
                ['UIColor']
            ]
        };      
        jQuery('#textAreaElement').ckeditor(config);
    });
何其悲哀 2024-08-26 17:44:57
var config = {
    toolbar:
    [
        ['Source','-','Save','NewPage','Preview','-','Templates'],
        ['Maximize', 'ShowBlocks','-','About']
    ],
    coreStyles_bold: { element : 'b', overrides : 'strong' }
};

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

var config = {
    toolbar:
    [
        ['Source','-','Save','NewPage','Preview','-','Templates'],
        ['Maximize', 'ShowBlocks','-','About']
    ],
    coreStyles_bold: { element : 'b', overrides : 'strong' }
};

Simply add the respective config object, above I added coreStyles_bold, All I did is change the "=" from the CK API documentation to a ":"

你另情深 2024-08-26 17:44:57
 $(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;
     });
 });
 $(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;
     });
 });
若相惜即相离 2024-08-26 17:44:57

有一个官方文档,请参阅 jQuery 适配器

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

  • 编辑器准备好时执行的回调函数。
  • 特定于创建的编辑器实例的配置选项:
    $( 'textarea' ).ckeditor({
        uiColor: '#9AB8F3'
    });

There is an official documentation for it, see jQuery Adapter

The ckeditor() method accepts two optional parameters:

  • A callback function to be executed when the editor is ready.
  • Configuration options specific to the created editor instance:
    $( 'textarea' ).ckeditor({
        uiColor: '#9AB8F3'
    });
愚人国度 2024-08-26 17:44:57

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

Not sure if this is a new feature of CKEDITOR, but just want to share my solution (in case it helps anyone looking for this now):

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

... and my config looks like this (simply copied the default 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' ] }
    ];  
};    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文