@gaoding/editor-sdk
Version:
稿定编辑器对外 SDK
81 lines (80 loc) • 2.29 kB
TypeScript
interface Config {
appId: string;
container?: string;
onCloseModal?(): Promise<boolean | void> | void | boolean;
/**
* 获取使用权益凭证
*/
getUseRightCert?(info: {
appId: string;
useKey: string;
abilityCode: string;
workId: string;
}): Promise<string | false | Error>;
/**
* 获取用户授权标识
*/
authorize?(): Promise<string>;
}
type FileType = 'jpg' | 'png' | 'gif' | 'ppt' | 'pdf' | 'mp4';
type EditorModuleType = 'panel.template' | 'panel.element' | 'panel.text' | 'panel.photo' | 'panel.widget' | 'panel.chart' | 'panel.component' | 'panel.my-resource';
interface Canva {
addImage(url: string, options?: {
width: number;
height: number;
}): Promise<void>;
}
export declare function createTemplateEditor(config: Config): {
readonly canva: Canva | null;
readonly isLoad: boolean;
openTemplateList: (options: {
categories?: number[] | string[];
onSelectTemplate?(info: {
id: string | number;
categoryId: string | number;
}): void;
}) => Promise<false | {
id: string | number;
categoryId: string | number;
}>;
close: () => void;
onSave: (fn: (info: {
workId: string;
files: Blob[];
title: string;
type: string;
}) => void) => void;
onTemplateLoad: (fn: () => any) => void;
onClose: (fn: () => any) => void;
onLoad: (fn: () => any) => void;
editDesign: (options: {
id: string | number;
fileTypes?: FileType[];
categories?: number[];
okText?: string;
disableModules?: EditorModuleType[];
filterPaidMaterial?: never;
}) => Promise<false | {
files: Blob[];
workId: number;
title: string;
type: string;
}>;
createDesign: (options?: {
templateId?: string | number;
size?: {
width: number;
height: number;
};
categoryId?: string | number;
fileTypes?: FileType[];
okText?: string;
disableModules?: EditorModuleType[];
}) => Promise<false | {
files: Blob[];
workId: number;
title: string;
type: string;
}>;
};
export {};