mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: rename elementType to activeTool and make it an object (#4968)
* refactor: rename elementType to activeTool * update docs * fix snap * update activeToll to be an object and review fixes * fix tests * fix
This commit is contained in:
parent
2209e2c1e8
commit
127af9db23
25 changed files with 364 additions and 207 deletions
|
@ -92,7 +92,7 @@ export const getDragOffsetXY = (
|
|||
|
||||
export const dragNewElement = (
|
||||
draggingElement: NonDeletedExcalidrawElement,
|
||||
elementType: AppState["elementType"],
|
||||
elementType: AppState["activeTool"]["type"],
|
||||
originX: number,
|
||||
originY: number,
|
||||
x: number,
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
ExcalidrawTextElement,
|
||||
NonDeletedExcalidrawElement,
|
||||
NonDeleted,
|
||||
ExcalidrawElement,
|
||||
} from "./types";
|
||||
import {
|
||||
getElementAbsoluteCoords,
|
||||
|
@ -186,7 +187,7 @@ const validateTwoPointElementNormalized = (
|
|||
};
|
||||
|
||||
const getPerfectElementSizeWithRotation = (
|
||||
elementType: string,
|
||||
elementType: ExcalidrawElement["type"],
|
||||
width: number,
|
||||
height: number,
|
||||
angle: number,
|
||||
|
|
|
@ -10,6 +10,6 @@ export const showSelectedShapeActions = (
|
|||
!appState.viewModeEnabled &&
|
||||
(appState.editingElement ||
|
||||
getSelectedElements(elements, appState).length ||
|
||||
(appState.elementType !== "selection" &&
|
||||
appState.elementType !== "eraser")),
|
||||
(appState.activeTool.type !== "selection" &&
|
||||
appState.activeTool.type !== "eraser")),
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@ import { ExcalidrawElement } from "./types";
|
|||
import { mutateElement } from "./mutateElement";
|
||||
import { isFreeDrawElement, isLinearElement } from "./typeChecks";
|
||||
import { SHIFT_LOCKING_ANGLE } from "../constants";
|
||||
import { AppState } from "../types";
|
||||
|
||||
export const isInvisiblySmallElement = (
|
||||
element: ExcalidrawElement,
|
||||
|
@ -16,7 +17,7 @@ export const isInvisiblySmallElement = (
|
|||
* Makes a perfect shape or diagonal/horizontal/vertical line
|
||||
*/
|
||||
export const getPerfectElementSize = (
|
||||
elementType: string,
|
||||
elementType: AppState["activeTool"]["type"],
|
||||
width: number,
|
||||
height: number,
|
||||
): { width: number; height: number } => {
|
||||
|
|
|
@ -61,7 +61,7 @@ export const isLinearElement = (
|
|||
};
|
||||
|
||||
export const isLinearElementType = (
|
||||
elementType: AppState["elementType"],
|
||||
elementType: AppState["activeTool"]["type"],
|
||||
): boolean => {
|
||||
return (
|
||||
elementType === "arrow" || elementType === "line" // || elementType === "freedraw"
|
||||
|
@ -75,7 +75,7 @@ export const isBindingElement = (
|
|||
};
|
||||
|
||||
export const isBindingElementType = (
|
||||
elementType: AppState["elementType"],
|
||||
elementType: AppState["activeTool"]["type"],
|
||||
): boolean => {
|
||||
return elementType === "arrow";
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue