Javascript CKEditor 4可以工作,但CKEditor 5不能';T
这项工作:Javascript CKEditor 4可以工作,但CKEditor 5不能';T,javascript,ckeditor,Javascript,Ckeditor,这项工作: <!DOCTYPE html> <html lang="en"> <head> <title>CKEditor Classic Editing Sample</title> <!-- Make sure the path to CKEditor is correct. --> <script src="scripts/ckeditor/ckeditor.js"></scr
<!DOCTYPE html>
<html lang="en">
<head>
<title>CKEditor Classic Editing Sample</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="scripts/ckeditor/ckeditor.js"></script>
<!-- this is with CKEDITOR 4 -->
<script>
window.addEventListener("load", function() {
CKEDITOR.replace ('editor1');
});
</script>
</head>
<body>
<form method="post">
<p>
My Editor:<br>
<textarea name="editor1" id="editor1"><p>Initial editor content.</p></textarea>
</p>
<p>
<input type="submit">
</p>
</form>
</body>
</html>
我遗漏了什么?因此,最终我在CKEditor网站上找到了相关文章: v5的API需要不同的语法:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CKEditor Classic Editing Sample</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
<script>
window.addEventListener("load", function() {
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
});
</script>
</head>
<body>
<div id="editor">This is some sample content.</div>
</body>
</html>
CKEditor经典编辑示例
addEventListener(“加载”,函数(){
分类编辑器
.create(document.querySelector('#editor'))
.然后(编辑=>{
console.log(编辑器);
} )
.catch(错误=>{
控制台错误(error);
} );
});
这是一些示例内容。
也许只有我一个人,但我认为基本的“入门”指南会更好。在将初始化代码放入事件侦听器之前,v5也出现了错误
Uncaught ReferenceError: CKEDITOR is not defined
<!DOCTYPE html>
<html lang="en">
<head>
<title>CKEditor Classic Editing Sample</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="https://cdn.ckeditor.com/ckeditor5/16.0.0/classic/ckeditor.js"></script>
<script>
window.addEventListener("load", function() {
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
});
</script>
</head>
<body>
<div id="editor">This is some sample content.</div>
</body>
</html>