2020-04-11 17:10:56 +01:00
|
|
|
import {
|
|
|
|
ExcalidrawElement,
|
|
|
|
NonDeletedExcalidrawElement,
|
|
|
|
NonDeleted,
|
|
|
|
} from "./types";
|
2020-03-14 20:46:57 -07:00
|
|
|
import { isInvisiblySmallElement } from "./sizeHelpers";
|
|
|
|
|
2020-03-17 20:55:40 +01:00
|
|
|
export {
|
|
|
|
newElement,
|
|
|
|
newTextElement,
|
|
|
|
newLinearElement,
|
|
|
|
duplicateElement,
|
|
|
|
} from "./newElement";
|
2020-01-06 19:34:22 +04:00
|
|
|
export {
|
2020-01-07 19:04:52 +04:00
|
|
|
getElementAbsoluteCoords,
|
2020-04-07 23:04:20 +09:00
|
|
|
getElementBounds,
|
2020-01-26 20:15:08 +01:00
|
|
|
getCommonBounds,
|
2020-01-06 19:34:22 +04:00
|
|
|
getDiamondPoints,
|
2020-01-15 22:07:19 +03:00
|
|
|
getArrowPoints,
|
2020-01-06 19:34:22 +04:00
|
|
|
} from "./bounds";
|
|
|
|
|
2020-04-07 17:49:59 +09:00
|
|
|
export {
|
|
|
|
OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,
|
|
|
|
handlerRectanglesFromCoords,
|
|
|
|
handlerRectangles,
|
|
|
|
} from "./handlerRectangles";
|
2020-01-06 19:34:22 +04:00
|
|
|
export { hitTest } from "./collision";
|
2020-01-24 20:45:52 +01:00
|
|
|
export {
|
|
|
|
resizeTest,
|
|
|
|
getCursorForResizingElement,
|
|
|
|
normalizeResizeHandle,
|
2020-04-07 17:49:59 +09:00
|
|
|
getElementWithResizeHandler,
|
|
|
|
getResizeHandlerFromCoords,
|
2020-01-24 20:45:52 +01:00
|
|
|
} from "./resizeTest";
|
2020-04-07 17:49:59 +09:00
|
|
|
export { resizeElements, canResizeMutlipleElements } from "./resizeElements";
|
2020-02-24 15:21:13 +01:00
|
|
|
export { isTextElement, isExcalidrawElement } from "./typeChecks";
|
2020-01-07 22:21:05 +05:00
|
|
|
export { textWysiwyg } from "./textWysiwyg";
|
2020-01-10 18:00:19 +04:00
|
|
|
export { redrawTextBoundingBox } from "./textElement";
|
2020-01-23 09:21:04 +00:00
|
|
|
export {
|
|
|
|
getPerfectElementSize,
|
|
|
|
isInvisiblySmallElement,
|
2020-01-24 12:04:54 +02:00
|
|
|
resizePerfectLineForNWHandler,
|
2020-01-24 20:45:52 +01:00
|
|
|
normalizeDimensions,
|
2020-01-23 09:21:04 +00:00
|
|
|
} from "./sizeHelpers";
|
2020-03-01 14:39:03 -05:00
|
|
|
export { showSelectedShapeActions } from "./showSelectedShapeActions";
|
2020-03-14 20:46:57 -07:00
|
|
|
|
|
|
|
export function getSyncableElements(elements: readonly ExcalidrawElement[]) {
|
|
|
|
// There are places in Excalidraw where synthetic invisibly small elements are added and removed.
|
|
|
|
// It's probably best to keep those local otherwise there might be a race condition that
|
|
|
|
// gets the app into an invalid state. I've never seen it happen but I'm worried about it :)
|
2020-04-03 14:16:14 +02:00
|
|
|
return elements.filter((el) => el.isDeleted || !isInvisiblySmallElement(el));
|
2020-03-14 20:46:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getElementMap(elements: readonly ExcalidrawElement[]) {
|
2020-03-19 19:41:32 +01:00
|
|
|
return elements.reduce(
|
2020-03-14 20:46:57 -07:00
|
|
|
(acc: { [key: string]: ExcalidrawElement }, element: ExcalidrawElement) => {
|
|
|
|
acc[element.id] = element;
|
|
|
|
return acc;
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getDrawingVersion(elements: readonly ExcalidrawElement[]) {
|
|
|
|
return elements.reduce((acc, el) => acc + el.version, 0);
|
|
|
|
}
|
|
|
|
|
2020-04-08 09:49:52 -07:00
|
|
|
export function getNonDeletedElements(elements: readonly ExcalidrawElement[]) {
|
2020-04-14 12:30:58 +03:00
|
|
|
return elements.filter(
|
|
|
|
(element) => !element.isDeleted,
|
|
|
|
) as readonly NonDeletedExcalidrawElement[];
|
2020-03-14 20:46:57 -07:00
|
|
|
}
|
2020-04-11 17:10:56 +01:00
|
|
|
|
|
|
|
export function isNonDeletedElement<T extends ExcalidrawElement>(
|
|
|
|
element: T,
|
|
|
|
): element is NonDeleted<T> {
|
|
|
|
return !element.isDeleted;
|
|
|
|
}
|