mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
30 lines
750 B
TypeScript
30 lines
750 B
TypeScript
import {
|
|
ExcalidrawElement,
|
|
ExcalidrawTextElement,
|
|
ExcalidrawLinearElement,
|
|
} from "./types";
|
|
|
|
export function isTextElement(
|
|
element: ExcalidrawElement | null,
|
|
): element is ExcalidrawTextElement {
|
|
return element != null && element.type === "text";
|
|
}
|
|
|
|
export function isLinearElement(
|
|
element?: ExcalidrawElement | null,
|
|
): element is ExcalidrawLinearElement {
|
|
return (
|
|
element != null && (element.type === "arrow" || element.type === "line")
|
|
);
|
|
}
|
|
|
|
export function isExcalidrawElement(element: any): boolean {
|
|
return (
|
|
element?.type === "text" ||
|
|
element?.type === "diamond" ||
|
|
element?.type === "rectangle" ||
|
|
element?.type === "ellipse" ||
|
|
element?.type === "arrow" ||
|
|
element?.type === "line"
|
|
);
|
|
}
|