公司的网站中也要集成富文本编辑器,我们选择了CKEditor 5,官方网址
在集成的过程中需要完成图片上传到公司服务器,在文档中有三种方法,三种方法,
第一种是用CKEditor 的服务肯定是不行,第二种需要后端配置一些东西,最好也不要麻烦别人,第三种就是自己根据引导去写一个自定义插件,因为他都基本写好了,所以比较容易,于是就自己写了一个MyUploadAdapter.js 文件,在需要的地方引用就可以使用其中的init方法来生成一个可以把图片上传到公司服务器的富文本编辑器,代码如下
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
export default class MyUploadAdapter {
constructor( loader, url ) {
// The FileLoader instance to use during the upload. It sounds scary but do not
// worry — the loader will be passed into the adapter later on in this guide.
this.loader = loader;
// The upload URL in your se