Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught ReferenceError: ClassicEditor is not defined(ckeditor5)

I am trying to setup the ckeditor5 in my local but I am facing this error

Uncaught SyntaxError: Invalid or unexpected token sample.html:14 Uncaught ReferenceError: ClassicEditor is not defined

Below is the local code.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CKEditor 5 – Classic editor</title>
<script src="ckeditor1.js"></script>
</head>
<body>
<h1>Classic editor</h1>
<textarea name="content" id="editor">
    &lt;p&gt;This is some sample content.&lt;/p&gt;
</textarea>
<script>
    ClassicEditor
        .create( document.querySelector( '#editor' ) )
        .catch( error => {
            console.error( error );
        } );
</script>
</body>
</html>

But the same is working when I am pointing to cdn ckeditor url:

https://cdn.ckeditor.com/ckeditor5/12.3.0/classic/ckeditor.js

working cdn jsfiddle

like image 611
Raphael Avatar asked Jun 16 '26 04:06

Raphael


2 Answers

It's not working because you don't have editor script loaded, so there's no ClassicEditor.

You need to load the editor from cdn first: <script src="https://cdn.ckeditor.com/ckeditor5/12.3.1/classic/ckeditor.js"></script>

like image 71
Clarity Avatar answered Jun 18 '26 18:06

Clarity


This is worked for me

window.addEventListener("load", (e)=>{
    ClassicEditor.create( document.querySelector( '#editor' ) )
    .then( editor => {
        console.log( editor );
    } )
    .catch( error => {
        console.error( error );
    } );
});
like image 24
Joy Kumar Bera Avatar answered Jun 18 '26 18:06

Joy Kumar Bera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!