editor-sdk
稿定编辑器对外 SDK
安装
npm i @gaoding/editor-sdk
# or
yarn add @gaoding/editor-sdk
npm 使用方式
import { GdEditorSdk } from '@gaoding/editor-sdk';
const sdk = new GdEditorSdk({
onUpload(blob) {
const url = window.URL.createObjectURL(blob);
const img = document.createElement('img');
img.src = url;
document.body.append(img);
const form = new FormData();
form.append('file', blob, 'gaoding.jpg');
axios.post('url', form, { headers: { 'Content-Type': 'multipart/form-data' } })
.then(res => {
alert('上传成功');
})
.catch(error => {
alert(error.message);
})
}
})
sdk.open({ filter: 'xinmeiti' });
API
interface IConfig {
onUpload(blob: Blob): any;
style?: {
[k: string]: string;
};
}
export declare class GdEditorSdk {
constructor(config: IConfig);
open(options: {
categoryId: number;
}): void;
close(): void;
}