|
@@ -1,167 +1,180 @@
|
|
|
-import { Point, simplify } from "points-on-curve";
|
|
|
import React from "react";
|
|
|
-import { RoughCanvas } from "roughjs/bin/canvas";
|
|
|
+
|
|
|
import rough from "roughjs/bin/rough";
|
|
|
-import "../actions";
|
|
|
-import { actionDeleteSelected, actionFinalize } from "../actions";
|
|
|
-import { createRedoAction, createUndoAction } from "../actions/actionHistory";
|
|
|
-import { ActionManager } from "../actions/manager";
|
|
|
-import { actions } from "../actions/register";
|
|
|
-import { ActionResult } from "../actions/types";
|
|
|
-import {
|
|
|
- EVENT_DIALOG,
|
|
|
- EVENT_LIBRARY,
|
|
|
- EVENT_SHAPE,
|
|
|
- trackEvent,
|
|
|
-} from "../analytics";
|
|
|
-import { getDefaultAppState } from "../appState";
|
|
|
-import { renderSpreadsheet } from "../charts";
|
|
|
-import {
|
|
|
- copyToClipboard,
|
|
|
- parseClipboard,
|
|
|
- probablySupportsClipboardBlob,
|
|
|
- probablySupportsClipboardWriteText,
|
|
|
-} from "../clipboard";
|
|
|
-import {
|
|
|
- APP_NAME,
|
|
|
- CANVAS_ONLY_ACTIONS,
|
|
|
- CURSOR_TYPE,
|
|
|
- DEFAULT_VERTICAL_ALIGN,
|
|
|
- DRAGGING_THRESHOLD,
|
|
|
- ELEMENT_SHIFT_TRANSLATE_AMOUNT,
|
|
|
- ELEMENT_TRANSLATE_AMOUNT,
|
|
|
- ENV,
|
|
|
- EVENT,
|
|
|
- LINE_CONFIRM_THRESHOLD,
|
|
|
- MIME_TYPES,
|
|
|
- POINTER_BUTTON,
|
|
|
- TAP_TWICE_TIMEOUT,
|
|
|
- TEXT_TO_CENTER_SNAP_THRESHOLD,
|
|
|
- TOUCH_CTX_MENU_TIMEOUT,
|
|
|
-} from "../constants";
|
|
|
-import { exportCanvas, loadFromBlob } from "../data";
|
|
|
-import { isValidLibrary } from "../data/json";
|
|
|
-import { Library } from "../data/library";
|
|
|
-import { restore } from "../data/restore";
|
|
|
+import { RoughCanvas } from "roughjs/bin/canvas";
|
|
|
+import { simplify, Point } from "points-on-curve";
|
|
|
+
|
|
|
import {
|
|
|
- dragNewElement,
|
|
|
- dragSelectedElements,
|
|
|
+ newElement,
|
|
|
+ newTextElement,
|
|
|
duplicateElement,
|
|
|
+ isInvisiblySmallElement,
|
|
|
+ isTextElement,
|
|
|
+ textWysiwyg,
|
|
|
getCommonBounds,
|
|
|
getCursorForResizingElement,
|
|
|
- getDragOffsetXY,
|
|
|
- getElementWithTransformHandleType,
|
|
|
- getNonDeletedElements,
|
|
|
- getNormalizedDimensions,
|
|
|
getPerfectElementSize,
|
|
|
- getResizeArrowDirection,
|
|
|
+ getNormalizedDimensions,
|
|
|
+ newLinearElement,
|
|
|
+ transformElements,
|
|
|
+ getElementWithTransformHandleType,
|
|
|
getResizeOffsetXY,
|
|
|
+ getResizeArrowDirection,
|
|
|
getTransformHandleTypeFromCoords,
|
|
|
- hitTest,
|
|
|
- isHittingElementBoundingBoxWithoutHittingElement,
|
|
|
- isInvisiblySmallElement,
|
|
|
isNonDeletedElement,
|
|
|
- isTextElement,
|
|
|
- newElement,
|
|
|
- newLinearElement,
|
|
|
- newTextElement,
|
|
|
- textWysiwyg,
|
|
|
- transformElements,
|
|
|
updateTextElement,
|
|
|
+ dragSelectedElements,
|
|
|
+ getDragOffsetXY,
|
|
|
+ dragNewElement,
|
|
|
+ hitTest,
|
|
|
+ isHittingElementBoundingBoxWithoutHittingElement,
|
|
|
+ getNonDeletedElements,
|
|
|
} from "../element";
|
|
|
import {
|
|
|
- bindOrUnbindSelectedElements,
|
|
|
- fixBindingsAfterDeletion,
|
|
|
- fixBindingsAfterDuplication,
|
|
|
- getEligibleElementsForBinding,
|
|
|
- getHoveredElementForBinding,
|
|
|
- isBindingEnabled,
|
|
|
- isLinearElementSimpleAndAlreadyBound,
|
|
|
- maybeBindLinearElement,
|
|
|
- shouldEnableBindingForPointerEvent,
|
|
|
- unbindLinearElements,
|
|
|
- updateBoundElements,
|
|
|
-} from "../element/binding";
|
|
|
-import { LinearElementEditor } from "../element/linearElementEditor";
|
|
|
-import { mutateElement } from "../element/mutateElement";
|
|
|
-import { deepCopyElement } from "../element/newElement";
|
|
|
-import { MaybeTransformHandleType } from "../element/transformHandles";
|
|
|
-import {
|
|
|
- isBindingElement,
|
|
|
- isBindingElementType,
|
|
|
- isLinearElement,
|
|
|
- isLinearElementType,
|
|
|
-} from "../element/typeChecks";
|
|
|
-import {
|
|
|
- ExcalidrawBindableElement,
|
|
|
- ExcalidrawElement,
|
|
|
- ExcalidrawGenericElement,
|
|
|
- ExcalidrawLinearElement,
|
|
|
- ExcalidrawTextElement,
|
|
|
- NonDeleted,
|
|
|
-} from "../element/types";
|
|
|
-import { getCenter, getDistance } from "../gesture";
|
|
|
-import {
|
|
|
- editGroupForSelectedElement,
|
|
|
- getElementsInGroup,
|
|
|
- getSelectedGroupIdForElement,
|
|
|
- getSelectedGroupIds,
|
|
|
- isElementInGroup,
|
|
|
- isSelectedViaGroup,
|
|
|
- selectGroupsForSelectedElements,
|
|
|
-} from "../groups";
|
|
|
-import { createHistory, SceneHistory } from "../history";
|
|
|
-import { getLanguage, t } from "../i18n";
|
|
|
-import {
|
|
|
- CODES,
|
|
|
- getResizeCenterPointKey,
|
|
|
- getResizeWithSidesSameLengthKey,
|
|
|
- getRotateWithDiscreteAngleKey,
|
|
|
- isArrowKey,
|
|
|
- KEYS,
|
|
|
-} from "../keys";
|
|
|
-import { distance2d, getGridPoint, isPathALoop } from "../math";
|
|
|
-import { renderScene } from "../renderer";
|
|
|
-import { invalidateShapeForElement } from "../renderer/renderElement";
|
|
|
-import {
|
|
|
- calculateScrollCenter,
|
|
|
- getElementContainingPosition,
|
|
|
- getElementsAtPosition,
|
|
|
getElementsWithinSelection,
|
|
|
+ isOverScrollBars,
|
|
|
+ getElementsAtPosition,
|
|
|
+ getElementContainingPosition,
|
|
|
getNormalizedZoom,
|
|
|
getSelectedElements,
|
|
|
- isOverScrollBars,
|
|
|
isSomeElementSelected,
|
|
|
- normalizeScroll,
|
|
|
+ calculateScrollCenter,
|
|
|
} from "../scene";
|
|
|
-import Scene from "../scene/Scene";
|
|
|
-import { SceneState, ScrollBars } from "../scene/types";
|
|
|
-import { getNewZoom } from "../scene/zoom";
|
|
|
-import { findShapeByKey } from "../shapes";
|
|
|
+import { loadFromBlob, exportCanvas } from "../data";
|
|
|
+
|
|
|
+import { renderScene } from "../renderer";
|
|
|
import {
|
|
|
AppState,
|
|
|
- ExcalidrawProps,
|
|
|
- Gesture,
|
|
|
GestureEvent,
|
|
|
+ Gesture,
|
|
|
+ ExcalidrawProps,
|
|
|
SceneData,
|
|
|
} from "../types";
|
|
|
import {
|
|
|
- debounce,
|
|
|
- distance,
|
|
|
+ ExcalidrawElement,
|
|
|
+ ExcalidrawTextElement,
|
|
|
+ NonDeleted,
|
|
|
+ ExcalidrawGenericElement,
|
|
|
+ ExcalidrawLinearElement,
|
|
|
+ ExcalidrawBindableElement,
|
|
|
+} from "../element/types";
|
|
|
+
|
|
|
+import { distance2d, isPathALoop, getGridPoint } from "../math";
|
|
|
+
|
|
|
+import {
|
|
|
+ isWritableElement,
|
|
|
isInputLike,
|
|
|
isToolIcon,
|
|
|
- isWritableElement,
|
|
|
+ debounce,
|
|
|
+ distance,
|
|
|
resetCursor,
|
|
|
- ResolvablePromise,
|
|
|
- resolvablePromise,
|
|
|
+ viewportCoordsToSceneCoords,
|
|
|
sceneCoordsToViewportCoords,
|
|
|
setCursorForShape,
|
|
|
tupleToCoors,
|
|
|
- viewportCoordsToSceneCoords,
|
|
|
+ ResolvablePromise,
|
|
|
+ resolvablePromise,
|
|
|
withBatchedUpdates,
|
|
|
} from "../utils";
|
|
|
+import {
|
|
|
+ KEYS,
|
|
|
+ isArrowKey,
|
|
|
+ getResizeCenterPointKey,
|
|
|
+ getResizeWithSidesSameLengthKey,
|
|
|
+ getRotateWithDiscreteAngleKey,
|
|
|
+ CODES,
|
|
|
+} from "../keys";
|
|
|
+
|
|
|
+import { findShapeByKey } from "../shapes";
|
|
|
+import { createHistory, SceneHistory } from "../history";
|
|
|
+
|
|
|
import ContextMenu from "./ContextMenu";
|
|
|
+
|
|
|
+import { ActionManager } from "../actions/manager";
|
|
|
+import "../actions";
|
|
|
+import { actions } from "../actions/register";
|
|
|
+
|
|
|
+import { ActionResult } from "../actions/types";
|
|
|
+import { getDefaultAppState } from "../appState";
|
|
|
+import { t, getLanguage } from "../i18n";
|
|
|
+
|
|
|
+import {
|
|
|
+ copyToClipboard,
|
|
|
+ parseClipboard,
|
|
|
+ probablySupportsClipboardBlob,
|
|
|
+ probablySupportsClipboardWriteText,
|
|
|
+} from "../clipboard";
|
|
|
+import { normalizeScroll } from "../scene";
|
|
|
+import { getCenter, getDistance } from "../gesture";
|
|
|
+import { createUndoAction, createRedoAction } from "../actions/actionHistory";
|
|
|
+
|
|
|
+import {
|
|
|
+ CURSOR_TYPE,
|
|
|
+ ELEMENT_SHIFT_TRANSLATE_AMOUNT,
|
|
|
+ ELEMENT_TRANSLATE_AMOUNT,
|
|
|
+ POINTER_BUTTON,
|
|
|
+ DRAGGING_THRESHOLD,
|
|
|
+ TEXT_TO_CENTER_SNAP_THRESHOLD,
|
|
|
+ LINE_CONFIRM_THRESHOLD,
|
|
|
+ EVENT,
|
|
|
+ ENV,
|
|
|
+ CANVAS_ONLY_ACTIONS,
|
|
|
+ DEFAULT_VERTICAL_ALIGN,
|
|
|
+ MIME_TYPES,
|
|
|
+ TAP_TWICE_TIMEOUT,
|
|
|
+ TOUCH_CTX_MENU_TIMEOUT,
|
|
|
+ APP_NAME,
|
|
|
+} from "../constants";
|
|
|
+
|
|
|
import LayerUI from "./LayerUI";
|
|
|
+import { ScrollBars, SceneState } from "../scene/types";
|
|
|
+import { mutateElement } from "../element/mutateElement";
|
|
|
+import { invalidateShapeForElement } from "../renderer/renderElement";
|
|
|
+import {
|
|
|
+ isLinearElement,
|
|
|
+ isLinearElementType,
|
|
|
+ isBindingElement,
|
|
|
+ isBindingElementType,
|
|
|
+} from "../element/typeChecks";
|
|
|
+import { actionFinalize, actionDeleteSelected } from "../actions";
|
|
|
+
|
|
|
+import { LinearElementEditor } from "../element/linearElementEditor";
|
|
|
+import {
|
|
|
+ getSelectedGroupIds,
|
|
|
+ isSelectedViaGroup,
|
|
|
+ selectGroupsForSelectedElements,
|
|
|
+ isElementInGroup,
|
|
|
+ getSelectedGroupIdForElement,
|
|
|
+ getElementsInGroup,
|
|
|
+ editGroupForSelectedElement,
|
|
|
+} from "../groups";
|
|
|
+import { Library } from "../data/library";
|
|
|
+import Scene from "../scene/Scene";
|
|
|
+import {
|
|
|
+ getHoveredElementForBinding,
|
|
|
+ maybeBindLinearElement,
|
|
|
+ getEligibleElementsForBinding,
|
|
|
+ bindOrUnbindSelectedElements,
|
|
|
+ unbindLinearElements,
|
|
|
+ fixBindingsAfterDuplication,
|
|
|
+ fixBindingsAfterDeletion,
|
|
|
+ isLinearElementSimpleAndAlreadyBound,
|
|
|
+ isBindingEnabled,
|
|
|
+ updateBoundElements,
|
|
|
+ shouldEnableBindingForPointerEvent,
|
|
|
+} from "../element/binding";
|
|
|
+import { MaybeTransformHandleType } from "../element/transformHandles";
|
|
|
+import { deepCopyElement } from "../element/newElement";
|
|
|
+import { renderSpreadsheet } from "../charts";
|
|
|
+import { isValidLibrary } from "../data/json";
|
|
|
+import { getNewZoom } from "../scene/zoom";
|
|
|
+import { restore } from "../data/restore";
|
|
|
+import {
|
|
|
+ EVENT_DIALOG,
|
|
|
+ EVENT_LIBRARY,
|
|
|
+ EVENT_SHAPE,
|
|
|
+ trackEvent,
|
|
|
+} from "../analytics";
|
|
|
import { Stats } from "./Stats";
|
|
|
|
|
|
const { history } = createHistory();
|