27
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
import Base64UploadAdapter from '@ckeditor/ckeditor5-upload/src/adapters/base64uploadadapter';

enter image description here Getting ckeditor 5 duplicate modules error. Anyone can help me. Thanks in Advance.

Mr. Chhatrola
  • 411
  • 1
  • 6
  • 10

6 Answers6

21

It's because you are importing the plugin with the build! In order to add plugins, you have to make a personnal build. Please read this page to know more about it: ckeditor offical documentation. They even have an official online builder that does all the work for you: ckeditor online builder. Once you created it, you have to import the editor just as you have done before on line 2, but instead of writing from "@ckeditor/ckeditor5-build-classic" you have to write from "adress of the build folder of your personnal build".

I hope it helped you.

2Who
  • 5
  • 4
Aime Aine
  • 272
  • 1
  • 6
11

I had this problem when I tried to add CKEditor and a plugin separately. the easiest way is go to CKEditor Online Builder and choose what plugins and toolbar items you need then after five steps the code that you need to work with is generated.

Then you can use the file named ckeditor.js in build folder and this is almost all that you need.

1- Add CKEditorModule

@NgModule({
  imports: [CKEditorModule],
...
}

2- Add the CKEditor tag to your template

<ckeditor
   [editor]="Editor"
   [(ngModel)]="notification.body"
   (ready)="onReady($event)"
   [config]="config"
></ckeditor>

3- import the customized CKEditor js file(that you should copy from build folder in downloaded customized CKEditor)in your component

import * as customEditor from './ckeditor';

4- Create a property in your component

 public Editor = customEditor;

5- Add your configs

 ngOnInit() {
   
    this.config = {
      toolbar: {
        items: [
          'heading',
          '|',
          'fontSize',
          'fontFamily',
          '|',
          'bold',
          'italic',
          'underline',
          'strikethrough',
          'highlight',
          '|',
          'alignment',
          '|',
          'numberedList',
          'bulletedList',
          '|',
          'indent',
          'outdent',
          '|',
          'todoList',
          'link',
          'blockQuote',
          'imageUpload',
          'insertTable',
          '|',
          'undo',
          'redo'
        ]
      },
      language: 'en',
      image: {
        toolbar: [
          'imageTextAlternative',
          'imageStyle:full',
          'imageStyle:side'
        ]
      },
      table: {
        contentToolbar: [
          'tableColumn',
          'tableRow',
          'mergeTableCells'
        ]
      },
      licenseKey: '',
      wordCount: {
        onUpdate: stats => {
          this.charactersLength = stats.characters
        }
      }
    }
  }

That's it :)

Mohammad Jamal Dashtaki
  • 1,415
  • 1
  • 16
  • 23
  • 1
    Anyone use in Vue? I got error Invalid prop: type check failed for prop "editor". Expected Function, got Module – Wakanina Sep 15 '20 at 12:34
8

I had a similar problem. I solved it when I installed all modules of one version

gorevanova
  • 539
  • 1
  • 7
  • 16
7

NOTE: We don't use @ckeditor/ckeditor5-build-classic any more!

Wrong: import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

Correct: import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';

Ehsan.Fahami
  • 137
  • 1
  • 3
  • 5
  • 1
    after install with "npm install --save @ckeditor/ckeditor5-build-classic", I can't see any src folder under ckeditor5-build-classic. I'm gonna download it form github and try it. – AntiqTech Jun 28 '21 at 14:04
0

I've face this issue when tried to use an editor on different pages few times. Tried everything what is written above, nothing helped. To solve the issue I used a React lazy loading for importing an editor.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 18 '22 at 17:47
0
For vue2: Use the code below from online builder and it works fine after this isse. Hope this helps someone. 

<ckeditor :editor="editor" v-model="editorForm.editor_content" :config="editorConfig"
    :height="120" :rows="6" @input="onEditorInput" @ready="onReady">
    <p>The initial editor data.</p>
</ckeditor>    

Import custom build file ckeditor.js from node_modules: 
        import CkEditorBuild from 'ckeditor5-custom-build/build/ckeditor';

Import ckeditor: 
        import CKEditor from '@ckeditor/ckeditor5-vue2';

variable: 
           

 editorForm: {
                editor_content: "",
            },
            editor: CkEditorBuild,
            editorConfig: {
                toolbar: {
                    items: [
                        'heading',
                        '|',
                        'htmlEmbed',
                        // 'pageBreak',
                        'fontSize',
                        'fontFamily',
                        'fontColor',
                        'fontBackgroundColor',
                        '|',
                        'bold',
                        'italic',
                        'underline',
                        'strikethrough',
                        '|',
                        'alignment',
                        '|',
                        'numberedList',
                        'bulletedList',
                        '|',
                        'indent',
                        'outdent',
                        '|',
                        'link',
                        'blockQuote',
                        'imageUpload',
                        'insertTable',
                        'mediaEmbed',
                        '|',
                        'undo',
                        'redo',
                    ]
                }, language: 'cs',
                image: {
                    toolbar: [
                        'imageTextAlternative',

                        'imageStyle:center',
                    ]
                },
                table: {
                    contentToolbar: [
                        'tableColumn',
                        'tableRow',
                        'mergeTableCells'
                    ]
                },
            },
Tech Leadz
  • 49
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 09 '23 at 21:06