如何在Angular 2中正确调用CKEDITOR.plugins.addExternal?

时间:2017-07-14 06:48:10

标签: angular ckeditor

在角度2中(通过ng2-ckeditor)我正在尝试使用{cnitor cdn无法提供的CKEditor-ShowProtected-Plugin

这就是我尝试遵循的原因:

import { CKEditorModule } from 'ng2-ckeditor';
declare var CKEDITOR:any;
CKEDITOR.plugins.addExternal('showprotected', '../assets/ckeditor-showprotected-plugin', 'plugin.js');

这是我的CKEDITOR_CONFIG

private CKEDITOR_CONFIG = {
 'extraPlugins': 'showprotected', 
  ...
}

然而,CKEDITOR.plugins.addExternal(..)似乎没有被考虑在内,因为ckeditor仍在尝试从cdn中获取ckeditor-showprotected-plugin

error_handler.js:54 EXCEPTION: [CKEDITOR.resourceManager.load] 
Resource name "showprotected" was not found at "https://cdn.ckeditor.com/4.5.11/full/../assets/ckeditor-showprotected-plugin?t=G87Eplugin.js".

1 个答案:

答案 0 :(得分:0)

我没有机会在Angular 2中实现,但它在Angular 1.x中在CKEDITOR.editorConfig = function( config ) { //end of configurations add following lines config.extraPlugins += (config.extraPlugins.length == 0 ? '' : ',') + '<your_plugin_name>'; config.allowedContent = true; }

中做了以下更改
ckeditor/plugins/

并在^\s{3}(?=\S)文件夹

中添加插件依赖项