matrix-react-sdk
Version:
SDK for matrix.org using React
42 lines (41 loc) • 2.68 kB
TypeScript
import { MutableRefObject, RefObject } from "react";
import { IEventRelation, MatrixClient } from "matrix-js-sdk/src/matrix";
import { WysiwygEvent } from "@vector-im/matrix-wysiwyg";
import { TimelineRenderingType } from "../../../../../contexts/RoomContext";
import { IRoomState } from "../../../../structures/RoomView";
import Autocomplete from "../../Autocomplete";
export declare function focusComposer(composerElement: MutableRefObject<HTMLElement | null>, renderingType: TimelineRenderingType, roomContext: IRoomState, timeoutId: MutableRefObject<number | null>): void;
export declare function setCursorPositionAtTheEnd(element: HTMLElement): void;
/**
* When the autocomplete modal is open we need to be able to properly
* handle events that are dispatched. This allows the user to move the selection
* in the autocomplete and select using enter.
*
* @param autocompleteRef - a ref to the autocomplete of interest
* @param event - the keyboard event that has been dispatched
* @returns boolean - whether or not the autocomplete has handled the event
*/
export declare function handleEventWithAutocomplete(autocompleteRef: RefObject<Autocomplete>, event: KeyboardEvent | React.KeyboardEvent<HTMLDivElement>): boolean;
/**
* Takes an event and handles image pasting. Returns a boolean to indicate if it has handled
* the event or not. Must accept either clipboard or input events in order to prevent issue:
* https://github.com/vector-im/element-web/issues/25327
*
* @param event - event to process
* @param data - data from the event to process
* @param roomContext - room in which the event occurs
* @param mxClient - current matrix client
* @param eventRelation - used to send the event to the correct place eg timeline vs thread
* @returns - boolean to show if the event was handled or not
*/
export declare function handleClipboardEvent(event: ClipboardEvent | InputEvent, data: DataTransfer | null, roomContext: IRoomState, mxClient: MatrixClient, eventRelation?: IEventRelation): boolean;
/**
* Util to determine if an input event or clipboard event must be handled as a clipboard event.
* Due to https://github.com/vector-im/element-web/issues/25327, certain paste events
* must be listenened for with an onBeforeInput handler and so will be caught as input events.
*
* @param event - the event to test, can be a WysiwygEvent if it comes from the rich text editor, or
* input or clipboard events if from the plain text editor
* @returns - true if event should be handled as a clipboard event
*/
export declare function isEventToHandleAsClipboardEvent(event: WysiwygEvent | InputEvent | ClipboardEvent): event is InputEvent | ClipboardEvent;