I installed CKEditor for Angular following this guide: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/angular.html
I imported CKEditorModule to my Module and added it to my imports.
import { CKEditorModule } from "@ckeditor/ckeditor5-angular";
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
CKEditorModule
],
providers: [],
bootstrap: [AppComponent]
})
In my component, I added the ClassicEditor build and assigned it to a public property.
import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
export class AppComponent {
title = 'AngularCkeditor';
public Editor = ClassicEditor;
}
Finally I'm using the ckeditor tag in my html template:
<ckeditor [editor]="Editor" data="<p>Hello, world!</p>"></ckeditor>
It works pretty well!
Now I want to add some plugins to it but there is no explanation how to achieve that.
So I followed the default guide for installing plugins: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/installing-plugins.html
For example I tried to install the Alignment plugin:
npm install --save @ckeditor/ckeditor5-alignment
Then I imported the plugin to my component and tried to load it.
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';
ClassicEditor.builtinPlugins = [
Alignment
];
When I do this I keep stucked with an error:
TypeError: Cannot read property 'getAttribute' of null
It's so strange because I followed the same guide to edit the configuration of CKEditor, and it works perfectly.
ClassicEditor.defaultConfig = {
toolbar: {
items: [
'heading',
'|',
'alignment',
'bold',
'italic',
'|',
'bulletedList',
'numberedList',
'|',
'link',
'blockQuote',
'|',
'imageUpload',
'|',
'undo',
'redo'
]
},
image: {
toolbar: [
'imageStyle:full',
'imageStyle:side',
'|',
'imageTextAlternative'
]
},
language: 'en'
};