import type { IMessage, IRoom, ISubscription, IE2EEMessage, IUpload, Subscribable } from '@rocket.chat/core-typings'; import type { IActionManager } from '@rocket.chat/ui-contexts'; import type { Upload } from './Upload'; import type { ReadStateManager } from './readStateManager'; import type { FormattingButton } from '../../../app/ui-message/client/messageBox/messageBoxFormatting'; export type ComposerAPI = { release(): void; readonly text: string; readonly selection: { readonly start: number; readonly end: number }; setText( text: string, options?: { selection?: | { readonly start?: number; readonly end?: number } | ((previous: { readonly start: number; readonly end: number }) => { readonly start?: number; readonly end?: number }); }, ): void; wrapSelection(pattern: string): void; insertText(text: string): void; insertNewLine(): void; clear(): void; focus(): void; blur(): void; getCursorPosition(): number | undefined; substring(start: number, end?: number): string; replaceText( text: string, selection: { start: number; end: number; }, ): void; setCursorToEnd(): void; setCursorToStart(): void; replyWith(text: string): Promise; quoteMessage(message: IMessage): Promise; dismissQuotedMessage(mid: IMessage['_id']): Promise; dismissAllQuotedMessages(): Promise; readonly quotedMessages: Subscribable; setEditingMode(editing: boolean): void; readonly editing: Subscribable; setRecordingMode(recording: boolean): void; readonly recording: Subscribable; setRecordingVideo(recording: boolean): void; readonly recordingVideo: Subscribable; setIsMicrophoneDenied(isMicrophoneDenied: boolean): void; readonly isMicrophoneDenied: Subscribable; readonly formatters: Subscribable; }; export type DataAPI = { composeMessage( text: string, options: { sendToChannel?: boolean; quotedMessages: IMessage[]; originalMessage?: IMessage | null }, ): Promise; findMessageByID(mid: IMessage['_id']): Promise; getMessageByID(mid: IMessage['_id']): Promise; findLastMessage(): Promise; getLastMessage(): Promise; findPreviousOwnMessage(message?: IMessage): Promise; getPreviousOwnMessage(message: IMessage): Promise; findNextOwnMessage(message: IMessage): Promise; getNextOwnMessage(message: IMessage): Promise; pushEphemeralMessage(message: Omit): Promise; canUpdateMessage(message: IMessage): Promise; updateMessage(message: Pick & Partial>, previewUrls?: string[]): Promise; canDeleteMessage(message: IMessage): Promise; deleteMessage(msgIdOrMsg: IMessage | IMessage['_id']): Promise; getDraft(mid: IMessage['_id'] | undefined): Promise; discardDraft(mid: IMessage['_id'] | undefined): Promise; saveDraft(mid: IMessage['_id'] | undefined, text: string): Promise; findRoom(): Promise; getRoom(): Promise; isSubscribedToRoom(): Promise; joinRoom(): Promise; findDiscussionByID(drid: IRoom['_id']): Promise; getDiscussionByID(drid: IRoom['_id']): Promise; findSubscription(): Promise; getSubscription(): Promise; findSubscriptionFromMessage(message: IMessage): Promise; getSubscriptionFromMessage(message: IMessage): Promise; }; export type UploadsAPI = { get(): readonly Upload[]; subscribe(callback: () => void): () => void; wipeFailedOnes(): void; cancel(id: Upload['id']): void; send( file: File, { description, msg, t, e2e }: { description?: string; msg?: string; t?: IMessage['t']; e2e?: IMessage['e2e'] }, getContent?: (fileId: string, fileUrl: string) => Promise, fileContent?: { raw: Partial; encrypted: IE2EEMessage['content'] }, ): Promise; }; export type ChatAPI = { readonly uid: string | undefined; readonly composer?: ComposerAPI; readonly setComposerAPI: (composer?: ComposerAPI) => void; readonly data: DataAPI; readonly uploads: UploadsAPI; readonly readStateManager: ReadStateManager; readonly messageEditing: { toPreviousMessage(): Promise; toNextMessage(): Promise; editMessage(message: IMessage, options?: { cursorAtStart?: boolean }): Promise; }; readonly currentEditingMessage: { setMID(mid: IMessage['_id']): void; getMID(): string | undefined; reset(): Promise; stop(): Promise; cancel(): Promise; }; readonly emojiPicker: { open(el: Element, cb: (emoji: string) => void): void; close(): void; }; readonly action: { start(action: 'typing'): void; stop(action: 'typing' | 'recording' | 'uploading' | 'playing'): void; performContinuously(action: 'recording' | 'uploading' | 'playing'): void; }; ActionManager: IActionManager; readonly flows: { readonly uploadFiles: (files: readonly File[], resetFileInput?: () => void) => Promise; readonly sendMessage: ({ text, tshow, }: { text: string; tshow?: boolean; previewUrls?: string[]; isSlashCommandAllowed?: boolean; }) => Promise; readonly processSlashCommand: (message: IMessage, userId: string | null) => Promise; readonly processTooLongMessage: (message: IMessage) => Promise; readonly processMessageEditing: ( message: Pick & Partial>, previewUrls?: string[], ) => Promise; readonly processSetReaction: (message: Pick) => Promise; readonly requestMessageDeletion: (message: IMessage) => Promise; readonly replyBroadcast: (message: IMessage) => Promise; }; };