@apoorvdwi/excalidraw-collab
Version:
Excalidraw as a React component
72 lines (71 loc) • 3.06 kB
TypeScript
import { ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawTextElement } from "../../element/types";
import { ToolName } from "../queries/toolQueries";
export declare type KeyboardModifiers = {
alt?: boolean;
shift?: boolean;
ctrl?: boolean;
};
export declare class Keyboard {
static withModifierKeys: (modifiers: KeyboardModifiers, cb: () => void) => void;
static keyDown: (key: string) => void;
static keyUp: (key: string) => void;
static keyPress: (key: string) => void;
static codeDown: (code: string) => void;
static codeUp: (code: string) => void;
static codePress: (code: string) => void;
}
export declare class Pointer {
private readonly pointerType;
private readonly pointerId;
clientX: number;
clientY: number;
constructor(pointerType: "mouse" | "touch" | "pen", pointerId?: number);
reset(): void;
getPosition(): number[];
restorePosition(x?: number, y?: number): void;
private getEvent;
move(dx: number, dy: number): void;
down(dx?: number, dy?: number): void;
up(dx?: number, dy?: number): void;
click(dx?: number, dy?: number): void;
doubleClick(dx?: number, dy?: number): void;
moveTo(x?: number, y?: number): void;
downAt(x?: number, y?: number): void;
upAt(x?: number, y?: number): void;
clickAt(x: number, y: number): void;
rightClickAt(x: number, y: number): void;
doubleClickAt(x: number, y: number): void;
select(
/** if multiple elements supplied, they're shift-selected */
elements: ExcalidrawElement | ExcalidrawElement[]): void;
clickOn(element: ExcalidrawElement): void;
doubleClickOn(element: ExcalidrawElement): void;
}
export declare class UI {
static clickTool: (toolName: ToolName) => void;
static clickLabeledElement: (label: string) => void;
/**
* Creates an Excalidraw element, and returns a proxy that wraps it so that
* accessing props will return the latest ones from the object existing in
* the app's elements array. This is because across the app lifecycle we tend
* to recreate element objects and the returned reference will become stale.
*
* If you need to get the actual element, not the proxy, call `get()` method
* on the proxy object.
*/
static createElement<T extends ToolName>(type: T, { position, x, y, size, width, height, angle, }?: {
position?: number;
x?: number;
y?: number;
size?: number;
width?: number;
height?: number;
angle?: number;
}): (T extends "arrow" | "line" | "freedraw" ? ExcalidrawLinearElement : T extends "text" ? ExcalidrawTextElement : ExcalidrawElement) & {
/** Returns the actual, current element from the elements array, instead
of the proxy */
get(): T extends "arrow" | "line" | "freedraw" ? ExcalidrawLinearElement : T extends "text" ? ExcalidrawTextElement : ExcalidrawElement;
};
static group(elements: ExcalidrawElement[]): void;
static queryContextMenu: () => Element | null;
}