/** * @module types */ import type { IDictionary, IViewComponent } from './types'; import type { IViewBased } from 'jodit/types/view'; import type { IJodit } from 'jodit/types/jodit'; type MediaFileType = 'image' | 'gif' | 'video' | 'file' | 'audio'; type MediaUploadType = 'image' | 'gif' | 'video' | 'file'; // 업로드시 사용한 파일 객체 + 어떤 팝업을 이용했는지 interface IUploaderPayload extends Partial {} interface IUploaderData { url: string; message: string; file: string; type: MediaFileType; // messages?: string[]; // files: string[]; // isImages?: boolean[]; // path?: string; // baseurl: string; // newfilename?: string; } interface IUploaderAnswer { success: boolean; time: string; data: IUploaderData; } export type HandlerSuccess = ( resp: IUploaderData, // 어떤 팝업에서 열렸는지 mediaUploadType?: MediaUploadType, // 화면에서 파일 이름 표시하려고 payload?: IUploaderPayload ) => void; export type HandlerError = (e: Error) => void; export type BuildDataResult = | FormData | IDictionary | Promise> | string; export interface IUploaderOptions { url: ( editor: IJodit, request: FormData | IDictionary | string ) => string; insertImageAsBase64URI: boolean; imagesExtensions: string[]; headers?: null | object; data: null | object; format: string; method: string; authToken: null | string; filesVariableName: (fileType: string, fileExtension: string) => string; /** * The method can be used to change the name of the uploaded file * This is the name the file will have when it is sent to the server * ```js * Jodit.make('#editor', { * uploader: { * url: 'some-connector.php', * processFileName: (key, file, name) => { * return [key, file, 'some-prefix_' + name]; * } * } * }); * ``` */ processFileName( this: T, key: string, file: File, name: string ): [string, File, string]; /** * The method can be used to change the displayed name of the uploaded file * ```javascript * Jodit.make('#editor', { * uploader: { * url: 'https://sitename.net/jodit/connector/index.php?action=fileUpload', * getDisplayName: (_, name) => 'File:' + name * } * }); * ``` */ getDisplayName(this: T, filename: string): string; pathVariableName: string; withCredentials: boolean; prepareData: (this: T, formData: FormData) => any; buildData?: (this: T, formData: any) => BuildDataResult; queryBuild?: ( obj: string | IDictionary | FormData, prefix?: string ) => string | FormData; isSuccess: (this: T, resp: IUploaderAnswer) => boolean; getMessage: (this: T, resp: IUploaderAnswer) => string; process: (this: T, resp: IUploaderAnswer) => IUploaderData; error: (this: T, e: Error) => void; defaultHandlerSuccess: HandlerSuccess; defaultHandlerError: HandlerError; contentType: (this: T, requestData: any) => string | false; } export interface IUploader extends IViewComponent { readonly jodit: IViewBased; readonly j: this['jodit']; readonly options: IUploaderOptions; readonly o: this['options']; bind( form: HTMLElement, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError, mediaUploadType?: MediaUploadType ): void; uploadRemoteImage( url: string, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError ): void; readonly path: string; readonly source: string; /** * It sets the path for uploading files */ setPath(path: string): this; /** * It sets the source for connector */ setSource(source: string): this; }