feat: support customType in activeTool (#5144)

* feat: support customType in activeTool

* fix

* rewrite types and handling

* tweaks

* fix

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Aakansha Doshi 2022-05-06 18:21:22 +05:30 committed by GitHub
parent 1ed1529f96
commit 64d330a332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 210 additions and 51 deletions

View file

@ -66,6 +66,16 @@ export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
export type LastActiveToolBeforeEraser =
| {
type: typeof SHAPES[number]["value"] | "eraser";
customType: null;
}
| {
type: "custom";
customType: string;
}
| null;
export type AppState = {
isLoading: boolean;
errorMessage: string | null;
@ -80,11 +90,19 @@ export type AppState = {
// (e.g. text element when typing into the input)
editingElement: NonDeletedExcalidrawElement | null;
editingLinearElement: LinearElementEditor | null;
activeTool: {
type: typeof SHAPES[number]["value"] | "eraser";
lastActiveToolBeforeEraser: typeof SHAPES[number]["value"] | null;
locked: boolean;
};
activeTool:
| {
type: typeof SHAPES[number]["value"] | "eraser";
lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
locked: boolean;
customType: null;
}
| {
type: "custom";
customType: string;
lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
locked: boolean;
};
penMode: boolean;
penDetected: boolean;
exportBackground: boolean;