1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import {
- ExcalidrawElement,
- ExcalidrawTextElement,
- ExcalidrawLinearElement,
- ExcalidrawBindableElement,
- } from "./types";
- export const isTextElement = (
- element: ExcalidrawElement | null,
- ): element is ExcalidrawTextElement => {
- return element != null && element.type === "text";
- };
- export const isLinearElement = (
- element?: ExcalidrawElement | null,
- ): element is ExcalidrawLinearElement => {
- return element != null && isLinearElementType(element.type);
- };
- export const isLinearElementType = (
- elementType: ExcalidrawElement["type"],
- ): boolean => {
- return (
- elementType === "arrow" || elementType === "line" || elementType === "draw"
- );
- };
- export const isBindingElement = (
- element?: ExcalidrawElement | null,
- ): element is ExcalidrawLinearElement => {
- return element != null && isBindingElementType(element.type);
- };
- export const isBindingElementType = (
- elementType: ExcalidrawElement["type"],
- ): boolean => {
- return elementType === "arrow";
- };
- export const isBindableElement = (
- element: ExcalidrawElement | null,
- ): element is ExcalidrawBindableElement => {
- return (
- element != null &&
- (element.type === "rectangle" ||
- element.type === "diamond" ||
- element.type === "ellipse" ||
- element.type === "text")
- );
- };
- export const isExcalidrawElement = (element: any): boolean => {
- return (
- element?.type === "text" ||
- element?.type === "diamond" ||
- element?.type === "rectangle" ||
- element?.type === "ellipse" ||
- element?.type === "arrow" ||
- element?.type === "draw" ||
- element?.type === "line"
- );
- };
|