ngx-ckeditor5
The CKEditor5 component for angular(2.x,4.x,5.x,6.x).
Before use this component , I think you already use the ckeditor5 on your normal js project.
Installation
-
Import CKEditor js file , and language js file , in angular.json or index.html
"scripts":or
-
Install
ngx-cheditor5
npm i ngx-ckeditor5 --saveorng add ngx-ckeditor5
Sample
Import CkeditorModule
module in your main module:
// app.compoennt.ts;
Then use in in your component :
// app.component.html
// app.compoennt.ts
CKEditorComponent
options
Type | Name | DataType | Allow Null | Default Value | Description |
---|---|---|---|---|---|
Input | type | string | Not | Set the ckeditor type[classic, balloon, decoupled, inline],depend on your imported ckeditor's js file. | |
Input | uploadConfig | {} | Yes | {url:"/",maxSize:"5M", useCkfinder: true} | Default UploadAdapter is CKFinder,but maxSize is invalid,set the useCKFinder to false,use another implementation ,and maxSize is available. |
Input | heading | {} | Yes | if is unset, then default the ckeditor's heading. | |
Input | toolbar | [] | Yes | if is unset then default the ckeditor's toolbar. | |
Input | language | string | Yes | "en" | toolbar's language,depend on your ckeditor's language js file. |
Input | readOnly | boolean | Yes | false | Enable / disable editable. |
Two-way | ngModel | string | Yes | Two-way binding the ckeditor's content. |
Notices
- This component's property
type
and imported js relation:
// classic// ...translations/....js // balloon// ...translations/....js // decoupled// ...translations/....js // inline// ...translations/....js
- If you get exception or have trouble on image upload operation, please check your
uploadConfig.url
,and your server response have to include url property at least,response.url
use to return the uploaded image, and it worked!
Example:
// upload method public Map<String, Object> throws IllegalStateException, IOException{ upload.; Map<String, Object> map = new HashMap<>(); map.; //not null map.; // allow null map.; // allow null map.; // allow null return map; } // request uploaded image method (is in upload method's response.url) public ResponseEntity<byte[]> throws IOException{ File file = new File("/users/chengyuxing/其他/"+name); FileInputStream in = new FileInputStream(file); byte[] buffer = new byte[in.]; in.; in.; HttpHeaders headers = new HttpHeaders(); headers.; return new ResponseEntity<byte[]>(buffer, headers, HttpStatus.OK); }
Update Logs
- 2018-7-16 14:23: fixed the ngModel bug.
- 2018-7-16 18:05: fixed the BalloonEditor's toolbar handle bug.
- 2018-7-18 11:43: update README.md of the uploadAdapter document.