typeChecks.ts 485 B

123456789101112131415161718
  1. import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
  2. export function isTextElement(
  3. element: ExcalidrawElement,
  4. ): element is ExcalidrawTextElement {
  5. return element.type === "text";
  6. }
  7. export function isExcalidrawElement(element: any): boolean {
  8. return (
  9. element?.type === "text" ||
  10. element?.type === "diamond" ||
  11. element?.type === "rectangle" ||
  12. element?.type === "ellipse" ||
  13. element?.type === "arrow" ||
  14. element?.type === "line"
  15. );
  16. }