Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

727
Vistas
CKEditorError: ckeditor-duplicated-modules in next js

so my code is:

import { useEffect, useState, useRef } from "react";

function TextEditor({ token }) {
  const editorRef = useRef();
  const [editorLoaded, setEditorLoaded] = useState(false);
  const { CKEditor, ClassicEditor } = editorRef.current || {};
  const [data, setData] = useState("");

  useEffect(() => {
    editorRef.current = {
      CKEditor: require("@ckeditor/ckeditor5-react").CKEditor,
      ClassicEditor: require("@ckeditor/ckeditor5-build-classic"),
      Paragraph: require("@ckeditor/ckeditor5-paragraph/src/paragraph"),
    };
    setEditorLoaded(true);
  }, []);

  return (
    <div className="bg-[#F8F9FA] h-5/7 overflow-y-scroll max-w-6xl mx-auto">
      {editorLoaded ? (
        <CKEditor
          editor={ClassicEditor}
          data=""
          config={{
            plugins: [Paragraph],
            toolbar: ["bold", "italic"],
          }}
          onReady={(editor) => {
            // You can store the "editor" and use when it is needed.
            console.log("Editor is ready to use!", editor);
          }}
          onChange={(event, editor) => {
            const data = editor.getData();
            setData(data);
          }}
        />
      ) : (
        <p>Loading...</p>
      )}
    </div>
  );
}

export default TextEditor;

so the problem is I only want the Paraghraph in my editor but when I run this code it returns CKEditorError: ckEditor-duplicated-modules I have also tried to add .Paragraph in front of the import for the paragraph is there something wrong with the code

Note next js 12

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

best tip is use next/script I guess.

import Script from "next/script";
...
<Script ... />

Because you will import CKEditor in a different way "outside" NextJs libs.

OR try this way :

    const Resumos = () => {
        const editorRef = useRef()
        const [ editorLoaded, setEditorLoaded ] = useState( false )
        const { CKEditor, ClassicEditor} = editorRef.current || {}

        useEffect( () => {
            editorRef.current = {
              CKEditor: require( '@ckeditor/ckeditor5-react' ).CKEditor, //Added .CKEditor
              ClassicEditor: require( '@ckeditor/ckeditor5-build-classic' ),
            }
            setEditorLoaded( true )
        }, [] );
        
      const [data, setData] = useState('');

        return( 
          <>
            {editorLoaded ? <CKEditor
                editor={ ClassicEditor }
                data={data}
                onReady={ editor => {
                  // You can store the "editor" and use when it is needed.
                  console.log('Editor is ready to use!', editor);           
                } }
                onChange={ (event, editor ) => {
                  const data = editor.getData()
                  setData(data);
                } }
            /> : <p>Carregando...</p>}
        </>
        )
    }

Editing configs ( removing editor options, etc )

    <CKEditor
      ...
      config={{
        removePlugins: ['Image', 'ImageCaption', 'ImageStyle', 'ImageToolbar', 'ImageUpload', 'MediaEmbed']
      }}
        ...
    >
    </CKEditor>

Editing toolbars

    <CKEditor
      ...
      toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote' ],
        ...
    >
    </CKEditor>

React ckEditor integration reference: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/react.html

Config reference : https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/configuration.html

Try this and keep me in touch. Hope this tip solves the problem!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda