Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create multiple ckeditor instances ("default" is already registered)

I have a page (using kendo-ui if that makes any difference) that has three text areas that need to be made into editors. The problem is that I can only create one ckeditor instance. No matter how I try to create new instances, I get this error:

uncaught exception: [CKEDITOR.resourceManager.add] The resource name "default" is already registered.

Google-ing for that specific error message only lands me one result that doesn't really tell me anything about it.

This is what I have tried so far after searching various issues like mine on Stack Overflow:

--Deleting instances of the editor if they are not being used /are hidden

var editor = CKEDITOR.instances['createText'];
if (editor) { editor.destroy(true); }
$('#editTemplate').ckeditor();

--creating all the instances in document ready

    $('#createText').ckeditor();
    $('#editText').ckeditor();
    $('#editTemplate').ckeditor();

--using class names instead of jquery to spawn the instances

    <textarea id="editText" class="ckeditor"></textarea>

--not using jquery and creating instances with

CKEDITOR.replace('createText');

No matter what I do I cannot create more than one editor, I just get "The resource name "default" is already registered." I've even tried to manually remove default from resourceManager, but there is no

CKEDITOR.resourceManager.remove

At this point I am completely out of ideas, and nothing I search for seems to address this exact issue. I am using ckeditor version 4.4.4

like image 769
CountMurphy Avatar asked Oct 25 '25 04:10

CountMurphy


1 Answers

just had this problem myself, here's a solution I found:
In config.js:

// For some reason having multiple on one page runs this config function twice, causing an error
//  Therefore we need to check if this already exists first
//  It should now work with multiple on one page
if (!CKEDITOR.stylesSet.registered['default']) {
    CKEDITOR.stylesSet.add('default', [
        ...,
    ]);
}

config.stylesSet = 'default';
like image 161
user15952954 Avatar answered Oct 26 '25 17:10

user15952954



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!