最近Django想写个博客,发现博客还真的不好写,为啥?没有好用的富文本编辑器,转战又去学php,发现PHP中的CKEditor5不错,但是有个弊端,上传不了图片,经过多次反复看文档,发现了一个比较好用安装方法,给大家提供一下:
CKEditor5资源下载:
https://ckeditor.com/ckeditor-5-builds/download
ckfinder3资源下载:
https://ckeditor.com/ckeditor-4/download/#ckfinder
写一个如下的html文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor 5 - Classic editor</title>
<script src="https://cdn.ckeditor.com/ckeditor5/10.0.0/classic/ckeditor.js"></script>
</head>
<body>
<h1>Classic editor</h1>
<textarea name="content" id="editor">
<p>This is some sample content.</p>
</textarea>
<script type="text/JAVAscript">
ClassicEditor
.create( document.querySelector( '#editor' ), {
//工具栏可选择项
//toolbar: ['headings', 'bold', 'italic', 'blockQuote', 'bulletedList', 'numberedList', 'link', 'ImageUpload', 'undo'],
language: 'zh-cn',
//ckfinder加载
ckfinder: {
uploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
}
}
)
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>
把ckfinder解压后,放到网站根目录下(例如:/Var/www/html)
打开ckfinder/config.php
$config['authentication'] = function () {
return true;
};
把false改成true,保存。
OK!就这么简单搞定了,没必要还要composer之类的安装,那样只是越来越晕。