|
|
5 days ago | |
|---|---|---|
| .. | ||
| bundles | 5 days ago | |
| esm2015 | 5 days ago | |
| esm5 | 5 days ago | |
| fesm2015 | 5 days ago | |
| fesm5 | 5 days ago | |
| LICENSE | 5 days ago | |
| README.md | 5 days ago | |
| ckbutton.directive.d.ts | 5 days ago | |
| ckeditor.component.d.ts | 5 days ago | |
| ckeditor.module.d.ts | 5 days ago | |
| ckgroup.directive.d.ts | 5 days ago | |
| index.d.ts | 5 days ago | |
| ng2-ckeditor.d.ts | 5 days ago | |
| ng2-ckeditor.metadata.json | 5 days ago | |
| package.json | 5 days ago | |
Use the CKEditor (4.x) wysiwyg in your Angular application.
Include CKEditor javascript files in your application :
<script src="https://cdn.ckeditor.com/4.10.1/full/ckeditor.js"></script>
Install ng2-ckeditor
jspm install npm:ng2-ckeditornpm install ng2-ckeditoryarn add ng2-ckeditorSystemJS Config :
System.config({
map: {
'ng2-ckeditor': 'npm:ng2-ckeditor',
},
packages: {
'ng2-ckeditor': {
main: 'lib/index.js',
defaultExtension: 'js',
},
},
});
Please consider usage of the plugin divarea of CKEditor (see Issues)
Include CKEditorModule in your main module :
import { CKEditorModule } from 'ng2-ckeditor';
import { FormsModule } from '@angular/forms';
@NgModule({
// ...
imports: [CKEditorModule, FormsModule],
// ...
})
export class AppModule {}
Then use it in your component :
import { Component } from '@angular/core';
@Component({
selector: 'sample',
template: `
<ckeditor
[(ngModel)]="ckeditorContent"
[config]="{uiColor: '#99000'}"
[readonly]="false"
(change)="onChange($event)"
(editorChange)="onEditorChange($event)" <!-- CKEditor change event -->
(ready)="onReady($event)"
(focus)="onFocus($event)"
(blur)="onBlur($event)"
(contentDom)="onContentDom($event)"
(fileUploadRequest)="onFileUploadRequest($event)"
(fileUploadResponse)="onFileUploadResponse($event)"
(paste)="onPaste($event)"
(drop)="onDrop($event)"
debounce="500">
</ckeditor>
`,
})
export class Sample {
ckeditorContent: string = '<p>Some html</p>';
}
config : The configuration object for CKEditor see http://docs.ckeditor.com/#!/api/CKEDITOR.configdebounce : You can add a delay (ms) when updating ngModelreadonly : Enabled / disable readonly on editorYou can use the following directives to add custom buttons to CKEditor's toolbar and organize them into groups. For more info about CKEditor's Toolbar API refer to http://docs.ckeditor.com/#!/api/CKEDITOR.ui
<ckbutton> : Note that the name and command attributes are mandatory for this one.
<ckeditor
[(ngModel)]="ckeditorContent">
<ckbutton [name]="'saveButton'"
[command]="'saveCmd'"
(click)="save($event)"
[icon]="'save.png'"
[label]="'Save Document'"
[toolbar]="'clipboard,1'">
</ckbutton>
</ckeditor>
<ckgroup> : Can be used to organize multiple buttons into groups.
<ckeditor
[(ngModel)]="ckeditorContent">
<ckgroup
[name]="'documenthandling'"
[previous]="'1'">
<ckbutton .... ></ckbutton>
<ckbutton .... ></ckbutton>
</ckgroup>
</ckeditor>
See LICENSE file