rhino-editor
Version:
A custom element wrapped rich text editor
60 lines (59 loc) • 2.81 kB
TypeScript
import { DirectUpload } from "@rails/activestorage";
import type { Blob, DirectUploadDelegate } from "@rails/activestorage";
import { AttachmentManager } from "./attachment-manager.js";
import { BaseEvent } from "./events/base-event.js";
export declare class AttachmentUploadStartEvent<T extends AttachmentUpload = AttachmentUpload> extends BaseEvent {
attachmentUpload: T;
static eventName: "rhino-direct-upload:start";
constructor(attachmentUpload: T, options?: EventInit | undefined);
}
export declare class AttachmentUploadProgressEvent<T extends AttachmentUpload = AttachmentUpload> extends BaseEvent {
attachmentUpload: T;
static eventName: "rhino-direct-upload:progress";
constructor(attachmentUpload: T, options?: EventInit | undefined);
}
export declare class AttachmentUploadErrorEvent<T extends AttachmentUpload = AttachmentUpload> extends BaseEvent {
attachmentUpload: T;
static eventName: "rhino-direct-upload:error";
constructor(attachmentUpload: T, options?: EventInit | undefined);
}
export declare class AttachmentUploadSucceedEvent<T extends AttachmentUpload = AttachmentUpload> extends BaseEvent {
attachmentUpload: T;
static eventName: "rhino-direct-upload:succeed";
constructor(attachmentUpload: T, options?: EventInit | undefined);
}
export declare class AttachmentUploadCompleteEvent<T extends AttachmentUpload = AttachmentUpload> extends BaseEvent {
attachmentUpload: T;
static eventName: "rhino-direct-upload:complete";
constructor(attachmentUpload: T, options?: EventInit | undefined);
}
declare global {
interface GlobalEventHandlersEventMap {
[AttachmentUploadStartEvent.eventName]: AttachmentUploadStartEvent;
[AttachmentUploadProgressEvent.eventName]: AttachmentUploadProgressEvent;
[AttachmentUploadErrorEvent.eventName]: AttachmentUploadErrorEvent;
[AttachmentUploadSucceedEvent.eventName]: AttachmentUploadSucceedEvent;
[AttachmentUploadCompleteEvent.eventName]: AttachmentUploadCompleteEvent;
}
}
/**
* An extension of DirectUpload. This is what handles uploading to remote sources
* for attachments.
*/
export declare class AttachmentUpload implements DirectUploadDelegate {
directUpload: DirectUpload;
attachment: AttachmentManager;
element: HTMLElement;
progress: number;
constructor(attachment: AttachmentManager, element: HTMLElement);
start(): void;
directUploadWillStoreFileWithXHR(xhr: XMLHttpRequest): void;
handleError(error?: Error): void;
directUploadDidComplete(error: Error, blob: Blob & {
attachable_sgid?: string;
}): void;
setUploadProgress(): void;
createBlobUrl(signedId: string, filename: string): string;
get directUploadUrl(): string;
get blobUrlTemplate(): string | undefined;
}