|
@@ -1,181 +1,167 @@
|
|
|
|
+import { Point, simplify } from "points-on-curve";
|
|
import React from "react";
|
|
import React from "react";
|
|
-
|
|
|
|
-import rough from "roughjs/bin/rough";
|
|
|
|
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
-import { simplify, Point } from "points-on-curve";
|
|
|
|
-
|
|
|
|
-import {
|
|
|
|
- newElement,
|
|
|
|
- newTextElement,
|
|
|
|
- duplicateElement,
|
|
|
|
- isInvisiblySmallElement,
|
|
|
|
- isTextElement,
|
|
|
|
- textWysiwyg,
|
|
|
|
- getCommonBounds,
|
|
|
|
- getCursorForResizingElement,
|
|
|
|
- getPerfectElementSize,
|
|
|
|
- getNormalizedDimensions,
|
|
|
|
- newLinearElement,
|
|
|
|
- transformElements,
|
|
|
|
- getElementWithTransformHandleType,
|
|
|
|
- getResizeOffsetXY,
|
|
|
|
- getResizeArrowDirection,
|
|
|
|
- getTransformHandleTypeFromCoords,
|
|
|
|
- isNonDeletedElement,
|
|
|
|
- updateTextElement,
|
|
|
|
- dragSelectedElements,
|
|
|
|
- getDragOffsetXY,
|
|
|
|
- dragNewElement,
|
|
|
|
- hitTest,
|
|
|
|
- isHittingElementBoundingBoxWithoutHittingElement,
|
|
|
|
- getNonDeletedElements,
|
|
|
|
-} from "../element";
|
|
|
|
-import {
|
|
|
|
- getElementsWithinSelection,
|
|
|
|
- isOverScrollBars,
|
|
|
|
- getElementsAtPosition,
|
|
|
|
- getElementContainingPosition,
|
|
|
|
- getNormalizedZoom,
|
|
|
|
- getSelectedElements,
|
|
|
|
- isSomeElementSelected,
|
|
|
|
- calculateScrollCenter,
|
|
|
|
-} from "../scene";
|
|
|
|
-import { loadFromBlob, exportCanvas } from "../data";
|
|
|
|
-
|
|
|
|
-import { renderScene } from "../renderer";
|
|
|
|
-import {
|
|
|
|
- AppState,
|
|
|
|
- GestureEvent,
|
|
|
|
- Gesture,
|
|
|
|
- ExcalidrawProps,
|
|
|
|
- SceneData,
|
|
|
|
-} from "../types";
|
|
|
|
-import {
|
|
|
|
- ExcalidrawElement,
|
|
|
|
- ExcalidrawTextElement,
|
|
|
|
- NonDeleted,
|
|
|
|
- ExcalidrawGenericElement,
|
|
|
|
- ExcalidrawLinearElement,
|
|
|
|
- ExcalidrawBindableElement,
|
|
|
|
-} from "../element/types";
|
|
|
|
-
|
|
|
|
-import { distance2d, isPathALoop, getGridPoint } from "../math";
|
|
|
|
-
|
|
|
|
-import {
|
|
|
|
- isWritableElement,
|
|
|
|
- isInputLike,
|
|
|
|
- isToolIcon,
|
|
|
|
- debounce,
|
|
|
|
- distance,
|
|
|
|
- resetCursor,
|
|
|
|
- viewportCoordsToSceneCoords,
|
|
|
|
- sceneCoordsToViewportCoords,
|
|
|
|
- setCursorForShape,
|
|
|
|
- tupleToCoors,
|
|
|
|
- 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 rough from "roughjs/bin/rough";
|
|
import "../actions";
|
|
import "../actions";
|
|
|
|
+import { actionDeleteSelected, actionFinalize } from "../actions";
|
|
|
|
+import { createRedoAction, createUndoAction } from "../actions/actionHistory";
|
|
|
|
+import { ActionManager } from "../actions/manager";
|
|
import { actions } from "../actions/register";
|
|
import { actions } from "../actions/register";
|
|
-
|
|
|
|
import { ActionResult } from "../actions/types";
|
|
import { ActionResult } from "../actions/types";
|
|
|
|
+import {
|
|
|
|
+ EVENT_DIALOG,
|
|
|
|
+ EVENT_LIBRARY,
|
|
|
|
+ EVENT_SHAPE,
|
|
|
|
+ trackEvent,
|
|
|
|
+} from "../analytics";
|
|
import { getDefaultAppState } from "../appState";
|
|
import { getDefaultAppState } from "../appState";
|
|
-import { t, getLanguage } from "../i18n";
|
|
|
|
-
|
|
|
|
|
|
+import { renderSpreadsheet } from "../charts";
|
|
import {
|
|
import {
|
|
copyToClipboard,
|
|
copyToClipboard,
|
|
parseClipboard,
|
|
parseClipboard,
|
|
probablySupportsClipboardBlob,
|
|
probablySupportsClipboardBlob,
|
|
probablySupportsClipboardWriteText,
|
|
probablySupportsClipboardWriteText,
|
|
} from "../clipboard";
|
|
} from "../clipboard";
|
|
-import { normalizeScroll } from "../scene";
|
|
|
|
-import { getCenter, getDistance } from "../gesture";
|
|
|
|
-import { createUndoAction, createRedoAction } from "../actions/actionHistory";
|
|
|
|
-
|
|
|
|
import {
|
|
import {
|
|
|
|
+ APP_NAME,
|
|
|
|
+ CANVAS_ONLY_ACTIONS,
|
|
CURSOR_TYPE,
|
|
CURSOR_TYPE,
|
|
|
|
+ DEFAULT_VERTICAL_ALIGN,
|
|
|
|
+ DRAGGING_THRESHOLD,
|
|
ELEMENT_SHIFT_TRANSLATE_AMOUNT,
|
|
ELEMENT_SHIFT_TRANSLATE_AMOUNT,
|
|
ELEMENT_TRANSLATE_AMOUNT,
|
|
ELEMENT_TRANSLATE_AMOUNT,
|
|
- POINTER_BUTTON,
|
|
|
|
- DRAGGING_THRESHOLD,
|
|
|
|
- TEXT_TO_CENTER_SNAP_THRESHOLD,
|
|
|
|
- LINE_CONFIRM_THRESHOLD,
|
|
|
|
- EVENT,
|
|
|
|
ENV,
|
|
ENV,
|
|
- CANVAS_ONLY_ACTIONS,
|
|
|
|
- DEFAULT_VERTICAL_ALIGN,
|
|
|
|
- GRID_SIZE,
|
|
|
|
|
|
+ EVENT,
|
|
|
|
+ LINE_CONFIRM_THRESHOLD,
|
|
MIME_TYPES,
|
|
MIME_TYPES,
|
|
|
|
+ POINTER_BUTTON,
|
|
TAP_TWICE_TIMEOUT,
|
|
TAP_TWICE_TIMEOUT,
|
|
|
|
+ TEXT_TO_CENTER_SNAP_THRESHOLD,
|
|
TOUCH_CTX_MENU_TIMEOUT,
|
|
TOUCH_CTX_MENU_TIMEOUT,
|
|
- APP_NAME,
|
|
|
|
} from "../constants";
|
|
} from "../constants";
|
|
-
|
|
|
|
-import LayerUI from "./LayerUI";
|
|
|
|
-import { ScrollBars, SceneState } from "../scene/types";
|
|
|
|
|
|
+import { exportCanvas, loadFromBlob } from "../data";
|
|
|
|
+import { isValidLibrary } from "../data/json";
|
|
|
|
+import { Library } from "../data/library";
|
|
|
|
+import { restore } from "../data/restore";
|
|
|
|
+import {
|
|
|
|
+ dragNewElement,
|
|
|
|
+ dragSelectedElements,
|
|
|
|
+ duplicateElement,
|
|
|
|
+ getCommonBounds,
|
|
|
|
+ getCursorForResizingElement,
|
|
|
|
+ getDragOffsetXY,
|
|
|
|
+ getElementWithTransformHandleType,
|
|
|
|
+ getNonDeletedElements,
|
|
|
|
+ getNormalizedDimensions,
|
|
|
|
+ getPerfectElementSize,
|
|
|
|
+ getResizeArrowDirection,
|
|
|
|
+ getResizeOffsetXY,
|
|
|
|
+ getTransformHandleTypeFromCoords,
|
|
|
|
+ hitTest,
|
|
|
|
+ isHittingElementBoundingBoxWithoutHittingElement,
|
|
|
|
+ isInvisiblySmallElement,
|
|
|
|
+ isNonDeletedElement,
|
|
|
|
+ isTextElement,
|
|
|
|
+ newElement,
|
|
|
|
+ newLinearElement,
|
|
|
|
+ newTextElement,
|
|
|
|
+ textWysiwyg,
|
|
|
|
+ transformElements,
|
|
|
|
+ updateTextElement,
|
|
|
|
+} 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 { mutateElement } from "../element/mutateElement";
|
|
-import { invalidateShapeForElement } from "../renderer/renderElement";
|
|
|
|
|
|
+import { deepCopyElement } from "../element/newElement";
|
|
|
|
+import { MaybeTransformHandleType } from "../element/transformHandles";
|
|
import {
|
|
import {
|
|
- isLinearElement,
|
|
|
|
- isLinearElementType,
|
|
|
|
isBindingElement,
|
|
isBindingElement,
|
|
isBindingElementType,
|
|
isBindingElementType,
|
|
|
|
+ isLinearElement,
|
|
|
|
+ isLinearElementType,
|
|
} from "../element/typeChecks";
|
|
} from "../element/typeChecks";
|
|
-import { actionFinalize, actionDeleteSelected } from "../actions";
|
|
|
|
-
|
|
|
|
-import { LinearElementEditor } from "../element/linearElementEditor";
|
|
|
|
import {
|
|
import {
|
|
|
|
+ ExcalidrawBindableElement,
|
|
|
|
+ ExcalidrawElement,
|
|
|
|
+ ExcalidrawGenericElement,
|
|
|
|
+ ExcalidrawLinearElement,
|
|
|
|
+ ExcalidrawTextElement,
|
|
|
|
+ NonDeleted,
|
|
|
|
+} from "../element/types";
|
|
|
|
+import { getCenter, getDistance } from "../gesture";
|
|
|
|
+import {
|
|
|
|
+ editGroupForSelectedElement,
|
|
|
|
+ getElementsInGroup,
|
|
|
|
+ getSelectedGroupIdForElement,
|
|
getSelectedGroupIds,
|
|
getSelectedGroupIds,
|
|
|
|
+ isElementInGroup,
|
|
isSelectedViaGroup,
|
|
isSelectedViaGroup,
|
|
selectGroupsForSelectedElements,
|
|
selectGroupsForSelectedElements,
|
|
- isElementInGroup,
|
|
|
|
- getSelectedGroupIdForElement,
|
|
|
|
- getElementsInGroup,
|
|
|
|
- editGroupForSelectedElement,
|
|
|
|
} from "../groups";
|
|
} from "../groups";
|
|
-import { Library } from "../data/library";
|
|
|
|
-import Scene from "../scene/Scene";
|
|
|
|
|
|
+import { createHistory, SceneHistory } from "../history";
|
|
|
|
+import { getLanguage, t } from "../i18n";
|
|
import {
|
|
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";
|
|
|
|
|
|
+ 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,
|
|
|
|
+ getNormalizedZoom,
|
|
|
|
+ getSelectedElements,
|
|
|
|
+ isOverScrollBars,
|
|
|
|
+ isSomeElementSelected,
|
|
|
|
+ normalizeScroll,
|
|
|
|
+} from "../scene";
|
|
|
|
+import Scene from "../scene/Scene";
|
|
|
|
+import { SceneState, ScrollBars } from "../scene/types";
|
|
import { getNewZoom } from "../scene/zoom";
|
|
import { getNewZoom } from "../scene/zoom";
|
|
-import { restore } from "../data/restore";
|
|
|
|
|
|
+import { findShapeByKey } from "../shapes";
|
|
import {
|
|
import {
|
|
- EVENT_DIALOG,
|
|
|
|
- EVENT_LIBRARY,
|
|
|
|
- EVENT_SHAPE,
|
|
|
|
- trackEvent,
|
|
|
|
-} from "../analytics";
|
|
|
|
|
|
+ AppState,
|
|
|
|
+ ExcalidrawProps,
|
|
|
|
+ Gesture,
|
|
|
|
+ GestureEvent,
|
|
|
|
+ SceneData,
|
|
|
|
+} from "../types";
|
|
|
|
+import {
|
|
|
|
+ debounce,
|
|
|
|
+ distance,
|
|
|
|
+ isInputLike,
|
|
|
|
+ isToolIcon,
|
|
|
|
+ isWritableElement,
|
|
|
|
+ resetCursor,
|
|
|
|
+ ResolvablePromise,
|
|
|
|
+ resolvablePromise,
|
|
|
|
+ sceneCoordsToViewportCoords,
|
|
|
|
+ setCursorForShape,
|
|
|
|
+ tupleToCoors,
|
|
|
|
+ viewportCoordsToSceneCoords,
|
|
|
|
+ withBatchedUpdates,
|
|
|
|
+} from "../utils";
|
|
|
|
+import ContextMenu from "./ContextMenu";
|
|
|
|
+import LayerUI from "./LayerUI";
|
|
import { Stats } from "./Stats";
|
|
import { Stats } from "./Stats";
|
|
|
|
|
|
const { history } = createHistory();
|
|
const { history } = createHistory();
|
|
@@ -3662,7 +3648,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
CANVAS_ONLY_ACTIONS.includes(action.name),
|
|
CANVAS_ONLY_ACTIONS.includes(action.name),
|
|
),
|
|
),
|
|
{
|
|
{
|
|
- checked: this.state.gridSize !== null,
|
|
|
|
|
|
+ checked: this.state.showGrid,
|
|
shortcutName: "gridMode",
|
|
shortcutName: "gridMode",
|
|
label: t("labels.gridMode"),
|
|
label: t("labels.gridMode"),
|
|
action: this.toggleGridMode,
|
|
action: this.toggleGridMode,
|