Fix all but components & tests

This commit is contained in:
Marcel Mraz 2025-03-17 19:42:10 +01:00
parent e2c2218f62
commit 44837c9bde
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
103 changed files with 1284 additions and 1003 deletions

View file

@ -7,71 +7,19 @@ import type {
NonDeleted, NonDeleted,
} from "./src/types"; } from "./src/types";
export { export * from "./src/bounds";
aabbForElement, export * from "./src/dragElements";
getElementShape,
pointInsideBounds,
} from "./src/shapes";
export {
newElement,
newTextElement,
refreshTextDimensions,
newLinearElement,
newArrowElement,
newImageElement,
duplicateElement,
} from "./src/newElement";
export {
getElementAbsoluteCoords,
getElementBounds,
getCommonBounds,
getDiamondPoints,
getArrowheadPoints,
getClosestElementBounds,
} from "./src/bounds";
export {
OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,
getTransformHandlesFromCoords,
getTransformHandles,
} from "./src/transformHandles";
export {
resizeTest,
getCursorForResizingElement,
getElementWithTransformHandleType,
getTransformHandleTypeFromCoords,
} from "./src/resizeTest";
export {
transformElements,
getResizeOffsetXY,
getResizeArrowDirection,
} from "./src/resizeElements";
export {
dragSelectedElements,
getDragOffsetXY,
dragNewElement,
} from "./src/dragElements";
export { isTextElement, isExcalidrawElement } from "./src/typeChecks";
export { redrawTextBoundingBox, getTextFromElements } from "./src/textElement";
export {
getPerfectElementSize,
getLockedLinearCursorAlignSize,
isInvisiblySmallElement,
resizePerfectLineForNWHandler,
getNormalizedDimensions,
} from "./src/sizeHelpers";
export { showSelectedShapeActions } from "./src/showSelectedShapeActions";
export * from "./src/frame"; export * from "./src/frame";
export * from "./src/mutateElement";
export * from "./src/newElement";
export * from "./src/resizeElements";
export * from "./src/resizeTest";
export * from "./src/shapes"; export * from "./src/shapes";
export * from "./src/showSelectedShapeActions";
export * from "./src/textElement";
export * from "./src/typeChecks";
export * from "./src/transformHandles";
export * from "./src/sizeHelpers";
/** /**
* @deprecated unsafe, use hashElementsVersion instead * @deprecated unsafe, use hashElementsVersion instead

View file

@ -1,3 +1,10 @@
import {
DEFAULT_ADAPTIVE_RADIUS,
DEFAULT_PROPORTIONAL_RADIUS,
LINE_CONFIRM_THRESHOLD,
ROUNDNESS,
invariant,
} from "@excalidraw/common";
import { import {
isPoint, isPoint,
pointFrom, pointFrom,
@ -18,27 +25,22 @@ import {
type GeometricShape, type GeometricShape,
} from "@excalidraw/utils/geometry/shape"; } from "@excalidraw/utils/geometry/shape";
import { import type { NormalizedZoomValue, Zoom } from "@excalidraw/excalidraw/types";
DEFAULT_ADAPTIVE_RADIUS,
DEFAULT_PROPORTIONAL_RADIUS,
LINE_CONFIRM_THRESHOLD,
ROUNDNESS,
} from "./constants";
import { getElementAbsoluteCoords } from "./element";
import { shouldTestInside } from "./element/collision";
import { LinearElementEditor } from "./element/linearElementEditor";
import { getBoundTextElement } from "./element/textElement";
import { ShapeCache } from "./scene/ShapeCache";
import { invariant } from "./utils";
import type { Bounds } from "./element/bounds"; import { getElementAbsoluteCoords } from "../index";
import { shouldTestInside } from "./collision";
import { LinearElementEditor } from "./linearElementEditor";
import { getBoundTextElement } from "./textElement";
import { ShapeCache } from "./scene/ShapeCache";
import type { Bounds } from "./bounds";
import type { import type {
ElementsMap, ElementsMap,
ExcalidrawElement, ExcalidrawElement,
ExcalidrawLinearElement, ExcalidrawLinearElement,
NonDeleted, NonDeleted,
} from "./element/types"; } from "./types";
import type { NormalizedZoomValue, Zoom } from "./types";
/** /**
* get the pure geometric shape of an excalidraw elementw * get the pure geometric shape of an excalidraw elementw

View file

@ -1,7 +1,7 @@
import { LIBRARY_DISABLED_TYPES } from "../constants"; import { LIBRARY_DISABLED_TYPES, randomId } from "@excalidraw/common";
import { deepCopyElement } from "../element/newElement"; import { deepCopyElement } from "@excalidraw/element/newElement";
import { t } from "../i18n"; import { t } from "../i18n";
import { randomId } from "../random";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,3 +1,13 @@
import { getNonDeletedElements } from "@excalidraw/element";
import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element/frame";
import { KEYS, arrayToMap, getShortcutKey } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { alignElements } from "../align"; import { alignElements } from "../align";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { import {
@ -8,19 +18,15 @@ import {
CenterHorizontallyIcon, CenterHorizontallyIcon,
CenterVerticallyIcon, CenterVerticallyIcon,
} from "../components/icons"; } from "../components/icons";
import { getNonDeletedElements } from "../element";
import { isFrameLikeElement } from "../element/typeChecks";
import { updateFrameMembershipOfSelectedElements } from "../frame";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { isSomeElementSelected } from "../scene"; import { isSomeElementSelected } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { arrayToMap, getShortcutKey } from "../utils";
import { register } from "./register"; import { register } from "./register";
import type { Alignment } from "../align"; import type { Alignment } from "../align";
import type { ExcalidrawElement } from "../element/types";
import type { AppClassProperties, AppState, UIAppState } from "../types"; import type { AppClassProperties, AppState, UIAppState } from "../types";
export const alignActionsPredicate = ( export const alignActionsPredicate = (

View file

@ -3,38 +3,44 @@ import {
ROUNDNESS, ROUNDNESS,
TEXT_ALIGN, TEXT_ALIGN,
VERTICAL_ALIGN, VERTICAL_ALIGN,
} from "../constants"; arrayToMap,
import { isTextElement, newElement } from "../element"; getFontString,
} from "@excalidraw/common";
import { isTextElement, newElement } from "@excalidraw/element";
import { import {
getOriginalContainerHeightFromCache, getOriginalContainerHeightFromCache,
resetOriginalContainerCache, resetOriginalContainerCache,
updateOriginalContainerCache, updateOriginalContainerCache,
} from "../element/containerCache"; } from "@excalidraw/element/containerCache";
import { mutateElement } from "../element/mutateElement";
import { import {
computeBoundTextPosition, computeBoundTextPosition,
computeContainerDimensionForBoundText, computeContainerDimensionForBoundText,
getBoundTextElement, getBoundTextElement,
redrawTextBoundingBox, redrawTextBoundingBox,
} from "../element/textElement"; } from "@excalidraw/element/textElement";
import { measureText } from "../element/textMeasurements";
import { import {
hasBoundTextElement, hasBoundTextElement,
isTextBindableContainer, isTextBindableContainer,
isUsingAdaptiveRadius, isUsingAdaptiveRadius,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { syncMovedIndices } from "../fractionalIndex";
import { CaptureUpdateAction } from "../store";
import { arrayToMap, getFontString } from "../utils";
import { register } from "./register"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { measureText } from "@excalidraw/element/textMeasurements";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawLinearElement, ExcalidrawLinearElement,
ExcalidrawTextContainer, ExcalidrawTextContainer,
ExcalidrawTextElement, ExcalidrawTextElement,
} from "../element/types"; } from "@excalidraw/element/types";
import { syncMovedIndices } from "../fractionalIndex";
import { CaptureUpdateAction } from "../store";
import { register } from "./register";
import type { AppState } from "../types"; import type { AppState } from "../types";
import type { Mutable } from "../utility-types"; import type { Mutable } from "../utility-types";

View file

@ -1,11 +1,31 @@
import { clamp, roundToStep } from "@excalidraw/math"; import { clamp, roundToStep } from "@excalidraw/math";
import {
DEFAULT_CANVAS_BACKGROUND_PICKS,
CURSOR_TYPE,
MAX_ZOOM,
MIN_ZOOM,
THEME,
ZOOM_STEP,
getShortcutKey,
updateActiveTool,
CODES,
KEYS,
} from "@excalidraw/common";
import { getCommonBounds, getNonDeletedElements } from "@excalidraw/element";
import { newElementWith } from "@excalidraw/element/mutateElement";
import type { SceneBounds } from "@excalidraw/element/bounds";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { import {
getDefaultAppState, getDefaultAppState,
isEraserActive, isEraserActive,
isHandToolActive, isHandToolActive,
} from "../appState"; } from "../appState";
import { DEFAULT_CANVAS_BACKGROUND_PICKS } from "../colors";
import { ColorPicker } from "../components/ColorPicker/ColorPicker"; import { ColorPicker } from "../components/ColorPicker/ColorPicker";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { Tooltip } from "../components/Tooltip"; import { Tooltip } from "../components/Tooltip";
@ -19,28 +39,16 @@ import {
ZoomOutIcon, ZoomOutIcon,
ZoomResetIcon, ZoomResetIcon,
} from "../components/icons"; } from "../components/icons";
import {
CURSOR_TYPE,
MAX_ZOOM,
MIN_ZOOM,
THEME,
ZOOM_STEP,
} from "../constants";
import { setCursor } from "../cursor"; import { setCursor } from "../cursor";
import { getCommonBounds, getNonDeletedElements } from "../element";
import { newElementWith } from "../element/mutateElement";
import { t } from "../i18n"; import { t } from "../i18n";
import { CODES, KEYS } from "../keys";
import { getNormalizedZoom } from "../scene"; import { getNormalizedZoom } from "../scene";
import { centerScrollOn } from "../scene/scroll"; import { centerScrollOn } from "../scene/scroll";
import { getStateForZoom } from "../scene/zoom"; import { getStateForZoom } from "../scene/zoom";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { getShortcutKey, updateActiveTool } from "../utils";
import { register } from "./register"; import { register } from "./register";
import type { SceneBounds } from "../element/bounds";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, Offsets } from "../types"; import type { AppState, Offsets } from "../types";
export const actionChangeViewBackgroundColor = register({ export const actionChangeViewBackgroundColor = register({

View file

@ -1,3 +1,8 @@
import { isTextElement } from "@excalidraw/element/typeChecks";
import { getTextFromElements } from "@excalidraw/element/textElement";
import { CODES, KEYS, isFirefox } from "@excalidraw/common";
import { import {
copyTextToSystemClipboard, copyTextToSystemClipboard,
copyToClipboard, copyToClipboard,
@ -7,11 +12,9 @@ import {
readSystemClipboard, readSystemClipboard,
} from "../clipboard"; } from "../clipboard";
import { DuplicateIcon, cutIcon, pngIcon, svgIcon } from "../components/icons"; import { DuplicateIcon, cutIcon, pngIcon, svgIcon } from "../components/icons";
import { isFirefox } from "../constants";
import { exportCanvas, prepareElementsForExport } from "../data/index"; import { exportCanvas, prepareElementsForExport } from "../data/index";
import { getTextFromElements, isTextElement } from "../element";
import { t } from "../i18n"; import { t } from "../i18n";
import { CODES, KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { actionDeleteSelected } from "./actionDeleteSelected"; import { actionDeleteSelected } from "./actionDeleteSelected";

View file

@ -1,26 +1,31 @@
import { ToolButton } from "../components/ToolButton"; import { KEYS, updateActiveTool } from "@excalidraw/common";
import { TrashIcon } from "../components/icons";
import { getNonDeletedElements } from "../element"; import { getNonDeletedElements } from "@excalidraw/element";
import { fixBindingsAfterDeletion } from "../element/binding"; import { fixBindingsAfterDeletion } from "@excalidraw/element/binding";
import { LinearElementEditor } from "../element/linearElementEditor"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { mutateElement, newElementWith } from "../element/mutateElement"; import {
import { getContainerElement } from "../element/textElement"; mutateElement,
newElementWith,
} from "@excalidraw/element/mutateElement";
import { getContainerElement } from "@excalidraw/element/textElement";
import { import {
isBoundToContainer, isBoundToContainer,
isElbowArrow, isElbowArrow,
isFrameLikeElement, isFrameLikeElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { getFrameChildren } from "../frame"; import { getFrameChildren } from "@excalidraw/element/frame";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { getElementsInGroup, selectGroupsForSelectedElements } from "../groups"; import { getElementsInGroup, selectGroupsForSelectedElements } from "../groups";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { getSelectedElements, isSomeElementSelected } from "../scene"; import { getSelectedElements, isSomeElementSelected } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { updateActiveTool } from "../utils"; import { TrashIcon } from "../components/icons";
import { ToolButton } from "../components/ToolButton";
import { register } from "./register"; import { register } from "./register";
import type { ExcalidrawElement } from "../element/types";
import type { AppClassProperties, AppState } from "../types"; import type { AppClassProperties, AppState } from "../types";
const deleteSelectedElements = ( const deleteSelectedElements = (

View file

@ -1,22 +1,29 @@
import { getNonDeletedElements } from "@excalidraw/element";
import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import { CODES, KEYS, arrayToMap, getShortcutKey } from "@excalidraw/common";
import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element/frame";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { import {
DistributeHorizontallyIcon, DistributeHorizontallyIcon,
DistributeVerticallyIcon, DistributeVerticallyIcon,
} from "../components/icons"; } from "../components/icons";
import { distributeElements } from "../distribute"; import { distributeElements } from "../distribute";
import { getNonDeletedElements } from "../element";
import { isFrameLikeElement } from "../element/typeChecks";
import { updateFrameMembershipOfSelectedElements } from "../frame";
import { t } from "../i18n"; import { t } from "../i18n";
import { CODES, KEYS } from "../keys";
import { isSomeElementSelected } from "../scene"; import { isSomeElementSelected } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { arrayToMap, getShortcutKey } from "../utils";
import { register } from "./register"; import { register } from "./register";
import type { Distribution } from "../distribute"; import type { Distribution } from "../distribute";
import type { ExcalidrawElement } from "../element/types";
import type { AppClassProperties, AppState } from "../types"; import type { AppClassProperties, AppState } from "../types";
const enableActionGroup = (appState: AppState, app: AppClassProperties) => { const enableActionGroup = (appState: AppState, app: AppClassProperties) => {

View file

@ -1,6 +1,5 @@
import React from "react"; import { ORIG_ID } from "@excalidraw/common";
import { ORIG_ID } from "../constants";
import { Excalidraw } from "../index"; import { Excalidraw } from "../index";
import { API } from "../tests/helpers/api"; import { API } from "../tests/helpers/api";
import { import {

View file

@ -1,49 +1,60 @@
import { ToolButton } from "../components/ToolButton"; import {
import { DuplicateIcon } from "../components/icons"; DEFAULT_GRID_SIZE,
import { DEFAULT_GRID_SIZE } from "../constants"; KEYS,
import { duplicateElement, getNonDeletedElements } from "../element"; arrayToMap,
import { fixBindingsAfterDuplication } from "../element/binding"; castArray,
findLastIndex,
getShortcutKey,
invariant,
} from "@excalidraw/common";
import { duplicateElement, getNonDeletedElements } from "@excalidraw/element";
import { fixBindingsAfterDuplication } from "@excalidraw/element/binding";
import { import {
bindTextToShapeAfterDuplication, bindTextToShapeAfterDuplication,
getBoundTextElement, getBoundTextElement,
getContainerElement, getContainerElement,
} from "../element/textElement"; } from "@excalidraw/element/textElement";
import { import {
hasBoundTextElement, hasBoundTextElement,
isBoundToContainer, isBoundToContainer,
isFrameLikeElement, isFrameLikeElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { normalizeElementOrder } from "../element/sortElements";
import { LinearElementEditor } from "../element/linearElementEditor"; import { normalizeElementOrder } from "@excalidraw/element/sortElements";
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { import {
bindElementsToFramesAfterDuplication, bindElementsToFramesAfterDuplication,
getFrameChildren, getFrameChildren,
} from "../frame"; } from "@excalidraw/element/frame";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { ToolButton } from "../components/ToolButton";
import { DuplicateIcon } from "../components/icons";
import { import {
selectGroupsForSelectedElements, selectGroupsForSelectedElements,
getSelectedGroupForElement, getSelectedGroupForElement,
getElementsInGroup, getElementsInGroup,
} from "../groups"; } from "../groups";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { isSomeElementSelected } from "../scene"; import { isSomeElementSelected } from "../scene";
import { import {
excludeElementsInFramesFromSelection, excludeElementsInFramesFromSelection,
getSelectedElements, getSelectedElements,
} from "../scene/selection"; } from "../scene/selection";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import {
arrayToMap,
castArray,
findLastIndex,
getShortcutKey,
invariant,
} from "../utils";
import { register } from "./register"; import { register } from "./register";
import type { ActionResult } from "./types"; import type { ActionResult } from "./types";
import type { ExcalidrawElement } from "../element/types";
import type { AppState } from "../types"; import type { AppState } from "../types";
export const actionDuplicateSelection = register({ export const actionDuplicateSelection = register({

View file

@ -1,10 +1,11 @@
import { copyTextToSystemClipboard } from "../clipboard";
import { copyIcon, elementLinkIcon } from "../components/icons";
import { import {
canCreateLinkFromElements, canCreateLinkFromElements,
defaultGetElementLinkFromSelection, defaultGetElementLinkFromSelection,
getLinkIdAndTypeFromSelection, getLinkIdAndTypeFromSelection,
} from "../element/elementLink"; } from "@excalidraw/element/elementLink";
import { copyTextToSystemClipboard } from "../clipboard";
import { copyIcon, elementLinkIcon } from "../components/icons";
import { t } from "../i18n"; import { t } from "../i18n";
import { getSelectedElements } from "../scene"; import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";

View file

@ -1,15 +1,18 @@
import { KEYS, arrayToMap } from "@excalidraw/common";
import { newElementWith } from "@excalidraw/element/mutateElement";
import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { LockedIcon, UnlockedIcon } from "../components/icons"; import { LockedIcon, UnlockedIcon } from "../components/icons";
import { newElementWith } from "../element/mutateElement";
import { isFrameLikeElement } from "../element/typeChecks";
import { KEYS } from "../keys";
import { getSelectedElements } from "../scene"; import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { arrayToMap } from "../utils";
import { register } from "./register"; import { register } from "./register";
import type { ExcalidrawElement } from "../element/types";
const shouldLock = (elements: readonly ExcalidrawElement[]) => const shouldLock = (elements: readonly ExcalidrawElement[]) =>
elements.every((el) => !el.locked); elements.every((el) => !el.locked);

View file

@ -1,6 +1,7 @@
import { updateActiveTool } from "@excalidraw/common";
import { setCursorForShape } from "../cursor"; import { setCursorForShape } from "../cursor";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { updateActiveTool } from "../utils";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,3 +1,14 @@
import {
KEYS,
DEFAULT_EXPORT_PADDING,
EXPORT_SCALES,
THEME,
} from "@excalidraw/common";
import { getNonDeletedElements } from "@excalidraw/element";
import type { Theme } from "@excalidraw/element/types";
import { useDevice } from "../components/App"; import { useDevice } from "../components/App";
import { CheckboxItem } from "../components/CheckboxItem"; import { CheckboxItem } from "../components/CheckboxItem";
import { DarkModeToggle } from "../components/DarkModeToggle"; import { DarkModeToggle } from "../components/DarkModeToggle";
@ -5,14 +16,12 @@ import { ProjectName } from "../components/ProjectName";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { Tooltip } from "../components/Tooltip"; import { Tooltip } from "../components/Tooltip";
import { ExportIcon, questionCircle, saveAs } from "../components/icons"; import { ExportIcon, questionCircle, saveAs } from "../components/icons";
import { DEFAULT_EXPORT_PADDING, EXPORT_SCALES, THEME } from "../constants";
import { loadFromJSON, saveAsJSON } from "../data"; import { loadFromJSON, saveAsJSON } from "../data";
import { isImageFileHandle } from "../data/blob"; import { isImageFileHandle } from "../data/blob";
import { nativeFileSystemSupported } from "../data/filesystem"; import { nativeFileSystemSupported } from "../data/filesystem";
import { resaveAsImageWithScene } from "../data/resave"; import { resaveAsImageWithScene } from "../data/resave";
import { getNonDeletedElements } from "../element";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { getSelectedElements, isSomeElementSelected } from "../scene"; import { getSelectedElements, isSomeElementSelected } from "../scene";
import { getExportSize } from "../scene/export"; import { getExportSize } from "../scene/export";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
@ -21,8 +30,6 @@ import "../components/ToolIcon.scss";
import { register } from "./register"; import { register } from "./register";
import type { Theme } from "../element/types";
export const actionChangeProjectName = register({ export const actionChangeProjectName = register({
name: "changeProjectName", name: "changeProjectName",
label: "labels.fileTitle", label: "labels.fileTitle",

View file

@ -1,21 +1,25 @@
import { pointFrom } from "@excalidraw/math"; import { pointFrom } from "@excalidraw/math";
import { ToolButton } from "../components/ToolButton"; import { isInvisiblySmallElement } from "@excalidraw/element";
import { done } from "../components/icons";
import { resetCursor } from "../cursor";
import { isInvisiblySmallElement } from "../element";
import { import {
maybeBindLinearElement, maybeBindLinearElement,
bindOrUnbindLinearElement, bindOrUnbindLinearElement,
} from "../element/binding"; } from "@excalidraw/element/binding";
import { LinearElementEditor } from "../element/linearElementEditor"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { mutateElement } from "../element/mutateElement"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { isBindingElement, isLinearElement } from "../element/typeChecks"; import {
isBindingElement,
isLinearElement,
} from "@excalidraw/element/typeChecks";
import { KEYS, arrayToMap, updateActiveTool } from "@excalidraw/common";
import { isPathALoop } from "@excalidraw/element/shapes";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys"; import { resetCursor } from "../cursor";
import { isPathALoop } from "../shapes"; import { done } from "../components/icons";
import { ToolButton } from "../components/ToolButton";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { arrayToMap, updateActiveTool } from "../utils";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,5 +1,4 @@
import { pointFrom } from "@excalidraw/math"; import { pointFrom } from "@excalidraw/math";
import React from "react";
import { Excalidraw } from "../index"; import { Excalidraw } from "../index";
import { API } from "../tests/helpers/api"; import { API } from "../tests/helpers/api";

View file

@ -1,25 +1,22 @@
import { flipHorizontal, flipVertical } from "../components/icons"; import { getNonDeletedElements } from "@excalidraw/element";
import { getNonDeletedElements } from "../element";
import { import {
bindOrUnbindLinearElements, bindOrUnbindLinearElements,
isBindingEnabled, isBindingEnabled,
} from "../element/binding"; } from "@excalidraw/element/binding";
import { getCommonBoundingBox } from "../element/bounds"; import { getCommonBoundingBox } from "@excalidraw/element/bounds";
import { mutateElement, newElementWith } from "../element/mutateElement"; import {
import { deepCopyElement } from "../element/newElement"; mutateElement,
import { resizeMultipleElements } from "../element/resizeElements"; newElementWith,
} from "@excalidraw/element/mutateElement";
import { deepCopyElement } from "@excalidraw/element/newElement";
import { resizeMultipleElements } from "@excalidraw/element/resizeElements";
import { import {
isArrowElement, isArrowElement,
isElbowArrow, isElbowArrow,
isLinearElement, isLinearElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { updateFrameMembershipOfSelectedElements } from "../frame"; import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element/frame";
import { CODES, KEYS } from "../keys"; import { CODES, KEYS, arrayToMap } from "@excalidraw/common";
import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store";
import { arrayToMap } from "../utils";
import { register } from "./register";
import type { import type {
ExcalidrawArrowElement, ExcalidrawArrowElement,
@ -27,7 +24,15 @@ import type {
ExcalidrawElement, ExcalidrawElement,
NonDeleted, NonDeleted,
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
} from "../element/types"; } from "@excalidraw/element/types";
import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store";
import { flipHorizontal, flipVertical } from "../components/icons";
import { register } from "./register";
import type { AppClassProperties, AppState } from "../types"; import type { AppClassProperties, AppState } from "../types";
export const actionFlipHorizontal = register({ export const actionFlipHorizontal = register({

View file

@ -1,20 +1,25 @@
import { frameToolIcon } from "../components/icons"; import { getCommonBounds, getNonDeletedElements } from "@excalidraw/element";
import { setCursorForShape } from "../cursor"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { getCommonBounds, getNonDeletedElements } from "../element"; import { newFrameElement } from "@excalidraw/element/newElement";
import { mutateElement } from "../element/mutateElement"; import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import { newFrameElement } from "../element/newElement"; import {
import { isFrameLikeElement } from "../element/typeChecks"; addElementsToFrame,
import { addElementsToFrame, removeAllElementsFromFrame } from "../frame"; removeAllElementsFromFrame,
import { getFrameChildren } from "../frame"; } from "@excalidraw/element/frame";
import { getFrameChildren } from "@excalidraw/element/frame";
import { KEYS, updateActiveTool } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { getElementsInGroup } from "../groups"; import { getElementsInGroup } from "../groups";
import { KEYS } from "../keys"; import { setCursorForShape } from "../cursor";
import { frameToolIcon } from "../components/icons";
import { getSelectedElements } from "../scene"; import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { updateActiveTool } from "../utils";
import { register } from "./register"; import { register } from "./register";
import type { ExcalidrawElement } from "../element/types";
import type { AppClassProperties, AppState, UIAppState } from "../types"; import type { AppClassProperties, AppState, UIAppState } from "../types";
const isSingleFrameSelected = ( const isSingleFrameSelected = (

View file

@ -1,9 +1,9 @@
import { ToolButton } from "../components/ToolButton"; import { getNonDeletedElements } from "@excalidraw/element";
import { UngroupIcon, GroupIcon } from "../components/icons";
import { getNonDeletedElements } from "../element"; import { newElementWith } from "@excalidraw/element/mutateElement";
import { newElementWith } from "../element/mutateElement";
import { isBoundToContainer } from "../element/typeChecks"; import { isBoundToContainer } from "@excalidraw/element/typeChecks";
import { syncMovedIndices } from "../fractionalIndex";
import { import {
frameAndChildrenSelectedTogether, frameAndChildrenSelectedTogether,
getElementsInResizingFrame, getElementsInResizingFrame,
@ -12,7 +12,21 @@ import {
groupByFrameLikes, groupByFrameLikes,
removeElementsFromFrame, removeElementsFromFrame,
replaceAllElementsInFrame, replaceAllElementsInFrame,
} from "../frame"; } from "@excalidraw/element/frame";
import { KEYS, randomId, arrayToMap, getShortcutKey } from "@excalidraw/common";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
OrderedExcalidrawElement,
} from "@excalidraw/element/types";
import { ToolButton } from "../components/ToolButton";
import { UngroupIcon, GroupIcon } from "../components/icons";
import { syncMovedIndices } from "../fractionalIndex";
import { import {
getSelectedGroupIds, getSelectedGroupIds,
selectGroup, selectGroup,
@ -23,19 +37,12 @@ import {
isElementInGroup, isElementInGroup,
} from "../groups"; } from "../groups";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { randomId } from "../random";
import { isSomeElementSelected } from "../scene"; import { isSomeElementSelected } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { arrayToMap, getShortcutKey } from "../utils";
import { register } from "./register"; import { register } from "./register";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
OrderedExcalidrawElement,
} from "../element/types";
import type { AppClassProperties, AppState } from "../types"; import type { AppClassProperties, AppState } from "../types";
const allElementsInSameGroup = (elements: readonly ExcalidrawElement[]) => { const allElementsInSameGroup = (elements: readonly ExcalidrawElement[]) => {

View file

@ -1,14 +1,14 @@
import { isWindows, KEYS, matchKey, arrayToMap } from "@excalidraw/common";
import type { SceneElementsMap } from "@excalidraw/element/types";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { UndoIcon, RedoIcon } from "../components/icons"; import { UndoIcon, RedoIcon } from "../components/icons";
import { isWindows } from "../constants";
import { HistoryChangedEvent } from "../history"; import { HistoryChangedEvent } from "../history";
import { useEmitter } from "../hooks/useEmitter"; import { useEmitter } from "../hooks/useEmitter";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS, matchKey } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { arrayToMap } from "../utils";
import type { SceneElementsMap } from "../element/types";
import type { History } from "../history"; import type { History } from "../history";
import type { Store } from "../store"; import type { Store } from "../store";
import type { AppClassProperties, AppState } from "../types"; import type { AppClassProperties, AppState } from "../types";

View file

@ -1,15 +1,18 @@
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { isElbowArrow, isLinearElement } from "@excalidraw/element/typeChecks";
import type { ExcalidrawLinearElement } from "@excalidraw/element/types";
import { DEFAULT_CATEGORIES } from "../components/CommandPalette/CommandPalette"; import { DEFAULT_CATEGORIES } from "../components/CommandPalette/CommandPalette";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { lineEditorIcon } from "../components/icons"; import { lineEditorIcon } from "../components/icons";
import { LinearElementEditor } from "../element/linearElementEditor";
import { isElbowArrow, isLinearElement } from "../element/typeChecks";
import { t } from "../i18n"; import { t } from "../i18n";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";
import type { ExcalidrawLinearElement } from "../element/types";
export const actionToggleLinearEditor = register({ export const actionToggleLinearEditor = register({
name: "toggleLinearEditor", name: "toggleLinearEditor",
category: DEFAULT_CATEGORIES.elements, category: DEFAULT_CATEGORIES.elements,

View file

@ -1,12 +1,14 @@
import { isEmbeddableElement } from "@excalidraw/element/typeChecks";
import { KEYS, getShortcutKey } from "@excalidraw/common";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { getContextMenuLabel } from "../components/hyperlink/Hyperlink"; import { getContextMenuLabel } from "../components/hyperlink/Hyperlink";
import { LinkIcon } from "../components/icons"; import { LinkIcon } from "../components/icons";
import { isEmbeddableElement } from "../element/typeChecks";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { getSelectedElements } from "../scene"; import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { getShortcutKey } from "../utils";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,8 +1,14 @@
import { KEYS } from "@excalidraw/common";
import {
showSelectedShapeActions,
getNonDeletedElements,
} from "@excalidraw/element";
import { ToolButton } from "../components/ToolButton"; import { ToolButton } from "../components/ToolButton";
import { HamburgerMenuIcon, HelpIconThin, palette } from "../components/icons"; import { HamburgerMenuIcon, HelpIconThin, palette } from "../components/icons";
import { showSelectedShapeActions, getNonDeletedElements } from "../element";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,8 +1,12 @@
import { queryByTestId } from "@testing-library/react"; import { queryByTestId } from "@testing-library/react";
import React from "react";
import { COLOR_PALETTE, DEFAULT_ELEMENT_BACKGROUND_PICKS } from "../colors"; import {
import { FONT_FAMILY, STROKE_WIDTH } from "../constants"; COLOR_PALETTE,
DEFAULT_ELEMENT_BACKGROUND_PICKS,
FONT_FAMILY,
STROKE_WIDTH,
} from "@excalidraw/common";
import { Excalidraw } from "../index"; import { Excalidraw } from "../index";
import { API } from "../tests/helpers/api"; import { API } from "../tests/helpers/api";
import { UI } from "../tests/helpers/ui"; import { UI } from "../tests/helpers/ui";

View file

@ -1,15 +1,72 @@
import { pointFrom } from "@excalidraw/math"; import { pointFrom } from "@excalidraw/math";
import { useEffect, useMemo, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import type { LocalPoint } from "@excalidraw/math";
import { trackEvent } from "../analytics";
import { import {
DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE, DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE,
DEFAULT_ELEMENT_BACKGROUND_PICKS, DEFAULT_ELEMENT_BACKGROUND_PICKS,
DEFAULT_ELEMENT_STROKE_COLOR_PALETTE, DEFAULT_ELEMENT_STROKE_COLOR_PALETTE,
DEFAULT_ELEMENT_STROKE_PICKS, DEFAULT_ELEMENT_STROKE_PICKS,
} from "../colors"; ARROW_TYPE,
DEFAULT_FONT_FAMILY,
DEFAULT_FONT_SIZE,
FONT_FAMILY,
ROUNDNESS,
STROKE_WIDTH,
VERTICAL_ALIGN,
KEYS,
randomInteger,
arrayToMap,
getFontFamilyString,
getShortcutKey,
tupleToCoors,
} from "@excalidraw/common";
import {
getNonDeletedElements,
isTextElement,
redrawTextBoundingBox,
} from "@excalidraw/element";
import {
bindLinearElement,
bindPointToSnapToElementOutline,
calculateFixedPointForElbowArrowBinding,
getHoveredElementForBinding,
updateBoundElements,
} from "@excalidraw/element/binding";
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import {
mutateElement,
newElementWith,
} from "@excalidraw/element/mutateElement";
import { getBoundTextElement } from "@excalidraw/element/textElement";
import {
isArrowElement,
isBoundToContainer,
isElbowArrow,
isLinearElement,
isUsingAdaptiveRadius,
} from "@excalidraw/element/typeChecks";
import type { LocalPoint } from "@excalidraw/math";
import type {
Arrowhead,
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawLinearElement,
ExcalidrawTextElement,
FontFamilyValues,
TextAlign,
VerticalAlign,
NonDeletedSceneElementsMap,
} from "@excalidraw/element/types";
import { trackEvent } from "../analytics";
import { ButtonIconSelect } from "../components/ButtonIconSelect"; import { ButtonIconSelect } from "../components/ButtonIconSelect";
import { ColorPicker } from "../components/ColorPicker/ColorPicker"; import { ColorPicker } from "../components/ColorPicker/ColorPicker";
import { FontPicker } from "../components/FontPicker/FontPicker"; import { FontPicker } from "../components/FontPicker/FontPicker";
@ -60,42 +117,10 @@ import {
ArrowheadCrowfootOneIcon, ArrowheadCrowfootOneIcon,
ArrowheadCrowfootOneOrManyIcon, ArrowheadCrowfootOneOrManyIcon,
} from "../components/icons"; } from "../components/icons";
import {
ARROW_TYPE,
DEFAULT_FONT_FAMILY,
DEFAULT_FONT_SIZE,
FONT_FAMILY,
ROUNDNESS,
STROKE_WIDTH,
VERTICAL_ALIGN,
} from "../constants";
import {
getNonDeletedElements,
isTextElement,
redrawTextBoundingBox,
} from "../element";
import {
bindLinearElement,
bindPointToSnapToElementOutline,
calculateFixedPointForElbowArrowBinding,
getHoveredElementForBinding,
updateBoundElements,
} from "../element/binding";
import { LinearElementEditor } from "../element/linearElementEditor";
import { mutateElement, newElementWith } from "../element/mutateElement";
import { getBoundTextElement } from "../element/textElement";
import {
isArrowElement,
isBoundToContainer,
isElbowArrow,
isLinearElement,
isUsingAdaptiveRadius,
} from "../element/typeChecks";
import { Fonts } from "../fonts"; import { Fonts } from "../fonts";
import { getLineHeight } from "../fonts/FontMetadata"; import { getLineHeight } from "../fonts/FontMetadata";
import { getLanguage, t } from "../i18n"; import { getLanguage, t } from "../i18n";
import { KEYS } from "../keys";
import { randomInteger } from "../random";
import { import {
canHaveArrowheads, canHaveArrowheads,
getCommonAttributeOfSelectedElements, getCommonAttributeOfSelectedElements,
@ -105,26 +130,9 @@ import {
} from "../scene"; } from "../scene";
import { hasStrokeColor } from "../scene/comparisons"; import { hasStrokeColor } from "../scene/comparisons";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import {
arrayToMap,
getFontFamilyString,
getShortcutKey,
tupleToCoors,
} from "../utils";
import { register } from "./register"; import { register } from "./register";
import type {
Arrowhead,
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawLinearElement,
ExcalidrawTextElement,
FontFamilyValues,
TextAlign,
VerticalAlign,
NonDeletedSceneElementsMap,
} from "../element/types";
import type { CaptureUpdateActionType } from "../store"; import type { CaptureUpdateActionType } from "../store";
import type { AppClassProperties, AppState, Primitive } from "../types"; import type { AppClassProperties, AppState, Primitive } from "../types";

View file

@ -1,14 +1,17 @@
import { selectAllIcon } from "../components/icons"; import { getNonDeletedElements, isTextElement } from "@excalidraw/element";
import { getNonDeletedElements, isTextElement } from "../element"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { LinearElementEditor } from "../element/linearElementEditor"; import { isLinearElement } from "@excalidraw/element/typeChecks";
import { isLinearElement } from "../element/typeChecks";
import { KEYS } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { selectGroupsForSelectedElements } from "../groups"; import { selectGroupsForSelectedElements } from "../groups";
import { KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { selectAllIcon } from "../components/icons";
import type { ExcalidrawElement } from "../element/types"; import { register } from "./register";
export const actionSelectAll = register({ export const actionSelectAll = register({
name: "selectAll", name: "selectAll",

View file

@ -1,33 +1,40 @@
import { paintIcon } from "../components/icons";
import { import {
DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE,
DEFAULT_FONT_FAMILY, DEFAULT_FONT_FAMILY,
DEFAULT_TEXT_ALIGN, DEFAULT_TEXT_ALIGN,
} from "../constants"; CODES,
KEYS,
} from "@excalidraw/common";
import { import {
isTextElement, isTextElement,
isExcalidrawElement, isExcalidrawElement,
redrawTextBoundingBox, redrawTextBoundingBox,
} from "../element"; } from "@excalidraw/element";
import { newElementWith } from "../element/mutateElement";
import { getBoundTextElement } from "../element/textElement"; import { newElementWith } from "@excalidraw/element/mutateElement";
import { import {
hasBoundTextElement, hasBoundTextElement,
canApplyRoundnessTypeToElement, canApplyRoundnessTypeToElement,
getDefaultRoundnessTypeForElement, getDefaultRoundnessTypeForElement,
isFrameLikeElement, isFrameLikeElement,
isArrowElement, isArrowElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { getBoundTextElement } from "@excalidraw/element/textElement";
import type { ExcalidrawTextElement } from "@excalidraw/element/types";
import { paintIcon } from "../components/icons";
import { getLineHeight } from "../fonts/FontMetadata"; import { getLineHeight } from "../fonts/FontMetadata";
import { t } from "../i18n"; import { t } from "../i18n";
import { CODES, KEYS } from "../keys";
import { getSelectedElements } from "../scene"; import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";
import type { ExcalidrawTextElement } from "../element/types";
// `copiedStyles` is exported only for tests. // `copiedStyles` is exported only for tests.
export let copiedStyles: string = "{}"; export let copiedStyles: string = "{}";

View file

@ -1,9 +1,11 @@
import { isTextElement } from "../element"; import { getFontString } from "@excalidraw/common";
import { newElementWith } from "../element/mutateElement";
import { measureText } from "../element/textMeasurements"; import { isTextElement } from "@excalidraw/element";
import { newElementWith } from "@excalidraw/element/mutateElement";
import { measureText } from "@excalidraw/element/textMeasurements";
import { getSelectedElements } from "../scene"; import { getSelectedElements } from "../scene";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { getFontString } from "../utils";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,5 +1,6 @@
import { CODES, KEYS } from "@excalidraw/common";
import { gridIcon } from "../components/icons"; import { gridIcon } from "../components/icons";
import { CODES, KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,5 +1,6 @@
import { CODES, KEYS } from "@excalidraw/common";
import { magnetIcon } from "../components/icons"; import { magnetIcon } from "../components/icons";
import { CODES, KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,6 +1,11 @@
import {
KEYS,
CANVAS_SEARCH_TAB,
CLASSES,
DEFAULT_SIDEBAR,
} from "@excalidraw/common";
import { searchIcon } from "../components/icons"; import { searchIcon } from "../components/icons";
import { CANVAS_SEARCH_TAB, CLASSES, DEFAULT_SIDEBAR } from "../constants";
import { KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,5 +1,6 @@
import { CODES, KEYS } from "@excalidraw/common";
import { abacusIcon } from "../components/icons"; import { abacusIcon } from "../components/icons";
import { CODES, KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,5 +1,6 @@
import { CODES, KEYS } from "@excalidraw/common";
import { eyeIcon } from "../components/icons"; import { eyeIcon } from "../components/icons";
import { CODES, KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,5 +1,6 @@
import { CODES, KEYS } from "@excalidraw/common";
import { coffeeIcon } from "../components/icons"; import { coffeeIcon } from "../components/icons";
import { CODES, KEYS } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { register } from "./register"; import { register } from "./register";

View file

@ -1,14 +1,13 @@
import { KEYS, CODES, getShortcutKey, isDarwin } from "@excalidraw/common";
import { import {
BringForwardIcon, BringForwardIcon,
BringToFrontIcon, BringToFrontIcon,
SendBackwardIcon, SendBackwardIcon,
SendToBackIcon, SendToBackIcon,
} from "../components/icons"; } from "../components/icons";
import { isDarwin } from "../constants";
import { t } from "../i18n"; import { t } from "../i18n";
import { KEYS, CODES } from "../keys";
import { CaptureUpdateAction } from "../store"; import { CaptureUpdateAction } from "../store";
import { getShortcutKey } from "../utils";
import { import {
moveOneLeft, moveOneLeft,
moveOneRight, moveOneRight,

View file

@ -1,12 +1,14 @@
import React from "react"; import React from "react";
import { trackEvent } from "../analytics"; import { isPromiseLike } from "@excalidraw/common";
import { isPromiseLike } from "../utils";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
OrderedExcalidrawElement, OrderedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import { trackEvent } from "../analytics";
import type { AppClassProperties, AppState } from "../types"; import type { AppClassProperties, AppState } from "../types";
import type { import type {
Action, Action,

View file

@ -1,6 +1,6 @@
import { isDarwin } from "../constants"; import { isDarwin, getShortcutKey } from "@excalidraw/common";
import { t } from "../i18n"; import { t } from "../i18n";
import { getShortcutKey } from "../utils";
import type { SubtypeOf } from "../utility-types"; import type { SubtypeOf } from "../utility-types";
import type { ActionName } from "./types"; import type { ActionName } from "./types";

View file

@ -1,7 +1,8 @@
import type { import type {
ExcalidrawElement, ExcalidrawElement,
OrderedExcalidrawElement, OrderedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import type { CaptureUpdateActionType } from "../store"; import type { CaptureUpdateActionType } from "../store";
import type { import type {
AppClassProperties, AppClassProperties,

View file

@ -1,10 +1,12 @@
import { updateBoundElements } from "./element/binding"; import { updateBoundElements } from "@excalidraw/element/binding";
import { getCommonBoundingBox } from "./element/bounds"; import { getCommonBoundingBox } from "@excalidraw/element/bounds";
import { mutateElement } from "./element/mutateElement"; import { mutateElement } from "@excalidraw/element/mutateElement";
import type { BoundingBox } from "@excalidraw/element/bounds";
import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
import { getMaximumGroups } from "./groups"; import { getMaximumGroups } from "./groups";
import type { BoundingBox } from "./element/bounds";
import type { ElementsMap, ExcalidrawElement } from "./element/types";
import type Scene from "./scene/Scene"; import type Scene from "./scene/Scene";
export interface Alignment { export interface Alignment {

View file

@ -1,9 +1,12 @@
import { LaserPointer } from "@excalidraw/laser-pointer"; import { LaserPointer } from "@excalidraw/laser-pointer";
import type { LaserPointerOptions } from "@excalidraw/laser-pointer"; import {
SVG_NS,
getSvgPathFromStroke,
sceneCoordsToViewportCoords,
} from "@excalidraw/common";
import { SVG_NS } from "./constants"; import type { LaserPointerOptions } from "@excalidraw/laser-pointer";
import { getSvgPathFromStroke, sceneCoordsToViewportCoords } from "./utils";
import type { AnimationFrameHandler } from "./animation-frame-handler"; import type { AnimationFrameHandler } from "./animation-frame-handler";
import type App from "./components/App"; import type App from "./components/App";

View file

@ -1,5 +1,5 @@
import { COLOR_PALETTE } from "./colors";
import { import {
COLOR_PALETTE,
ARROW_TYPE, ARROW_TYPE,
DEFAULT_ELEMENT_PROPS, DEFAULT_ELEMENT_PROPS,
DEFAULT_FONT_FAMILY, DEFAULT_FONT_FAMILY,
@ -10,7 +10,7 @@ import {
STATS_PANELS, STATS_PANELS,
THEME, THEME,
DEFAULT_GRID_STEP, DEFAULT_GRID_STEP,
} from "./constants"; } from "@excalidraw/common";
import type { AppState, NormalizedZoomValue } from "./types"; import type { AppState, NormalizedZoomValue } from "./types";

View file

@ -1,36 +1,38 @@
import { ENV } from "./constants"; import {
ENV,
arrayToMap,
arrayToObject,
assertNever,
isShallowEqual,
toBrandedType,
} from "@excalidraw/common";
import { import {
BoundElement, BoundElement,
BindableElement, BindableElement,
bindingProperties, bindingProperties,
updateBoundElements, updateBoundElements,
} from "./element/binding"; } from "@excalidraw/element/binding";
import { LinearElementEditor } from "./element/linearElementEditor"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { mutateElement, newElementWith } from "./element/mutateElement"; import {
mutateElement,
newElementWith,
} from "@excalidraw/element/mutateElement";
import { import {
getBoundTextElementId, getBoundTextElementId,
redrawTextBoundingBox, redrawTextBoundingBox,
} from "./element/textElement"; } from "@excalidraw/element/textElement";
import { import {
hasBoundTextElement, hasBoundTextElement,
isBindableElement, isBindableElement,
isBoundToContainer, isBoundToContainer,
isImageElement, isImageElement,
isTextElement, isTextElement,
} from "./element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { orderByFractionalIndex, syncMovedIndices } from "./fractionalIndex";
import { getNonDeletedGroupIds } from "./groups"; import type { BindableProp, BindingProp } from "@excalidraw/element/binding";
import { getObservedAppState } from "./store";
import { import type { ElementUpdate } from "@excalidraw/element/mutateElement";
arrayToMap,
arrayToObject,
assertNever,
isShallowEqual,
toBrandedType,
} from "./utils";
import type { BindableProp, BindingProp } from "./element/binding";
import type { ElementUpdate } from "./element/mutateElement";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawImageElement, ExcalidrawImageElement,
@ -40,7 +42,12 @@ import type {
Ordered, Ordered,
OrderedExcalidrawElement, OrderedExcalidrawElement,
SceneElementsMap, SceneElementsMap,
} from "./element/types"; } from "@excalidraw/element/types";
import { orderByFractionalIndex, syncMovedIndices } from "./fractionalIndex";
import { getNonDeletedGroupIds } from "./groups";
import { getObservedAppState } from "./store";
import type { import type {
AppState, AppState,
ObservedAppState, ObservedAppState,

View file

@ -1,21 +1,23 @@
import { pointFrom } from "@excalidraw/math"; import { pointFrom } from "@excalidraw/math";
import type { Radians } from "@excalidraw/math";
import { import {
COLOR_PALETTE, COLOR_PALETTE,
DEFAULT_CHART_COLOR_INDEX, DEFAULT_CHART_COLOR_INDEX,
getAllColorsSpecificShade, getAllColorsSpecificShade,
} from "./colors";
import {
DEFAULT_FONT_FAMILY, DEFAULT_FONT_FAMILY,
DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE,
VERTICAL_ALIGN, VERTICAL_ALIGN,
} from "./constants"; randomId,
import { newElement, newLinearElement, newTextElement } from "./element"; } from "@excalidraw/common";
import { randomId } from "./random"; import {
newElement,
newLinearElement,
newTextElement,
} from "@excalidraw/element";
import type { NonDeletedExcalidrawElement } from "./element/types"; import type { Radians } from "@excalidraw/math";
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
export type ChartElements = readonly NonDeletedExcalidrawElement[]; export type ChartElements = readonly NonDeletedExcalidrawElement[];

View file

@ -4,7 +4,8 @@ import {
COLOR_WHITE, COLOR_WHITE,
THEME, THEME,
UserIdleState, UserIdleState,
} from "./constants"; } from "@excalidraw/common";
import { roundRect } from "./renderer/roundRect"; import { roundRect } from "./renderer/roundRect";
import type { InteractiveCanvasRenderConfig } from "./scene/types"; import type { InteractiveCanvasRenderConfig } from "./scene/types";

View file

@ -1,25 +1,32 @@
import { tryParseSpreadsheet, VALID_SPREADSHEET } from "./charts";
import { import {
ALLOWED_PASTE_MIME_TYPES, ALLOWED_PASTE_MIME_TYPES,
EXPORT_DATA_TYPES, EXPORT_DATA_TYPES,
MIME_TYPES, MIME_TYPES,
} from "./constants"; arrayToMap,
import { createFile, isSupportedImageFileType } from "./data/blob"; isMemberOf,
import { mutateElement } from "./element/mutateElement"; isPromiseLike,
import { deepCopyElement } from "./element/newElement"; } from "@excalidraw/common";
import { mutateElement } from "@excalidraw/element/mutateElement";
import { deepCopyElement } from "@excalidraw/element/newElement";
import { import {
isFrameLikeElement, isFrameLikeElement,
isInitializedImageElement, isInitializedImageElement,
} from "./element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { ExcalidrawError } from "./errors";
import { getContainingFrame } from "./frame"; import { getContainingFrame } from "@excalidraw/element/frame";
import { arrayToMap, isMemberOf, isPromiseLike } from "./utils";
import type { Spreadsheet } from "./charts";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "./element/types"; } from "@excalidraw/element/types";
import { ExcalidrawError } from "./errors";
import { createFile, isSupportedImageFileType } from "./data/blob";
import { tryParseSpreadsheet, VALID_SPREADSHEET } from "./charts";
import type { Spreadsheet } from "./charts";
import type { BinaryFiles } from "./types"; import type { BinaryFiles } from "./types";
type ElementsClipboard = { type ElementsClipboard = {

View file

@ -1,3 +1,10 @@
import clsx from "clsx";
import throttle from "lodash.throttle";
import { nanoid } from "nanoid";
import React, { useContext } from "react";
import { flushSync } from "react-dom";
import rough from "roughjs/bin/rough";
import { import {
clamp, clamp,
pointFrom, pointFrom,
@ -12,15 +19,284 @@ import {
} from "@excalidraw/math"; } from "@excalidraw/math";
import { isPointInShape } from "@excalidraw/utils/collision"; import { isPointInShape } from "@excalidraw/utils/collision";
import { getSelectionBoxShape } from "@excalidraw/utils/geometry/shape"; import { getSelectionBoxShape } from "@excalidraw/utils/geometry/shape";
import clsx from "clsx";
import throttle from "lodash.throttle"; import {
import { nanoid } from "nanoid"; COLOR_PALETTE,
import React, { useContext } from "react"; CODES,
import { flushSync } from "react-dom"; shouldResizeFromCenter,
import rough from "roughjs/bin/rough"; shouldMaintainAspectRatio,
shouldRotateWithDiscreteAngle,
isArrowKey,
KEYS,
APP_NAME,
CURSOR_TYPE,
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
DEFAULT_VERTICAL_ALIGN,
DRAGGING_THRESHOLD,
ELEMENT_SHIFT_TRANSLATE_AMOUNT,
ELEMENT_TRANSLATE_AMOUNT,
ENV,
EVENT,
FRAME_STYLE,
IMAGE_MIME_TYPES,
IMAGE_RENDER_TIMEOUT,
isBrave,
LINE_CONFIRM_THRESHOLD,
MAX_ALLOWED_FILE_BYTES,
MIME_TYPES,
MQ_MAX_HEIGHT_LANDSCAPE,
MQ_MAX_WIDTH_LANDSCAPE,
MQ_MAX_WIDTH_PORTRAIT,
MQ_RIGHT_SIDEBAR_MIN_WIDTH,
POINTER_BUTTON,
ROUNDNESS,
SCROLL_TIMEOUT,
TAP_TWICE_TIMEOUT,
TEXT_TO_CENTER_SNAP_THRESHOLD,
THEME,
THEME_FILTER,
TOUCH_CTX_MENU_TIMEOUT,
VERTICAL_ALIGN,
YOUTUBE_STATES,
ZOOM_STEP,
POINTER_EVENTS,
TOOL_TYPE,
isIOS,
supportsResizeObserver,
DEFAULT_COLLISION_THRESHOLD,
DEFAULT_TEXT_ALIGN,
ARROW_TYPE,
DEFAULT_REDUCED_GLOBAL_ALPHA,
isSafari,
isLocalLink,
normalizeLink,
toValidURL,
getGridPoint,
type EXPORT_IMAGE_TYPES,
} from "@excalidraw/common";
import {
dragNewElement,
dragSelectedElements,
duplicateElement,
getCommonBounds,
getCursorForResizingElement,
getDragOffsetXY,
getElementWithTransformHandleType,
getNormalizedDimensions,
getResizeArrowDirection,
getResizeOffsetXY,
getLockedLinearCursorAlignSize,
getTransformHandleTypeFromCoords,
isInvisiblySmallElement,
isNonDeletedElement,
isTextElement,
newElement,
newLinearElement,
newTextElement,
newImageElement,
transformElements,
refreshTextDimensions,
redrawTextBoundingBox,
getElementAbsoluteCoords,
} from "@excalidraw/element";
import {
bindOrUnbindLinearElement,
bindOrUnbindLinearElements,
fixBindingsAfterDeletion,
fixBindingsAfterDuplication,
getHoveredElementForBinding,
isBindingEnabled,
isLinearElementSimpleAndAlreadyBound,
maybeBindLinearElement,
shouldEnableBindingForPointerEvent,
updateBoundElements,
getSuggestedBindingsForArrows,
} from "@excalidraw/element/binding";
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import {
mutateElement,
newElementWith,
} from "@excalidraw/element/mutateElement";
import {
deepCopyElement,
duplicateElements,
newFrameElement,
newFreeDrawElement,
newEmbeddableElement,
newMagicFrameElement,
newIframeElement,
newArrowElement,
} from "@excalidraw/element/newElement";
import {
hasBoundTextElement,
isArrowElement,
isBindingElement,
isBindingElementType,
isBoundToContainer,
isFrameLikeElement,
isImageElement,
isEmbeddableElement,
isInitializedImageElement,
isLinearElement,
isLinearElementType,
isUsingAdaptiveRadius,
isIframeElement,
isIframeLikeElement,
isMagicFrameElement,
isTextBindableContainer,
isElbowArrow,
isFlowchartNodeElement,
isBindableElement,
} from "@excalidraw/element/typeChecks";
import {
isElementCompletelyInViewport,
isElementInViewport,
} from "@excalidraw/element/sizeHelpers";
import {
getBoundTextShape,
getCornerRadius,
getElementShape,
isPathALoop,
} from "@excalidraw/element/shapes";
import {
debounce,
distance,
getFontString,
getNearestScrollableContainer,
isInputLike,
isToolIcon,
isWritableElement,
sceneCoordsToViewportCoords,
tupleToCoors,
viewportCoordsToSceneCoords,
wrapEvent,
updateObject,
updateActiveTool,
getShortcutKey,
isTransparent,
easeToValuesRAF,
muteFSAbortError,
isTestEnv,
easeOut,
updateStable,
addEventListener,
normalizeEOL,
getDateTime,
isShallowEqual,
arrayToMap,
} from "@excalidraw/common/utils";
import {
createSrcDoc,
embeddableURLValidator,
maybeParseEmbedSrc,
getEmbedLink,
} from "@excalidraw/element/embeddable";
import {
getInitializedImageElements,
loadHTMLImageElement,
normalizeSVG,
updateImageCache as _updateImageCache,
} from "@excalidraw/element/image";
import {
bindTextToShapeAfterDuplication,
getBoundTextElement,
getContainerCenter,
getContainerElement,
isValidTextContainer,
} from "@excalidraw/element/textElement";
import { shouldShowBoundingBox } from "@excalidraw/element/transformHandles";
import {
getFrameChildren,
isCursorInFrame,
bindElementsToFramesAfterDuplication,
addElementsToFrame,
replaceAllElementsInFrame,
removeElementsFromFrame,
getElementsInResizingFrame,
getElementsInNewFrame,
getContainingFrame,
elementOverlapsWithFrame,
updateFrameMembershipOfSelectedElements,
isElementInFrame,
getFrameLikeTitle,
getElementsOverlappingFrame,
filterElementsEligibleAsFrameChildren,
} from "@excalidraw/element/frame";
import {
hitElementBoundText,
hitElementBoundingBoxOnly,
hitElementItself,
} from "@excalidraw/element/collision";
import { getVisibleSceneBounds } from "@excalidraw/element/bounds";
import {
FlowChartCreator,
FlowChartNavigator,
getLinkDirectionFromKey,
} from "@excalidraw/element/flowchart";
import { cropElement } from "@excalidraw/element/cropElement";
import { wrapText } from "@excalidraw/element/textWrapping";
import {
isElementLink,
parseElementLinkFromURL,
} from "@excalidraw/element/elementLink";
import {
isMeasureTextSupported,
normalizeText,
measureText,
getLineHeightInPx,
getApproxMinLineWidth,
getApproxMinLineHeight,
getMinTextElementWidth,
} from "@excalidraw/element/textMeasurements";
import type { LocalPoint, Radians } from "@excalidraw/math"; import type { LocalPoint, Radians } from "@excalidraw/math";
import type {
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawFreeDrawElement,
ExcalidrawGenericElement,
ExcalidrawLinearElement,
ExcalidrawTextElement,
NonDeleted,
InitializedExcalidrawImageElement,
ExcalidrawImageElement,
FileId,
NonDeletedExcalidrawElement,
ExcalidrawTextContainer,
ExcalidrawFrameLikeElement,
ExcalidrawMagicFrameElement,
ExcalidrawIframeLikeElement,
IframeData,
ExcalidrawIframeElement,
ExcalidrawEmbeddableElement,
Ordered,
MagicGenerationData,
ExcalidrawNonSelectionElement,
ExcalidrawArrowElement,
} from "@excalidraw/element/types";
import { import {
actionAddToLibrary, actionAddToLibrary,
actionBringForward, actionBringForward,
@ -77,123 +353,10 @@ import {
isHandToolActive, isHandToolActive,
} from "../appState"; } from "../appState";
import { copyTextToSystemClipboard, parseClipboard } from "../clipboard"; import { copyTextToSystemClipboard, parseClipboard } from "../clipboard";
import {
APP_NAME,
CURSOR_TYPE,
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
DEFAULT_VERTICAL_ALIGN,
DRAGGING_THRESHOLD,
ELEMENT_SHIFT_TRANSLATE_AMOUNT,
ELEMENT_TRANSLATE_AMOUNT,
ENV,
EVENT,
FRAME_STYLE,
IMAGE_MIME_TYPES,
IMAGE_RENDER_TIMEOUT,
isBrave,
LINE_CONFIRM_THRESHOLD,
MAX_ALLOWED_FILE_BYTES,
MIME_TYPES,
MQ_MAX_HEIGHT_LANDSCAPE,
MQ_MAX_WIDTH_LANDSCAPE,
MQ_MAX_WIDTH_PORTRAIT,
MQ_RIGHT_SIDEBAR_MIN_WIDTH,
POINTER_BUTTON,
ROUNDNESS,
SCROLL_TIMEOUT,
TAP_TWICE_TIMEOUT,
TEXT_TO_CENTER_SNAP_THRESHOLD,
THEME,
THEME_FILTER,
TOUCH_CTX_MENU_TIMEOUT,
VERTICAL_ALIGN,
YOUTUBE_STATES,
ZOOM_STEP,
POINTER_EVENTS,
TOOL_TYPE,
isIOS,
supportsResizeObserver,
DEFAULT_COLLISION_THRESHOLD,
DEFAULT_TEXT_ALIGN,
ARROW_TYPE,
DEFAULT_REDUCED_GLOBAL_ALPHA,
isSafari,
type EXPORT_IMAGE_TYPES,
} from "../constants";
import { exportCanvas, loadFromBlob } from "../data"; import { exportCanvas, loadFromBlob } from "../data";
import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { restore, restoreElements } from "../data/restore"; import { restore, restoreElements } from "../data/restore";
import {
dragNewElement,
dragSelectedElements,
duplicateElement,
getCommonBounds,
getCursorForResizingElement,
getDragOffsetXY,
getElementWithTransformHandleType,
getNormalizedDimensions,
getResizeArrowDirection,
getResizeOffsetXY,
getLockedLinearCursorAlignSize,
getTransformHandleTypeFromCoords,
isInvisiblySmallElement,
isNonDeletedElement,
isTextElement,
newElement,
newLinearElement,
newTextElement,
newImageElement,
transformElements,
refreshTextDimensions,
redrawTextBoundingBox,
getElementAbsoluteCoords,
} from "../element";
import {
bindOrUnbindLinearElement,
bindOrUnbindLinearElements,
fixBindingsAfterDeletion,
fixBindingsAfterDuplication,
getHoveredElementForBinding,
isBindingEnabled,
isLinearElementSimpleAndAlreadyBound,
maybeBindLinearElement,
shouldEnableBindingForPointerEvent,
updateBoundElements,
getSuggestedBindingsForArrows,
} from "../element/binding";
import { LinearElementEditor } from "../element/linearElementEditor";
import { mutateElement, newElementWith } from "../element/mutateElement";
import {
deepCopyElement,
duplicateElements,
newFrameElement,
newFreeDrawElement,
newEmbeddableElement,
newMagicFrameElement,
newIframeElement,
newArrowElement,
} from "../element/newElement";
import {
hasBoundTextElement,
isArrowElement,
isBindingElement,
isBindingElementType,
isBoundToContainer,
isFrameLikeElement,
isImageElement,
isEmbeddableElement,
isInitializedImageElement,
isLinearElement,
isLinearElementType,
isUsingAdaptiveRadius,
isIframeElement,
isIframeLikeElement,
isMagicFrameElement,
isTextBindableContainer,
isElbowArrow,
isFlowchartNodeElement,
isBindableElement,
} from "../element/typeChecks";
import { getCenter, getDistance } from "../gesture"; import { getCenter, getDistance } from "../gesture";
import { import {
editGroupForSelectedElement, editGroupForSelectedElement,
@ -206,18 +369,7 @@ import {
} from "../groups"; } from "../groups";
import { History } from "../history"; import { History } from "../history";
import { defaultLang, getLanguage, languages, setLanguage, t } from "../i18n"; import { defaultLang, getLanguage, languages, setLanguage, t } from "../i18n";
import {
CODES,
shouldResizeFromCenter,
shouldMaintainAspectRatio,
shouldRotateWithDiscreteAngle,
isArrowKey,
KEYS,
} from "../keys";
import {
isElementCompletelyInViewport,
isElementInViewport,
} from "../element/sizeHelpers";
import { import {
calculateScrollCenter, calculateScrollCenter,
getElementsWithinSelection, getElementsWithinSelection,
@ -228,46 +380,7 @@ import {
} from "../scene"; } from "../scene";
import Scene from "../scene/Scene"; import Scene from "../scene/Scene";
import { getStateForZoom } from "../scene/zoom"; import { getStateForZoom } from "../scene/zoom";
import {
findShapeByKey,
getBoundTextShape,
getCornerRadius,
getElementShape,
isPathALoop,
} from "../shapes";
import {
debounce,
distance,
getFontString,
getNearestScrollableContainer,
isInputLike,
isToolIcon,
isWritableElement,
sceneCoordsToViewportCoords,
tupleToCoors,
viewportCoordsToSceneCoords,
wrapEvent,
updateObject,
updateActiveTool,
getShortcutKey,
isTransparent,
easeToValuesRAF,
muteFSAbortError,
isTestEnv,
easeOut,
updateStable,
addEventListener,
normalizeEOL,
getDateTime,
isShallowEqual,
arrayToMap,
} from "../utils";
import {
createSrcDoc,
embeddableURLValidator,
maybeParseEmbedSrc,
getEmbedLink,
} from "../element/embeddable";
import { import {
dataURLToFile, dataURLToFile,
dataURLToString, dataURLToString,
@ -284,46 +397,17 @@ import {
resizeImageFile, resizeImageFile,
SVGStringToFile, SVGStringToFile,
} from "../data/blob"; } from "../data/blob";
import {
getInitializedImageElements,
loadHTMLImageElement,
normalizeSVG,
updateImageCache as _updateImageCache,
} from "../element/image";
import { fileOpen } from "../data/filesystem"; import { fileOpen } from "../data/filesystem";
import {
bindTextToShapeAfterDuplication,
getBoundTextElement,
getContainerCenter,
getContainerElement,
isValidTextContainer,
} from "../element/textElement";
import { import {
showHyperlinkTooltip, showHyperlinkTooltip,
hideHyperlinkToolip, hideHyperlinkToolip,
Hyperlink, Hyperlink,
} from "../components/hyperlink/Hyperlink"; } from "../components/hyperlink/Hyperlink";
import { isLocalLink, normalizeLink, toValidURL } from "../data/url";
import { shouldShowBoundingBox } from "../element/transformHandles";
import { Fonts } from "../fonts"; import { Fonts } from "../fonts";
import { getLineHeight } from "../fonts/FontMetadata"; import { getLineHeight } from "../fonts/FontMetadata";
import {
getFrameChildren,
isCursorInFrame,
bindElementsToFramesAfterDuplication,
addElementsToFrame,
replaceAllElementsInFrame,
removeElementsFromFrame,
getElementsInResizingFrame,
getElementsInNewFrame,
getContainingFrame,
elementOverlapsWithFrame,
updateFrameMembershipOfSelectedElements,
isElementInFrame,
getFrameLikeTitle,
getElementsOverlappingFrame,
filterElementsEligibleAsFrameChildren,
} from "../frame";
import { import {
excludeElementsInFramesFromSelection, excludeElementsInFramesFromSelection,
makeNextSelectedElementIds, makeNextSelectedElementIds,
@ -341,7 +425,6 @@ import {
getReferenceSnapPoints, getReferenceSnapPoints,
SnapCache, SnapCache,
isGridModeEnabled, isGridModeEnabled,
getGridPoint,
} from "../snapping"; } from "../snapping";
import { convertToExcalidrawElements } from "../data/transform"; import { convertToExcalidrawElements } from "../data/transform";
import { Renderer } from "../scene/Renderer"; import { Renderer } from "../scene/Renderer";
@ -354,39 +437,16 @@ import {
} from "../cursor"; } from "../cursor";
import { Emitter } from "../emitter"; import { Emitter } from "../emitter";
import { ElementCanvasButtons } from "../components/ElementCanvasButtons"; import { ElementCanvasButtons } from "../components/ElementCanvasButtons";
import { COLOR_PALETTE } from "../colors";
import { Store, CaptureUpdateAction } from "../store"; import { Store, CaptureUpdateAction } from "../store";
import { AnimatedTrail } from "../animated-trail"; import { AnimatedTrail } from "../animated-trail";
import { LaserTrails } from "../laser-trails"; import { LaserTrails } from "../laser-trails";
import { withBatchedUpdates, withBatchedUpdatesThrottled } from "../reactUtils"; import { withBatchedUpdates, withBatchedUpdatesThrottled } from "../reactUtils";
import { getRenderOpacity } from "../renderer/renderElement"; import { getRenderOpacity } from "../renderer/renderElement";
import {
hitElementBoundText,
hitElementBoundingBoxOnly,
hitElementItself,
} from "../element/collision";
import { textWysiwyg } from "../wysiwyg/textWysiwyg"; import { textWysiwyg } from "../wysiwyg/textWysiwyg";
import { isOverScrollBars } from "../scene/scrollbars"; import { isOverScrollBars } from "../scene/scrollbars";
import { syncInvalidIndices, syncMovedIndices } from "../fractionalIndex"; import { syncInvalidIndices, syncMovedIndices } from "../fractionalIndex";
import { getVisibleSceneBounds } from "../element/bounds";
import { isMaybeMermaidDefinition } from "../mermaid"; import { isMaybeMermaidDefinition } from "../mermaid";
import {
FlowChartCreator,
FlowChartNavigator,
getLinkDirectionFromKey,
} from "../element/flowchart";
import { cropElement } from "../element/cropElement";
import { wrapText } from "../element/textWrapping";
import { isElementLink, parseElementLinkFromURL } from "../element/elementLink";
import {
isMeasureTextSupported,
normalizeText,
measureText,
getLineHeightInPx,
getApproxMinLineWidth,
getApproxMinLineHeight,
getMinTextElementWidth,
} from "../element/textMeasurements";
import { activeConfirmDialogAtom } from "./ActiveConfirmDialog"; import { activeConfirmDialogAtom } from "./ActiveConfirmDialog";
import BraveMeasureTextError from "./BraveMeasureTextError"; import BraveMeasureTextError from "./BraveMeasureTextError";
@ -407,40 +467,19 @@ import {
import { MagicIcon, copyIcon, fullscreenIcon } from "./icons"; import { MagicIcon, copyIcon, fullscreenIcon } from "./icons";
import { Toast } from "./Toast"; import { Toast } from "./Toast";
import type { Action, ActionResult } from "../actions/types"; import { findShapeByKey } from "./shapes";
import type {
RenderInteractiveSceneCallback,
ScrollBars,
} from "../scene/types";
import type { PastedMixedContent } from "../clipboard"; import type { PastedMixedContent } from "../clipboard";
import type { ExportedElements } from "../data"; import type { ExportedElements } from "../data";
import type { ContextMenuItems } from "./ContextMenu"; import type { ContextMenuItems } from "./ContextMenu";
import type { FileSystemHandle } from "../data/filesystem"; import type { FileSystemHandle } from "../data/filesystem";
import type { ExcalidrawElementSkeleton } from "../data/transform"; import type { ExcalidrawElementSkeleton } from "../data/transform";
import type {
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawFreeDrawElement,
ExcalidrawGenericElement,
ExcalidrawLinearElement,
ExcalidrawTextElement,
NonDeleted,
InitializedExcalidrawImageElement,
ExcalidrawImageElement,
FileId,
NonDeletedExcalidrawElement,
ExcalidrawTextContainer,
ExcalidrawFrameLikeElement,
ExcalidrawMagicFrameElement,
ExcalidrawIframeLikeElement,
IframeData,
ExcalidrawIframeElement,
ExcalidrawEmbeddableElement,
Ordered,
MagicGenerationData,
ExcalidrawNonSelectionElement,
ExcalidrawArrowElement,
} from "../element/types";
import type {
RenderInteractiveSceneCallback,
ScrollBars,
} from "../scene/types";
import type { import type {
AppClassProperties, AppClassProperties,
AppProps, AppProps,
@ -471,6 +510,7 @@ import type {
} from "../types"; } from "../types";
import type { ValueOf } from "../utility-types"; import type { ValueOf } from "../utility-types";
import type { RoughCanvas } from "roughjs/bin/canvas"; import type { RoughCanvas } from "roughjs/bin/canvas";
import type { Action, ActionResult } from "../actions/types";
const AppContext = React.createContext<AppClassProperties>(null!); const AppContext = React.createContext<AppClassProperties>(null!);
const AppPropsContext = React.createContext<AppProps>(null!); const AppPropsContext = React.createContext<AppProps>(null!);

View file

@ -1,15 +1,16 @@
import { useExcalidrawAppState } from "../components/App"; import { sceneCoordsToViewportCoords } from "@excalidraw/common";
import { sceneCoordsToViewportCoords } from "../utils"; import { getElementAbsoluteCoords } from "@excalidraw/element";
import { getElementAbsoluteCoords } from "../element";
import "./ElementCanvasButtons.scss";
import type { AppState } from "../types";
import type { import type {
ElementsMap, ElementsMap,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import { useExcalidrawAppState } from "../components/App";
import "./ElementCanvasButtons.scss";
import type { AppState } from "../types";
const CONTAINER_PADDING = 5; const CONTAINER_PADDING = 5;

View file

@ -1,7 +1,8 @@
import OpenColor from "open-color"; import OpenColor from "open-color";
import { CURSOR_TYPE, MIME_TYPES, THEME } from "@excalidraw/common";
import { isHandToolActive, isEraserActive } from "./appState"; import { isHandToolActive, isEraserActive } from "./appState";
import { CURSOR_TYPE, MIME_TYPES, THEME } from "./constants";
import type { AppState, DataURL } from "./types"; import type { AppState, DataURL } from "./types";

View file

@ -1,4 +1,5 @@
import type { EDITOR_LS_KEYS } from "../constants"; import type { EDITOR_LS_KEYS } from "@excalidraw/common";
import type { JSONValue } from "../types"; import type { JSONValue } from "../types";
export class EditorLocalStorage { export class EditorLocalStorage {

View file

@ -1,12 +1,21 @@
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import {
IMAGE_MIME_TYPES,
MIME_TYPES,
bytesToHexString,
isPromiseLike,
} from "@excalidraw/common";
import { clearElementsForExport } from "@excalidraw/element";
import type { ExcalidrawElement, FileId } from "@excalidraw/element/types";
import { cleanAppStateForExport } from "../appState"; import { cleanAppStateForExport } from "../appState";
import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
import { clearElementsForExport } from "../element";
import { CanvasError, ImageSceneDataError } from "../errors"; import { CanvasError, ImageSceneDataError } from "../errors";
import { calculateScrollCenter } from "../scene"; import { calculateScrollCenter } from "../scene";
import { decodeSvgBase64Payload } from "../scene/export"; import { decodeSvgBase64Payload } from "../scene/export";
import { bytesToHexString, isPromiseLike } from "../utils";
import { base64ToString, stringToBase64, toByteString } from "./encode"; import { base64ToString, stringToBase64, toByteString } from "./encode";
import { nativeFileSystemSupported } from "./filesystem"; import { nativeFileSystemSupported } from "./filesystem";
@ -14,7 +23,7 @@ import { isValidExcalidrawData, isValidLibrary } from "./json";
import { restore, restoreLibraryItems } from "./restore"; import { restore, restoreLibraryItems } from "./restore";
import type { FileSystemHandle } from "./filesystem"; import type { FileSystemHandle } from "./filesystem";
import type { ExcalidrawElement, FileId } from "../element/types";
import type { AppState, DataURL, LibraryItem } from "../types"; import type { AppState, DataURL, LibraryItem } from "../types";
import type { ValueOf } from "../utility-types"; import type { ValueOf } from "../utility-types";
import type { ImportedLibraryData } from "./types"; import type { ImportedLibraryData } from "./types";

View file

@ -1,4 +1,4 @@
import { ENCRYPTION_KEY_BITS } from "../constants"; import { ENCRYPTION_KEY_BITS } from "@excalidraw/common";
import { blobToArrayBuffer } from "./blob"; import { blobToArrayBuffer } from "./blob";

View file

@ -4,9 +4,9 @@ import {
supported as nativeFileSystemSupported, supported as nativeFileSystemSupported,
} from "browser-fs-access"; } from "browser-fs-access";
import { EVENT, MIME_TYPES } from "../constants"; import { EVENT, MIME_TYPES, debounce } from "@excalidraw/common";
import { AbortError } from "../errors"; import { AbortError } from "../errors";
import { debounce } from "../utils";
import type { FileSystemHandle } from "browser-fs-access"; import type { FileSystemHandle } from "browser-fs-access";

View file

@ -2,7 +2,7 @@ import tEXt from "png-chunk-text";
import encodePng from "png-chunks-encode"; import encodePng from "png-chunks-encode";
import decodePng from "png-chunks-extract"; import decodePng from "png-chunks-extract";
import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants"; import { EXPORT_DATA_TYPES, MIME_TYPES } from "@excalidraw/common";
import { blobToArrayBuffer } from "./blob"; import { blobToArrayBuffer } from "./blob";
import { encode, decode } from "./encode"; import { encode, decode } from "./encode";

View file

@ -1,32 +1,39 @@
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
} from "../clipboard";
import { import {
DEFAULT_EXPORT_PADDING, DEFAULT_EXPORT_PADDING,
DEFAULT_FILENAME, DEFAULT_FILENAME,
IMAGE_MIME_TYPES, IMAGE_MIME_TYPES,
isFirefox, isFirefox,
MIME_TYPES, MIME_TYPES,
} from "../constants"; cloneJSON,
import { getNonDeletedElements } from "../element"; } from "@excalidraw/common";
import { isFrameLikeElement } from "../element/typeChecks";
import { getElementsOverlappingFrame } from "../frame"; import { getNonDeletedElements } from "@excalidraw/element";
import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import { getElementsOverlappingFrame } from "@excalidraw/element/frame";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement,
} from "@excalidraw/element/types";
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
} from "../clipboard";
import { t } from "../i18n"; import { t } from "../i18n";
import { getSelectedElements, isSomeElementSelected } from "../scene"; import { getSelectedElements, isSomeElementSelected } from "../scene";
import { exportToCanvas, exportToSvg } from "../scene/export"; import { exportToCanvas, exportToSvg } from "../scene/export";
import { cloneJSON } from "../utils";
import { canvasToBlob } from "./blob"; import { canvasToBlob } from "./blob";
import { fileSave } from "./filesystem"; import { fileSave } from "./filesystem";
import { serializeAsJSON } from "./json"; import { serializeAsJSON } from "./json";
import type { FileSystemHandle } from "./filesystem"; import type { FileSystemHandle } from "./filesystem";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement,
} from "../element/types";
import type { ExportType } from "../scene/types"; import type { ExportType } from "../scene/types";
import type { AppState, BinaryFiles } from "../types"; import type { AppState, BinaryFiles } from "../types";

View file

@ -1,17 +1,23 @@
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
import { import {
DEFAULT_FILENAME, DEFAULT_FILENAME,
EXPORT_DATA_TYPES, EXPORT_DATA_TYPES,
EXPORT_SOURCE, EXPORT_SOURCE,
MIME_TYPES, MIME_TYPES,
VERSIONS, VERSIONS,
} from "../constants"; } from "@excalidraw/common";
import { clearElementsForDatabase, clearElementsForExport } from "../element";
import {
clearElementsForDatabase,
clearElementsForExport,
} from "@excalidraw/element";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob";
import { fileOpen, fileSave } from "./filesystem"; import { fileOpen, fileSave } from "./filesystem";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, BinaryFiles, LibraryItems } from "../types"; import type { AppState, BinaryFiles, LibraryItems } from "../types";
import type { import type {
ExportedDataState, ExportedDataState,

View file

@ -7,29 +7,33 @@ import {
EVENT, EVENT,
DEFAULT_SIDEBAR, DEFAULT_SIDEBAR,
LIBRARY_SIDEBAR_TAB, LIBRARY_SIDEBAR_TAB,
} from "../constants";
import { atom, editorJotaiStore } from "../editor-jotai";
import { hashElementsVersion, hashString } from "../element";
import { getCommonBoundingBox } from "../element/bounds";
import { Emitter } from "../emitter";
import { AbortError } from "../errors";
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
import { t } from "../i18n";
import { Queue } from "../queue";
import {
arrayToMap, arrayToMap,
cloneJSON, cloneJSON,
preventUnload, preventUnload,
promiseTry, promiseTry,
resolvablePromise, resolvablePromise,
} from "../utils"; toValidURL,
} from "@excalidraw/common";
import { hashElementsVersion, hashString } from "@excalidraw/element";
import { getCommonBoundingBox } from "@excalidraw/element/bounds";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { atom, editorJotaiStore } from "../editor-jotai";
import { Emitter } from "../emitter";
import { AbortError } from "../errors";
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
import { t } from "../i18n";
import { Queue } from "../queue";
import { loadLibraryFromBlob } from "./blob"; import { loadLibraryFromBlob } from "./blob";
import { restoreLibraryItems } from "./restore"; import { restoreLibraryItems } from "./restore";
import { toValidURL } from "./url";
import type App from "../components/App"; import type App from "../components/App";
import type { ExcalidrawElement } from "../element/types";
import type { import type {
LibraryItems, LibraryItems,
LibraryItem, LibraryItem,

View file

@ -1,14 +1,15 @@
import throttle from "lodash.throttle"; import throttle from "lodash.throttle";
import { ENV } from "../constants"; import { ENV, arrayToMap } from "@excalidraw/common";
import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
import { import {
orderByFractionalIndex, orderByFractionalIndex,
syncInvalidIndices, syncInvalidIndices,
validateFractionalIndices, validateFractionalIndices,
} from "../fractionalIndex"; } from "../fractionalIndex";
import { arrayToMap } from "../utils";
import type { OrderedExcalidrawElement } from "../element/types";
import type { AppState } from "../types"; import type { AppState } from "../types";
import type { MakeBrand } from "../utility-types"; import type { MakeBrand } from "../utility-types";

View file

@ -1,8 +1,9 @@
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { getFileHandleType, isImageFileHandleType } from "./blob"; import { getFileHandleType, isImageFileHandleType } from "./blob";
import { exportCanvas, prepareElementsForExport } from "."; import { exportCanvas, prepareElementsForExport } from ".";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, BinaryFiles } from "../types"; import type { AppState, BinaryFiles } from "../types";
export const resaveAsImageWithScene = async ( export const resaveAsImageWithScene = async (

View file

@ -1,8 +1,5 @@
import { isFiniteNumber, pointFrom } from "@excalidraw/math"; import { isFiniteNumber, pointFrom } from "@excalidraw/math";
import type { LocalPoint, Radians } from "@excalidraw/math";
import { getDefaultAppState } from "../appState";
import { import {
DEFAULT_FONT_FAMILY, DEFAULT_FONT_FAMILY,
DEFAULT_TEXT_ALIGN, DEFAULT_TEXT_ALIGN,
@ -13,22 +10,28 @@ import {
DEFAULT_ELEMENT_PROPS, DEFAULT_ELEMENT_PROPS,
DEFAULT_GRID_SIZE, DEFAULT_GRID_SIZE,
DEFAULT_GRID_STEP, DEFAULT_GRID_STEP,
} from "../constants"; randomId,
getUpdatedTimestamp,
updateActiveTool,
arrayToMap,
getSizeFromPoints,
normalizeLink,
} from "@excalidraw/common";
import { import {
getNonDeletedElements, getNonDeletedElements,
getNormalizedDimensions, getNormalizedDimensions,
isInvisiblySmallElement, isInvisiblySmallElement,
refreshTextDimensions, refreshTextDimensions,
} from "../element"; } from "@excalidraw/element";
import { normalizeFixedPoint } from "../element/binding"; import { normalizeFixedPoint } from "@excalidraw/element/binding";
import { import {
updateElbowArrowPoints, updateElbowArrowPoints,
validateElbowPoints, validateElbowPoints,
} from "../element/elbowArrow"; } from "@excalidraw/element/elbowArrow";
import { LinearElementEditor } from "../element/linearElementEditor"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { bumpVersion } from "../element/mutateElement"; import { bumpVersion } from "@excalidraw/element/mutateElement";
import { getContainerElement } from "../element/textElement"; import { getContainerElement } from "@excalidraw/element/textElement";
import { detectLineHeight } from "../element/textMeasurements"; import { detectLineHeight } from "@excalidraw/element/textMeasurements";
import { import {
isArrowElement, isArrowElement,
isElbowArrow, isElbowArrow,
@ -36,20 +39,9 @@ import {
isLinearElement, isLinearElement,
isTextElement, isTextElement,
isUsingAdaptiveRadius, isUsingAdaptiveRadius,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import { randomId } from "../random";
import {
getNormalizedGridSize,
getNormalizedGridStep,
getNormalizedZoom,
} from "../scene";
import { getUpdatedTimestamp, updateActiveTool } from "../utils";
import { arrayToMap } from "../utils";
import { getSizeFromPoints } from "../points";
import { normalizeLink } from "./url"; import type { LocalPoint, Radians } from "@excalidraw/math";
import type { import type {
ExcalidrawArrowElement, ExcalidrawArrowElement,
@ -65,7 +57,18 @@ import type {
OrderedExcalidrawElement, OrderedExcalidrawElement,
PointBinding, PointBinding,
StrokeRoundness, StrokeRoundness,
} from "../element/types"; } from "@excalidraw/element/types";
import { getDefaultAppState } from "../appState";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import {
getNormalizedGridSize,
getNormalizedGridStep,
getNormalizedZoom,
} from "../scene";
import type { AppState, BinaryFiles, LibraryItem } from "../types"; import type { AppState, BinaryFiles, LibraryItem } from "../types";
import type { MarkOptional, Mutable } from "../utility-types"; import type { MarkOptional, Mutable } from "../utility-types";
import type { ImportedDataState, LegacyAppState } from "./types"; import type { ImportedDataState, LegacyAppState } from "./types";

View file

@ -1,10 +1,11 @@
import { pointFrom } from "@excalidraw/math"; import { pointFrom } from "@excalidraw/math";
import { vi } from "vitest"; import { vi } from "vitest";
import type { ExcalidrawArrowElement } from "@excalidraw/element/types";
import { convertToExcalidrawElements } from "./transform"; import { convertToExcalidrawElements } from "./transform";
import type { ExcalidrawElementSkeleton } from "./transform"; import type { ExcalidrawElementSkeleton } from "./transform";
import type { ExcalidrawArrowElement } from "../element/types";
const opts = { regenerateIds: false }; const opts = { regenerateIds: false };

View file

@ -5,37 +5,37 @@ import {
DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE,
TEXT_ALIGN, TEXT_ALIGN,
VERTICAL_ALIGN, VERTICAL_ALIGN,
} from "../constants"; getSizeFromPoints,
import { randomId,
getCommonBounds,
newElement,
newLinearElement,
redrawTextBoundingBox,
} from "../element";
import { bindLinearElement } from "../element/binding";
import {
newArrowElement,
newFrameElement,
newImageElement,
newMagicFrameElement,
newTextElement,
} from "../element/newElement";
import { measureText, normalizeText } from "../element/textMeasurements";
import { isArrowElement } from "../element/typeChecks";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import { getSizeFromPoints } from "../points";
import { randomId } from "../random";
import {
arrayToMap, arrayToMap,
assertNever, assertNever,
cloneJSON, cloneJSON,
getFontString, getFontString,
isDevEnv, isDevEnv,
toBrandedType, toBrandedType,
} from "../utils"; } from "@excalidraw/common";
import {
getCommonBounds,
newElement,
newLinearElement,
redrawTextBoundingBox,
} from "@excalidraw/element";
import { bindLinearElement } from "@excalidraw/element/binding";
import {
newArrowElement,
newFrameElement,
newImageElement,
newMagicFrameElement,
newTextElement,
} from "@excalidraw/element/newElement";
import {
measureText,
normalizeText,
} from "@excalidraw/element/textMeasurements";
import { isArrowElement } from "@excalidraw/element/typeChecks";
import type { ElementConstructorOpts } from "@excalidraw/element/newElement";
import type { ElementConstructorOpts } from "../element/newElement";
import type { import type {
ElementsMap, ElementsMap,
ExcalidrawArrowElement, ExcalidrawArrowElement,
@ -55,7 +55,11 @@ import type {
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
TextAlign, TextAlign,
VerticalAlign, VerticalAlign,
} from "../element/types"; } from "@excalidraw/element/types";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import type { MarkOptional } from "../utility-types"; import type { MarkOptional } from "../utility-types";
export type ValidLinearElement = { export type ValidLinearElement = {

View file

@ -1,6 +1,8 @@
import type { VERSIONS } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import type { cleanAppStateForExport } from "../appState"; import type { cleanAppStateForExport } from "../appState";
import type { VERSIONS } from "../constants";
import type { ExcalidrawElement } from "../element/types";
import type { import type {
AppState, AppState,
BinaryFiles, BinaryFiles,

View file

@ -1,8 +1,9 @@
import { getCommonBoundingBox } from "./element/bounds"; import { getCommonBoundingBox } from "@excalidraw/element/bounds";
import { newElementWith } from "./element/mutateElement"; import { newElementWith } from "@excalidraw/element/mutateElement";
import { getMaximumGroups } from "./groups";
import type { ElementsMap, ExcalidrawElement } from "./element/types"; import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
import { getMaximumGroups } from "./groups";
export interface Distribution { export interface Distribution {
space: "between"; space: "between";

View file

@ -1,5 +1,6 @@
import { promiseTry } from "@excalidraw/common";
import { subsetWoff2GlyphsByCodepoints } from "../subset/subset-main"; import { subsetWoff2GlyphsByCodepoints } from "../subset/subset-main";
import { promiseTry } from "../utils";
import { LOCAL_FONT_PROTOCOL } from "./FontMetadata"; import { LOCAL_FONT_PROTOCOL } from "./FontMetadata";

View file

@ -1,3 +1,5 @@
import { FONT_FAMILY, FONT_FAMILY_FALLBACKS } from "@excalidraw/common";
import type { import type {
ExcalidrawTextElement, ExcalidrawTextElement,
FontFamilyValues, FontFamilyValues,
@ -9,7 +11,6 @@ import {
FontFamilyHeadingIcon, FontFamilyHeadingIcon,
FontFamilyCodeIcon, FontFamilyCodeIcon,
} from "../components/icons"; } from "../components/icons";
import { FONT_FAMILY, FONT_FAMILY_FALLBACKS } from "../constants";
import type { JSX } from "react"; import type { JSX } from "react";

View file

@ -4,13 +4,20 @@ import {
CJK_HAND_DRAWN_FALLBACK_FONT, CJK_HAND_DRAWN_FALLBACK_FONT,
WINDOWS_EMOJI_FALLBACK_FONT, WINDOWS_EMOJI_FALLBACK_FONT,
getFontFamilyFallbacks, getFontFamilyFallbacks,
} from "../constants"; } from "@excalidraw/common";
import { isTextElement } from "../element"; import { isTextElement } from "@excalidraw/element";
import { getContainerElement } from "../element/textElement"; import { getContainerElement } from "@excalidraw/element/textElement";
import { charWidth } from "../element/textMeasurements"; import { charWidth } from "@excalidraw/element/textMeasurements";
import { containsCJK } from "../element/textWrapping"; import { containsCJK } from "@excalidraw/element/textWrapping";
import { getFontString, PromisePool, promiseTry } from "@excalidraw/common";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
} from "@excalidraw/element/types";
import { ShapeCache } from "../scene/ShapeCache"; import { ShapeCache } from "../scene/ShapeCache";
import { getFontString, PromisePool, promiseTry } from "../utils";
import { CascadiaFontFaces } from "./Cascadia"; import { CascadiaFontFaces } from "./Cascadia";
import { ComicShannsFontFaces } from "./ComicShanns"; import { ComicShannsFontFaces } from "./ComicShanns";
@ -25,11 +32,6 @@ import { NunitoFontFaces } from "./Nunito";
import { VirgilFontFaces } from "./Virgil"; import { VirgilFontFaces } from "./Virgil";
import { XiaolaiFontFaces } from "./Xiaolai"; import { XiaolaiFontFaces } from "./Xiaolai";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
FontFamilyValues,
} from "../element/types";
import type Scene from "../scene/Scene"; import type Scene from "../scene/Scene";
import type { ValueOf } from "../utility-types"; import type { ValueOf } from "../utility-types";

View file

@ -1,16 +1,18 @@
import { generateNKeysBetween } from "fractional-indexing"; import { generateNKeysBetween } from "fractional-indexing";
import { mutateElement } from "./element/mutateElement"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { getBoundTextElement } from "./element/textElement"; import { getBoundTextElement } from "@excalidraw/element/textElement";
import { hasBoundTextElement } from "./element/typeChecks"; import { hasBoundTextElement } from "@excalidraw/element/typeChecks";
import { InvalidFractionalIndexError } from "./errors";
import { arrayToMap } from "./utils"; import { arrayToMap } from "@excalidraw/common";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
FractionalIndex, FractionalIndex,
OrderedExcalidrawElement, OrderedExcalidrawElement,
} from "./element/types"; } from "@excalidraw/element/types";
import { InvalidFractionalIndexError } from "./errors";
/** /**
* Envisioned relation between array order and fractional indices: * Envisioned relation between array order and fractional indices:

View file

@ -1,11 +1,11 @@
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { API } from "./tests/helpers/api"; import { API } from "./tests/helpers/api";
import { Keyboard, Pointer } from "./tests/helpers/ui"; import { Keyboard, Pointer } from "./tests/helpers/ui";
import { getCloneByOrigId, render } from "./tests/test-utils"; import { getCloneByOrigId, render } from "./tests/test-utils";
import { convertToExcalidrawElements, Excalidraw } from "./index"; import { convertToExcalidrawElements, Excalidraw } from "./index";
import type { ExcalidrawElement } from "./element/types";
const { h } = window; const { h } = window;
const mouse = new Pointer("mouse"); const mouse = new Pointer("mouse");

View file

@ -1,6 +1,4 @@
import { getBoundTextElement } from "./element/textElement"; import { getBoundTextElement } from "@excalidraw/element/textElement";
import { getSelectedElements } from "./scene";
import { makeNextSelectedElementIds } from "./scene/selection";
import type { import type {
GroupId, GroupId,
@ -9,7 +7,11 @@ import type {
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
ElementsMapOrArray, ElementsMapOrArray,
ElementsMap, ElementsMap,
} from "./element/types"; } from "@excalidraw/element/types";
import { getSelectedElements } from "./scene";
import { makeNextSelectedElementIds } from "./scene/selection";
import type { import type {
AppClassProperties, AppClassProperties,
AppState, AppState,

View file

@ -1,7 +1,8 @@
import type { SceneElementsMap } from "@excalidraw/element/types";
import { Emitter } from "./emitter"; import { Emitter } from "./emitter";
import type { AppStateChange, ElementsChange } from "./change"; import type { AppStateChange, ElementsChange } from "./change";
import type { SceneElementsMap } from "./element/types";
import type { Snapshot } from "./store"; import type { Snapshot } from "./store";
import type { AppState } from "./types"; import type { AppState } from "./types";

View file

@ -1,7 +1,8 @@
import { useState, useLayoutEffect } from "react"; import { useState, useLayoutEffect } from "react";
import { THEME } from "@excalidraw/common";
import { useDevice, useExcalidrawContainer } from "../components/App"; import { useDevice, useExcalidrawContainer } from "../components/App";
import { THEME } from "../constants";
import { useUIAppState } from "../context/ui-appState"; import { useUIAppState } from "../context/ui-appState";
export const useCreatePortalContainer = (opts?: { export const useCreatePortalContainer = (opts?: {

View file

@ -1,6 +1,6 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { EVENT } from "../constants"; import { EVENT } from "@excalidraw/common";
export function useOutsideClick<T extends HTMLElement>( export function useOutsideClick<T extends HTMLElement>(
ref: React.RefObject<T | null>, ref: React.RefObject<T | null>,

View file

@ -1,16 +1,16 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { DEFAULT_UI_OPTIONS, isShallowEqual } from "@excalidraw/common";
import App from "./components/App"; import App from "./components/App";
import { InitializeApp } from "./components/InitializeApp"; import { InitializeApp } from "./components/InitializeApp";
import Footer from "./components/footer/FooterCenter"; import Footer from "./components/footer/FooterCenter";
import LiveCollaborationTrigger from "./components/live-collaboration/LiveCollaborationTrigger"; import LiveCollaborationTrigger from "./components/live-collaboration/LiveCollaborationTrigger";
import MainMenu from "./components/main-menu/MainMenu"; import MainMenu from "./components/main-menu/MainMenu";
import WelcomeScreen from "./components/welcome-screen/WelcomeScreen"; import WelcomeScreen from "./components/welcome-screen/WelcomeScreen";
import { DEFAULT_UI_OPTIONS } from "./constants";
import { defaultLang } from "./i18n"; import { defaultLang } from "./i18n";
import { EditorJotaiProvider, editorJotaiStore } from "./editor-jotai"; import { EditorJotaiProvider, editorJotaiStore } from "./editor-jotai";
import polyfill from "./polyfill"; import polyfill from "./polyfill";
import { isShallowEqual } from "./utils";
import "./css/app.scss"; import "./css/app.scss";
import "./css/styles.scss"; import "./css/styles.scss";
@ -218,7 +218,7 @@ export {
isInvisiblySmallElement, isInvisiblySmallElement,
getNonDeletedElements, getNonDeletedElements,
getTextFromElements, getTextFromElements,
} from "./element"; } from "@excalidraw/element";
export { defaultLang, useI18n, languages } from "./i18n"; export { defaultLang, useI18n, languages } from "./i18n";
export { export {
restore, restore,
@ -244,7 +244,7 @@ export {
} from "./data/blob"; } from "./data/blob";
export { getFreeDrawSvgPath } from "./renderer/renderElement"; export { getFreeDrawSvgPath } from "./renderer/renderElement";
export { mergeLibraryItems, getLibraryItemsHash } from "./data/library"; export { mergeLibraryItems, getLibraryItemsHash } from "./data/library";
export { isLinearElement } from "./element/typeChecks"; export { isLinearElement } from "@excalidraw/element/typeChecks";
export { export {
FONT_FAMILY, FONT_FAMILY,
@ -253,13 +253,14 @@ export {
ROUNDNESS, ROUNDNESS,
DEFAULT_LASER_COLOR, DEFAULT_LASER_COLOR,
UserIdleState, UserIdleState,
} from "./constants"; normalizeLink,
} from "@excalidraw/common";
export { export {
mutateElement, mutateElement,
newElementWith, newElementWith,
bumpVersion, bumpVersion,
} from "./element/mutateElement"; } from "@excalidraw/element/mutateElement";
export { CaptureUpdateAction } from "./store"; export { CaptureUpdateAction } from "./store";
@ -268,7 +269,7 @@ export { parseLibraryTokensFromUrl, useHandleLibrary } from "./data/library";
export { export {
sceneCoordsToViewportCoords, sceneCoordsToViewportCoords,
viewportCoordsToSceneCoords, viewportCoordsToSceneCoords,
} from "./utils"; } from "@excalidraw/common";
export { Sidebar } from "./components/Sidebar/Sidebar"; export { Sidebar } from "./components/Sidebar/Sidebar";
export { Button } from "./components/Button"; export { Button } from "./components/Button";
@ -283,10 +284,12 @@ export { DefaultSidebar } from "./components/DefaultSidebar";
export { TTDDialog } from "./components/TTDDialog/TTDDialog"; export { TTDDialog } from "./components/TTDDialog/TTDDialog";
export { TTDDialogTrigger } from "./components/TTDDialog/TTDDialogTrigger"; export { TTDDialogTrigger } from "./components/TTDDialog/TTDDialogTrigger";
export { normalizeLink } from "./data/url";
export { zoomToFitBounds } from "./actions/actionCanvas"; export { zoomToFitBounds } from "./actions/actionCanvas";
export { convertToExcalidrawElements } from "./data/transform"; export { convertToExcalidrawElements } from "./data/transform";
export { getCommonBounds, getVisibleSceneBounds } from "./element/bounds"; export {
getCommonBounds,
getVisibleSceneBounds,
} from "@excalidraw/element/bounds";
export { export {
elementsOverlappingBBox, elementsOverlappingBBox,
@ -296,6 +299,6 @@ export {
export { DiagramToCodePlugin } from "./components/DiagramToCodePlugin/DiagramToCodePlugin"; export { DiagramToCodePlugin } from "./components/DiagramToCodePlugin/DiagramToCodePlugin";
export { getDataURL } from "./data/blob"; export { getDataURL } from "./data/blob";
export { isElementLink } from "./element/elementLink"; export { isElementLink } from "@excalidraw/element/elementLink";
export { setCustomTextMetricsProvider } from "./element/textMeasurements"; export { setCustomTextMetricsProvider } from "@excalidraw/element/textMeasurements";

View file

@ -1,9 +1,9 @@
import { DEFAULT_LASER_COLOR, easeOut } from "@excalidraw/common";
import type { LaserPointerOptions } from "@excalidraw/laser-pointer"; import type { LaserPointerOptions } from "@excalidraw/laser-pointer";
import { AnimatedTrail } from "./animated-trail"; import { AnimatedTrail } from "./animated-trail";
import { getClientColor } from "./clients"; import { getClientColor } from "./clients";
import { DEFAULT_LASER_COLOR } from "./constants";
import { easeOut } from "./utils";
import type { Trail } from "./animated-trail"; import type { Trail } from "./animated-trail";
import type { AnimationFrameHandler } from "./animation-frame-handler"; import type { AnimationFrameHandler } from "./animation-frame-handler";

View file

@ -1,7 +1,8 @@
import { promiseTry, resolvablePromise } from "./utils"; import { promiseTry, resolvablePromise } from "@excalidraw/common";
import type { ResolvablePromise } from "@excalidraw/common";
import type { MaybePromise } from "./utility-types"; import type { MaybePromise } from "./utility-types";
import type { ResolvablePromise } from "./utils";
type Job<T, TArgs extends unknown[]> = (...args: TArgs) => MaybePromise<T>; type Job<T, TArgs extends unknown[]> = (...args: TArgs) => MaybePromise<T>;

View file

@ -5,7 +5,7 @@
import { version as ReactVersion } from "react"; import { version as ReactVersion } from "react";
import { unstable_batchedUpdates } from "react-dom"; import { unstable_batchedUpdates } from "react-dom";
import { throttleRAF } from "./utils"; import { throttleRAF } from "@excalidraw/common";
export const withBatchedUpdates = < export const withBatchedUpdates = <
TFunction extends ((event: any) => void) | (() => void), TFunction extends ((event: any) => void) | (() => void),

View file

@ -1,4 +1,4 @@
import { THEME, THEME_FILTER } from "../constants"; import { THEME, THEME_FILTER } from "@excalidraw/common";
import type { StaticCanvasRenderConfig } from "../scene/types"; import type { StaticCanvasRenderConfig } from "../scene/types";
import type { StaticCanvasAppState, AppState } from "../types"; import type { StaticCanvasAppState, AppState } from "../types";

View file

@ -6,35 +6,62 @@ import {
} from "@excalidraw/math"; } from "@excalidraw/math";
import oc from "open-color"; import oc from "open-color";
import { getClientColor, renderRemoteCursors } from "../clients";
import { import {
DEFAULT_TRANSFORM_HANDLE_SPACING, DEFAULT_TRANSFORM_HANDLE_SPACING,
FRAME_STYLE, FRAME_STYLE,
THEME, THEME,
} from "../constants"; arrayToMap,
invariant,
throttleRAF,
} from "@excalidraw/common";
import { import {
getElementAbsoluteCoords, getElementAbsoluteCoords,
getTransformHandlesFromCoords, getTransformHandlesFromCoords,
getTransformHandles, getTransformHandles,
getCommonBounds, getCommonBounds,
} from "../element"; } from "@excalidraw/element";
import { import {
BINDING_HIGHLIGHT_OFFSET, BINDING_HIGHLIGHT_OFFSET,
BINDING_HIGHLIGHT_THICKNESS, BINDING_HIGHLIGHT_THICKNESS,
maxBindingGap, maxBindingGap,
} from "../element/binding"; } from "@excalidraw/element/binding";
import { LinearElementEditor } from "../element/linearElementEditor"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { import {
getOmitSidesForDevice, getOmitSidesForDevice,
shouldShowBoundingBox, shouldShowBoundingBox,
} from "../element/transformHandles"; } from "@excalidraw/element/transformHandles";
import { import {
isElbowArrow, isElbowArrow,
isFrameLikeElement, isFrameLikeElement,
isImageElement, isImageElement,
isLinearElement, isLinearElement,
isTextElement, isTextElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { getCornerRadius } from "@excalidraw/element/shapes";
import type {
SuggestedBinding,
SuggestedPointBinding,
} from "@excalidraw/element/binding";
import type {
TransformHandles,
TransformHandleType,
} from "@excalidraw/element/transformHandles";
import type {
ElementsMap,
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawFrameLikeElement,
ExcalidrawImageElement,
ExcalidrawLinearElement,
ExcalidrawTextElement,
GroupId,
NonDeleted,
} from "@excalidraw/element/types";
import { import {
isSelectedViaGroup, isSelectedViaGroup,
getSelectedGroupIds, getSelectedGroupIds,
@ -49,9 +76,9 @@ import {
SCROLLBAR_COLOR, SCROLLBAR_COLOR,
SCROLLBAR_WIDTH, SCROLLBAR_WIDTH,
} from "../scene/scrollbars"; } from "../scene/scrollbars";
import { getCornerRadius } from "../shapes";
import { type InteractiveCanvasAppState } from "../types"; import { type InteractiveCanvasAppState } from "../types";
import { arrayToMap, invariant, throttleRAF } from "../utils";
import { getClientColor, renderRemoteCursors } from "../clients";
import { import {
bootstrapCanvas, bootstrapCanvas,
@ -59,25 +86,6 @@ import {
getNormalizedCanvasDimensions, getNormalizedCanvasDimensions,
} from "./helpers"; } from "./helpers";
import type {
SuggestedBinding,
SuggestedPointBinding,
} from "../element/binding";
import type {
TransformHandles,
TransformHandleType,
} from "../element/transformHandles";
import type {
ElementsMap,
ExcalidrawBindableElement,
ExcalidrawElement,
ExcalidrawFrameLikeElement,
ExcalidrawImageElement,
ExcalidrawLinearElement,
ExcalidrawTextElement,
GroupId,
NonDeleted,
} from "../element/types";
import type { import type {
InteractiveCanvasRenderConfig, InteractiveCanvasRenderConfig,
InteractiveSceneRenderConfig, InteractiveSceneRenderConfig,

View file

@ -2,7 +2,6 @@ import { isRightAngleRads } from "@excalidraw/math";
import { getStroke } from "perfect-freehand"; import { getStroke } from "perfect-freehand";
import rough from "roughjs/bin/rough"; import rough from "roughjs/bin/rough";
import { getDefaultAppState } from "../appState";
import { import {
BOUND_TEXT_PADDING, BOUND_TEXT_PADDING,
DEFAULT_REDUCED_GLOBAL_ALPHA, DEFAULT_REDUCED_GLOBAL_ALPHA,
@ -10,18 +9,21 @@ import {
FRAME_STYLE, FRAME_STYLE,
MIME_TYPES, MIME_TYPES,
THEME, THEME,
} from "../constants"; distance,
import { getElementAbsoluteCoords } from "../element/bounds"; getFontString,
import { getUncroppedImageElement } from "../element/cropElement"; isRTL,
import { LinearElementEditor } from "../element/linearElementEditor"; } from "@excalidraw/common";
import { getElementAbsoluteCoords } from "@excalidraw/element/bounds";
import { getUncroppedImageElement } from "@excalidraw/element/cropElement";
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { import {
getBoundTextElement, getBoundTextElement,
getContainerCoords, getContainerCoords,
getContainerElement, getContainerElement,
getBoundTextMaxHeight, getBoundTextMaxHeight,
getBoundTextMaxWidth, getBoundTextMaxWidth,
} from "../element/textElement"; } from "@excalidraw/element/textElement";
import { getLineHeightInPx } from "../element/textMeasurements"; import { getLineHeightInPx } from "@excalidraw/element/textMeasurements";
import { import {
isTextElement, isTextElement,
isLinearElement, isLinearElement,
@ -31,12 +33,9 @@ import {
hasBoundTextElement, hasBoundTextElement,
isMagicFrameElement, isMagicFrameElement,
isImageElement, isImageElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { getVerticalOffset } from "../fonts/FontMetadata"; import { getContainingFrame } from "@excalidraw/element/frame";
import { getContainingFrame } from "../frame"; import { getCornerRadius } from "@excalidraw/element/shapes";
import { ShapeCache } from "../scene/ShapeCache";
import { getCornerRadius } from "../shapes";
import { distance, getFontString, isRTL } from "../utils";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
@ -48,7 +47,12 @@ import type {
ExcalidrawFrameLikeElement, ExcalidrawFrameLikeElement,
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
ElementsMap, ElementsMap,
} from "../element/types"; } from "@excalidraw/element/types";
import { getDefaultAppState } from "../appState";
import { getVerticalOffset } from "../fonts/FontMetadata";
import { ShapeCache } from "../scene/ShapeCache";
import type { import type {
StaticCanvasRenderConfig, StaticCanvasRenderConfig,
RenderableElementsMap, RenderableElementsMap,

View file

@ -1,4 +1,4 @@
import { throttleRAF } from "../utils"; import { throttleRAF } from "@excalidraw/common";
import { bootstrapCanvas, getNormalizedCanvasDimensions } from "./helpers"; import { bootstrapCanvas, getNormalizedCanvasDimensions } from "./helpers";
import { renderElement } from "./renderElement"; import { renderElement } from "./renderElement";

View file

@ -1,6 +1,6 @@
import { pointFrom, type GlobalPoint, type LocalPoint } from "@excalidraw/math"; import { pointFrom, type GlobalPoint, type LocalPoint } from "@excalidraw/math";
import { THEME } from "../constants"; import { THEME } from "@excalidraw/common";
import type { PointSnapLine, PointerSnapLine } from "../snapping"; import type { PointSnapLine, PointerSnapLine } from "../snapping";
import type { InteractiveCanvasAppState } from "../types"; import type { InteractiveCanvasAppState } from "../types";

View file

@ -1,33 +1,34 @@
import { import { FRAME_STYLE, throttleRAF } from "@excalidraw/common";
EXTERNAL_LINK_IMG, import { getElementAbsoluteCoords } from "@excalidraw/element";
ELEMENT_LINK_IMG, import { isElementLink } from "@excalidraw/element/elementLink";
getLinkHandleFromCoords, import { createPlaceholderEmbeddableLabel } from "@excalidraw/element/embeddable";
} from "../components/hyperlink/helpers"; import { getBoundTextElement } from "@excalidraw/element/textElement";
import { FRAME_STYLE } from "../constants";
import { getElementAbsoluteCoords } from "../element";
import { isElementLink } from "../element/elementLink";
import { createPlaceholderEmbeddableLabel } from "../element/embeddable";
import { getBoundTextElement } from "../element/textElement";
import { import {
isEmbeddableElement, isEmbeddableElement,
isIframeLikeElement, isIframeLikeElement,
isTextElement, isTextElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { import {
elementOverlapsWithFrame, elementOverlapsWithFrame,
getTargetFrame, getTargetFrame,
shouldApplyFrameClip, shouldApplyFrameClip,
} from "../frame"; } from "@excalidraw/element/frame";
import { renderElement } from "../renderer/renderElement";
import { throttleRAF } from "../utils";
import { bootstrapCanvas, getNormalizedCanvasDimensions } from "./helpers";
import type { import type {
ElementsMap, ElementsMap,
ExcalidrawFrameLikeElement, ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import {
EXTERNAL_LINK_IMG,
ELEMENT_LINK_IMG,
getLinkHandleFromCoords,
} from "../components/hyperlink/helpers";
import { renderElement } from "../renderer/renderElement";
import { bootstrapCanvas, getNormalizedCanvasDimensions } from "./helpers";
import type { import type {
StaticCanvasRenderConfig, StaticCanvasRenderConfig,
StaticSceneRenderConfig, StaticSceneRenderConfig,

View file

@ -3,39 +3,45 @@ import {
MAX_DECIMALS_FOR_SVG_EXPORT, MAX_DECIMALS_FOR_SVG_EXPORT,
MIME_TYPES, MIME_TYPES,
SVG_NS, SVG_NS,
} from "../constants"; getFontFamilyString,
import { normalizeLink, toValidURL } from "../data/url"; isRTL,
import { getElementAbsoluteCoords, hashString } from "../element"; isTestEnv,
import { getUncroppedWidthAndHeight } from "../element/cropElement"; } from "@excalidraw/common";
import { normalizeLink, toValidURL } from "@excalidraw/common";
import { getElementAbsoluteCoords, hashString } from "@excalidraw/element";
import { getUncroppedWidthAndHeight } from "@excalidraw/element/cropElement";
import { import {
createPlaceholderEmbeddableLabel, createPlaceholderEmbeddableLabel,
getEmbedLink, getEmbedLink,
} from "../element/embeddable"; } from "@excalidraw/element/embeddable";
import { LinearElementEditor } from "../element/linearElementEditor"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { import {
getBoundTextElement, getBoundTextElement,
getContainerElement, getContainerElement,
} from "../element/textElement"; } from "@excalidraw/element/textElement";
import { getLineHeightInPx } from "../element/textMeasurements"; import { getLineHeightInPx } from "@excalidraw/element/textMeasurements";
import { import {
isArrowElement, isArrowElement,
isIframeLikeElement, isIframeLikeElement,
isInitializedImageElement, isInitializedImageElement,
isTextElement, isTextElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { getVerticalOffset } from "../fonts/FontMetadata";
import { getContainingFrame } from "../frame";
import { ShapeCache } from "../scene/ShapeCache";
import { getCornerRadius, isPathALoop } from "../shapes";
import { getFontFamilyString, isRTL, isTestEnv } from "../utils";
import { getFreeDrawSvgPath, IMAGE_INVERT_FILTER } from "./renderElement"; import { getContainingFrame } from "@excalidraw/element/frame";
import { getCornerRadius, isPathALoop } from "@excalidraw/element/shapes";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawTextElementWithContainer, ExcalidrawTextElementWithContainer,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import { getVerticalOffset } from "../fonts/FontMetadata";
import { ShapeCache } from "../scene/ShapeCache";
import { getFreeDrawSvgPath, IMAGE_INVERT_FILTER } from "./renderElement";
import type { RenderableElementsMap, SVGRenderConfig } from "../scene/types"; import type { RenderableElementsMap, SVGRenderConfig } from "../scene/types";
import type { AppState, BinaryFiles } from "../types"; import type { AppState, BinaryFiles } from "../types";
import type { Drawable } from "roughjs/bin/core"; import type { Drawable } from "roughjs/bin/core";

View file

@ -1,16 +1,20 @@
import { isElementInViewport } from "../element/sizeHelpers"; import { isElementInViewport } from "@excalidraw/element/sizeHelpers";
import { isImageElement } from "../element/typeChecks"; import { isImageElement } from "@excalidraw/element/typeChecks";
import { renderInteractiveSceneThrottled } from "../renderer/interactiveScene";
import { renderStaticSceneThrottled } from "../renderer/staticScene"; import { memoize, toBrandedType } from "@excalidraw/common";
import { memoize, toBrandedType } from "../utils";
import type Scene from "./Scene";
import type { RenderableElementsMap } from "./types";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
NonDeletedElementsMap, NonDeletedElementsMap,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import { renderInteractiveSceneThrottled } from "../renderer/interactiveScene";
import { renderStaticSceneThrottled } from "../renderer/staticScene";
import type Scene from "./Scene";
import type { RenderableElementsMap } from "./types";
import type { AppState } from "../types"; import type { AppState } from "../types";
export class Renderer { export class Renderer {

View file

@ -1,21 +1,14 @@
import throttle from "lodash.throttle"; import throttle from "lodash.throttle";
import { ENV } from "../constants"; import { ENV } from "@excalidraw/common";
import { isNonDeletedElement } from "../element"; import { isNonDeletedElement } from "@excalidraw/element";
import { isFrameLikeElement } from "../element/typeChecks"; import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import {
syncInvalidIndices,
syncMovedIndices,
validateFractionalIndices,
} from "../fractionalIndex";
import { getElementsInGroup } from "../groups";
import { randomInteger } from "../random";
import { arrayToMap } from "../utils";
import { toBrandedType } from "../utils";
import { getSelectedElements } from "./selection"; import { randomInteger } from "@excalidraw/common";
import { arrayToMap } from "@excalidraw/common";
import { toBrandedType } from "@excalidraw/common";
import type { LinearElementEditor } from "../element/linearElementEditor"; import type { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
@ -26,7 +19,17 @@ import type {
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
OrderedExcalidrawElement, OrderedExcalidrawElement,
Ordered, Ordered,
} from "../element/types"; } from "@excalidraw/element/types";
import { getElementsInGroup } from "../groups";
import {
syncInvalidIndices,
syncMovedIndices,
validateFractionalIndices,
} from "../fractionalIndex";
import { getSelectedElements } from "./selection";
import type { AppState } from "../types"; import type { AppState } from "../types";
import type { Assert, SameType } from "../utility-types"; import type { Assert, SameType } from "../utility-types";

View file

@ -1,21 +1,18 @@
import { pointFrom, pointDistance, type LocalPoint } from "@excalidraw/math"; import { pointFrom, pointDistance, type LocalPoint } from "@excalidraw/math";
import { simplify } from "points-on-curve"; import { simplify } from "points-on-curve";
import { ROUGHNESS } from "../constants"; import { ROUGHNESS, isTransparent, assertNever } from "@excalidraw/common";
import { getDiamondPoints, getArrowheadPoints } from "../element"; import { getDiamondPoints, getArrowheadPoints } from "@excalidraw/element";
import { headingForPointIsHorizontal } from "../element/heading"; import { headingForPointIsHorizontal } from "@excalidraw/element/heading";
import { import {
isElbowArrow, isElbowArrow,
isEmbeddableElement, isEmbeddableElement,
isIframeElement, isIframeElement,
isIframeLikeElement, isIframeLikeElement,
isLinearElement, isLinearElement,
} from "../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { generateFreeDrawShape } from "../renderer/renderElement";
import { getCornerRadius, isPathALoop } from "../shapes";
import { isTransparent, assertNever } from "../utils";
import { canChangeRoundness } from "./comparisons"; import { getCornerRadius, isPathALoop } from "@excalidraw/element/shapes";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
@ -23,7 +20,12 @@ import type {
ExcalidrawSelectionElement, ExcalidrawSelectionElement,
ExcalidrawLinearElement, ExcalidrawLinearElement,
Arrowhead, Arrowhead,
} from "../element/types"; } from "@excalidraw/element/types";
import { generateFreeDrawShape } from "../renderer/renderElement";
import { canChangeRoundness } from "./comparisons";
import type { EmbedsValidationStatus } from "../types"; import type { EmbedsValidationStatus } from "../types";
import type { ElementShapes } from "./types"; import type { ElementShapes } from "./types";
import type { Drawable, Options } from "roughjs/bin/core"; import type { Drawable, Options } from "roughjs/bin/core";

View file

@ -1,14 +1,16 @@
import { RoughGenerator } from "roughjs/bin/generator"; import { RoughGenerator } from "roughjs/bin/generator";
import { COLOR_PALETTE } from "../colors"; import { COLOR_PALETTE } from "@excalidraw/common";
import { elementWithCanvasCache } from "../renderer/renderElement";
import { _generateElementShape } from "./Shape";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawSelectionElement, ExcalidrawSelectionElement,
} from "../element/types"; } from "@excalidraw/element/types";
import { elementWithCanvasCache } from "../renderer/renderElement";
import { _generateElementShape } from "./Shape";
import type { AppState, EmbedsValidationStatus } from "../types"; import type { AppState, EmbedsValidationStatus } from "../types";
import type { ElementShape, ElementShapes } from "./types"; import type { ElementShape, ElementShapes } from "./types";
import type { Drawable } from "roughjs/bin/core"; import type { Drawable } from "roughjs/bin/core";

View file

@ -1,6 +1,5 @@
import rough from "roughjs/bin/rough"; import rough from "roughjs/bin/rough";
import { getDefaultAppState } from "../appState";
import { import {
DEFAULT_EXPORT_PADDING, DEFAULT_EXPORT_PADDING,
FRAME_STYLE, FRAME_STYLE,
@ -10,39 +9,58 @@ import {
THEME_FILTER, THEME_FILTER,
MIME_TYPES, MIME_TYPES,
EXPORT_DATA_TYPES, EXPORT_DATA_TYPES,
} from "../constants"; arrayToMap,
import { base64ToString, decode, encode, stringToBase64 } from "../data/encode"; distance,
import { serializeAsJSON } from "../data/json"; getFontString,
import { newTextElement } from "../element"; toBrandedType,
import { getCommonBounds, getElementAbsoluteCoords } from "../element/bounds"; } from "@excalidraw/common";
import { newTextElement } from "@excalidraw/element";
import {
getCommonBounds,
getElementAbsoluteCoords,
} from "@excalidraw/element/bounds";
import { import {
getInitializedImageElements, getInitializedImageElements,
updateImageCache, updateImageCache,
} from "../element/image"; } from "@excalidraw/element/image";
import { newElementWith } from "../element/mutateElement";
import { isFrameLikeElement } from "../element/typeChecks"; import { newElementWith } from "@excalidraw/element/mutateElement";
import { Fonts } from "../fonts";
import { syncInvalidIndices } from "../fractionalIndex"; import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import { import {
getElementsOverlappingFrame, getElementsOverlappingFrame,
getFrameLikeElements, getFrameLikeElements,
getFrameLikeTitle, getFrameLikeTitle,
getRootElements, getRootElements,
} from "../frame"; } from "@excalidraw/element/frame";
import { renderStaticScene } from "../renderer/staticScene";
import { renderSceneToSvg } from "../renderer/staticSvgScene"; import type { Bounds } from "@excalidraw/element/bounds";
import { type Mutable } from "../utility-types";
import { arrayToMap, distance, getFontString, toBrandedType } from "../utils";
import type { RenderableElementsMap } from "./types";
import type { Bounds } from "../element/bounds";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawFrameLikeElement, ExcalidrawFrameLikeElement,
ExcalidrawTextElement, ExcalidrawTextElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
} from "../element/types"; } from "@excalidraw/element/types";
import { getDefaultAppState } from "../appState";
import { base64ToString, decode, encode, stringToBase64 } from "../data/encode";
import { serializeAsJSON } from "../data/json";
import { Fonts } from "../fonts";
import { syncInvalidIndices } from "../fractionalIndex";
import { renderStaticScene } from "../renderer/staticScene";
import { renderSceneToSvg } from "../renderer/staticSvgScene";
import { type Mutable } from "../utility-types";
import type { RenderableElementsMap } from "./types";
import type { AppState, BinaryFiles } from "../types"; import type { AppState, BinaryFiles } from "../types";
const truncateText = (element: ExcalidrawTextElement, maxWidth: number) => { const truncateText = (element: ExcalidrawTextElement, maxWidth: number) => {

View file

@ -1,6 +1,6 @@
import { clamp, round } from "@excalidraw/math"; import { MAX_ZOOM, MIN_ZOOM } from "@excalidraw/common";
import { MAX_ZOOM, MIN_ZOOM } from "../constants"; import { clamp, round } from "@excalidraw/math";
import type { NormalizedZoomValue } from "../types"; import type { NormalizedZoomValue } from "../types";

View file

@ -2,13 +2,14 @@ import {
getCommonBounds, getCommonBounds,
getClosestElementBounds, getClosestElementBounds,
getVisibleElements, getVisibleElements,
} from "../element"; } from "@excalidraw/element";
import { import {
sceneCoordsToViewportCoords, sceneCoordsToViewportCoords,
viewportCoordsToSceneCoords, viewportCoordsToSceneCoords,
} from "../utils"; } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, Offsets, PointerCoords, Zoom } from "../types"; import type { AppState, Offsets, PointerCoords, Zoom } from "../types";
const isOutsideViewPort = (appState: AppState, cords: Array<number>) => { const isOutsideViewPort = (appState: AppState, cords: Array<number>) => {

View file

@ -1,8 +1,11 @@
import { getCommonBounds } from "../element"; import { getCommonBounds } from "@excalidraw/element";
import { getLanguage } from "../i18n";
import { getGlobalCSSVariable } from "../utils"; import { getGlobalCSSVariable } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { getLanguage } from "../i18n";
import type { ExcalidrawElement } from "../element/types";
import type { InteractiveCanvasAppState } from "../types"; import type { InteractiveCanvasAppState } from "../types";
import type { ScrollBars } from "./types"; import type { ScrollBars } from "./types";

View file

@ -1,19 +1,26 @@
import { getElementAbsoluteCoords, getElementBounds } from "../element"; import {
import { isElementInViewport } from "../element/sizeHelpers"; getElementAbsoluteCoords,
import { isBoundToContainer, isFrameLikeElement } from "../element/typeChecks"; getElementBounds,
} from "@excalidraw/element/bounds";
import { isElementInViewport } from "@excalidraw/element/sizeHelpers";
import {
isBoundToContainer,
isFrameLikeElement,
} from "@excalidraw/element/typeChecks";
import { import {
elementOverlapsWithFrame, elementOverlapsWithFrame,
getContainingFrame, getContainingFrame,
getFrameChildren, getFrameChildren,
} from "../frame"; } from "@excalidraw/element/frame";
import { isShallowEqual } from "../utils"; import { isShallowEqual } from "@excalidraw/common";
import type { import type {
ElementsMap, ElementsMap,
ElementsMapOrArray, ElementsMapOrArray,
ExcalidrawElement, ExcalidrawElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "../element/types"; } from "@excalidraw/element/types";
import type { AppState, InteractiveCanvasAppState } from "../types"; import type { AppState, InteractiveCanvasAppState } from "../types";
/** /**

View file

@ -1,10 +1,11 @@
import type { UserIdleState } from "../constants"; import type { UserIdleState } from "@excalidraw/common";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
NonDeletedElementsMap, NonDeletedElementsMap,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
} from "../element/types"; } from "@excalidraw/element/types";
import type { import type {
AppClassProperties, AppClassProperties,
AppState, AppState,

View file

@ -7,34 +7,37 @@ import {
type GlobalPoint, type GlobalPoint,
} from "@excalidraw/math"; } from "@excalidraw/math";
import type { InclusiveRange } from "@excalidraw/math"; import { TOOL_TYPE, KEYS } from "@excalidraw/common";
import { TOOL_TYPE } from "./constants";
import { import {
getCommonBounds, getCommonBounds,
getDraggedElementsBounds, getDraggedElementsBounds,
getElementAbsoluteCoords, getElementAbsoluteCoords,
} from "./element/bounds"; } from "@excalidraw/element/bounds";
import { isBoundToContainer, isFrameLikeElement } from "./element/typeChecks"; import {
isBoundToContainer,
isFrameLikeElement,
} from "@excalidraw/element/typeChecks";
import type { InclusiveRange } from "@excalidraw/math";
import type { Bounds } from "@excalidraw/element/bounds";
import type { MaybeTransformHandleType } from "@excalidraw/element/transformHandles";
import type {
ElementsMap,
ExcalidrawElement,
NonDeletedExcalidrawElement,
} from "@excalidraw/element/types";
import { getMaximumGroups } from "./groups"; import { getMaximumGroups } from "./groups";
import { KEYS } from "./keys";
import { import {
getSelectedElements, getSelectedElements,
getVisibleAndNonSelectedElements, getVisibleAndNonSelectedElements,
} from "./scene/selection"; } from "./scene/selection";
import type { Bounds } from "./element/bounds";
import type { MaybeTransformHandleType } from "./element/transformHandles";
import type {
ElementsMap,
ExcalidrawElement,
NonDeletedExcalidrawElement,
} from "./element/types";
import type { import type {
AppClassProperties, AppClassProperties,
AppState, AppState,
KeyboardModifiersObject, KeyboardModifiersObject,
NullableGridSize,
} from "./types"; } from "./types";
const SNAP_DISTANCE = 8; const SNAP_DISTANCE = 8;

View file

@ -1,12 +1,14 @@
import { ENV, isShallowEqual } from "@excalidraw/common";
import { deepCopyElement, newElementWith } from "@excalidraw/element";
import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
import { getDefaultAppState } from "./appState"; import { getDefaultAppState } from "./appState";
import { AppStateChange, ElementsChange } from "./change"; import { AppStateChange, ElementsChange } from "./change";
import { ENV } from "./constants";
import { newElementWith } from "./element/mutateElement";
import { deepCopyElement } from "./element/newElement";
import { Emitter } from "./emitter";
import { isShallowEqual } from "./utils";
import type { OrderedExcalidrawElement } from "./element/types"; import { Emitter } from "./emitter";
import type { AppState, ObservedAppState } from "./types"; import type { AppState, ObservedAppState } from "./types";
import type { ValueOf } from "./utility-types"; import type { ValueOf } from "./utility-types";

View file

@ -1,5 +1,6 @@
import { isServerEnv, promiseTry } from "@excalidraw/common";
import { WorkerInTheMainChunkError, WorkerUrlNotDefinedError } from "../errors"; import { WorkerInTheMainChunkError, WorkerUrlNotDefinedError } from "../errors";
import { isServerEnv, promiseTry } from "../utils";
import { WorkerPool } from "../workers"; import { WorkerPool } from "../workers";
import type { Commands } from "./subset-shared.chunk"; import type { Commands } from "./subset-shared.chunk";

View file

@ -1,19 +1,16 @@
import type { Action } from "./actions/types"; import type {
import type { Spreadsheet } from "./charts"; IMAGE_MIME_TYPES,
import type { ClipboardData } from "./clipboard"; UserIdleState,
import type App from "./components/App"; throttleRAF,
import type Library from "./data/library"; MIME_TYPES,
import type { FileSystemHandle } from "./data/filesystem"; } from "@excalidraw/common";
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
import type { ContextMenuItems } from "./components/ContextMenu"; import type { SuggestedBinding } from "@excalidraw/element/binding";
import type { SnapLine } from "./snapping";
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "./utility-types"; import type { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import type { CaptureUpdateActionType } from "./store";
import type { UserIdleState } from "./constants"; import type { MaybeTransformHandleType } from "@excalidraw/element/transformHandles";
import type { ImportedDataState } from "./data/types";
import type { SuggestedBinding } from "./element/binding";
import type { LinearElementEditor } from "./element/linearElementEditor";
import type { MaybeTransformHandleType } from "./element/transformHandles";
import type { import type {
PointerType, PointerType,
ExcalidrawLinearElement, ExcalidrawLinearElement,
@ -37,10 +34,22 @@ import type {
ExcalidrawIframeLikeElement, ExcalidrawIframeLikeElement,
OrderedExcalidrawElement, OrderedExcalidrawElement,
ExcalidrawNonSelectionElement, ExcalidrawNonSelectionElement,
} from "./element/types"; } from "@excalidraw/element/types";
import type { Action } from "./actions/types";
import type { Spreadsheet } from "./charts";
import type { ClipboardData } from "./clipboard";
import type App from "./components/App";
import type Library from "./data/library";
import type { FileSystemHandle } from "./data/filesystem";
import type { ContextMenuItems } from "./components/ContextMenu";
import type { SnapLine } from "./snapping";
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "./utility-types";
import type { CaptureUpdateActionType } from "./store";
import type { ImportedDataState } from "./data/types";
import type { Language } from "./i18n"; import type { Language } from "./i18n";
import type { isOverScrollBars } from "./scene/scrollbars"; import type { isOverScrollBars } from "./scene/scrollbars";
import type { throttleRAF } from "./utils";
import type React from "react"; import type React from "react";
import type { JSX } from "react"; import type { JSX } from "react";

View file

@ -6,12 +6,12 @@ import {
type LocalPoint, type LocalPoint,
} from "@excalidraw/math"; } from "@excalidraw/math";
import { isBounds } from "@excalidraw/element/typeChecks";
import type { Curve } from "@excalidraw/math"; import type { Curve } from "@excalidraw/math";
import type { LineSegment } from "@excalidraw/utils"; import type { LineSegment } from "@excalidraw/utils";
import { isBounds } from "./element/typeChecks"; import type { Bounds } from "@excalidraw/element/bounds";
import type { Bounds } from "./element/bounds";
// The global data holder to collect the debug operations // The global data holder to collect the debug operations
declare global { declare global {

View file

@ -1,5 +1,6 @@
import { debounce } from "@excalidraw/common";
import { WorkerInTheMainChunkError, WorkerUrlNotDefinedError } from "./errors"; import { WorkerInTheMainChunkError, WorkerUrlNotDefinedError } from "./errors";
import { debounce } from "./utils";
class IdleWorker { class IdleWorker {
public instance: Worker; public instance: Worker;

Some files were not shown because too many files have changed in this diff Show more