GrapesJS / ckeditor

This plugin replaces the default Rich Text Editor with the one from CKEditor
BSD 3-Clause "New" or "Revised" License
103 stars 101 forks source link

How to use this plugin in React? #34

Closed hellocaio closed 4 years ago

hellocaio commented 5 years ago

I'm trying to use this plugin with GrapeJS in React but can't get it to work. When I select a piece of text I get an error:

Uncaught SyntaxError: Unexpected token <
Uncaught TypeError: Cannot set property 'dir' of undefined
     at Object.f (ckeditor.js:5782)
     at e (ckeditor.js:5816)
     at Array.n (ckeditor.js:5822)
     at q (ckeditor.js:5829)
     at ckeditor.js:5848

This is how I am loading it:

import "ckeditor";
import pluginCKEditor from "grapesjs-plugin-ckeditor";

then:

const editor = grapesjs.init({
    {...}
    plugins: [pluginCKEditor],
    {...}
})

What am I doing wrong?

hellocaio commented 5 years ago

After doing some searching on this error, some were able to solve it by importing ckeditor using the CDN. So I added the CDN:

const editor = grapesjs.init({
    container: "#canvas",
    canvas: {
    scripts: [
        "https://cdn.ckeditor.com/ckeditor5/12.4.0/classic/ckeditor.js"
    ]
    }
    ...

This did not solve the issue.

HelveticaScenario commented 4 years ago

try including ckeditor using a script tag in your html, not the scripts field in grapesjs.init. http://cdn.ckeditor.com/