CKEditor New Instance always unloaded

久未见 提交于 2020-01-13 11:26:07

问题


I'm using CKEditor in my Angular app and have a view that reloads my CKEditor instance every time users access a new model.

I'm using the following JS to initialize the editor:

var initEditor = function() {
  $('.js-editor-wrap').html("<textarea id='editor'></textarea>");

  var editor = CKEDITOR.replace('editor', {});

  editor.on('loaded', function() {
    console.log('editor loaded');
  });

  editor.on('instanceReady', function() {
    console.log('instance ready')
  });
}

And the following to destroy the editor:

var destroyEditor = function() {
  if (CKEDITOR.instances['editor']) {
    CKEDITOR.instances['editor'].destroy(true);
    $('#editor').off().remove();
  }
}

The first editor initialization works just as expected, but subsequent initializations create an editor instance with a status of "unloaded" that never triggers the "loaded" or "instanceReady" events. I'm not seeing any errors in the console.

Any ideas what might be causing this?

This is definitely a similar issue to the following, but different enough that I think it warrants its own question: CKEditor instance already exists


回答1:


After a LOT more digging and thanks to the jsfiddle from Jey Dwork, I figured out where the issue is here. My CKEditor config file adds a couple of plugins that referenced lang files that were improperly named. For some reason, when these plugins were included together they caused the editor to not fully load during a second initialization.

Removing the lang files and reference to them in the plugin definitions resolved the issue. It's too bad that there wasn't some error that was triggered around this. All's well that ends well though.



来源:https://stackoverflow.com/questions/28818099/ckeditor-new-instance-always-unloaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!