这是可行的:
<!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 5,<textarea>不会被替换:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CKEditor Classic Editing Sample</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="scripts/ckeditor5-build-classic/ckeditor.js"></script>
<!-- this is with CKEDITOR 5 -->
<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 5压缩文件并解压缩到指定的路径。在第二种情况下,chrome error控制台显示:
Uncaught ReferenceError: CKEDITOR is not defined我错过了什么?
发布于 2020-02-06 05:10:41
因此,我最终在CKEditor网站上找到了相关文章:https://cdn.ckeditor.com/#ckeditor5
v5应用编程接口需要不同的语法:
<!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>也许只有我这样认为,但我认为基本的“入门”指南可能会更好。在我将初始化代码放入事件侦听器之前,我也得到了v5的错误。
https://stackoverflow.com/questions/60083777
复制相似问题