mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: DRY out tool typing (#7086)
This commit is contained in:
parent
fa33aa08ab
commit
e6f74350ac
3 changed files with 26 additions and 42 deletions
12
src/utils.ts
12
src/utils.ts
|
@ -15,9 +15,8 @@ import {
|
|||
FontString,
|
||||
NonDeletedExcalidrawElement,
|
||||
} from "./element/types";
|
||||
import { AppState, DataURL, LastActiveTool, Zoom } from "./types";
|
||||
import { ActiveTool, AppState, DataURL, ToolType, Zoom } from "./types";
|
||||
import { unstable_batchedUpdates } from "react-dom";
|
||||
import { SHAPES } from "./shapes";
|
||||
import { isEraserActive, isHandToolActive } from "./appState";
|
||||
import { ResolutionType } from "./utility-types";
|
||||
import React from "react";
|
||||
|
@ -371,15 +370,10 @@ export const updateActiveTool = (
|
|||
appState: Pick<AppState, "activeTool">,
|
||||
data: (
|
||||
| {
|
||||
type:
|
||||
| typeof SHAPES[number]["value"]
|
||||
| "eraser"
|
||||
| "hand"
|
||||
| "frame"
|
||||
| "embeddable";
|
||||
type: ToolType;
|
||||
}
|
||||
| { type: "custom"; customType: string }
|
||||
) & { lastActiveToolBeforeEraser?: LastActiveTool },
|
||||
) & { lastActiveToolBeforeEraser?: ActiveTool | null },
|
||||
): AppState["activeTool"] => {
|
||||
if (data.type === "custom") {
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue