How to install CKEDITOR to angular project and add plugins

前端 未结 2 1245
一生所求
一生所求 2020-12-18 10:19

I am trying to install ckeditor to my angular project. I already tried installing ckeditor4-angular via npm but was unable to find a way to add plugins like the

2条回答
  •  庸人自扰
    2020-12-18 11:25

    After step 7

    Add ckeditor code to package.json "dependencies": { ... "@ckeditor/ckeditor5-angular": "^1.1.2", ... }

    Step 8:

    npm install

    step 9:

    In app.module.ts file you can add

    import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
    import { FormsModule } from '@angular/forms'; 
    import { ReactiveFormsModule } from '@angular/forms'; 
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        AppRoutingModule,
        FormsModule,
        ReactiveFormsModule,
        CKEditorModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    

    step 10: In file tsconfig.json add allowJs: ture

    "compilerOptions": {
        "allowJs": true,
    }
    

    step 11:

    Import CKEditor to your component:

    import * as ClassicEditor from '../../assets/js/ck-editor-math-type/ckeditor.js';
    
    ...
    export class CkeditComponent implements OnInit {
    
        public Editor = ClassicEditor;
    
        public model = {
            editorData: '

    Hello, world!

    ' }; }

    step 12:

    Add it too your template.html

    
    

提交回复
热议问题