最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught ReferenceError: ClassicEditor is not defined(ckeditor5) - Stack Overflow

programmeradmin1浏览0评论

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:

.3.0/classic/ckeditor.js

working cdn jsfiddle

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

Share Improve this question edited Jul 17, 2019 at 9:14 Lelio Faieta 6,6899 gold badges47 silver badges84 bronze badges asked Jul 17, 2019 at 8:27 RaphaelRaphael 1,8122 gold badges28 silver badges49 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 8

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>

This is worked for me

window.addEventListener("load", (e)=>{
    ClassicEditor.create( document.querySelector( '#editor' ) )
    .then( editor => {
        console.log( editor );
    } )
    .catch( error => {
        console.error( error );
    } );
});

I had the same problem but when I looked in the files I found a folder called

发布评论

评论列表(0)

  1. 暂无评论