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-11-11 15:55:22 +01:00
|
|
|
import { isLinearElementType } from "./typeChecks";
|
2020-03-14 20:46:57 -07:00
|
|
|
|
2020-03-17 20:55:40 +01:00
|
|
|
export {
|
|
|
|
newElement,
|
|
|
|
newTextElement,
|
2020-06-25 21:21:27 +02:00
|
|
|
updateTextElement,
|
2022-10-28 23:31:56 +02:00
|
|
|
refreshTextDimensions,
|
2020-03-17 20:55:40 +01:00
|
|
|
newLinearElement,
|
2021-10-21 22:05:48 +02:00
|
|
|
newImageElement,
|
2020-03-17 20:55:40 +01:00
|
|
|
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-12-08 15:02:55 +00:00
|
|
|
getArrowheadPoints,
|
2020-05-30 17:32:32 +05:30
|
|
|
getClosestElementBounds,
|
2020-01-06 19:34:22 +04:00
|
|
|
} from "./bounds";
|
|
|
|
|
2020-04-07 17:49:59 +09:00
|
|
|
export {
|
|
|
|
OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,
|
2020-08-10 14:16:39 +02:00
|
|
|
getTransformHandlesFromCoords,
|
|
|
|
getTransformHandles,
|
|
|
|
} from "./transformHandles";
|
2020-08-26 17:37:44 +01:00
|
|
|
export {
|
|
|
|
hitTest,
|
|
|
|
isHittingElementBoundingBoxWithoutHittingElement,
|
|
|
|
} from "./collision";
|
2020-01-24 20:45:52 +01:00
|
|
|
export {
|
|
|
|
resizeTest,
|
|
|
|
getCursorForResizingElement,
|
2020-08-10 14:16:39 +02:00
|
|
|
getElementWithTransformHandleType,
|
|
|
|
getTransformHandleTypeFromCoords,
|
2020-01-24 20:45:52 +01:00
|
|
|
} from "./resizeTest";
|
2020-05-09 17:57:00 +09:00
|
|
|
export {
|
2020-08-28 17:20:06 +09:00
|
|
|
transformElements,
|
2020-05-09 17:57:00 +09:00
|
|
|
getResizeOffsetXY,
|
2020-05-11 00:41:36 +09:00
|
|
|
getResizeArrowDirection,
|
2020-05-09 17:57:00 +09:00
|
|
|
} from "./resizeElements";
|
2020-06-24 00:24:52 +09:00
|
|
|
export {
|
|
|
|
dragSelectedElements,
|
|
|
|
getDragOffsetXY,
|
|
|
|
dragNewElement,
|
|
|
|
} from "./dragElements";
|
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,
|
2022-08-02 18:13:19 +08:00
|
|
|
getLockedLinearCursorAlignSize,
|
2020-01-23 09:21:04 +00:00
|
|
|
isInvisiblySmallElement,
|
2020-01-24 12:04:54 +02:00
|
|
|
resizePerfectLineForNWHandler,
|
2020-05-28 11:41:34 +02:00
|
|
|
getNormalizedDimensions,
|
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
|
|
|
|
2020-10-04 11:12:47 -07:00
|
|
|
export const getSceneVersion = (elements: readonly ExcalidrawElement[]) =>
|
2020-05-20 16:21:37 +03:00
|
|
|
elements.reduce((acc, el) => acc + el.version, 0);
|
2020-03-14 20:46:57 -07:00
|
|
|
|
2021-04-19 17:29:13 +02:00
|
|
|
export const getVisibleElements = (elements: readonly ExcalidrawElement[]) =>
|
|
|
|
elements.filter(
|
|
|
|
(el) => !el.isDeleted && !isInvisiblySmallElement(el),
|
|
|
|
) as readonly NonDeletedExcalidrawElement[];
|
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
export const getNonDeletedElements = (elements: readonly ExcalidrawElement[]) =>
|
|
|
|
elements.filter(
|
2020-04-14 12:30:58 +03:00
|
|
|
(element) => !element.isDeleted,
|
|
|
|
) as readonly NonDeletedExcalidrawElement[];
|
2020-04-11 17:10:56 +01:00
|
|
|
|
2020-05-20 16:21:37 +03:00
|
|
|
export const isNonDeletedElement = <T extends ExcalidrawElement>(
|
2020-04-11 17:10:56 +01:00
|
|
|
element: T,
|
2020-05-20 16:21:37 +03:00
|
|
|
): element is NonDeleted<T> => !element.isDeleted;
|
2020-11-11 15:55:22 +01:00
|
|
|
|
|
|
|
const _clearElements = (
|
|
|
|
elements: readonly ExcalidrawElement[],
|
|
|
|
): ExcalidrawElement[] =>
|
|
|
|
getNonDeletedElements(elements).map((element) =>
|
|
|
|
isLinearElementType(element.type)
|
|
|
|
? { ...element, lastCommittedPoint: null }
|
|
|
|
: element,
|
|
|
|
);
|
|
|
|
|
2021-10-21 22:05:48 +02:00
|
|
|
export const clearElementsForDatabase = (
|
|
|
|
elements: readonly ExcalidrawElement[],
|
|
|
|
) => _clearElements(elements);
|
|
|
|
|
2020-11-11 15:55:22 +01:00
|
|
|
export const clearElementsForExport = (
|
|
|
|
elements: readonly ExcalidrawElement[],
|
|
|
|
) => _clearElements(elements);
|
|
|
|
|
|
|
|
export const clearElementsForLocalStorage = (
|
|
|
|
elements: readonly ExcalidrawElement[],
|
|
|
|
) => _clearElements(elements);
|