1.0.1 • Published 4 years ago

ali-ckeditor-upload v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

CKEditor 阿里云上传适配器插件

  1. 您需要创建CKEditor的自定义版本。
  2. 将此插件注册到您的自定义版本中

1.创建自己的CKEditor

有关更多详细信息,请查看此官方教程

git clone -b stable https://github.com/ckeditor/ckeditor5-build-classic.git
cd ckeditor5-build-classic
yarn install

或者使用官方在线定制

在安装此插件之前,您可以使用默认设置测试自己的版本。

yarn build

构建完成后,您将在build文件夹中获得一个自定义CKEditor 。

打开sample/index.html查看效果

2.安装此插件

在您的自定义CKEditor构建中,将此插件安装在程序包管理器中。

yarn add ali-ckeditor-upload
or
npm install ali-ckeditor-upload

修改node_modules\ali-ckeditor-upload\index.js,输入阿里云OSS的相关信息,参考文档

const config = {
	// region以杭州为例(oss-cn-hangzhou),其他region按实际情况填写。
    region: '<Your region>',
    accessKeyId: '<Your AccessKeyId>',
    accessKeySecret: '<Your AccessKeySecret>',
 	bucket: 'Your bucket name'
    // 您保存的在OSS的文件路径
	savePath: "images/",
};

转到src/ckeditor.js,进行以下更改以加载此插件。

+import AliUploadAdapter from "ali-ckeditor-upload";

export default class ClassicEditor extends ClassicEditorBase {}

// Plugins to include in the build.
ClassicEditor.builtinPlugins = [
	...,
+	AliUploadAdapter
];

// Editor configuration.
ClassicEditor.defaultConfig = {...};

如果您在中进行任何更改src/ckeditor.js,则必须重新构建。

yarn build

故障排除

ckeditor复制模块

  1. 请确保您的自定义CKEditor 5构建依赖项版本 >= 19.0.0

  2. 更新/检查依赖关系后,尝试为您创建一个干净的CKEditor 5

    	rm -rf node_modules && yarn install 
    	yarn build
  1. 使用npm ls,搜索@ckeditor以查看是否存在重复的模块

  2. 如果问题仍然存在,请阅读官方文档

1.0.1

4 years ago

1.0.0

4 years ago