UNPKG

1.94 kBMarkdownView Raw
1# Angular2 - CKEditor component
2
3Use the [CKEditor (4.x)](http://ckeditor.com/) wysiwyg in your Angular2 application.
4
5**Demo** : https://embed.plnkr.co/hnB0R3/
6
7### <a name="install"></a>Installation
8
9- Include CKEditor javascript files in your application :
10```
11<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
12```
13
14- Install ng2-ckeditor
15 - JSPM : ```jspm install npm:ng2-ckeditor```
16 - NPM : ```npm install ng2-ckeditor```
17
18- SystemJS Config :
19```javascript
20 SystemJS.config({
21 "map": {
22 "ng2-ckeditor": "npm:ng2-ckeditor",
23 },
24 "packages": {
25 "ng2-ckeditor": {
26 "main": "lib/index.js",
27 "defaultExtension": "js",
28 },
29 }
30 });
31```
32
33- Please consider usage of the plugin `divarea` of CKEditor (see [Issues](#issues))
34
35### <a name="sample"></a>Sample
36
37Include `CKEditorModule` in your main module :
38
39```javascript
40import { CKEditorModule } from 'ng2-ckeditor';
41
42@NgModule({
43 // ...
44 imports: [
45 CKEditorModule
46 ],
47 // ...
48})
49export class AppModule { }
50```
51
52Then use it in your component :
53
54```javascript
55import { Component } from '@angular/core';
56
57@Component({
58 selector: 'sample',
59 template: `
60 <ckeditor
61 [(ngModel)]="ckeditorContent"
62 [config]="{uiColor: '#99000'}"
63 (change)="onChange($event)"
64 (ready)="onReady($event)"
65 (blur)="onBlur($event)"
66 debounce="500">
67 </ckeditor>
68 `
69})
70export class Sample{
71 constructor(){
72 this.ckeditorContent = `<p>My HTML</p>`;
73 }
74}
75```
76
77### <a name="config"></a>Configuration
78
79* `config` : The configuration object for CKEditor see http://docs.ckeditor.com/#!/api/CKEDITOR.config
80* `debounce` : You can add a delay (ms) when updating ngModel
81
82### <a name="issues"></a>Issues
83- [with ngFor](https://github.com/chymz/ng2-ckeditor/issues/23)
84- [[CKEDITOR] Error code: editor-destroy-iframe](https://github.com/chymz/ng2-ckeditor/issues/24)
85
86### <a name="licence"></a>Licence
87See `LICENCE` file