feat: add onChange, onPointerDown, onPointerUp api subs (#7154)

This commit is contained in:
David Luzar 2023-10-20 13:08:22 +02:00 committed by GitHub
parent 9eb89f9960
commit e7cc2337ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 173 additions and 0 deletions

View file

@ -607,6 +607,8 @@ export type PointerDownState = Readonly<{
};
}>;
type UnsubscribeCallback = () => void;
export type ExcalidrawImperativeAPI = {
updateScene: InstanceType<typeof App>["updateScene"];
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
@ -637,6 +639,27 @@ export type ExcalidrawImperativeAPI = {
* used in conjunction with view mode (props.viewModeEnabled).
*/
updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
onChange: (
callback: (
elements: readonly ExcalidrawElement[],
appState: AppState,
files: BinaryFiles,
) => void,
) => UnsubscribeCallback;
onPointerDown: (
callback: (
activeTool: AppState["activeTool"],
pointerDownState: PointerDownState,
event: React.PointerEvent<HTMLElement>,
) => void,
) => UnsubscribeCallback;
onPointerUp: (
callback: (
activeTool: AppState["activeTool"],
pointerDownState: PointerDownState,
event: PointerEvent,
) => void,
) => UnsubscribeCallback;
};
export type Device = Readonly<{