如何使用TypeScript和Angular 2将插件添加到ng2-ckeditor? [英] How to add plugins to ng2-ckeditor using TypeScript and Angular 2 ?

查看:54
本文介绍了如何使用TypeScript和Angular 2将插件添加到ng2-ckeditor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Justify 插件添加到我的ckeditor,但遗憾的是我无法找到有关如何将插件添加到ng2-ckeditor的任何信息。

I'm trying to add the Justify plugin to my ckeditor, but unfortunately I can't find any information about how I should add plugins to ng2-ckeditor.

此外,我无法找到我应该添加插件的任何目录或配置文件。

Also I'm not able to find any directory or config file where I should add plugins.

我正在使用ng2-ckeditor <使用TypeScript强> 1.0.6 。

I'm using ng2-ckeditor 1.0.6 with TypeScript.

推荐答案

ng-ckeditor使用CKEditor CDN。 此页面向您展示如何从cdn或下载插件并使用本地版本添加外部插件。

ng-ckeditor uses the CKEditor CDN. This page shows you how to add external plugins either from the cdn or downloading the plugin and using a local version.

declare var CKEDITOR: any;

CKEDITOR.plugins.addExternal(
  'uploadimage',
  '../full-all/plugins/divarea/',
  'plugin.js');

这是访问cdn上的完整路径。或者,如果你想从本地文件夹访问它,你可以使路径类似于/users/app/assets/...etc,具体取决于你下载的文件夹所在的位置。

This is accessing the full-all path on the cdn. alternatively if you want to access it from a local folder you would make the path something like /users/app/assets/...etc depending on where your downloaded folder is located.

在你的html中你要添加以下内容: [config] ={extraPlugins:'divarea'}
到你的ckeditor标签。

In your html you'd add the following: [config]="{extraPlugins: 'divarea'}" to your ckeditor tag.

由于崩溃问题,大多数Angular2用例默认需要divarea插件,因此您添加的任何其他插件都需要以逗号分隔的字符串形式插入:

Since most Angular2 use cases need the divarea plugin by default due to crash issues, any other plugins you add need to be inserted as a comma-separated string:

[config] ={extraPlugins:'divarea,uploadimage'}

如果绑定到本地组件变量,例如,它将是这样的:

If binding to a local component variable, for example, it would be like this:

this.ckConfig = {
  height: '250',
  extraPlugins: 'divarea,uploadimage',
  enterMode: '2',
  toolbar: [
    {name: 'document', items: ['Source', '-']},
    {name: 'clipboard', items: ['Undo', 'Redo']},
    {name: 'paragraph', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight']},
    {name: 'insert', items: ['Image']},
    {name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', '-']},
    {name: 'styles', items: ['Font', 'FontSize']},
    {name: 'colors', items: [ 'TextColor' ]},
  ]
};

注意 - 请勿在逗号后留空格。实际上该字符串中没有空格,它必须是'pluginname,pluginname,pluginname' ...等...

NOTE - do not leave a space after the comma. In fact NO spaces in that string, it has to be 'pluginname,pluginname,pluginname' ...etc...

这篇关于如何使用TypeScript和Angular 2将插件添加到ng2-ckeditor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆