2020-03-17 20:55:40 +01:00
|
|
|
import {
|
|
|
|
ExcalidrawElement,
|
|
|
|
ExcalidrawTextElement,
|
|
|
|
ExcalidrawLinearElement,
|
|
|
|
} from "./types";
|
2020-01-06 19:34:22 +04:00
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
export const isTextElement = (
|
2020-04-06 22:26:54 +02:00
|
|
|
element: ExcalidrawElement | null,
|
2020-05-20 16:21:37 +03:00
|
|
|
): element is ExcalidrawTextElement => {
|
2020-04-06 22:26:54 +02:00
|
|
|
return element != null && element.type === "text";
|
2020-05-20 16:21:37 +03:00
|
|
|
};
|
2020-02-24 15:21:13 +01:00
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
export const isLinearElement = (
|
2020-03-17 20:55:40 +01:00
|
|
|
element?: ExcalidrawElement | null,
|
2020-05-20 16:21:37 +03:00
|
|
|
): element is ExcalidrawLinearElement => {
|
2020-03-17 20:55:40 +01:00
|
|
|
return (
|
2020-05-12 20:10:11 +01:00
|
|
|
element != null &&
|
|
|
|
(element.type === "arrow" ||
|
|
|
|
element.type === "line" ||
|
|
|
|
element.type === "draw")
|
2020-03-17 20:55:40 +01:00
|
|
|
);
|
2020-05-20 16:21:37 +03:00
|
|
|
};
|
2020-03-17 20:55:40 +01:00
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
export const isExcalidrawElement = (element: any): boolean => {
|
2020-02-24 15:21:13 +01:00
|
|
|
return (
|
|
|
|
element?.type === "text" ||
|
|
|
|
element?.type === "diamond" ||
|
|
|
|
element?.type === "rectangle" ||
|
|
|
|
element?.type === "ellipse" ||
|
|
|
|
element?.type === "arrow" ||
|
2020-05-12 20:10:11 +01:00
|
|
|
element?.type === "draw" ||
|
2020-02-24 15:21:13 +01:00
|
|
|
element?.type === "line"
|
|
|
|
);
|
2020-05-20 16:21:37 +03:00
|
|
|
};
|