diff --git a/README.md b/README.md index 9458779ce..7d8aa622a 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ The Excalidraw editor (npm package) supports: - 🏗️ Customizable. - 📷 Image support. - 😀 Shape libraries support. -- 👅 Localization (i18n) support. +- 🌐 Localization (i18n) support. - 🖼️ Export to PNG, SVG & clipboard. - 💾 Open format - export drawings as an `.excalidraw` json file. - ⚒️ Wide range of tools - rectangle, circle, diamond, arrow, line, free-draw, eraser... diff --git a/excalidraw-app/App.tsx b/excalidraw-app/App.tsx index bb62a0e96..932743ddf 100644 --- a/excalidraw-app/App.tsx +++ b/excalidraw-app/App.tsx @@ -47,10 +47,10 @@ import { share, youtubeIcon, } from "@excalidraw/excalidraw/components/icons"; -import { isElementLink } from "@excalidraw/element/elementLink"; +import { isElementLink } from "@excalidraw/element"; import { restore, restoreAppState } from "@excalidraw/excalidraw/data/restore"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; +import { newElementWith } from "@excalidraw/element"; +import { isInitializedImageElement } from "@excalidraw/element"; import clsx from "clsx"; import { parseLibraryTokensFromUrl, diff --git a/excalidraw-app/collab/Collab.tsx b/excalidraw-app/collab/Collab.tsx index 98c66e425..bed130e24 100644 --- a/excalidraw-app/collab/Collab.tsx +++ b/excalidraw-app/collab/Collab.tsx @@ -19,12 +19,9 @@ import { throttleRAF, } from "@excalidraw/common"; import { decryptData } from "@excalidraw/excalidraw/data/encryption"; -import { getVisibleSceneBounds } from "@excalidraw/element/bounds"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { - isImageElement, - isInitializedImageElement, -} from "@excalidraw/element/typeChecks"; +import { getVisibleSceneBounds } from "@excalidraw/element"; +import { newElementWith } from "@excalidraw/element"; +import { isImageElement, isInitializedImageElement } from "@excalidraw/element"; import { AbortError } from "@excalidraw/excalidraw/errors"; import { t } from "@excalidraw/excalidraw/i18n"; import { withBatchedUpdates } from "@excalidraw/excalidraw/reactUtils"; diff --git a/excalidraw-app/collab/Portal.tsx b/excalidraw-app/collab/Portal.tsx index 26a7d0d9e..2e076a661 100644 --- a/excalidraw-app/collab/Portal.tsx +++ b/excalidraw-app/collab/Portal.tsx @@ -1,7 +1,7 @@ import { CaptureUpdateAction } from "@excalidraw/excalidraw"; import { trackEvent } from "@excalidraw/excalidraw/analytics"; import { encryptData } from "@excalidraw/excalidraw/data/encryption"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; import throttle from "lodash.throttle"; import type { UserIdleState } from "@excalidraw/common"; diff --git a/excalidraw-app/components/ExportToExcalidrawPlus.tsx b/excalidraw-app/components/ExportToExcalidrawPlus.tsx index 60f1608b2..0e9703a10 100644 --- a/excalidraw-app/components/ExportToExcalidrawPlus.tsx +++ b/excalidraw-app/components/ExportToExcalidrawPlus.tsx @@ -12,7 +12,7 @@ import { generateEncryptionKey, } from "@excalidraw/excalidraw/data/encryption"; import { serializeAsJSON } from "@excalidraw/excalidraw/data/json"; -import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; +import { isInitializedImageElement } from "@excalidraw/element"; import { useI18n } from "@excalidraw/excalidraw/i18n"; import type { diff --git a/excalidraw-app/data/FileManager.ts b/excalidraw-app/data/FileManager.ts index 5d134144f..435d81325 100644 --- a/excalidraw-app/data/FileManager.ts +++ b/excalidraw-app/data/FileManager.ts @@ -1,7 +1,7 @@ import { CaptureUpdateAction } from "@excalidraw/excalidraw"; import { compressData } from "@excalidraw/excalidraw/data/encode"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; +import { newElementWith } from "@excalidraw/element"; +import { isInitializedImageElement } from "@excalidraw/element"; import { t } from "@excalidraw/excalidraw/i18n"; import type { diff --git a/excalidraw-app/data/index.ts b/excalidraw-app/data/index.ts index 7bb0f9d8d..75aa27877 100644 --- a/excalidraw-app/data/index.ts +++ b/excalidraw-app/data/index.ts @@ -9,14 +9,14 @@ import { } from "@excalidraw/excalidraw/data/encryption"; import { serializeAsJSON } from "@excalidraw/excalidraw/data/json"; import { restore } from "@excalidraw/excalidraw/data/restore"; -import { isInvisiblySmallElement } from "@excalidraw/element/sizeHelpers"; -import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; +import { isInvisiblySmallElement } from "@excalidraw/element"; +import { isInitializedImageElement } from "@excalidraw/element"; import { t } from "@excalidraw/excalidraw/i18n"; import { bytesToHexString } from "@excalidraw/common"; import type { UserIdleState } from "@excalidraw/common"; import type { ImportedDataState } from "@excalidraw/excalidraw/data/types"; -import type { SceneBounds } from "@excalidraw/element/bounds"; +import type { SceneBounds } from "@excalidraw/element"; import type { ExcalidrawElement, FileId, diff --git a/excalidraw-app/tests/collab.test.tsx b/excalidraw-app/tests/collab.test.tsx index 4549c2128..ed19c96e8 100644 --- a/excalidraw-app/tests/collab.test.tsx +++ b/excalidraw-app/tests/collab.test.tsx @@ -3,17 +3,14 @@ import { createRedoAction, createUndoAction, } from "@excalidraw/excalidraw/actions/actionHistory"; -import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex"; +import { syncInvalidIndices } from "@excalidraw/element"; import { API } from "@excalidraw/excalidraw/tests/helpers/api"; import { act, render, waitFor } from "@excalidraw/excalidraw/tests/test-utils"; import { vi } from "vitest"; -import { StoreIncrement } from "@excalidraw/element/store"; +import { StoreIncrement } from "@excalidraw/element"; -import type { - DurableIncrement, - EphemeralIncrement, -} from "@excalidraw/element/store"; +import type { DurableIncrement, EphemeralIncrement } from "@excalidraw/element"; import ExcalidrawApp from "../App"; diff --git a/packages/common/src/constants.ts b/packages/common/src/constants.ts index 02999a05a..3184e8f67 100644 --- a/packages/common/src/constants.ts +++ b/packages/common/src/constants.ts @@ -143,6 +143,7 @@ export const FONT_FAMILY = { "Lilita One": 7, "Comic Shanns": 8, "Liberation Sans": 9, + Assistant: 10, }; export const FONT_FAMILY_FALLBACKS = { diff --git a/packages/common/src/font-metadata.ts b/packages/common/src/font-metadata.ts index de4cc57bf..f6005ee45 100644 --- a/packages/common/src/font-metadata.ts +++ b/packages/common/src/font-metadata.ts @@ -22,8 +22,10 @@ export interface FontMetadata { }; /** flag to indicate a deprecated font */ deprecated?: true; - /** flag to indicate a server-side only font */ - serverSide?: true; + /** + * whether this is a font that users can use (= shown in font picker) + */ + private?: true; /** flag to indiccate a local-only font */ local?: true; /** flag to indicate a fallback font */ @@ -98,7 +100,16 @@ export const FONT_METADATA: Record = { descender: -434, lineHeight: 1.15, }, - serverSide: true, + private: true, + }, + [FONT_FAMILY.Assistant]: { + metrics: { + unitsPerEm: 2048, + ascender: 1021, + descender: -287, + lineHeight: 1.25, + }, + private: true, }, [FONT_FAMILY_FALLBACKS.Xiaolai]: { metrics: { diff --git a/packages/element/src/Scene.ts b/packages/element/src/Scene.ts index a31c96264..df0fd3e2d 100644 --- a/packages/element/src/Scene.ts +++ b/packages/element/src/Scene.ts @@ -9,21 +9,18 @@ import { toArray, } from "@excalidraw/common"; import { isNonDeletedElement } from "@excalidraw/element"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; -import { getElementsInGroup } from "@excalidraw/element/groups"; +import { isFrameLikeElement } from "@excalidraw/element"; +import { getElementsInGroup } from "@excalidraw/element"; import { syncInvalidIndices, syncMovedIndices, validateFractionalIndices, -} from "@excalidraw/element/fractionalIndex"; +} from "@excalidraw/element"; -import { getSelectedElements } from "@excalidraw/element/selection"; +import { getSelectedElements } from "@excalidraw/element"; -import { - mutateElement, - type ElementUpdate, -} from "@excalidraw/element/mutateElement"; +import { mutateElement, type ElementUpdate } from "@excalidraw/element"; import type { ExcalidrawElement, @@ -108,7 +105,7 @@ const hashSelectionOpts = ( // in our codebase export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[]; -class Scene { +export class Scene { // --------------------------------------------------------------------------- // instance methods/props // --------------------------------------------------------------------------- @@ -457,5 +454,3 @@ class Scene { return element; } } - -export default Scene; diff --git a/packages/element/src/align.ts b/packages/element/src/align.ts index b6dd4d454..546bbbfa4 100644 --- a/packages/element/src/align.ts +++ b/packages/element/src/align.ts @@ -2,7 +2,7 @@ import { updateBoundElements } from "./binding"; import { getCommonBoundingBox } from "./bounds"; import { getMaximumGroups } from "./groups"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { BoundingBox } from "./bounds"; import type { ExcalidrawElement } from "./types"; diff --git a/packages/element/src/binding.ts b/packages/element/src/binding.ts index 58f378998..2ea05510b 100644 --- a/packages/element/src/binding.ts +++ b/packages/element/src/binding.ts @@ -66,7 +66,7 @@ import { import { aabbForElement, getElementShape, pointInsideBounds } from "./shapes"; import { updateElbowArrowPoints } from "./elbowArrow"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { Bounds } from "./bounds"; import type { ElementUpdate } from "./mutateElement"; diff --git a/packages/element/src/delta.ts b/packages/element/src/delta.ts index 2499f7d66..c6d5fcc6b 100644 --- a/packages/element/src/delta.ts +++ b/packages/element/src/delta.ts @@ -49,7 +49,7 @@ import { getNonDeletedGroupIds } from "./groups"; import { orderByFractionalIndex, syncMovedIndices } from "./fractionalIndex"; -import Scene from "./Scene"; +import { Scene } from "./Scene"; import type { BindableProp, BindingProp } from "./binding"; diff --git a/packages/element/src/dragElements.ts b/packages/element/src/dragElements.ts index 4f9eb9ca4..4b17ba20c 100644 --- a/packages/element/src/dragElements.ts +++ b/packages/element/src/dragElements.ts @@ -26,7 +26,7 @@ import { isTextElement, } from "./typeChecks"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { Bounds } from "./bounds"; import type { ExcalidrawElement } from "./types"; diff --git a/packages/element/src/flowchart.ts b/packages/element/src/flowchart.ts index c537cb719..5194e5425 100644 --- a/packages/element/src/flowchart.ts +++ b/packages/element/src/flowchart.ts @@ -39,7 +39,7 @@ import { type OrderedExcalidrawElement, } from "./types"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; type LinkDirection = "up" | "right" | "down" | "left"; diff --git a/packages/element/src/frame.ts b/packages/element/src/frame.ts index 74375a48d..3c8209954 100644 --- a/packages/element/src/frame.ts +++ b/packages/element/src/frame.ts @@ -905,13 +905,16 @@ export const shouldApplyFrameClip = ( return false; }; -export const getFrameLikeTitle = (element: ExcalidrawFrameLikeElement) => { +const DEFAULT_FRAME_NAME = "Frame"; +const DEFAULT_AI_FRAME_NAME = "AI Frame"; + +export const getDefaultFrameName = (element: ExcalidrawFrameLikeElement) => { // TODO name frames "AI" only if specific to AI frames - return element.name === null - ? isFrameElement(element) - ? "Frame" - : "AI Frame" - : element.name; + return isFrameElement(element) ? DEFAULT_FRAME_NAME : DEFAULT_AI_FRAME_NAME; +}; + +export const getFrameLikeTitle = (element: ExcalidrawFrameLikeElement) => { + return element.name === null ? getDefaultFrameName(element) : element.name; }; export const getElementsOverlappingFrame = ( diff --git a/packages/element/src/index.ts b/packages/element/src/index.ts index eafa609c4..93024f994 100644 --- a/packages/element/src/index.ts +++ b/packages/element/src/index.ts @@ -72,3 +72,47 @@ export const clearElementsForExport = ( export const clearElementsForLocalStorage = ( elements: readonly ExcalidrawElement[], ) => _clearElements(elements); + +export * from "./align"; +export * from "./binding"; +export * from "./bounds"; +export * from "./collision"; +export * from "./comparisons"; +export * from "./containerCache"; +export * from "./cropElement"; +export * from "./delta"; +export * from "./distance"; +export * from "./distribute"; +export * from "./dragElements"; +export * from "./duplicate"; +export * from "./elbowArrow"; +export * from "./elementLink"; +export * from "./embeddable"; +export * from "./flowchart"; +export * from "./fractionalIndex"; +export * from "./frame"; +export * from "./groups"; +export * from "./heading"; +export * from "./image"; +export * from "./linearElementEditor"; +export * from "./mutateElement"; +export * from "./newElement"; +export * from "./renderElement"; +export * from "./resizeElements"; +export * from "./resizeTest"; +export * from "./Scene"; +export * from "./selection"; +export * from "./Shape"; +export * from "./ShapeCache"; +export * from "./shapes"; +export * from "./showSelectedShapeActions"; +export * from "./sizeHelpers"; +export * from "./sortElements"; +export * from "./store"; +export * from "./textElement"; +export * from "./textMeasurements"; +export * from "./textWrapping"; +export * from "./transformHandles"; +export * from "./typeChecks"; +export * from "./utils"; +export * from "./zindex"; diff --git a/packages/element/src/linearElementEditor.ts b/packages/element/src/linearElementEditor.ts index ce74950e9..f14ba45b3 100644 --- a/packages/element/src/linearElementEditor.ts +++ b/packages/element/src/linearElementEditor.ts @@ -20,7 +20,7 @@ import { tupleToCoors, } from "@excalidraw/common"; -import type { Store } from "@excalidraw/element/store"; +import type { Store } from "@excalidraw/element"; import type { Radians } from "@excalidraw/math"; @@ -70,7 +70,7 @@ import { getLockedLinearCursorAlignSize } from "./sizeHelpers"; import { isLineElement } from "./typeChecks"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { Bounds } from "./bounds"; import type { diff --git a/packages/element/src/resizeElements.ts b/packages/element/src/resizeElements.ts index 43a5e7211..dea6e3d75 100644 --- a/packages/element/src/resizeElements.ts +++ b/packages/element/src/resizeElements.ts @@ -57,7 +57,7 @@ import { import { isInGroup } from "./groups"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { BoundingBox } from "./bounds"; import type { diff --git a/packages/element/src/textElement.ts b/packages/element/src/textElement.ts index 8ec0ef426..46b728158 100644 --- a/packages/element/src/textElement.ts +++ b/packages/element/src/textElement.ts @@ -30,7 +30,7 @@ import { isTextElement, } from "./typeChecks"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { MaybeTransformHandleType } from "./transformHandles"; import type { diff --git a/packages/element/src/zindex.ts b/packages/element/src/zindex.ts index b99cf833c..fed937825 100644 --- a/packages/element/src/zindex.ts +++ b/packages/element/src/zindex.ts @@ -10,7 +10,7 @@ import { syncMovedIndices } from "./fractionalIndex"; import { getSelectedElements } from "./selection"; -import type Scene from "./Scene"; +import type { Scene } from "./Scene"; import type { ExcalidrawElement, ExcalidrawFrameLikeElement } from "./types"; diff --git a/packages/excalidraw/tests/__snapshots__/linearElementEditor.test.tsx.snap b/packages/element/tests/__snapshots__/linearElementEditor.test.tsx.snap similarity index 100% rename from packages/excalidraw/tests/__snapshots__/linearElementEditor.test.tsx.snap rename to packages/element/tests/__snapshots__/linearElementEditor.test.tsx.snap diff --git a/packages/excalidraw/tests/cropElement.test.tsx b/packages/element/tests/cropElement.test.tsx similarity index 94% rename from packages/excalidraw/tests/cropElement.test.tsx rename to packages/element/tests/cropElement.test.tsx index 8764962fe..73edb4c80 100644 --- a/packages/excalidraw/tests/cropElement.test.tsx +++ b/packages/element/tests/cropElement.test.tsx @@ -3,21 +3,30 @@ import { vi } from "vitest"; import { KEYS, cloneJSON } from "@excalidraw/common"; -import { duplicateElement } from "@excalidraw/element/duplicate"; +import { + Excalidraw, + exportToCanvas, + exportToSvg, +} from "@excalidraw/excalidraw"; +import { + actionFlipHorizontal, + actionFlipVertical, +} from "@excalidraw/excalidraw/actions"; -import type { - ExcalidrawImageElement, - ImageCrop, -} from "@excalidraw/element/types"; +import { API } from "@excalidraw/excalidraw/tests/helpers/api"; +import { Keyboard, Pointer, UI } from "@excalidraw/excalidraw/tests/helpers/ui"; +import { + act, + GlobalTestState, + render, + unmountComponent, +} from "@excalidraw/excalidraw/tests/test-utils"; -import { Excalidraw, exportToCanvas, exportToSvg } from ".."; -import { actionFlipHorizontal, actionFlipVertical } from "../actions"; +import type { NormalizedZoomValue } from "@excalidraw/excalidraw/types"; -import { API } from "./helpers/api"; -import { Keyboard, Pointer, UI } from "./helpers/ui"; -import { act, GlobalTestState, render, unmountComponent } from "./test-utils"; +import { duplicateElement } from "../src/duplicate"; -import type { NormalizedZoomValue } from "../types"; +import type { ExcalidrawImageElement, ImageCrop } from "../src/types"; const { h } = window; const mouse = new Pointer("mouse"); diff --git a/packages/element/tests/delta.test.tsx b/packages/element/tests/delta.test.tsx index 48e925c30..50c2dcfc6 100644 --- a/packages/element/tests/delta.test.tsx +++ b/packages/element/tests/delta.test.tsx @@ -1,5 +1,5 @@ import type { ObservedAppState } from "@excalidraw/excalidraw/types"; -import type { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import type { LinearElementEditor } from "@excalidraw/element"; import { AppStateDelta } from "../src/delta"; diff --git a/packages/element/tests/elbowArrow.test.tsx b/packages/element/tests/elbowArrow.test.tsx index 25f64072e..b279e596c 100644 --- a/packages/element/tests/elbowArrow.test.tsx +++ b/packages/element/tests/elbowArrow.test.tsx @@ -22,7 +22,7 @@ import type { LocalPoint } from "@excalidraw/math"; import { bindLinearElement } from "../src/binding"; -import Scene from "../src/Scene"; +import { Scene } from "../src/Scene"; import type { ExcalidrawArrowElement, diff --git a/packages/element/tests/fractionalIndex.test.ts b/packages/element/tests/fractionalIndex.test.ts index c8cc9ad2d..1cc3ca5af 100644 --- a/packages/element/tests/fractionalIndex.test.ts +++ b/packages/element/tests/fractionalIndex.test.ts @@ -7,9 +7,9 @@ import { syncInvalidIndices, syncMovedIndices, validateFractionalIndices, -} from "@excalidraw/element/fractionalIndex"; +} from "@excalidraw/element"; -import { deepCopyElement } from "@excalidraw/element/duplicate"; +import { deepCopyElement } from "@excalidraw/element"; import { API } from "@excalidraw/excalidraw/tests/helpers/api"; diff --git a/packages/excalidraw/tests/linearElementEditor.test.tsx b/packages/element/tests/linearElementEditor.test.tsx similarity index 98% rename from packages/excalidraw/tests/linearElementEditor.test.tsx rename to packages/element/tests/linearElementEditor.test.tsx index dad797334..77b99fa7f 100644 --- a/packages/excalidraw/tests/linearElementEditor.test.tsx +++ b/packages/element/tests/linearElementEditor.test.tsx @@ -1,5 +1,3 @@ -import { newArrowElement } from "@excalidraw/element/newElement"; - import { pointCenter, pointFrom } from "@excalidraw/math"; import { act, queryByTestId, queryByText } from "@testing-library/react"; import React from "react"; @@ -13,36 +11,34 @@ import { arrayToMap, } from "@excalidraw/common"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; -import { - getBoundTextElementPosition, - getBoundTextMaxWidth, -} from "@excalidraw/element/textElement"; -import * as textElementUtils from "@excalidraw/element/textElement"; -import { wrapText } from "@excalidraw/element/textWrapping"; +import { Excalidraw } from "@excalidraw/excalidraw"; +import * as InteractiveCanvas from "@excalidraw/excalidraw/renderer/interactiveScene"; +import * as StaticScene from "@excalidraw/excalidraw/renderer/staticScene"; +import { API } from "@excalidraw/excalidraw/tests/helpers/api"; -import type { GlobalPoint, LocalPoint } from "@excalidraw/math"; - -import type { - ExcalidrawElement, - ExcalidrawLinearElement, - ExcalidrawTextElementWithContainer, - FontString, -} from "@excalidraw/element/types"; - -import { Excalidraw } from "../index"; -import * as InteractiveCanvas from "../renderer/interactiveScene"; -import * as StaticScene from "../renderer/staticScene"; -import { API } from "../tests/helpers/api"; - -import { Keyboard, Pointer, UI } from "./helpers/ui"; +import { Keyboard, Pointer, UI } from "@excalidraw/excalidraw/tests/helpers/ui"; import { screen, render, fireEvent, GlobalTestState, unmountComponent, -} from "./test-utils"; +} from "@excalidraw/excalidraw/tests/test-utils"; + +import type { GlobalPoint, LocalPoint } from "@excalidraw/math"; + +import { wrapText } from "../src"; +import * as textElementUtils from "../src/textElement"; +import { getBoundTextElementPosition, getBoundTextMaxWidth } from "../src"; +import { LinearElementEditor } from "../src"; +import { newArrowElement } from "../src"; + +import type { + ExcalidrawElement, + ExcalidrawLinearElement, + ExcalidrawTextElementWithContainer, + FontString, +} from "../src/types"; const renderInteractiveScene = vi.spyOn( InteractiveCanvas, diff --git a/packages/element/tests/sortElements.test.ts b/packages/element/tests/sortElements.test.ts index 1735a6bec..0928b84f2 100644 --- a/packages/element/tests/sortElements.test.ts +++ b/packages/element/tests/sortElements.test.ts @@ -1,6 +1,6 @@ import { API } from "@excalidraw/excalidraw/tests/helpers/api"; -import { mutateElement } from "@excalidraw/element/mutateElement"; +import { mutateElement } from "@excalidraw/element"; import { normalizeElementOrder } from "../src/sortElements"; diff --git a/packages/excalidraw/actions/actionAddToLibrary.ts b/packages/excalidraw/actions/actionAddToLibrary.ts index cb45f64d6..83ac8d2af 100644 --- a/packages/excalidraw/actions/actionAddToLibrary.ts +++ b/packages/excalidraw/actions/actionAddToLibrary.ts @@ -1,7 +1,7 @@ import { LIBRARY_DISABLED_TYPES, randomId } from "@excalidraw/common"; -import { deepCopyElement } from "@excalidraw/element/duplicate"; +import { deepCopyElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { t } from "../i18n"; diff --git a/packages/excalidraw/actions/actionAlign.tsx b/packages/excalidraw/actions/actionAlign.tsx index 918bdd8f4..de5cd2c1e 100644 --- a/packages/excalidraw/actions/actionAlign.tsx +++ b/packages/excalidraw/actions/actionAlign.tsx @@ -1,18 +1,18 @@ import { getNonDeletedElements } from "@excalidraw/element"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; +import { isFrameLikeElement } from "@excalidraw/element"; -import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element/frame"; +import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element"; import { KEYS, arrayToMap, getShortcutKey } from "@excalidraw/common"; -import { alignElements } from "@excalidraw/element/align"; +import { alignElements } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; -import type { Alignment } from "@excalidraw/element/align"; +import type { Alignment } from "@excalidraw/element"; import { ToolButton } from "../components/ToolButton"; import { diff --git a/packages/excalidraw/actions/actionBoundText.tsx b/packages/excalidraw/actions/actionBoundText.tsx index c740d6e90..606770dde 100644 --- a/packages/excalidraw/actions/actionBoundText.tsx +++ b/packages/excalidraw/actions/actionBoundText.tsx @@ -10,14 +10,14 @@ import { getOriginalContainerHeightFromCache, resetOriginalContainerCache, updateOriginalContainerCache, -} from "@excalidraw/element/containerCache"; +} from "@excalidraw/element"; import { computeBoundTextPosition, computeContainerDimensionForBoundText, getBoundTextElement, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; import { hasBoundTextElement, @@ -25,15 +25,15 @@ import { isTextBindableContainer, isTextElement, isUsingAdaptiveRadius, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { measureText } from "@excalidraw/element/textMeasurements"; +import { measureText } from "@excalidraw/element"; -import { syncMovedIndices } from "@excalidraw/element/fractionalIndex"; +import { syncMovedIndices } from "@excalidraw/element"; -import { newElement } from "@excalidraw/element/newElement"; +import { newElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/actions/actionCanvas.tsx b/packages/excalidraw/actions/actionCanvas.tsx index 7d6bb6aad..80a9eedaa 100644 --- a/packages/excalidraw/actions/actionCanvas.tsx +++ b/packages/excalidraw/actions/actionCanvas.tsx @@ -14,10 +14,10 @@ import { } from "@excalidraw/common"; import { getNonDeletedElements } from "@excalidraw/element"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { getCommonBounds, type SceneBounds } from "@excalidraw/element/bounds"; +import { newElementWith } from "@excalidraw/element"; +import { getCommonBounds, type SceneBounds } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionClipboard.tsx b/packages/excalidraw/actions/actionClipboard.tsx index 2494595a8..d9b011d2b 100644 --- a/packages/excalidraw/actions/actionClipboard.tsx +++ b/packages/excalidraw/actions/actionClipboard.tsx @@ -1,9 +1,9 @@ -import { isTextElement } from "@excalidraw/element/typeChecks"; -import { getTextFromElements } from "@excalidraw/element/textElement"; +import { isTextElement } from "@excalidraw/element"; +import { getTextFromElements } from "@excalidraw/element"; import { CODES, KEYS, isFirefox } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { copyTextToSystemClipboard, diff --git a/packages/excalidraw/actions/actionCropEditor.tsx b/packages/excalidraw/actions/actionCropEditor.tsx index b6e801785..d143bba19 100644 --- a/packages/excalidraw/actions/actionCropEditor.tsx +++ b/packages/excalidraw/actions/actionCropEditor.tsx @@ -1,6 +1,6 @@ -import { isImageElement } from "@excalidraw/element/typeChecks"; +import { isImageElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawImageElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionDeleteSelected.tsx b/packages/excalidraw/actions/actionDeleteSelected.tsx index d2d49ca23..20d7d129f 100644 --- a/packages/excalidraw/actions/actionDeleteSelected.tsx +++ b/packages/excalidraw/actions/actionDeleteSelected.tsx @@ -1,23 +1,23 @@ import { KEYS, updateActiveTool } from "@excalidraw/common"; import { getNonDeletedElements } from "@excalidraw/element"; -import { fixBindingsAfterDeletion } from "@excalidraw/element/binding"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { getContainerElement } from "@excalidraw/element/textElement"; +import { fixBindingsAfterDeletion } from "@excalidraw/element"; +import { LinearElementEditor } from "@excalidraw/element"; +import { newElementWith } from "@excalidraw/element"; +import { getContainerElement } from "@excalidraw/element"; import { isBoundToContainer, isElbowArrow, isFrameLikeElement, -} from "@excalidraw/element/typeChecks"; -import { getFrameChildren } from "@excalidraw/element/frame"; +} from "@excalidraw/element"; +import { getFrameChildren } from "@excalidraw/element"; import { getElementsInGroup, selectGroupsForSelectedElements, -} from "@excalidraw/element/groups"; +} from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionDistribute.tsx b/packages/excalidraw/actions/actionDistribute.tsx index ab964d3b3..bd823ec01 100644 --- a/packages/excalidraw/actions/actionDistribute.tsx +++ b/packages/excalidraw/actions/actionDistribute.tsx @@ -1,18 +1,18 @@ import { getNonDeletedElements } from "@excalidraw/element"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; +import { isFrameLikeElement } from "@excalidraw/element"; import { CODES, KEYS, arrayToMap, getShortcutKey } from "@excalidraw/common"; -import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element/frame"; +import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element"; -import { distributeElements } from "@excalidraw/element/distribute"; +import { distributeElements } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; -import type { Distribution } from "@excalidraw/element/distribute"; +import type { Distribution } from "@excalidraw/element"; import { ToolButton } from "../components/ToolButton"; import { diff --git a/packages/excalidraw/actions/actionDuplicateSelection.tsx b/packages/excalidraw/actions/actionDuplicateSelection.tsx index 882f8716a..b6363a730 100644 --- a/packages/excalidraw/actions/actionDuplicateSelection.tsx +++ b/packages/excalidraw/actions/actionDuplicateSelection.tsx @@ -7,18 +7,18 @@ import { import { getNonDeletedElements } from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { LinearElementEditor } from "@excalidraw/element"; import { getSelectedElements, getSelectionStateForElements, -} from "@excalidraw/element/selection"; +} from "@excalidraw/element"; -import { syncMovedIndices } from "@excalidraw/element/fractionalIndex"; +import { syncMovedIndices } from "@excalidraw/element"; -import { duplicateElements } from "@excalidraw/element/duplicate"; +import { duplicateElements } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { ToolButton } from "../components/ToolButton"; import { DuplicateIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionElementLink.ts b/packages/excalidraw/actions/actionElementLink.ts index ad8d01687..204ce94bd 100644 --- a/packages/excalidraw/actions/actionElementLink.ts +++ b/packages/excalidraw/actions/actionElementLink.ts @@ -2,9 +2,9 @@ import { canCreateLinkFromElements, defaultGetElementLinkFromSelection, getLinkIdAndTypeFromSelection, -} from "@excalidraw/element/elementLink"; +} from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { copyTextToSystemClipboard } from "../clipboard"; import { copyIcon, elementLinkIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionElementLock.ts b/packages/excalidraw/actions/actionElementLock.ts index 0e97f1955..7d3daaaec 100644 --- a/packages/excalidraw/actions/actionElementLock.ts +++ b/packages/excalidraw/actions/actionElementLock.ts @@ -1,10 +1,10 @@ import { KEYS, arrayToMap } from "@excalidraw/common"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; +import { isFrameLikeElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionEmbeddable.ts b/packages/excalidraw/actions/actionEmbeddable.ts index 987b2b45a..ff3828845 100644 --- a/packages/excalidraw/actions/actionEmbeddable.ts +++ b/packages/excalidraw/actions/actionEmbeddable.ts @@ -1,6 +1,6 @@ import { updateActiveTool } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { setCursorForShape } from "../cursor"; diff --git a/packages/excalidraw/actions/actionExport.tsx b/packages/excalidraw/actions/actionExport.tsx index f8a9dca82..908e2463e 100644 --- a/packages/excalidraw/actions/actionExport.tsx +++ b/packages/excalidraw/actions/actionExport.tsx @@ -7,7 +7,7 @@ import { import { getNonDeletedElements } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { Theme } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionFinalize.tsx b/packages/excalidraw/actions/actionFinalize.tsx index 6689e166a..7de9c3ce8 100644 --- a/packages/excalidraw/actions/actionFinalize.tsx +++ b/packages/excalidraw/actions/actionFinalize.tsx @@ -3,22 +3,22 @@ import { pointFrom } from "@excalidraw/math"; import { maybeBindLinearElement, bindOrUnbindLinearElement, -} from "@excalidraw/element/binding"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +} from "@excalidraw/element"; +import { LinearElementEditor } from "@excalidraw/element"; import { isBindingElement, isFreeDrawElement, isLinearElement, isLineElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { KEYS, arrayToMap, updateActiveTool } from "@excalidraw/common"; -import { isPathALoop } from "@excalidraw/element/shapes"; +import { isPathALoop } from "@excalidraw/element"; -import { isInvisiblySmallElement } from "@excalidraw/element/sizeHelpers"; +import { isInvisiblySmallElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { LocalPoint } from "@excalidraw/math"; diff --git a/packages/excalidraw/actions/actionFlip.ts b/packages/excalidraw/actions/actionFlip.ts index f6c4f0c71..6456fca8d 100644 --- a/packages/excalidraw/actions/actionFlip.ts +++ b/packages/excalidraw/actions/actionFlip.ts @@ -2,20 +2,20 @@ import { getNonDeletedElements } from "@excalidraw/element"; import { bindOrUnbindLinearElements, isBindingEnabled, -} from "@excalidraw/element/binding"; -import { getCommonBoundingBox } from "@excalidraw/element/bounds"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { deepCopyElement } from "@excalidraw/element/duplicate"; -import { resizeMultipleElements } from "@excalidraw/element/resizeElements"; +} from "@excalidraw/element"; +import { getCommonBoundingBox } from "@excalidraw/element"; +import { newElementWith } from "@excalidraw/element"; +import { deepCopyElement } from "@excalidraw/element"; +import { resizeMultipleElements } from "@excalidraw/element"; import { isArrowElement, isElbowArrow, isLinearElement, -} from "@excalidraw/element/typeChecks"; -import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element/frame"; +} from "@excalidraw/element"; +import { updateFrameMembershipOfSelectedElements } from "@excalidraw/element"; import { CODES, KEYS, arrayToMap } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawArrowElement, diff --git a/packages/excalidraw/actions/actionFrame.ts b/packages/excalidraw/actions/actionFrame.ts index f5e91fd93..3a1b3635d 100644 --- a/packages/excalidraw/actions/actionFrame.ts +++ b/packages/excalidraw/actions/actionFrame.ts @@ -1,20 +1,20 @@ import { getNonDeletedElements } from "@excalidraw/element"; -import { mutateElement } from "@excalidraw/element/mutateElement"; -import { newFrameElement } from "@excalidraw/element/newElement"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; +import { mutateElement } from "@excalidraw/element"; +import { newFrameElement } from "@excalidraw/element"; +import { isFrameLikeElement } from "@excalidraw/element"; import { addElementsToFrame, removeAllElementsFromFrame, -} from "@excalidraw/element/frame"; -import { getFrameChildren } from "@excalidraw/element/frame"; +} from "@excalidraw/element"; +import { getFrameChildren } from "@excalidraw/element"; import { KEYS, updateActiveTool } from "@excalidraw/common"; -import { getElementsInGroup } from "@excalidraw/element/groups"; +import { getElementsInGroup } from "@excalidraw/element"; -import { getCommonBounds } from "@excalidraw/element/bounds"; +import { getCommonBounds } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionGroup.tsx b/packages/excalidraw/actions/actionGroup.tsx index de3f6b266..dc0c22efd 100644 --- a/packages/excalidraw/actions/actionGroup.tsx +++ b/packages/excalidraw/actions/actionGroup.tsx @@ -1,8 +1,8 @@ import { getNonDeletedElements } from "@excalidraw/element"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; -import { isBoundToContainer } from "@excalidraw/element/typeChecks"; +import { isBoundToContainer } from "@excalidraw/element"; import { frameAndChildrenSelectedTogether, @@ -12,7 +12,7 @@ import { groupByFrameLikes, removeElementsFromFrame, replaceAllElementsInFrame, -} from "@excalidraw/element/frame"; +} from "@excalidraw/element"; import { KEYS, randomId, arrayToMap, getShortcutKey } from "@excalidraw/common"; @@ -24,11 +24,11 @@ import { addToGroup, removeFromSelectedGroups, isElementInGroup, -} from "@excalidraw/element/groups"; +} from "@excalidraw/element"; -import { syncMovedIndices } from "@excalidraw/element/fractionalIndex"; +import { syncMovedIndices } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/actions/actionHistory.tsx b/packages/excalidraw/actions/actionHistory.tsx index 6477f795f..b948fe7d4 100644 --- a/packages/excalidraw/actions/actionHistory.tsx +++ b/packages/excalidraw/actions/actionHistory.tsx @@ -1,8 +1,8 @@ import { isWindows, KEYS, matchKey, arrayToMap } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; -import { orderByFractionalIndex } from "@excalidraw/element/fractionalIndex"; +import { orderByFractionalIndex } from "@excalidraw/element"; import type { SceneElementsMap } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionLinearEditor.tsx b/packages/excalidraw/actions/actionLinearEditor.tsx index c21a51a6c..1c9e460bc 100644 --- a/packages/excalidraw/actions/actionLinearEditor.tsx +++ b/packages/excalidraw/actions/actionLinearEditor.tsx @@ -1,12 +1,12 @@ -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { LinearElementEditor } from "@excalidraw/element"; import { isElbowArrow, isLinearElement, isLineElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { arrayToMap } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawLinearElement, diff --git a/packages/excalidraw/actions/actionLink.tsx b/packages/excalidraw/actions/actionLink.tsx index d7a5ca7d2..abb78f7f5 100644 --- a/packages/excalidraw/actions/actionLink.tsx +++ b/packages/excalidraw/actions/actionLink.tsx @@ -1,8 +1,8 @@ -import { isEmbeddableElement } from "@excalidraw/element/typeChecks"; +import { isEmbeddableElement } from "@excalidraw/element"; import { KEYS, getShortcutKey } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { ToolButton } from "../components/ToolButton"; import { getContextMenuLabel } from "../components/hyperlink/Hyperlink"; diff --git a/packages/excalidraw/actions/actionMenu.tsx b/packages/excalidraw/actions/actionMenu.tsx index 8cdc489b4..2c6a77445 100644 --- a/packages/excalidraw/actions/actionMenu.tsx +++ b/packages/excalidraw/actions/actionMenu.tsx @@ -2,9 +2,9 @@ import { KEYS } from "@excalidraw/common"; import { getNonDeletedElements } from "@excalidraw/element"; -import { showSelectedShapeActions } from "@excalidraw/element/showSelectedShapeActions"; +import { showSelectedShapeActions } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { ToolButton } from "../components/ToolButton"; import { HamburgerMenuIcon, HelpIconThin, palette } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionNavigate.tsx b/packages/excalidraw/actions/actionNavigate.tsx index 637df0450..27f0d6024 100644 --- a/packages/excalidraw/actions/actionNavigate.tsx +++ b/packages/excalidraw/actions/actionNavigate.tsx @@ -1,6 +1,6 @@ import clsx from "clsx"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { getClientColor } from "../clients"; import { Avatar } from "../components/Avatar"; diff --git a/packages/excalidraw/actions/actionProperties.tsx b/packages/excalidraw/actions/actionProperties.tsx index ed079ff6d..ded81b500 100644 --- a/packages/excalidraw/actions/actionProperties.tsx +++ b/packages/excalidraw/actions/actionProperties.tsx @@ -31,16 +31,16 @@ import { calculateFixedPointForElbowArrowBinding, getHoveredElementForBinding, updateBoundElements, -} from "@excalidraw/element/binding"; +} from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { LinearElementEditor } from "@excalidraw/element"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; import { getBoundTextElement, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; import { isArrowElement, @@ -50,13 +50,13 @@ import { isLineElement, isTextElement, isUsingAdaptiveRadius, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { hasStrokeColor } from "@excalidraw/element/comparisons"; +import { hasStrokeColor } from "@excalidraw/element"; -import { updateElbowArrowPoints } from "@excalidraw/element/elbowArrow"; +import { updateElbowArrowPoints } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { LocalPoint } from "@excalidraw/math"; @@ -72,9 +72,9 @@ import type { VerticalAlign, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; -import type { CaptureUpdateActionType } from "@excalidraw/element/store"; +import type { CaptureUpdateActionType } from "@excalidraw/element"; import { trackEvent } from "../analytics"; import { ButtonIconSelect } from "../components/ButtonIconSelect"; diff --git a/packages/excalidraw/actions/actionSelectAll.ts b/packages/excalidraw/actions/actionSelectAll.ts index 9386bc9a1..a58052858 100644 --- a/packages/excalidraw/actions/actionSelectAll.ts +++ b/packages/excalidraw/actions/actionSelectAll.ts @@ -1,12 +1,12 @@ import { getNonDeletedElements } from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; -import { isLinearElement, isTextElement } from "@excalidraw/element/typeChecks"; +import { LinearElementEditor } from "@excalidraw/element"; +import { isLinearElement, isTextElement } from "@excalidraw/element"; import { arrayToMap, KEYS } from "@excalidraw/common"; -import { selectGroupsForSelectedElements } from "@excalidraw/element/groups"; +import { selectGroupsForSelectedElements } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionStyles.ts b/packages/excalidraw/actions/actionStyles.ts index f80a56990..aa8bf41fc 100644 --- a/packages/excalidraw/actions/actionStyles.ts +++ b/packages/excalidraw/actions/actionStyles.ts @@ -7,7 +7,7 @@ import { getLineHeight, } from "@excalidraw/common"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; import { hasBoundTextElement, @@ -17,14 +17,14 @@ import { isArrowElement, isExcalidrawElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { getBoundTextElement, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawTextElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionTextAutoResize.ts b/packages/excalidraw/actions/actionTextAutoResize.ts index 15af36658..d4338e779 100644 --- a/packages/excalidraw/actions/actionTextAutoResize.ts +++ b/packages/excalidraw/actions/actionTextAutoResize.ts @@ -1,11 +1,11 @@ import { getFontString } from "@excalidraw/common"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import { measureText } from "@excalidraw/element/textMeasurements"; +import { newElementWith } from "@excalidraw/element"; +import { measureText } from "@excalidraw/element"; -import { isTextElement } from "@excalidraw/element/typeChecks"; +import { isTextElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { getSelectedElements } from "../scene"; diff --git a/packages/excalidraw/actions/actionToggleGridMode.tsx b/packages/excalidraw/actions/actionToggleGridMode.tsx index 543485d8a..1fcc882fd 100644 --- a/packages/excalidraw/actions/actionToggleGridMode.tsx +++ b/packages/excalidraw/actions/actionToggleGridMode.tsx @@ -1,6 +1,6 @@ import { CODES, KEYS } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { gridIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionToggleObjectsSnapMode.tsx b/packages/excalidraw/actions/actionToggleObjectsSnapMode.tsx index 1eef483aa..ec87769c3 100644 --- a/packages/excalidraw/actions/actionToggleObjectsSnapMode.tsx +++ b/packages/excalidraw/actions/actionToggleObjectsSnapMode.tsx @@ -1,6 +1,6 @@ import { CODES, KEYS } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { magnetIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionToggleSearchMenu.ts b/packages/excalidraw/actions/actionToggleSearchMenu.ts index b7821bce4..bd2b0d68b 100644 --- a/packages/excalidraw/actions/actionToggleSearchMenu.ts +++ b/packages/excalidraw/actions/actionToggleSearchMenu.ts @@ -5,7 +5,7 @@ import { DEFAULT_SIDEBAR, } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { searchIcon } from "../components/icons"; @@ -34,13 +34,6 @@ export const actionToggleSearchMenu = register({ `.${CLASSES.SEARCH_MENU_INPUT_WRAPPER} input`, ); - if (searchInput?.matches(":focus")) { - return { - appState: { ...appState, openSidebar: null }, - captureUpdate: CaptureUpdateAction.EVENTUALLY, - }; - } - searchInput?.focus(); searchInput?.select(); return false; diff --git a/packages/excalidraw/actions/actionToggleShapeSwitch.tsx b/packages/excalidraw/actions/actionToggleShapeSwitch.tsx index aea8f986e..84ad0b352 100644 --- a/packages/excalidraw/actions/actionToggleShapeSwitch.tsx +++ b/packages/excalidraw/actions/actionToggleShapeSwitch.tsx @@ -1,4 +1,4 @@ -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/actions/actionToggleStats.tsx b/packages/excalidraw/actions/actionToggleStats.tsx index d044c01fb..eb3cd0406 100644 --- a/packages/excalidraw/actions/actionToggleStats.tsx +++ b/packages/excalidraw/actions/actionToggleStats.tsx @@ -1,6 +1,6 @@ import { CODES, KEYS } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { abacusIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionToggleViewMode.tsx b/packages/excalidraw/actions/actionToggleViewMode.tsx index f511ec619..c635f2869 100644 --- a/packages/excalidraw/actions/actionToggleViewMode.tsx +++ b/packages/excalidraw/actions/actionToggleViewMode.tsx @@ -1,6 +1,6 @@ import { CODES, KEYS } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { eyeIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionToggleZenMode.tsx b/packages/excalidraw/actions/actionToggleZenMode.tsx index a9dc8dd1f..98175b384 100644 --- a/packages/excalidraw/actions/actionToggleZenMode.tsx +++ b/packages/excalidraw/actions/actionToggleZenMode.tsx @@ -1,6 +1,6 @@ import { CODES, KEYS } from "@excalidraw/common"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { coffeeIcon } from "../components/icons"; diff --git a/packages/excalidraw/actions/actionZindex.tsx b/packages/excalidraw/actions/actionZindex.tsx index 753e42321..62a6aa411 100644 --- a/packages/excalidraw/actions/actionZindex.tsx +++ b/packages/excalidraw/actions/actionZindex.tsx @@ -5,9 +5,9 @@ import { moveOneRight, moveAllLeft, moveAllRight, -} from "@excalidraw/element/zindex"; +} from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import { BringForwardIcon, diff --git a/packages/excalidraw/actions/types.ts b/packages/excalidraw/actions/types.ts index 3051b62f6..e6f363126 100644 --- a/packages/excalidraw/actions/types.ts +++ b/packages/excalidraw/actions/types.ts @@ -3,7 +3,7 @@ import type { OrderedExcalidrawElement, } from "@excalidraw/element/types"; -import type { CaptureUpdateActionType } from "@excalidraw/element/store"; +import type { CaptureUpdateActionType } from "@excalidraw/element"; import type { AppClassProperties, diff --git a/packages/excalidraw/appState.ts b/packages/excalidraw/appState.ts index a75745f2a..2e4ae8348 100644 --- a/packages/excalidraw/appState.ts +++ b/packages/excalidraw/appState.ts @@ -121,7 +121,7 @@ export const getDefaultAppState = (): Omit< followedBy: new Set(), isCropping: false, croppingElementId: null, - searchMatches: [], + searchMatches: null, }; }; diff --git a/packages/excalidraw/charts.ts b/packages/excalidraw/charts.ts index 7a221d547..97ca08155 100644 --- a/packages/excalidraw/charts.ts +++ b/packages/excalidraw/charts.ts @@ -15,7 +15,7 @@ import { newTextElement, newLinearElement, newElement, -} from "@excalidraw/element/newElement"; +} from "@excalidraw/element"; import type { Radians } from "@excalidraw/math"; diff --git a/packages/excalidraw/clipboard.ts b/packages/excalidraw/clipboard.ts index c9ee92cac..99b7d41f4 100644 --- a/packages/excalidraw/clipboard.ts +++ b/packages/excalidraw/clipboard.ts @@ -7,14 +7,14 @@ import { isPromiseLike, } from "@excalidraw/common"; -import { mutateElement } from "@excalidraw/element/mutateElement"; -import { deepCopyElement } from "@excalidraw/element/duplicate"; +import { mutateElement } from "@excalidraw/element"; +import { deepCopyElement } from "@excalidraw/element"; import { isFrameLikeElement, isInitializedImageElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { getContainingFrame } from "@excalidraw/element/frame"; +import { getContainingFrame } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/components/Actions.tsx b/packages/excalidraw/components/Actions.tsx index 3a7df37a8..4f3782048 100644 --- a/packages/excalidraw/components/Actions.tsx +++ b/packages/excalidraw/components/Actions.tsx @@ -11,7 +11,7 @@ import { import { shouldAllowVerticalAlign, suppportsHorizontalAlign, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; import { hasBoundTextElement, @@ -19,9 +19,9 @@ import { isImageElement, isLinearElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { hasStrokeColor, toolIsArrow } from "@excalidraw/element/comparisons"; +import { hasStrokeColor, toolIsArrow } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index d94d39e77..29de62cf4 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -104,10 +104,7 @@ import { Emitter, } from "@excalidraw/common"; -import { - getCommonBounds, - getElementAbsoluteCoords, -} from "@excalidraw/element/bounds"; +import { getCommonBounds, getElementAbsoluteCoords } from "@excalidraw/element"; import { bindOrUnbindLinearElement, @@ -120,11 +117,11 @@ import { shouldEnableBindingForPointerEvent, updateBoundElements, getSuggestedBindingsForArrows, -} from "@excalidraw/element/binding"; +} from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { LinearElementEditor } from "@excalidraw/element"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; import { newFrameElement, @@ -138,12 +135,9 @@ import { newLinearElement, newTextElement, refreshTextDimensions, -} from "@excalidraw/element/newElement"; +} from "@excalidraw/element"; -import { - deepCopyElement, - duplicateElements, -} from "@excalidraw/element/duplicate"; +import { deepCopyElement, duplicateElements } from "@excalidraw/element"; import { hasBoundTextElement, @@ -166,7 +160,7 @@ import { isFlowchartNodeElement, isBindableElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { getLockedLinearCursorAlignSize, @@ -174,28 +168,28 @@ import { isElementCompletelyInViewport, isElementInViewport, isInvisiblySmallElement, -} from "@excalidraw/element/sizeHelpers"; +} from "@excalidraw/element"; import { getBoundTextShape, getCornerRadius, getElementShape, isPathALoop, -} from "@excalidraw/element/shapes"; +} from "@excalidraw/element"; import { createSrcDoc, embeddableURLValidator, maybeParseEmbedSrc, getEmbedLink, -} from "@excalidraw/element/embeddable"; +} from "@excalidraw/element"; import { getInitializedImageElements, loadHTMLImageElement, normalizeSVG, updateImageCache as _updateImageCache, -} from "@excalidraw/element/image"; +} from "@excalidraw/element"; import { getBoundTextElement, @@ -203,9 +197,9 @@ import { getContainerElement, isValidTextContainer, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; -import { shouldShowBoundingBox } from "@excalidraw/element/transformHandles"; +import { shouldShowBoundingBox } from "@excalidraw/element"; import { getFrameChildren, @@ -222,30 +216,27 @@ import { getFrameLikeTitle, getElementsOverlappingFrame, filterElementsEligibleAsFrameChildren, -} from "@excalidraw/element/frame"; +} from "@excalidraw/element"; import { hitElementBoundText, hitElementBoundingBoxOnly, hitElementItself, -} from "@excalidraw/element/collision"; +} from "@excalidraw/element"; -import { getVisibleSceneBounds } from "@excalidraw/element/bounds"; +import { getVisibleSceneBounds } from "@excalidraw/element"; import { FlowChartCreator, FlowChartNavigator, getLinkDirectionFromKey, -} from "@excalidraw/element/flowchart"; +} from "@excalidraw/element"; -import { cropElement } from "@excalidraw/element/cropElement"; +import { cropElement } from "@excalidraw/element"; -import { wrapText } from "@excalidraw/element/textWrapping"; +import { wrapText } from "@excalidraw/element"; -import { - isElementLink, - parseElementLinkFromURL, -} from "@excalidraw/element/elementLink"; +import { isElementLink, parseElementLinkFromURL } from "@excalidraw/element"; import { isMeasureTextSupported, @@ -255,11 +246,11 @@ import { getApproxMinLineWidth, getApproxMinLineHeight, getMinTextElementWidth, -} from "@excalidraw/element/textMeasurements"; +} from "@excalidraw/element"; -import { ShapeCache } from "@excalidraw/element/ShapeCache"; +import { ShapeCache } from "@excalidraw/element"; -import { getRenderOpacity } from "@excalidraw/element/renderElement"; +import { getRenderOpacity } from "@excalidraw/element"; import { editGroupForSelectedElement, @@ -269,44 +260,41 @@ import { isElementInGroup, isSelectedViaGroup, selectGroupsForSelectedElements, -} from "@excalidraw/element/groups"; +} from "@excalidraw/element"; -import { - syncInvalidIndices, - syncMovedIndices, -} from "@excalidraw/element/fractionalIndex"; +import { syncInvalidIndices, syncMovedIndices } from "@excalidraw/element"; import { excludeElementsInFramesFromSelection, getSelectionStateForElements, makeNextSelectedElementIds, -} from "@excalidraw/element/selection"; +} from "@excalidraw/element"; import { getResizeOffsetXY, getResizeArrowDirection, transformElements, -} from "@excalidraw/element/resizeElements"; +} from "@excalidraw/element"; import { getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, -} from "@excalidraw/element/resizeTest"; +} from "@excalidraw/element"; import { dragNewElement, dragSelectedElements, getDragOffsetXY, -} from "@excalidraw/element/dragElements"; +} from "@excalidraw/element"; import { isNonDeletedElement } from "@excalidraw/element"; -import Scene from "@excalidraw/element/Scene"; +import { Scene } from "@excalidraw/element"; -import { Store, CaptureUpdateAction } from "@excalidraw/element/store"; +import { Store, CaptureUpdateAction } from "@excalidraw/element"; -import type { ElementUpdate } from "@excalidraw/element/mutateElement"; +import type { ElementUpdate } from "@excalidraw/element"; import type { LocalPoint, Radians } from "@excalidraw/math"; @@ -1417,8 +1405,19 @@ class App extends React.Component { } const isDarkTheme = this.state.theme === THEME.DARK; + const nonDeletedFramesLikes = this.scene.getNonDeletedFramesLikes(); - return this.scene.getNonDeletedFramesLikes().map((f) => { + const focusedSearchMatch = + nonDeletedFramesLikes.length > 0 + ? this.state.searchMatches?.focusedId && + isFrameLikeElement( + this.scene.getElement(this.state.searchMatches.focusedId), + ) + ? this.state.searchMatches.matches.find((sm) => sm.focus) + : null + : null; + + return nonDeletedFramesLikes.map((f) => { if ( !isElementInViewport( f, @@ -1484,7 +1483,7 @@ class App extends React.Component { borderRadius: 4, boxShadow: "inset 0 0 0 1px var(--color-primary)", fontFamily: "Assistant", - fontSize: "14px", + fontSize: `${FRAME_STYLE.nameFontSize}px`, transform: `translate(-${FRAME_NAME_EDIT_PADDING}px, ${FRAME_NAME_EDIT_PADDING}px)`, color: "var(--color-gray-80)", overflow: "hidden", @@ -1528,7 +1527,10 @@ class App extends React.Component { : FRAME_STYLE.nameColorLightTheme, lineHeight: FRAME_STYLE.nameLineHeight, width: "max-content", - maxWidth: `${f.width}px`, + maxWidth: + focusedSearchMatch?.id === f.id && focusedSearchMatch?.focus + ? "none" + : `${f.width * this.state.zoom.value}px`, overflow: f.id === this.state.editingFrame ? "visible" : "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", @@ -6405,12 +6407,17 @@ class App extends React.Component { this.maybeUnfollowRemoteUser(); if (this.state.searchMatches) { - this.setState((state) => ({ - searchMatches: state.searchMatches.map((searchMatch) => ({ - ...searchMatch, - focus: false, - })), - })); + this.setState((state) => { + return { + searchMatches: state.searchMatches && { + focusedId: null, + matches: state.searchMatches.matches.map((searchMatch) => ({ + ...searchMatch, + focus: false, + })), + }, + }; + }); this.updateEditorAtom(searchItemInFocusAtom, null); } diff --git a/packages/excalidraw/components/ConvertElementTypePopup.tsx b/packages/excalidraw/components/ConvertElementTypePopup.tsx index 9ff171988..d64475d64 100644 --- a/packages/excalidraw/components/ConvertElementTypePopup.tsx +++ b/packages/excalidraw/components/ConvertElementTypePopup.tsx @@ -1,6 +1,6 @@ import { type ReactNode, useEffect, useMemo, useRef, useState } from "react"; -import { updateElbowArrowPoints } from "@excalidraw/element/elbowArrow"; +import { updateElbowArrowPoints } from "@excalidraw/element"; import { pointFrom, pointRotateRads, type LocalPoint } from "@excalidraw/math"; @@ -13,21 +13,21 @@ import { isLinearElement, isSharpArrow, isUsingAdaptiveRadius, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { getCommonBoundingBox, getElementAbsoluteCoords, -} from "@excalidraw/element/bounds"; +} from "@excalidraw/element"; import { getBoundTextElement, getBoundTextMaxHeight, getBoundTextMaxWidth, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; -import { wrapText } from "@excalidraw/element/textWrapping"; +import { wrapText } from "@excalidraw/element"; import { assertNever, @@ -37,17 +37,19 @@ import { updateActiveTool, } from "@excalidraw/common"; -import { measureText } from "@excalidraw/element/textMeasurements"; +import { measureText } from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { LinearElementEditor } from "@excalidraw/element"; import { newArrowElement, newElement, newLinearElement, -} from "@excalidraw/element/newElement"; +} from "@excalidraw/element"; -import { ShapeCache } from "@excalidraw/element/ShapeCache"; +import { ShapeCache } from "@excalidraw/element"; + +import { updateBindings } from "@excalidraw/element"; import type { ConvertibleGenericTypes, @@ -66,7 +68,7 @@ import type { FixedSegment, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { bumpVersion, @@ -76,7 +78,6 @@ import { } from ".."; import { trackEvent } from "../analytics"; import { atom, editorJotaiStore, useSetAtom } from "../editor-jotai"; -import { updateBindings } from "../../element/src/binding"; import "./ConvertElementTypePopup.scss"; import { ToolButton } from "./ToolButton"; diff --git a/packages/excalidraw/components/ElementCanvasButtons.tsx b/packages/excalidraw/components/ElementCanvasButtons.tsx index 424c4f3b4..0069b327e 100644 --- a/packages/excalidraw/components/ElementCanvasButtons.tsx +++ b/packages/excalidraw/components/ElementCanvasButtons.tsx @@ -1,5 +1,5 @@ import { sceneCoordsToViewportCoords } from "@excalidraw/common"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; import type { ElementsMap, diff --git a/packages/excalidraw/components/ElementLinkDialog.tsx b/packages/excalidraw/components/ElementLinkDialog.tsx index e9766f3d7..5d4309c9e 100644 --- a/packages/excalidraw/components/ElementLinkDialog.tsx +++ b/packages/excalidraw/components/ElementLinkDialog.tsx @@ -5,11 +5,11 @@ import { normalizeLink, KEYS } from "@excalidraw/common"; import { defaultGetElementLinkFromSelection, getLinkIdAndTypeFromSelection, -} from "@excalidraw/element/elementLink"; +} from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { t } from "../i18n"; import { getSelectedElements } from "../scene"; diff --git a/packages/excalidraw/components/FontPicker/FontPickerList.tsx b/packages/excalidraw/components/FontPicker/FontPickerList.tsx index 2ec9e7d6d..6faab2917 100644 --- a/packages/excalidraw/components/FontPicker/FontPickerList.tsx +++ b/packages/excalidraw/components/FontPicker/FontPickerList.tsx @@ -99,7 +99,7 @@ export const FontPickerList = React.memo( () => Array.from(Fonts.registered.entries()) .filter( - ([_, { metadata }]) => !metadata.serverSide && !metadata.fallback, + ([_, { metadata }]) => !metadata.private && !metadata.fallback, ) .map(([familyId, { metadata, fontFaces }]) => { const fontDescriptor = { diff --git a/packages/excalidraw/components/HintViewer.tsx b/packages/excalidraw/components/HintViewer.tsx index 5072e4471..017fccf8e 100644 --- a/packages/excalidraw/components/HintViewer.tsx +++ b/packages/excalidraw/components/HintViewer.tsx @@ -6,11 +6,11 @@ import { isLinearElement, isTextBindableContainer, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { getShortcutKey } from "@excalidraw/common"; -import { isNodeInFlowchart } from "@excalidraw/element/flowchart"; +import { isNodeInFlowchart } from "@excalidraw/element"; import { t } from "../i18n"; import { isEraserActive } from "../appState"; @@ -39,7 +39,7 @@ const getHints = ({ if ( appState.openSidebar?.name === DEFAULT_SIDEBAR.name && appState.openSidebar.tab === CANVAS_SEARCH_TAB && - appState.searchMatches?.length + appState.searchMatches?.matches.length ) { return t("hints.dismissSearch"); } diff --git a/packages/excalidraw/components/LayerUI.tsx b/packages/excalidraw/components/LayerUI.tsx index b2e0d446f..d216f1d46 100644 --- a/packages/excalidraw/components/LayerUI.tsx +++ b/packages/excalidraw/components/LayerUI.tsx @@ -10,11 +10,11 @@ import { isShallowEqual, } from "@excalidraw/common"; -import { mutateElement } from "@excalidraw/element/mutateElement"; +import { mutateElement } from "@excalidraw/element"; -import { showSelectedShapeActions } from "@excalidraw/element/showSelectedShapeActions"; +import { showSelectedShapeActions } from "@excalidraw/element"; -import { ShapeCache } from "@excalidraw/element/ShapeCache"; +import { ShapeCache } from "@excalidraw/element"; import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/components/LibraryMenuItems.tsx b/packages/excalidraw/components/LibraryMenuItems.tsx index 160cc2640..8e06632aa 100644 --- a/packages/excalidraw/components/LibraryMenuItems.tsx +++ b/packages/excalidraw/components/LibraryMenuItems.tsx @@ -8,7 +8,7 @@ import React, { import { MIME_TYPES, arrayToMap } from "@excalidraw/common"; -import { duplicateElements } from "@excalidraw/element/duplicate"; +import { duplicateElements } from "@excalidraw/element"; import { serializeLibraryAsJSON } from "../data/json"; import { useLibraryCache } from "../hooks/useLibraryItemSvg"; diff --git a/packages/excalidraw/components/MobileMenu.tsx b/packages/excalidraw/components/MobileMenu.tsx index 6e75b5992..454c0f64e 100644 --- a/packages/excalidraw/components/MobileMenu.tsx +++ b/packages/excalidraw/components/MobileMenu.tsx @@ -1,6 +1,6 @@ import React from "react"; -import { showSelectedShapeActions } from "@excalidraw/element/showSelectedShapeActions"; +import { showSelectedShapeActions } from "@excalidraw/element"; import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/components/SearchMenu.scss b/packages/excalidraw/components/SearchMenu.scss index 1f47f9876..4f9e36a66 100644 --- a/packages/excalidraw/components/SearchMenu.scss +++ b/packages/excalidraw/components/SearchMenu.scss @@ -1,4 +1,5 @@ @import "open-color/open-color"; +@import "../css//variables.module.scss"; .excalidraw { .layer-ui__search { @@ -64,21 +65,51 @@ flex: 1 1 0; display: flex; flex-direction: column; + padding: 0 0.75rem; gap: 0.125rem; } + .layer-ui__search .collapsible-items { + gap: 2px; + } + + .layer-ui__search-result-title { + font-size: 0.875rem; + margin-bottom: 0.25rem; + display: flex; + align-items: center; + gap: 0.25rem; + font-weight: 700; + + .title-icon { + width: 0.875rem; + height: 0.875rem; + margin-right: 0.25rem; + svg g { + stroke-width: 1.25; + } + } + } + + .layer-ui__divider { + width: 100%; + margin-top: 0.25rem; + margin-bottom: 1rem; + position: relative; + } + .layer-ui__result-item { display: flex; align-items: center; - min-height: 2rem; + min-height: 1.875rem; flex: 0 0 auto; padding: 0.25rem 0.75rem; cursor: pointer; border: 1px solid transparent; outline: none; + font-size: 16px; - margin: 0 0.75rem; border-radius: var(--border-radius-md); .text-icon { diff --git a/packages/excalidraw/components/SearchMenu.tsx b/packages/excalidraw/components/SearchMenu.tsx index 3e0b31a69..291249851 100644 --- a/packages/excalidraw/components/SearchMenu.tsx +++ b/packages/excalidraw/components/SearchMenu.tsx @@ -1,13 +1,19 @@ import { round } from "@excalidraw/math"; import clsx from "clsx"; import debounce from "lodash.debounce"; -import { Fragment, memo, useEffect, useRef, useState } from "react"; +import { Fragment, memo, useEffect, useMemo, useRef, useState } from "react"; -import { CLASSES, EVENT } from "@excalidraw/common"; +import { + CLASSES, + EVENT, + FONT_FAMILY, + FRAME_STYLE, + getLineHeight, +} from "@excalidraw/common"; -import { isElementCompletelyInViewport } from "@excalidraw/element/sizeHelpers"; +import { isElementCompletelyInViewport } from "@excalidraw/element"; -import { measureText } from "@excalidraw/element/textMeasurements"; +import { measureText } from "@excalidraw/element"; import { KEYS, @@ -16,10 +22,15 @@ import { getFontString, } from "@excalidraw/common"; -import { newTextElement } from "@excalidraw/element/newElement"; -import { isTextElement } from "@excalidraw/element/typeChecks"; +import { newTextElement } from "@excalidraw/element"; +import { isTextElement, isFrameLikeElement } from "@excalidraw/element"; -import type { ExcalidrawTextElement } from "@excalidraw/element/types"; +import { getDefaultFrameName } from "@excalidraw/element/frame"; + +import type { + ExcalidrawFrameLikeElement, + ExcalidrawTextElement, +} from "@excalidraw/element/types"; import { atom, useAtom } from "../editor-jotai"; @@ -29,11 +40,17 @@ import { t } from "../i18n"; import { useApp, useExcalidrawSetAppState } from "./App"; import { Button } from "./Button"; import { TextField } from "./TextField"; -import { collapseDownIcon, upIcon, searchIcon } from "./icons"; +import { + collapseDownIcon, + upIcon, + searchIcon, + frameToolIcon, + TextIcon, +} from "./icons"; import "./SearchMenu.scss"; -import type { AppClassProperties } from "../types"; +import type { AppClassProperties, SearchMatch } from "../types"; const searchQueryAtom = atom(""); export const searchItemInFocusAtom = atom(null); @@ -41,7 +58,7 @@ export const searchItemInFocusAtom = atom(null); const SEARCH_DEBOUNCE = 350; type SearchMatchItem = { - textElement: ExcalidrawTextElement; + element: ExcalidrawTextElement | ExcalidrawFrameLikeElement; searchQuery: SearchQuery; index: number; preview: { @@ -50,12 +67,7 @@ type SearchMatchItem = { moreBefore: boolean; moreAfter: boolean; }; - matchedLines: { - offsetX: number; - offsetY: number; - width: number; - height: number; - }[]; + matchedLines: SearchMatch["matchedLines"]; }; type SearchMatches = { @@ -103,11 +115,16 @@ export const SearchMenu = () => { searchedQueryRef.current = searchQuery; lastSceneNonceRef.current = app.scene.getSceneNonce(); setAppState({ - searchMatches: matchItems.map((searchMatch) => ({ - id: searchMatch.textElement.id, - focus: false, - matchedLines: searchMatch.matchedLines, - })), + searchMatches: matchItems.length + ? { + focusedId: null, + matches: matchItems.map((searchMatch) => ({ + id: searchMatch.element.id, + focus: false, + matchedLines: searchMatch.matchedLines, + })), + } + : null, }); }); } @@ -149,13 +166,25 @@ export const SearchMenu = () => { useEffect(() => { setAppState((state) => { + if (!state.searchMatches) { + return null; + } + + const focusedId = + focusIndex !== null + ? state.searchMatches?.matches[focusIndex]?.id || null + : null; + return { - searchMatches: state.searchMatches.map((match, index) => { - if (index === focusIndex) { - return { ...match, focus: true }; - } - return { ...match, focus: false }; - }), + searchMatches: { + focusedId, + matches: state.searchMatches.matches.map((match, index) => { + if (index === focusIndex) { + return { ...match, focus: true }; + } + return { ...match, focus: false }; + }), + }, }; }); }, [focusIndex, setAppState]); @@ -169,17 +198,21 @@ export const SearchMenu = () => { const matchAsElement = newTextElement({ text: match.searchQuery, - x: match.textElement.x + (match.matchedLines[0]?.offsetX ?? 0), - y: match.textElement.y + (match.matchedLines[0]?.offsetY ?? 0), + x: match.element.x + (match.matchedLines[0]?.offsetX ?? 0), + y: match.element.y + (match.matchedLines[0]?.offsetY ?? 0), width: match.matchedLines[0]?.width, height: match.matchedLines[0]?.height, - fontSize: match.textElement.fontSize, - fontFamily: match.textElement.fontFamily, + fontSize: isFrameLikeElement(match.element) + ? FRAME_STYLE.nameFontSize + : match.element.fontSize, + fontFamily: isFrameLikeElement(match.element) + ? FONT_FAMILY.Assistant + : match.element.fontFamily, }); const FONT_SIZE_LEGIBILITY_THRESHOLD = 14; - const fontSize = match.textElement.fontSize; + const fontSize = matchAsElement.fontSize; const isTextTiny = fontSize * zoomValue < FONT_SIZE_LEGIBILITY_THRESHOLD; @@ -233,7 +266,7 @@ export const SearchMenu = () => { searchedQueryRef.current = null; lastSceneNonceRef.current = undefined; setAppState({ - searchMatches: [], + searchMatches: null, }); setIsSearching(false); }; @@ -272,10 +305,6 @@ export const SearchMenu = () => { } searchInputRef.current?.focus(); searchInputRef.current?.select(); - } else { - setAppState({ - openSidebar: null, - }); } } @@ -336,11 +365,16 @@ export const SearchMenu = () => { searchedQueryRef.current = searchQuery; lastSceneNonceRef.current = app.scene.getSceneNonce(); setAppState({ - searchMatches: matchItems.map((searchMatch) => ({ - id: searchMatch.textElement.id, - focus: false, - matchedLines: searchMatch.matchedLines, - })), + searchMatches: matchItems.length + ? { + focusedId: null, + matches: matchItems.map((searchMatch) => ({ + id: searchMatch.element.id, + focus: false, + matchedLines: searchMatch.matchedLines, + })), + } + : null, }); setIsSearching(false); @@ -447,17 +481,56 @@ interface MatchListProps { } const MatchListBase = (props: MatchListProps) => { + const frameNameMatches = useMemo( + () => + props.matches.items.filter((match) => isFrameLikeElement(match.element)), + [props.matches], + ); + + const textMatches = useMemo( + () => props.matches.items.filter((match) => isTextElement(match.element)), + [props.matches], + ); + return ( -
- {props.matches.items.map((searchMatch, index) => ( - props.onItemClick(index)} - /> - ))} +
+ {frameNameMatches.length > 0 && ( +
+
+
{frameToolIcon}
+
{t("search.frames")}
+
+ {frameNameMatches.map((searchMatch, index) => ( + props.onItemClick(index)} + /> + ))} + + {textMatches.length > 0 &&
} +
+ )} + + {textMatches.length > 0 && ( +
+
+
{TextIcon}
+
{t("search.texts")}
+
+ {textMatches.map((searchMatch, index) => ( + props.onItemClick(index + frameNameMatches.length)} + /> + ))} +
+ )}
); }; @@ -592,12 +665,7 @@ const getMatchedLines = ( index, index + searchQuery.length, ); - const matchedLines: { - offsetX: number; - offsetY: number; - width: number; - height: number; - }[] = []; + const matchedLines: SearchMatch["matchedLines"] = []; for (const lineIndexRange of lineIndexRanges) { if (remainingQuery === "") { @@ -657,6 +725,7 @@ const getMatchedLines = ( offsetY, width, height, + showOnCanvas: true, }); startIndex += matchCapacity; @@ -666,6 +735,47 @@ const getMatchedLines = ( return matchedLines; }; +const getMatchInFrame = ( + frame: ExcalidrawFrameLikeElement, + searchQuery: SearchQuery, + index: number, + zoomValue: number, +): SearchMatch["matchedLines"] => { + const text = frame.name ?? getDefaultFrameName(frame); + const matchedText = text.slice(index, index + searchQuery.length); + + const prefixText = text.slice(0, index); + const font = getFontString({ + fontSize: FRAME_STYLE.nameFontSize, + fontFamily: FONT_FAMILY.Assistant, + }); + + const lineHeight = getLineHeight(FONT_FAMILY.Assistant); + + const offset = measureText(prefixText, font, lineHeight); + + // Correct non-zero width for empty string + if (prefixText === "") { + offset.width = 0; + } + + const matchedMetrics = measureText(matchedText, font, lineHeight); + + const offsetX = offset.width; + const offsetY = -offset.height - FRAME_STYLE.strokeWidth; + const width = matchedMetrics.width; + + return [ + { + offsetX, + offsetY, + width, + height: matchedMetrics.height, + showOnCanvas: offsetX + width <= frame.width * zoomValue, + }, + ]; +}; + const escapeSpecialCharacters = (string: string) => { return string.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&"); }; @@ -686,9 +796,14 @@ const handleSearch = debounce( isTextElement(el), ) as ExcalidrawTextElement[]; - texts.sort((a, b) => a.y - b.y); + const frames = elements.filter((el) => + isFrameLikeElement(el), + ) as ExcalidrawFrameLikeElement[]; - const matchItems: SearchMatchItem[] = []; + texts.sort((a, b) => a.y - b.y); + frames.sort((a, b) => a.y - b.y); + + const textMatches: SearchMatchItem[] = []; const regex = new RegExp(escapeSpecialCharacters(searchQuery), "gi"); @@ -701,8 +816,35 @@ const handleSearch = debounce( const matchedLines = getMatchedLines(textEl, searchQuery, match.index); if (matchedLines.length > 0) { - matchItems.push({ - textElement: textEl, + textMatches.push({ + element: textEl, + searchQuery, + preview, + index: match.index, + matchedLines, + }); + } + } + } + + const frameMatches: SearchMatchItem[] = []; + + for (const frame of frames) { + let match = null; + const name = frame.name ?? getDefaultFrameName(frame); + + while ((match = regex.exec(name)) !== null) { + const preview = getMatchPreview(name, match.index, searchQuery); + const matchedLines = getMatchInFrame( + frame, + searchQuery, + match.index, + app.state.zoom.value, + ); + + if (matchedLines.length > 0) { + frameMatches.push({ + element: frame, searchQuery, preview, index: match.index, @@ -716,9 +858,12 @@ const handleSearch = debounce( app.visibleElements.map((visibleElement) => visibleElement.id), ); + // putting frame matches first + const matchItems: SearchMatchItem[] = [...frameMatches, ...textMatches]; + const focusIndex = matchItems.findIndex((matchItem) => - visibleIds.has(matchItem.textElement.id), + visibleIds.has(matchItem.element.id), ) ?? null; cb(matchItems, focusIndex); diff --git a/packages/excalidraw/components/Stats/Angle.tsx b/packages/excalidraw/components/Stats/Angle.tsx index 76cb4876d..773f86888 100644 --- a/packages/excalidraw/components/Stats/Angle.tsx +++ b/packages/excalidraw/components/Stats/Angle.tsx @@ -1,18 +1,18 @@ import { degreesToRadians, radiansToDegrees } from "@excalidraw/math"; -import { getBoundTextElement } from "@excalidraw/element/textElement"; -import { isArrowElement, isElbowArrow } from "@excalidraw/element/typeChecks"; +import { getBoundTextElement } from "@excalidraw/element"; +import { isArrowElement, isElbowArrow } from "@excalidraw/element"; + +import { updateBindings } from "@excalidraw/element"; import type { Degrees } from "@excalidraw/math"; import type { ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { angleIcon } from "../icons"; -import { updateBindings } from "../../../element/src/binding"; - import DragInput from "./DragInput"; import { getStepSizedValue, isPropertyEditable } from "./utils"; diff --git a/packages/excalidraw/components/Stats/CanvasGrid.tsx b/packages/excalidraw/components/Stats/CanvasGrid.tsx index 4766f8204..4eed85c24 100644 --- a/packages/excalidraw/components/Stats/CanvasGrid.tsx +++ b/packages/excalidraw/components/Stats/CanvasGrid.tsx @@ -1,4 +1,4 @@ -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { getNormalizedGridStep } from "../../scene"; diff --git a/packages/excalidraw/components/Stats/Collapsible.tsx b/packages/excalidraw/components/Stats/Collapsible.tsx index 13d476d2a..4d73b81bb 100644 --- a/packages/excalidraw/components/Stats/Collapsible.tsx +++ b/packages/excalidraw/components/Stats/Collapsible.tsx @@ -10,6 +10,7 @@ interface CollapsibleProps { openTrigger: () => void; children: React.ReactNode; className?: string; + showCollapsedIcon?: boolean; } const Collapsible = ({ @@ -18,6 +19,7 @@ const Collapsible = ({ openTrigger, children, className, + showCollapsedIcon = true, }: CollapsibleProps) => { return ( <> @@ -32,7 +34,9 @@ const Collapsible = ({ onClick={openTrigger} > {label} - + {showCollapsedIcon && ( + + )}
{open && (
diff --git a/packages/excalidraw/components/Stats/Dimension.tsx b/packages/excalidraw/components/Stats/Dimension.tsx index c838b581f..a8868721b 100644 --- a/packages/excalidraw/components/Stats/Dimension.tsx +++ b/packages/excalidraw/components/Stats/Dimension.tsx @@ -4,13 +4,13 @@ import { MIN_WIDTH_OR_HEIGHT } from "@excalidraw/common"; import { MINIMAL_CROP_SIZE, getUncroppedWidthAndHeight, -} from "@excalidraw/element/cropElement"; -import { resizeSingleElement } from "@excalidraw/element/resizeElements"; -import { isImageElement } from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; +import { resizeSingleElement } from "@excalidraw/element"; +import { isImageElement } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import DragInput from "./DragInput"; import { getStepSizedValue, isPropertyEditable } from "./utils"; diff --git a/packages/excalidraw/components/Stats/DragInput.tsx b/packages/excalidraw/components/Stats/DragInput.tsx index 208b48f6c..56138d810 100644 --- a/packages/excalidraw/components/Stats/DragInput.tsx +++ b/packages/excalidraw/components/Stats/DragInput.tsx @@ -3,13 +3,13 @@ import { useEffect, useRef, useState } from "react"; import { EVENT, KEYS, cloneJSON } from "@excalidraw/common"; -import { deepCopyElement } from "@excalidraw/element/duplicate"; +import { deepCopyElement } from "@excalidraw/element"; -import { CaptureUpdateAction } from "@excalidraw/element/store"; +import { CaptureUpdateAction } from "@excalidraw/element"; import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { useApp } from "../App"; import { InlineIcon } from "../InlineIcon"; diff --git a/packages/excalidraw/components/Stats/FontSize.tsx b/packages/excalidraw/components/Stats/FontSize.tsx index 635f2cd5a..62edcf7b4 100644 --- a/packages/excalidraw/components/Stats/FontSize.tsx +++ b/packages/excalidraw/components/Stats/FontSize.tsx @@ -1,18 +1,15 @@ import { getBoundTextElement, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; -import { - hasBoundTextElement, - isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; +import { hasBoundTextElement, isTextElement } from "@excalidraw/element"; import type { ExcalidrawElement, ExcalidrawTextElement, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { fontSizeIcon } from "../icons"; diff --git a/packages/excalidraw/components/Stats/MultiAngle.tsx b/packages/excalidraw/components/Stats/MultiAngle.tsx index a22a01147..966425f3b 100644 --- a/packages/excalidraw/components/Stats/MultiAngle.tsx +++ b/packages/excalidraw/components/Stats/MultiAngle.tsx @@ -1,15 +1,15 @@ import { degreesToRadians, radiansToDegrees } from "@excalidraw/math"; -import { getBoundTextElement } from "@excalidraw/element/textElement"; -import { isArrowElement } from "@excalidraw/element/typeChecks"; +import { getBoundTextElement } from "@excalidraw/element"; +import { isArrowElement } from "@excalidraw/element"; -import { isInGroup } from "@excalidraw/element/groups"; +import { isInGroup } from "@excalidraw/element"; import type { Degrees } from "@excalidraw/math"; import type { ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { angleIcon } from "../icons"; diff --git a/packages/excalidraw/components/Stats/MultiDimension.tsx b/packages/excalidraw/components/Stats/MultiDimension.tsx index ddac0ee3f..65f59ffe3 100644 --- a/packages/excalidraw/components/Stats/MultiDimension.tsx +++ b/packages/excalidraw/components/Stats/MultiDimension.tsx @@ -2,17 +2,14 @@ import { pointFrom, type GlobalPoint } from "@excalidraw/math"; import { useMemo } from "react"; import { MIN_WIDTH_OR_HEIGHT } from "@excalidraw/common"; -import { updateBoundElements } from "@excalidraw/element/binding"; +import { updateBoundElements } from "@excalidraw/element"; import { rescalePointsInElement, resizeSingleElement, -} from "@excalidraw/element/resizeElements"; -import { - getBoundTextElement, - handleBindTextResize, -} from "@excalidraw/element/textElement"; +} from "@excalidraw/element"; +import { getBoundTextElement, handleBindTextResize } from "@excalidraw/element"; -import { isTextElement } from "@excalidraw/element/typeChecks"; +import { isTextElement } from "@excalidraw/element"; import { getCommonBounds } from "@excalidraw/utils"; @@ -22,7 +19,7 @@ import type { NonDeletedSceneElementsMap, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import DragInput from "./DragInput"; import { getAtomicUnits, getStepSizedValue, isPropertyEditable } from "./utils"; diff --git a/packages/excalidraw/components/Stats/MultiFontSize.tsx b/packages/excalidraw/components/Stats/MultiFontSize.tsx index 075016ad1..921bfb021 100644 --- a/packages/excalidraw/components/Stats/MultiFontSize.tsx +++ b/packages/excalidraw/components/Stats/MultiFontSize.tsx @@ -1,13 +1,10 @@ import { getBoundTextElement, redrawTextBoundingBox, -} from "@excalidraw/element/textElement"; -import { - hasBoundTextElement, - isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; +import { hasBoundTextElement, isTextElement } from "@excalidraw/element"; -import { isInGroup } from "@excalidraw/element/groups"; +import { isInGroup } from "@excalidraw/element"; import type { ExcalidrawElement, @@ -15,7 +12,7 @@ import type { NonDeletedSceneElementsMap, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { fontSizeIcon } from "../icons"; diff --git a/packages/excalidraw/components/Stats/MultiPosition.tsx b/packages/excalidraw/components/Stats/MultiPosition.tsx index 6a6dc0c6d..19b52e2f4 100644 --- a/packages/excalidraw/components/Stats/MultiPosition.tsx +++ b/packages/excalidraw/components/Stats/MultiPosition.tsx @@ -1,13 +1,13 @@ import { pointFrom, pointRotateRads } from "@excalidraw/math"; import { useMemo } from "react"; -import { isTextElement } from "@excalidraw/element/typeChecks"; +import { isTextElement } from "@excalidraw/element"; -import { getCommonBounds } from "@excalidraw/element/bounds"; +import { getCommonBounds } from "@excalidraw/element"; import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import StatsDragInput from "./DragInput"; import { diff --git a/packages/excalidraw/components/Stats/Position.tsx b/packages/excalidraw/components/Stats/Position.tsx index 7b590cdf7..f89ce2615 100644 --- a/packages/excalidraw/components/Stats/Position.tsx +++ b/packages/excalidraw/components/Stats/Position.tsx @@ -3,12 +3,12 @@ import { clamp, pointFrom, pointRotateRads, round } from "@excalidraw/math"; import { getFlipAdjustedCropPosition, getUncroppedWidthAndHeight, -} from "@excalidraw/element/cropElement"; -import { isImageElement } from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; +import { isImageElement } from "@excalidraw/element"; import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import StatsDragInput from "./DragInput"; import { getStepSizedValue, moveElement, STEP_SIZE } from "./utils"; diff --git a/packages/excalidraw/components/Stats/index.tsx b/packages/excalidraw/components/Stats/index.tsx index 11a5d6b5d..bcfab8520 100644 --- a/packages/excalidraw/components/Stats/index.tsx +++ b/packages/excalidraw/components/Stats/index.tsx @@ -4,13 +4,13 @@ import throttle from "lodash.throttle"; import { useEffect, useMemo, useState, memo } from "react"; import { STATS_PANELS } from "@excalidraw/common"; -import { getCommonBounds } from "@excalidraw/element/bounds"; -import { getUncroppedWidthAndHeight } from "@excalidraw/element/cropElement"; -import { isElbowArrow, isImageElement } from "@excalidraw/element/typeChecks"; +import { getCommonBounds } from "@excalidraw/element"; +import { getUncroppedWidthAndHeight } from "@excalidraw/element"; +import { isElbowArrow, isImageElement } from "@excalidraw/element"; -import { frameAndChildrenSelectedTogether } from "@excalidraw/element/frame"; +import { frameAndChildrenSelectedTogether } from "@excalidraw/element"; -import { elementsAreInSameGroup } from "@excalidraw/element/groups"; +import { elementsAreInSameGroup } from "@excalidraw/element"; import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/components/Stats/stats.test.tsx b/packages/excalidraw/components/Stats/stats.test.tsx index cfb2b4ee4..cc1cfce98 100644 --- a/packages/excalidraw/components/Stats/stats.test.tsx +++ b/packages/excalidraw/components/Stats/stats.test.tsx @@ -5,9 +5,9 @@ import { vi } from "vitest"; import { setDateTimeForTests, reseed } from "@excalidraw/common"; -import { isInGroup } from "@excalidraw/element/groups"; +import { isInGroup } from "@excalidraw/element"; -import { isTextElement } from "@excalidraw/element/typeChecks"; +import { isTextElement } from "@excalidraw/element"; import type { Degrees } from "@excalidraw/math"; diff --git a/packages/excalidraw/components/Stats/utils.ts b/packages/excalidraw/components/Stats/utils.ts index c30777e42..f07a53dfe 100644 --- a/packages/excalidraw/components/Stats/utils.ts +++ b/packages/excalidraw/components/Stats/utils.ts @@ -1,18 +1,17 @@ import { pointFrom, pointRotateRads } from "@excalidraw/math"; -import { getBoundTextElement } from "@excalidraw/element/textElement"; -import { - isFrameLikeElement, - isTextElement, -} from "@excalidraw/element/typeChecks"; +import { getBoundTextElement } from "@excalidraw/element"; +import { isFrameLikeElement, isTextElement } from "@excalidraw/element"; import { getSelectedGroupIds, getElementsInGroup, isInGroup, -} from "@excalidraw/element/groups"; +} from "@excalidraw/element"; -import { getFrameChildren } from "@excalidraw/element/frame"; +import { getFrameChildren } from "@excalidraw/element"; + +import { updateBindings } from "@excalidraw/element"; import type { Radians } from "@excalidraw/math"; @@ -22,9 +21,7 @@ import type { NonDeletedExcalidrawElement, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; - -import { updateBindings } from "../../../element/src/binding"; +import type { Scene } from "@excalidraw/element"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/hyperlink/Hyperlink.tsx b/packages/excalidraw/components/hyperlink/Hyperlink.tsx index 65883017e..292659bdb 100644 --- a/packages/excalidraw/components/hyperlink/Hyperlink.tsx +++ b/packages/excalidraw/components/hyperlink/Hyperlink.tsx @@ -10,16 +10,13 @@ import { import { EVENT, HYPERLINK_TOOLTIP_DELAY, KEYS } from "@excalidraw/common"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; -import { hitElementBoundingBox } from "@excalidraw/element/collision"; +import { hitElementBoundingBox } from "@excalidraw/element"; -import { isElementLink } from "@excalidraw/element/elementLink"; +import { isElementLink } from "@excalidraw/element"; -import { - getEmbedLink, - embeddableURLValidator, -} from "@excalidraw/element/embeddable"; +import { getEmbedLink, embeddableURLValidator } from "@excalidraw/element"; import { sceneCoordsToViewportCoords, @@ -29,9 +26,9 @@ import { normalizeLink, } from "@excalidraw/common"; -import { isEmbeddableElement } from "@excalidraw/element/typeChecks"; +import { isEmbeddableElement } from "@excalidraw/element"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import type { ElementsMap, diff --git a/packages/excalidraw/components/hyperlink/helpers.ts b/packages/excalidraw/components/hyperlink/helpers.ts index d1345db98..bdabbfc44 100644 --- a/packages/excalidraw/components/hyperlink/helpers.ts +++ b/packages/excalidraw/components/hyperlink/helpers.ts @@ -1,14 +1,14 @@ import { pointFrom, pointRotateRads } from "@excalidraw/math"; import { MIME_TYPES } from "@excalidraw/common"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; -import { hitElementBoundingBox } from "@excalidraw/element/collision"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; +import { hitElementBoundingBox } from "@excalidraw/element"; -import { DEFAULT_LINK_SIZE } from "@excalidraw/element/renderElement"; +import { DEFAULT_LINK_SIZE } from "@excalidraw/element"; import type { GlobalPoint, Radians } from "@excalidraw/math"; -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; import type { ElementsMap, NonDeletedExcalidrawElement, diff --git a/packages/excalidraw/data/index.ts b/packages/excalidraw/data/index.ts index 93d5f5677..f655e5e8e 100644 --- a/packages/excalidraw/data/index.ts +++ b/packages/excalidraw/data/index.ts @@ -10,9 +10,9 @@ import { import { getNonDeletedElements } from "@excalidraw/element"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; +import { isFrameLikeElement } from "@excalidraw/element"; -import { getElementsOverlappingFrame } from "@excalidraw/element/frame"; +import { getElementsOverlappingFrame } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/data/library.ts b/packages/excalidraw/data/library.ts index 5a9b7fc15..4269edbd7 100644 --- a/packages/excalidraw/data/library.ts +++ b/packages/excalidraw/data/library.ts @@ -19,7 +19,7 @@ import { import { hashElementsVersion, hashString } from "@excalidraw/element"; -import { getCommonBoundingBox } from "@excalidraw/element/bounds"; +import { getCommonBoundingBox } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/data/reconcile.ts b/packages/excalidraw/data/reconcile.ts index a69ee2dee..d758796a7 100644 --- a/packages/excalidraw/data/reconcile.ts +++ b/packages/excalidraw/data/reconcile.ts @@ -6,7 +6,7 @@ import { orderByFractionalIndex, syncInvalidIndices, validateFractionalIndices, -} from "@excalidraw/element/fractionalIndex"; +} from "@excalidraw/element"; import type { OrderedExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/data/restore.ts b/packages/excalidraw/data/restore.ts index 22ed507de..e282767c3 100644 --- a/packages/excalidraw/data/restore.ts +++ b/packages/excalidraw/data/restore.ts @@ -19,15 +19,15 @@ import { getLineHeight, } from "@excalidraw/common"; import { getNonDeletedElements } from "@excalidraw/element"; -import { normalizeFixedPoint } from "@excalidraw/element/binding"; +import { normalizeFixedPoint } from "@excalidraw/element"; import { updateElbowArrowPoints, validateElbowPoints, -} from "@excalidraw/element/elbowArrow"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; -import { bumpVersion } from "@excalidraw/element/mutateElement"; -import { getContainerElement } from "@excalidraw/element/textElement"; -import { detectLineHeight } from "@excalidraw/element/textMeasurements"; +} from "@excalidraw/element"; +import { LinearElementEditor } from "@excalidraw/element"; +import { bumpVersion } from "@excalidraw/element"; +import { getContainerElement } from "@excalidraw/element"; +import { detectLineHeight } from "@excalidraw/element"; import { isArrowBoundToElement, isArrowElement, @@ -37,15 +37,15 @@ import { isLineElement, isTextElement, isUsingAdaptiveRadius, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex"; +import { syncInvalidIndices } from "@excalidraw/element"; -import { refreshTextDimensions } from "@excalidraw/element/newElement"; +import { refreshTextDimensions } from "@excalidraw/element"; -import { getNormalizedDimensions } from "@excalidraw/element/sizeHelpers"; +import { getNormalizedDimensions } from "@excalidraw/element"; -import { isInvisiblySmallElement } from "@excalidraw/element/sizeHelpers"; +import { isInvisiblySmallElement } from "@excalidraw/element"; import type { LocalPoint, Radians } from "@excalidraw/math"; diff --git a/packages/excalidraw/data/transform.ts b/packages/excalidraw/data/transform.ts index d594614fb..fd0d3388f 100644 --- a/packages/excalidraw/data/transform.ts +++ b/packages/excalidraw/data/transform.ts @@ -16,7 +16,7 @@ import { getLineHeight, } from "@excalidraw/common"; -import { bindLinearElement } from "@excalidraw/element/binding"; +import { bindLinearElement } from "@excalidraw/element"; import { newArrowElement, newElement, @@ -25,24 +25,21 @@ import { newLinearElement, newMagicFrameElement, newTextElement, -} from "@excalidraw/element/newElement"; -import { - measureText, - normalizeText, -} from "@excalidraw/element/textMeasurements"; -import { isArrowElement } from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; +import { measureText, normalizeText } from "@excalidraw/element"; +import { isArrowElement } from "@excalidraw/element"; -import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex"; +import { syncInvalidIndices } from "@excalidraw/element"; -import { redrawTextBoundingBox } from "@excalidraw/element/textElement"; +import { redrawTextBoundingBox } from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { LinearElementEditor } from "@excalidraw/element"; -import { getCommonBounds } from "@excalidraw/element/bounds"; +import { getCommonBounds } from "@excalidraw/element"; -import Scene from "@excalidraw/element/Scene"; +import { Scene } from "@excalidraw/element"; -import type { ElementConstructorOpts } from "@excalidraw/element/newElement"; +import type { ElementConstructorOpts } from "@excalidraw/element"; import type { ExcalidrawArrowElement, diff --git a/packages/excalidraw/eraser/index.ts b/packages/excalidraw/eraser/index.ts index 2ea668aef..5e6c4e517 100644 --- a/packages/excalidraw/eraser/index.ts +++ b/packages/excalidraw/eraser/index.ts @@ -1,21 +1,18 @@ import { arrayToMap, easeOut, THEME } from "@excalidraw/common"; -import { getElementLineSegments } from "@excalidraw/element/bounds"; +import { getElementLineSegments } from "@excalidraw/element"; import { lineSegment, lineSegmentIntersectionPoints, pointFrom, } from "@excalidraw/math"; -import { getElementsInGroup } from "@excalidraw/element/groups"; +import { getElementsInGroup } from "@excalidraw/element"; -import { getElementShape } from "@excalidraw/element/shapes"; -import { shouldTestInside } from "@excalidraw/element/collision"; +import { getElementShape } from "@excalidraw/element"; +import { shouldTestInside } from "@excalidraw/element"; import { isPointInShape } from "@excalidraw/utils/collision"; -import { - hasBoundTextElement, - isBoundToContainer, -} from "@excalidraw/element/typeChecks"; -import { getBoundTextElementId } from "@excalidraw/element/textElement"; +import { hasBoundTextElement, isBoundToContainer } from "@excalidraw/element"; +import { getBoundTextElementId } from "@excalidraw/element"; import type { GeometricShape } from "@excalidraw/utils/shape"; import type { diff --git a/packages/excalidraw/fonts/Fonts.ts b/packages/excalidraw/fonts/Fonts.ts index a9419892b..c1de529cd 100644 --- a/packages/excalidraw/fonts/Fonts.ts +++ b/packages/excalidraw/fonts/Fonts.ts @@ -5,9 +5,9 @@ import { WINDOWS_EMOJI_FALLBACK_FONT, getFontFamilyFallbacks, } from "@excalidraw/common"; -import { getContainerElement } from "@excalidraw/element/textElement"; -import { charWidth } from "@excalidraw/element/textMeasurements"; -import { containsCJK } from "@excalidraw/element/textWrapping"; +import { getContainerElement } from "@excalidraw/element"; +import { charWidth } from "@excalidraw/element"; +import { containsCJK } from "@excalidraw/element"; import { FONT_METADATA, @@ -17,9 +17,9 @@ import { promiseTry, } from "@excalidraw/common"; -import { ShapeCache } from "@excalidraw/element/ShapeCache"; +import { ShapeCache } from "@excalidraw/element"; -import { isTextElement } from "@excalidraw/element/typeChecks"; +import { isTextElement } from "@excalidraw/element"; import type { ExcalidrawElement, @@ -28,7 +28,7 @@ import type { import type { ValueOf } from "@excalidraw/common/utility-types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { CascadiaFontFaces } from "./Cascadia"; import { ComicShannsFontFaces } from "./ComicShanns"; diff --git a/packages/excalidraw/history.ts b/packages/excalidraw/history.ts index f3022fd41..cd9dcffe2 100644 --- a/packages/excalidraw/history.ts +++ b/packages/excalidraw/history.ts @@ -5,7 +5,7 @@ import { StoreChange, StoreDelta, type Store, -} from "@excalidraw/element/store"; +} from "@excalidraw/element"; import type { SceneElementsMap } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/index.tsx b/packages/excalidraw/index.tsx index 07fbdfdbb..478ecc42f 100644 --- a/packages/excalidraw/index.tsx +++ b/packages/excalidraw/index.tsx @@ -222,8 +222,8 @@ export { getNonDeletedElements, } from "@excalidraw/element"; -export { getTextFromElements } from "@excalidraw/element/textElement"; -export { isInvisiblySmallElement } from "@excalidraw/element/sizeHelpers"; +export { getTextFromElements } from "@excalidraw/element"; +export { isInvisiblySmallElement } from "@excalidraw/element"; export { defaultLang, useI18n, languages } from "./i18n"; export { @@ -248,9 +248,9 @@ export { loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "./data/blob"; -export { getFreeDrawSvgPath } from "@excalidraw/element/renderElement"; +export { getFreeDrawSvgPath } from "@excalidraw/element"; export { mergeLibraryItems, getLibraryItemsHash } from "./data/library"; -export { isLinearElement } from "@excalidraw/element/typeChecks"; +export { isLinearElement } from "@excalidraw/element"; export { FONT_FAMILY, @@ -266,9 +266,9 @@ export { mutateElement, newElementWith, bumpVersion, -} from "@excalidraw/element/mutateElement"; +} from "@excalidraw/element"; -export { CaptureUpdateAction } from "@excalidraw/element/store"; +export { CaptureUpdateAction } from "@excalidraw/element"; export { parseLibraryTokensFromUrl, useHandleLibrary } from "./data/library"; @@ -292,10 +292,7 @@ export { TTDDialogTrigger } from "./components/TTDDialog/TTDDialogTrigger"; export { zoomToFitBounds } from "./actions/actionCanvas"; export { convertToExcalidrawElements } from "./data/transform"; -export { - getCommonBounds, - getVisibleSceneBounds, -} from "@excalidraw/element/bounds"; +export { getCommonBounds, getVisibleSceneBounds } from "@excalidraw/element"; export { elementsOverlappingBBox, @@ -305,6 +302,6 @@ export { export { DiagramToCodePlugin } from "./components/DiagramToCodePlugin/DiagramToCodePlugin"; export { getDataURL } from "./data/blob"; -export { isElementLink } from "@excalidraw/element/elementLink"; +export { isElementLink } from "@excalidraw/element"; -export { setCustomTextMetricsProvider } from "@excalidraw/element/textMeasurements"; +export { setCustomTextMetricsProvider } from "@excalidraw/element"; diff --git a/packages/excalidraw/lasso/index.ts b/packages/excalidraw/lasso/index.ts index f7e791665..41e6b2080 100644 --- a/packages/excalidraw/lasso/index.ts +++ b/packages/excalidraw/lasso/index.ts @@ -4,18 +4,18 @@ import { pointFrom, } from "@excalidraw/math"; -import { getElementLineSegments } from "@excalidraw/element/bounds"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { getElementLineSegments } from "@excalidraw/element"; +import { LinearElementEditor } from "@excalidraw/element"; import { isFrameLikeElement, isLinearElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { getFrameChildren } from "@excalidraw/element/frame"; -import { selectGroupsForSelectedElements } from "@excalidraw/element/groups"; +import { getFrameChildren } from "@excalidraw/element"; +import { selectGroupsForSelectedElements } from "@excalidraw/element"; -import { getContainerElement } from "@excalidraw/element/textElement"; +import { getContainerElement } from "@excalidraw/element"; import { arrayToMap, easeOut } from "@excalidraw/common"; diff --git a/packages/excalidraw/locales/en.json b/packages/excalidraw/locales/en.json index b585cb314..736c41722 100644 --- a/packages/excalidraw/locales/en.json +++ b/packages/excalidraw/locales/en.json @@ -188,7 +188,9 @@ "noMatch": "No matches found...", "singleResult": "result", "multipleResults": "results", - "placeholder": "Find text on canvas..." + "placeholder": "Find text on canvas...", + "frames": "Frames", + "texts": "Texts" }, "buttons": { "clearReset": "Reset the canvas", diff --git a/packages/excalidraw/renderer/helpers.ts b/packages/excalidraw/renderer/helpers.ts index 92d228322..e42f4166b 100644 --- a/packages/excalidraw/renderer/helpers.ts +++ b/packages/excalidraw/renderer/helpers.ts @@ -1,8 +1,8 @@ import { elementCenterPoint, THEME, THEME_FILTER } from "@excalidraw/common"; -import { FIXED_BINDING_DISTANCE } from "@excalidraw/element/binding"; -import { getDiamondPoints } from "@excalidraw/element/bounds"; -import { getCornerRadius } from "@excalidraw/element/shapes"; +import { FIXED_BINDING_DISTANCE } from "@excalidraw/element"; +import { getDiamondPoints } from "@excalidraw/element"; +import { getCornerRadius } from "@excalidraw/element"; import { bezierEquation, diff --git a/packages/excalidraw/renderer/interactiveScene.ts b/packages/excalidraw/renderer/interactiveScene.ts index 695028f70..67ebf1812 100644 --- a/packages/excalidraw/renderer/interactiveScene.ts +++ b/packages/excalidraw/renderer/interactiveScene.ts @@ -16,17 +16,14 @@ import { throttleRAF, } from "@excalidraw/common"; -import { - FIXED_BINDING_DISTANCE, - maxBindingGap, -} from "@excalidraw/element/binding"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import { FIXED_BINDING_DISTANCE, maxBindingGap } from "@excalidraw/element"; +import { LinearElementEditor } from "@excalidraw/element"; import { getOmitSidesForDevice, getTransformHandles, getTransformHandlesFromCoords, shouldShowBoundingBox, -} from "@excalidraw/element/transformHandles"; +} from "@excalidraw/element"; import { isElbowArrow, isFrameLikeElement, @@ -34,31 +31,28 @@ import { isLinearElement, isLineElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { renderSelectionElement } from "@excalidraw/element/renderElement"; +import { renderSelectionElement } from "@excalidraw/element"; import { getElementsInGroup, getSelectedGroupIds, isSelectedViaGroup, selectGroupsFromGivenElements, -} from "@excalidraw/element/groups"; +} from "@excalidraw/element"; -import { - getCommonBounds, - getElementAbsoluteCoords, -} from "@excalidraw/element/bounds"; +import { getCommonBounds, getElementAbsoluteCoords } from "@excalidraw/element"; import type { SuggestedBinding, SuggestedPointBinding, -} from "@excalidraw/element/binding"; +} from "@excalidraw/element"; import type { TransformHandles, TransformHandleType, -} from "@excalidraw/element/transformHandles"; +} from "@excalidraw/element"; import type { ElementsMap, @@ -1072,10 +1066,10 @@ const _renderInteractiveScene = ({ context.restore(); } - appState.searchMatches.forEach(({ id, focus, matchedLines }) => { + appState.searchMatches?.matches.forEach(({ id, focus, matchedLines }) => { const element = elementsMap.get(id); - if (element && isTextElement(element)) { + if (element) { const [elementX1, elementY1, , , cx, cy] = getElementAbsoluteCoords( element, elementsMap, @@ -1095,17 +1089,20 @@ const _renderInteractiveScene = ({ context.fillStyle = "rgba(99, 52, 0, 0.4)"; } + const zoomFactor = isFrameLikeElement(element) ? appState.zoom.value : 1; + context.translate(appState.scrollX, appState.scrollY); context.translate(cx, cy); context.rotate(element.angle); matchedLines.forEach((matchedLine) => { - context.fillRect( - elementX1 + matchedLine.offsetX - cx, - elementY1 + matchedLine.offsetY - cy, - matchedLine.width, - matchedLine.height, - ); + (matchedLine.showOnCanvas || focus) && + context.fillRect( + elementX1 + matchedLine.offsetX / zoomFactor - cx, + elementY1 + matchedLine.offsetY / zoomFactor - cy, + matchedLine.width / zoomFactor, + matchedLine.height / zoomFactor, + ); }); context.restore(); diff --git a/packages/excalidraw/renderer/renderNewElementScene.ts b/packages/excalidraw/renderer/renderNewElementScene.ts index bbc14654a..69966687d 100644 --- a/packages/excalidraw/renderer/renderNewElementScene.ts +++ b/packages/excalidraw/renderer/renderNewElementScene.ts @@ -1,6 +1,6 @@ import { throttleRAF } from "@excalidraw/common"; -import { renderElement } from "@excalidraw/element/renderElement"; +import { renderElement } from "@excalidraw/element"; import { bootstrapCanvas, getNormalizedCanvasDimensions } from "./helpers"; diff --git a/packages/excalidraw/renderer/staticScene.ts b/packages/excalidraw/renderer/staticScene.ts index 16743ff91..d63779464 100644 --- a/packages/excalidraw/renderer/staticScene.ts +++ b/packages/excalidraw/renderer/staticScene.ts @@ -1,21 +1,21 @@ import { FRAME_STYLE, throttleRAF } from "@excalidraw/common"; -import { isElementLink } from "@excalidraw/element/elementLink"; -import { createPlaceholderEmbeddableLabel } from "@excalidraw/element/embeddable"; -import { getBoundTextElement } from "@excalidraw/element/textElement"; +import { isElementLink } from "@excalidraw/element"; +import { createPlaceholderEmbeddableLabel } from "@excalidraw/element"; +import { getBoundTextElement } from "@excalidraw/element"; import { isEmbeddableElement, isIframeLikeElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { elementOverlapsWithFrame, getTargetFrame, shouldApplyFrameClip, -} from "@excalidraw/element/frame"; +} from "@excalidraw/element"; -import { renderElement } from "@excalidraw/element/renderElement"; +import { renderElement } from "@excalidraw/element"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; import type { ElementsMap, diff --git a/packages/excalidraw/renderer/staticSvgScene.ts b/packages/excalidraw/renderer/staticSvgScene.ts index 0d3f5bad9..89af1dc72 100644 --- a/packages/excalidraw/renderer/staticSvgScene.ts +++ b/packages/excalidraw/renderer/staticSvgScene.ts @@ -10,36 +10,30 @@ import { } from "@excalidraw/common"; import { normalizeLink, toValidURL } from "@excalidraw/common"; import { hashString } from "@excalidraw/element"; -import { getUncroppedWidthAndHeight } from "@excalidraw/element/cropElement"; +import { getUncroppedWidthAndHeight } from "@excalidraw/element"; import { createPlaceholderEmbeddableLabel, getEmbedLink, -} from "@excalidraw/element/embeddable"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; -import { - getBoundTextElement, - getContainerElement, -} from "@excalidraw/element/textElement"; -import { getLineHeightInPx } from "@excalidraw/element/textMeasurements"; +} from "@excalidraw/element"; +import { LinearElementEditor } from "@excalidraw/element"; +import { getBoundTextElement, getContainerElement } from "@excalidraw/element"; +import { getLineHeightInPx } from "@excalidraw/element"; import { isArrowElement, isIframeLikeElement, isInitializedImageElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; -import { getContainingFrame } from "@excalidraw/element/frame"; +import { getContainingFrame } from "@excalidraw/element"; -import { getCornerRadius, isPathALoop } from "@excalidraw/element/shapes"; +import { getCornerRadius, isPathALoop } from "@excalidraw/element"; -import { ShapeCache } from "@excalidraw/element/ShapeCache"; +import { ShapeCache } from "@excalidraw/element"; -import { - getFreeDrawSvgPath, - IMAGE_INVERT_FILTER, -} from "@excalidraw/element/renderElement"; +import { getFreeDrawSvgPath, IMAGE_INVERT_FILTER } from "@excalidraw/element"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/scene/Renderer.ts b/packages/excalidraw/scene/Renderer.ts index 47d859cbf..cf112c2ce 100644 --- a/packages/excalidraw/scene/Renderer.ts +++ b/packages/excalidraw/scene/Renderer.ts @@ -1,5 +1,5 @@ -import { isElementInViewport } from "@excalidraw/element/sizeHelpers"; -import { isImageElement } from "@excalidraw/element/typeChecks"; +import { isElementInViewport } from "@excalidraw/element"; +import { isImageElement } from "@excalidraw/element"; import { memoize, toBrandedType } from "@excalidraw/common"; @@ -9,7 +9,7 @@ import type { NonDeletedExcalidrawElement, } from "@excalidraw/element/types"; -import type Scene from "@excalidraw/element/Scene"; +import type { Scene } from "@excalidraw/element"; import { renderInteractiveSceneThrottled } from "../renderer/interactiveScene"; import { renderStaticSceneThrottled } from "../renderer/staticScene"; diff --git a/packages/excalidraw/scene/export.ts b/packages/excalidraw/scene/export.ts index 229992354..f2e5b32df 100644 --- a/packages/excalidraw/scene/export.ts +++ b/packages/excalidraw/scene/export.ts @@ -15,34 +15,31 @@ import { toBrandedType, } from "@excalidraw/common"; -import { - getCommonBounds, - getElementAbsoluteCoords, -} from "@excalidraw/element/bounds"; +import { getCommonBounds, getElementAbsoluteCoords } from "@excalidraw/element"; import { getInitializedImageElements, updateImageCache, -} from "@excalidraw/element/image"; +} from "@excalidraw/element"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; -import { isFrameLikeElement } from "@excalidraw/element/typeChecks"; +import { isFrameLikeElement } from "@excalidraw/element"; import { getElementsOverlappingFrame, getFrameLikeElements, getFrameLikeTitle, getRootElements, -} from "@excalidraw/element/frame"; +} from "@excalidraw/element"; -import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex"; +import { syncInvalidIndices } from "@excalidraw/element"; import { type Mutable } from "@excalidraw/common/utility-types"; -import { newTextElement } from "@excalidraw/element/newElement"; +import { newTextElement } from "@excalidraw/element"; -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/scene/index.ts b/packages/excalidraw/scene/index.ts index 6f39a7fe2..ce2cb10fe 100644 --- a/packages/excalidraw/scene/index.ts +++ b/packages/excalidraw/scene/index.ts @@ -4,7 +4,7 @@ export { getCommonAttributeOfSelectedElements, getSelectedElements, getTargetElements, -} from "@excalidraw/element/selection"; +} from "@excalidraw/element"; export { calculateScrollCenter } from "./scroll"; export { hasBackground, @@ -12,7 +12,7 @@ export { hasStrokeStyle, canHaveArrowheads, canChangeRoundness, -} from "@excalidraw/element/comparisons"; +} from "@excalidraw/element"; export { getNormalizedZoom, getNormalizedGridSize, diff --git a/packages/excalidraw/scene/scroll.ts b/packages/excalidraw/scene/scroll.ts index a99ad075f..f05a3c0a4 100644 --- a/packages/excalidraw/scene/scroll.ts +++ b/packages/excalidraw/scene/scroll.ts @@ -4,9 +4,9 @@ import { viewportCoordsToSceneCoords, } from "@excalidraw/common"; -import { getClosestElementBounds } from "@excalidraw/element/bounds"; +import { getClosestElementBounds } from "@excalidraw/element"; -import { getCommonBounds } from "@excalidraw/element/bounds"; +import { getCommonBounds } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/scene/scrollbars.ts b/packages/excalidraw/scene/scrollbars.ts index 35fecba37..699d7eb72 100644 --- a/packages/excalidraw/scene/scrollbars.ts +++ b/packages/excalidraw/scene/scrollbars.ts @@ -1,6 +1,6 @@ import { getGlobalCSSVariable } from "@excalidraw/common"; -import { getCommonBounds } from "@excalidraw/element/bounds"; +import { getCommonBounds } from "@excalidraw/element"; import { getLanguage } from "../i18n"; diff --git a/packages/excalidraw/snapping.ts b/packages/excalidraw/snapping.ts index 6ea23bd87..635ba065d 100644 --- a/packages/excalidraw/snapping.ts +++ b/packages/excalidraw/snapping.ts @@ -12,23 +12,20 @@ import { getCommonBounds, getDraggedElementsBounds, getElementAbsoluteCoords, -} from "@excalidraw/element/bounds"; -import { - isBoundToContainer, - isFrameLikeElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; +import { isBoundToContainer, isFrameLikeElement } from "@excalidraw/element"; -import { getMaximumGroups } from "@excalidraw/element/groups"; +import { getMaximumGroups } from "@excalidraw/element"; import { getSelectedElements, getVisibleAndNonSelectedElements, -} from "@excalidraw/element/selection"; +} from "@excalidraw/element"; import type { InclusiveRange } from "@excalidraw/math"; -import type { Bounds } from "@excalidraw/element/bounds"; -import type { MaybeTransformHandleType } from "@excalidraw/element/transformHandles"; +import type { Bounds } from "@excalidraw/element"; +import type { MaybeTransformHandleType } from "@excalidraw/element"; import type { ElementsMap, ExcalidrawElement, diff --git a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap index 87fb23abd..6c258c621 100644 --- a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap @@ -961,7 +961,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -1159,7 +1159,7 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -1373,7 +1373,7 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -1704,7 +1704,7 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -2035,7 +2035,7 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -2249,7 +2249,7 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -2488,7 +2488,7 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id3": true, }, @@ -2790,7 +2790,7 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id3": true, @@ -3158,7 +3158,7 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -3639,7 +3639,7 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id3": true, }, @@ -3962,7 +3962,7 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id3": true, }, @@ -4287,7 +4287,7 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id3": true, @@ -5566,7 +5566,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id3": true, @@ -6785,7 +6785,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id3": true, @@ -7719,7 +7719,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -8714,7 +8714,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -9706,7 +9706,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap index 30bfe5c63..5e3f00c31 100644 --- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap @@ -84,7 +84,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id691": true, }, @@ -673,7 +673,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id668": true, }, @@ -1181,7 +1181,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -1547,7 +1547,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -1914,7 +1914,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -2176,7 +2176,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id740": true, }, @@ -2614,7 +2614,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -2911,7 +2911,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -3193,7 +3193,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -3485,7 +3485,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -3769,7 +3769,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -4002,7 +4002,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -4259,7 +4259,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -4530,7 +4530,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -4759,7 +4759,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -4988,7 +4988,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -5215,7 +5215,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -5442,7 +5442,7 @@ exports[`history > multiplayer undo/redo > conflicts in frames and their childre "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -5699,7 +5699,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -6030,7 +6030,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -6457,7 +6457,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id433": true, "id434": true, @@ -6836,7 +6836,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id452": true, "id453": true, @@ -7151,7 +7151,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id486": true, }, @@ -7450,7 +7450,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -7678,7 +7678,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -8032,7 +8032,7 @@ exports[`history > multiplayer undo/redo > should iterate through the history wh "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -8389,7 +8389,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id542": true, "id545": true, @@ -8792,7 +8792,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -9077,7 +9077,7 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id531": true, }, @@ -9341,7 +9341,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id333": true, }, @@ -9606,7 +9606,7 @@ exports[`history > multiplayer undo/redo > should not override remote changes on "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id342": true, }, @@ -9839,7 +9839,7 @@ exports[`history > multiplayer undo/redo > should override remotely added groups "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -10135,7 +10135,7 @@ exports[`history > multiplayer undo/redo > should override remotely added points "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id379": true, }, @@ -10475,7 +10475,7 @@ exports[`history > multiplayer undo/redo > should redistribute deltas when eleme "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -10712,7 +10712,7 @@ exports[`history > multiplayer undo/redo > should redraw arrows on undo > [end o "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -11157,7 +11157,7 @@ exports[`history > multiplayer undo/redo > should update history entries after r "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id349": true, }, @@ -11413,7 +11413,7 @@ exports[`history > singleplayer undo/redo > remounting undo/redo buttons should "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -11650,7 +11650,7 @@ exports[`history > singleplayer undo/redo > should clear the redo stack on eleme "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id50": true, }, @@ -11889,7 +11889,7 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -12293,7 +12293,7 @@ exports[`history > singleplayer undo/redo > should create new history entry on s "resizingElement": null, "scrollX": -50, "scrollY": -50, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -12535,7 +12535,7 @@ exports[`history > singleplayer undo/redo > should disable undo/redo buttons whe "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id323": true, }, @@ -12774,7 +12774,7 @@ exports[`history > singleplayer undo/redo > should end up with no history entry "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id70": true, }, @@ -13015,7 +13015,7 @@ exports[`history > singleplayer undo/redo > should iterate through the history w "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -13260,7 +13260,7 @@ exports[`history > singleplayer undo/redo > should not clear the redo stack on s "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id18": true, }, @@ -13596,7 +13596,7 @@ exports[`history > singleplayer undo/redo > should not collapse when applying co "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -13763,7 +13763,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id4": true, "id5": true, @@ -14052,7 +14052,7 @@ exports[`history > singleplayer undo/redo > should not end up with history entry "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -14316,7 +14316,7 @@ exports[`history > singleplayer undo/redo > should not override appstate changes "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id29": true, }, @@ -14595,7 +14595,7 @@ exports[`history > singleplayer undo/redo > should support appstate name or view "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -14754,7 +14754,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id243": true, }, @@ -15453,7 +15453,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id225": true, }, @@ -16071,7 +16071,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id262": true, }, @@ -16687,7 +16687,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id275": true, }, @@ -17402,7 +17402,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id297": true, "id299": true, @@ -18153,7 +18153,7 @@ exports[`history > singleplayer undo/redo > should support changes in elements' "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id189": true, "id195": true, @@ -18631,7 +18631,7 @@ exports[`history > singleplayer undo/redo > should support duplication of groups "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id184": true, "id186": true, @@ -19152,7 +19152,7 @@ exports[`history > singleplayer undo/redo > should support element creation, del "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -19611,7 +19611,7 @@ exports[`history > singleplayer undo/redo > should support linear element creati "resizingElement": null, "scrollX": 0, "scrollY": 0, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id119": true, }, diff --git a/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap index b580b4c95..0393c9b49 100644 --- a/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap @@ -88,7 +88,7 @@ exports[`given element A and group of elements B and given both are selected whe "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id2": true, @@ -504,7 +504,7 @@ exports[`given element A and group of elements B and given both are selected whe "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -907,7 +907,7 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id7": true, }, @@ -1453,7 +1453,7 @@ exports[`regression tests > Drags selected element when hitting only bounding bo "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -1660,7 +1660,7 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id2": true, @@ -2036,7 +2036,7 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id2": true, }, @@ -2270,7 +2270,7 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = ` "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -2453,7 +2453,7 @@ exports[`regression tests > can drag element that covers another element, while "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -2772,7 +2772,7 @@ exports[`regression tests > change the properties of a shape > [end of test] app "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -3021,7 +3021,7 @@ exports[`regression tests > click on an element and drag it > [dragged] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -3265,7 +3265,7 @@ exports[`regression tests > click on an element and drag it > [end of test] appS "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -3496,7 +3496,7 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`] "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -3753,7 +3753,7 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -4063,7 +4063,7 @@ exports[`regression tests > deleting last but one element in editing group shoul "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -4489,7 +4489,7 @@ exports[`regression tests > deselects group of selected elements on pointer down "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -4773,7 +4773,7 @@ exports[`regression tests > deselects group of selected elements on pointer up w "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -5026,7 +5026,7 @@ exports[`regression tests > deselects selected element on pointer down when poin "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -5237,7 +5237,7 @@ exports[`regression tests > deselects selected element, on pointer up, when clic "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -5435,7 +5435,7 @@ exports[`regression tests > double click to edit a group > [end of test] appStat "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id2": true, }, @@ -5821,7 +5821,7 @@ exports[`regression tests > drags selected elements from point inside common bou "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -6109,7 +6109,7 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1` "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -6923,7 +6923,7 @@ exports[`regression tests > given a group of selected elements with an element t "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -7253,7 +7253,7 @@ exports[`regression tests > given a selected element A and a not selected elemen "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -7530,7 +7530,7 @@ exports[`regression tests > given selected element A with lower z-index than uns "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -7765,7 +7765,7 @@ exports[`regression tests > given selected element A with lower z-index than uns "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -8001,7 +8001,7 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -8182,7 +8182,7 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -8363,7 +8363,7 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -8544,7 +8544,7 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1` "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -8768,7 +8768,7 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`] "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -8992,7 +8992,7 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -9187,7 +9187,7 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1` "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -9411,7 +9411,7 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -9592,7 +9592,7 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`] "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -9816,7 +9816,7 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -9997,7 +9997,7 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -10192,7 +10192,7 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -10377,7 +10377,7 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id6": true, "id8": true, @@ -10871,7 +10871,7 @@ exports[`regression tests > noop interaction after undo shouldn't create history "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -11147,7 +11147,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = ` "scrollX": "-6.25000", "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -11276,7 +11276,7 @@ exports[`regression tests > shift click on selected element should deselect it o "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -11477,7 +11477,7 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -11790,7 +11790,7 @@ exports[`regression tests > should group elements and ungroup them > [end of tes "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -12204,7 +12204,7 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, "id1": true, @@ -12816,7 +12816,7 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a "scrollX": 60, "scrollY": 60, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -12945,7 +12945,7 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`] "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -13531,7 +13531,7 @@ exports[`regression tests > switches from group of selected elements to another "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -13869,7 +13869,7 @@ exports[`regression tests > switches selected element on pointer down > [end of "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id0": true, }, @@ -14133,7 +14133,7 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`] "scrollX": 20, "scrollY": "-18.53553", "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -14260,7 +14260,7 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": { "id1": true, }, @@ -14640,7 +14640,7 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -14770,7 +14770,7 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = ` "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, diff --git a/packages/excalidraw/tests/clipboard.test.tsx b/packages/excalidraw/tests/clipboard.test.tsx index 7d0e3906c..7386b360c 100644 --- a/packages/excalidraw/tests/clipboard.test.tsx +++ b/packages/excalidraw/tests/clipboard.test.tsx @@ -1,11 +1,11 @@ import React from "react"; import { vi } from "vitest"; -import { getLineHeightInPx } from "@excalidraw/element/textMeasurements"; +import { getLineHeightInPx } from "@excalidraw/element"; import { KEYS, arrayToMap, getLineHeight } from "@excalidraw/common"; -import { getElementBounds } from "@excalidraw/element/bounds"; +import { getElementBounds } from "@excalidraw/element"; import { createPasteEvent, serializeAsClipboardJSON } from "../clipboard"; diff --git a/packages/excalidraw/tests/data/reconcile.test.ts b/packages/excalidraw/tests/data/reconcile.test.ts index 1c0bf13db..362d167e4 100644 --- a/packages/excalidraw/tests/data/reconcile.test.ts +++ b/packages/excalidraw/tests/data/reconcile.test.ts @@ -1,4 +1,4 @@ -import { syncInvalidIndices } from "@excalidraw/element/fractionalIndex"; +import { syncInvalidIndices } from "@excalidraw/element"; import { randomInteger, cloneJSON } from "@excalidraw/common"; diff --git a/packages/excalidraw/tests/data/restore.test.ts b/packages/excalidraw/tests/data/restore.test.ts index 4b414bbf1..d06daafba 100644 --- a/packages/excalidraw/tests/data/restore.test.ts +++ b/packages/excalidraw/tests/data/restore.test.ts @@ -3,8 +3,8 @@ import { vi } from "vitest"; import { DEFAULT_SIDEBAR, FONT_FAMILY, ROUNDNESS } from "@excalidraw/common"; -import { newElementWith } from "@excalidraw/element/mutateElement"; -import * as sizeHelpers from "@excalidraw/element/sizeHelpers"; +import { newElementWith } from "@excalidraw/element"; +import * as sizeHelpers from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/tests/flip.test.tsx b/packages/excalidraw/tests/flip.test.tsx index 22a6c67f8..d9b2731cc 100644 --- a/packages/excalidraw/tests/flip.test.tsx +++ b/packages/excalidraw/tests/flip.test.tsx @@ -5,9 +5,9 @@ import { ROUNDNESS, KEYS, arrayToMap, cloneJSON } from "@excalidraw/common"; import { pointFrom, type Radians } from "@excalidraw/math"; -import { getBoundTextElementPosition } from "@excalidraw/element/textElement"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; -import { newLinearElement } from "@excalidraw/element/newElement"; +import { getBoundTextElementPosition } from "@excalidraw/element"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; +import { newLinearElement } from "@excalidraw/element"; import type { LocalPoint } from "@excalidraw/math"; diff --git a/packages/excalidraw/tests/helpers/api.ts b/packages/excalidraw/tests/helpers/api.ts index 5ac1bca8c..9c1ac9913 100644 --- a/packages/excalidraw/tests/helpers/api.ts +++ b/packages/excalidraw/tests/helpers/api.ts @@ -17,11 +17,11 @@ import { newLinearElement, newMagicFrameElement, newTextElement, -} from "@excalidraw/element/newElement"; +} from "@excalidraw/element"; -import { isLinearElementType } from "@excalidraw/element/typeChecks"; -import { getSelectedElements } from "@excalidraw/element/selection"; -import { selectGroupsForSelectedElements } from "@excalidraw/element/groups"; +import { isLinearElementType } from "@excalidraw/element"; +import { getSelectedElements } from "@excalidraw/element"; +import { selectGroupsForSelectedElements } from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/excalidraw/tests/helpers/ui.ts b/packages/excalidraw/tests/helpers/ui.ts index d60d488f1..abfadf331 100644 --- a/packages/excalidraw/tests/helpers/ui.ts +++ b/packages/excalidraw/tests/helpers/ui.ts @@ -1,10 +1,7 @@ import { pointFrom, pointRotateRads } from "@excalidraw/math"; -import { - getCommonBounds, - getElementPointsCoords, -} from "@excalidraw/element/bounds"; -import { cropElement } from "@excalidraw/element/cropElement"; +import { getCommonBounds, getElementPointsCoords } from "@excalidraw/element"; +import { cropElement } from "@excalidraw/element"; import { getTransformHandles, getTransformHandlesFromCoords, @@ -12,18 +9,18 @@ import { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, type TransformHandle, type TransformHandleDirection, -} from "@excalidraw/element/transformHandles"; +} from "@excalidraw/element"; import { isLinearElement, isFreeDrawElement, isTextElement, isFrameLikeElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { KEYS, arrayToMap, elementCenterPoint } from "@excalidraw/common"; import type { GlobalPoint, LocalPoint, Radians } from "@excalidraw/math"; -import type { TransformHandleType } from "@excalidraw/element/transformHandles"; +import type { TransformHandleType } from "@excalidraw/element"; import type { ExcalidrawElement, ExcalidrawLinearElement, diff --git a/packages/excalidraw/tests/history.test.tsx b/packages/excalidraw/tests/history.test.tsx index f8e01f469..328dab7c4 100644 --- a/packages/excalidraw/tests/history.test.tsx +++ b/packages/excalidraw/tests/history.test.tsx @@ -8,7 +8,7 @@ import { import { vi } from "vitest"; import { pointFrom } from "@excalidraw/math"; -import { newElementWith } from "@excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element"; import { EXPORT_DATA_TYPES, @@ -23,9 +23,9 @@ import { import "@excalidraw/utils/test-utils"; -import { ElementsDelta, AppStateDelta } from "@excalidraw/element/delta"; +import { ElementsDelta, AppStateDelta } from "@excalidraw/element"; -import { CaptureUpdateAction, StoreDelta } from "@excalidraw/element/store"; +import { CaptureUpdateAction, StoreDelta } from "@excalidraw/element"; import type { LocalPoint, Radians } from "@excalidraw/math"; diff --git a/packages/excalidraw/tests/lasso.test.tsx b/packages/excalidraw/tests/lasso.test.tsx index aa32b13d6..7e67d9b5b 100644 --- a/packages/excalidraw/tests/lasso.test.tsx +++ b/packages/excalidraw/tests/lasso.test.tsx @@ -22,7 +22,7 @@ import { type ElementsSegmentsMap, } from "@excalidraw/math"; -import { getElementLineSegments } from "@excalidraw/element/bounds"; +import { getElementLineSegments } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/tests/library.test.tsx b/packages/excalidraw/tests/library.test.tsx index d2b6c13c8..1c9b7a53a 100644 --- a/packages/excalidraw/tests/library.test.tsx +++ b/packages/excalidraw/tests/library.test.tsx @@ -4,7 +4,7 @@ import { vi } from "vitest"; import { MIME_TYPES, ORIG_ID } from "@excalidraw/common"; -import { getCommonBoundingBox } from "@excalidraw/element/bounds"; +import { getCommonBoundingBox } from "@excalidraw/element"; import type { ExcalidrawGenericElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/tests/move.test.tsx b/packages/excalidraw/tests/move.test.tsx index 71a489561..1a02ba1db 100644 --- a/packages/excalidraw/tests/move.test.tsx +++ b/packages/excalidraw/tests/move.test.tsx @@ -1,7 +1,7 @@ import React from "react"; import { vi } from "vitest"; -import { bindOrUnbindLinearElement } from "@excalidraw/element/binding"; +import { bindOrUnbindLinearElement } from "@excalidraw/element"; import { KEYS, reseed } from "@excalidraw/common"; diff --git a/packages/excalidraw/tests/search.test.tsx b/packages/excalidraw/tests/search.test.tsx index 3a42cff62..b9a60bf59 100644 --- a/packages/excalidraw/tests/search.test.tsx +++ b/packages/excalidraw/tests/search.test.tsx @@ -7,7 +7,10 @@ import { KEYS, } from "@excalidraw/common"; -import type { ExcalidrawTextElement } from "@excalidraw/element/types"; +import type { + ExcalidrawFrameLikeElement, + ExcalidrawTextElement, +} from "@excalidraw/element/types"; import { Excalidraw } from "../index"; @@ -97,17 +100,17 @@ describe("search", () => { updateTextEditor(searchInput, "test"); await waitFor(() => { - expect(h.app.state.searchMatches.length).toBe(2); - expect(h.app.state.searchMatches[0].focus).toBe(true); + expect(h.app.state.searchMatches?.matches.length).toBe(2); + expect(h.app.state.searchMatches?.matches[0].focus).toBe(true); }); Keyboard.keyPress(KEYS.ENTER, searchInput); - expect(h.app.state.searchMatches[0].focus).toBe(false); - expect(h.app.state.searchMatches[1].focus).toBe(true); + expect(h.app.state.searchMatches?.matches[0].focus).toBe(false); + expect(h.app.state.searchMatches?.matches[1].focus).toBe(true); Keyboard.keyPress(KEYS.ENTER, searchInput); - expect(h.app.state.searchMatches[0].focus).toBe(true); - expect(h.app.state.searchMatches[1].focus).toBe(false); + expect(h.app.state.searchMatches?.matches[0].focus).toBe(true); + expect(h.app.state.searchMatches?.matches[1].focus).toBe(false); }); it("should match text split across multiple lines", async () => { @@ -142,15 +145,53 @@ describe("search", () => { updateTextEditor(searchInput, "test"); await waitFor(() => { - expect(h.app.state.searchMatches.length).toBe(1); - expect(h.app.state.searchMatches[0]?.matchedLines?.length).toBe(4); + expect(h.app.state.searchMatches?.matches.length).toBe(1); + expect(h.app.state.searchMatches?.matches[0]?.matchedLines?.length).toBe( + 4, + ); }); updateTextEditor(searchInput, "ext spli"); await waitFor(() => { - expect(h.app.state.searchMatches.length).toBe(1); - expect(h.app.state.searchMatches[0]?.matchedLines?.length).toBe(6); + expect(h.app.state.searchMatches?.matches.length).toBe(1); + expect(h.app.state.searchMatches?.matches[0]?.matchedLines?.length).toBe( + 6, + ); + }); + }); + + it("should match frame names", async () => { + const scrollIntoViewMock = jest.fn(); + window.HTMLElement.prototype.scrollIntoView = scrollIntoViewMock; + + API.setElements([ + API.createElement({ + type: "frame", + }), + ]); + + API.updateElement(h.elements[0] as ExcalidrawFrameLikeElement, { + name: "Frame: name test for frame, yes, frame!", + }); + + expect(h.app.state.openSidebar).toBeNull(); + + Keyboard.withModifierKeys({ ctrl: true }, () => { + Keyboard.keyPress(KEYS.F); + }); + expect(h.app.state.openSidebar).not.toBeNull(); + expect(h.app.state.openSidebar?.name).toBe(DEFAULT_SIDEBAR.name); + expect(h.app.state.openSidebar?.tab).toBe(CANVAS_SEARCH_TAB); + + const searchInput = await querySearchInput(); + + expect(searchInput.matches(":focus")).toBe(true); + + updateTextEditor(searchInput, "frame"); + + await waitFor(() => { + expect(h.app.state.searchMatches?.matches.length).toBe(3); }); }); }); diff --git a/packages/excalidraw/tests/test-utils.ts b/packages/excalidraw/tests/test-utils.ts index ea0f66e44..bc137a1d8 100644 --- a/packages/excalidraw/tests/test-utils.ts +++ b/packages/excalidraw/tests/test-utils.ts @@ -11,7 +11,7 @@ import ansi from "ansicolor"; import { ORIG_ID, arrayToMap } from "@excalidraw/common"; -import { getSelectedElements } from "@excalidraw/element/selection"; +import { getSelectedElements } from "@excalidraw/element"; import type { ExcalidrawElement } from "@excalidraw/element/types"; diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.ts index 146906d50..ea9396015 100644 --- a/packages/excalidraw/types.ts +++ b/packages/excalidraw/types.ts @@ -5,11 +5,11 @@ import type { MIME_TYPES, } from "@excalidraw/common"; -import type { SuggestedBinding } from "@excalidraw/element/binding"; +import type { SuggestedBinding } from "@excalidraw/element"; -import type { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; +import type { LinearElementEditor } from "@excalidraw/element"; -import type { MaybeTransformHandleType } from "@excalidraw/element/transformHandles"; +import type { MaybeTransformHandleType } from "@excalidraw/element"; import type { PointerType, @@ -47,7 +47,7 @@ import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement, -} from "@excalidraw/element/store"; +} from "@excalidraw/element"; import type { Action } from "./actions/types"; import type { Spreadsheet } from "./charts"; @@ -432,10 +432,14 @@ export interface AppState { isCropping: boolean; croppingElementId: ExcalidrawElement["id"] | null; - searchMatches: readonly SearchMatch[]; + /** null if no search matches found / search closed */ + searchMatches: Readonly<{ + focusedId: ExcalidrawElement["id"] | null; + matches: readonly SearchMatch[]; + }> | null; } -type SearchMatch = { +export type SearchMatch = { id: string; focus: boolean; matchedLines: { @@ -443,6 +447,7 @@ type SearchMatch = { offsetY: number; width: number; height: number; + showOnCanvas: boolean; }[]; }; diff --git a/packages/excalidraw/visualdebug.ts b/packages/excalidraw/visualdebug.ts index 9ad1490d1..961fa919f 100644 --- a/packages/excalidraw/visualdebug.ts +++ b/packages/excalidraw/visualdebug.ts @@ -6,12 +6,12 @@ import { type LocalPoint, } from "@excalidraw/math"; -import { isBounds } from "@excalidraw/element/typeChecks"; +import { isBounds } from "@excalidraw/element"; import type { Curve } from "@excalidraw/math"; import type { LineSegment } from "@excalidraw/utils"; -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; // The global data holder to collect the debug operations declare global { diff --git a/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx b/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx index 0ba1960d6..fb142057f 100644 --- a/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx +++ b/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx @@ -1,7 +1,7 @@ import { queryByText } from "@testing-library/react"; import { pointFrom } from "@excalidraw/math"; -import { getOriginalContainerHeightFromCache } from "@excalidraw/element/containerCache"; +import { getOriginalContainerHeightFromCache } from "@excalidraw/element"; import { CODES, diff --git a/packages/excalidraw/wysiwyg/textWysiwyg.tsx b/packages/excalidraw/wysiwyg/textWysiwyg.tsx index f9c4536d6..2255d8a5a 100644 --- a/packages/excalidraw/wysiwyg/textWysiwyg.tsx +++ b/packages/excalidraw/wysiwyg/textWysiwyg.tsx @@ -12,10 +12,10 @@ import { import { originalContainerCache, updateOriginalContainerCache, -} from "@excalidraw/element/containerCache"; +} from "@excalidraw/element"; -import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; -import { bumpVersion } from "@excalidraw/element/mutateElement"; +import { LinearElementEditor } from "@excalidraw/element"; +import { bumpVersion } from "@excalidraw/element"; import { getBoundTextElementId, getContainerElement, @@ -26,15 +26,15 @@ import { computeContainerDimensionForBoundText, computeBoundTextPosition, getBoundTextElement, -} from "@excalidraw/element/textElement"; -import { getTextWidth } from "@excalidraw/element/textMeasurements"; -import { normalizeText } from "@excalidraw/element/textMeasurements"; -import { wrapText } from "@excalidraw/element/textWrapping"; +} from "@excalidraw/element"; +import { getTextWidth } from "@excalidraw/element"; +import { normalizeText } from "@excalidraw/element"; +import { wrapText } from "@excalidraw/element"; import { isArrowElement, isBoundToContainer, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import type { ExcalidrawElement, diff --git a/packages/math/src/curve.ts b/packages/math/src/curve.ts index ec2d1afcd..359caee09 100644 --- a/packages/math/src/curve.ts +++ b/packages/math/src/curve.ts @@ -1,4 +1,4 @@ -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; import { isPoint, pointDistance, pointFrom } from "./point"; import { rectangle, rectangleIntersectLineSegment } from "./rectangle"; diff --git a/packages/utils/src/bbox.ts b/packages/utils/src/bbox.ts index a56128156..07dd8907a 100644 --- a/packages/utils/src/bbox.ts +++ b/packages/utils/src/bbox.ts @@ -5,7 +5,7 @@ import { type LocalPoint, } from "@excalidraw/math"; -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; export type LineSegment

= [P, P]; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 58830b356..a6207e9c3 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,4 +1,4 @@ export * from "./export"; export * from "./withinBounds"; export * from "./bbox"; -export { getCommonBounds } from "@excalidraw/element/bounds"; +export { getCommonBounds } from "@excalidraw/element"; diff --git a/packages/utils/src/shape.ts b/packages/utils/src/shape.ts index b750c232e..5d50f4b47 100644 --- a/packages/utils/src/shape.ts +++ b/packages/utils/src/shape.ts @@ -34,7 +34,7 @@ import { type LocalPoint, } from "@excalidraw/math"; -import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; +import { getElementAbsoluteCoords } from "@excalidraw/element"; import type { ElementsMap, diff --git a/packages/utils/src/withinBounds.ts b/packages/utils/src/withinBounds.ts index 0e1cf38a6..d635655fc 100644 --- a/packages/utils/src/withinBounds.ts +++ b/packages/utils/src/withinBounds.ts @@ -1,12 +1,12 @@ import { arrayToMap } from "@excalidraw/common"; -import { getElementBounds } from "@excalidraw/element/bounds"; +import { getElementBounds } from "@excalidraw/element"; import { isArrowElement, isExcalidrawElement, isFreeDrawElement, isLinearElement, isTextElement, -} from "@excalidraw/element/typeChecks"; +} from "@excalidraw/element"; import { rangeIncludesValue, pointFrom, @@ -14,7 +14,7 @@ import { rangeInclusive, } from "@excalidraw/math"; -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; import type { ExcalidrawElement, ExcalidrawFreeDrawElement, diff --git a/packages/utils/tests/__snapshots__/export.test.ts.snap b/packages/utils/tests/__snapshots__/export.test.ts.snap index 91108a600..baa5e3d31 100644 --- a/packages/utils/tests/__snapshots__/export.test.ts.snap +++ b/packages/utils/tests/__snapshots__/export.test.ts.snap @@ -85,7 +85,7 @@ exports[`exportToSvg > with default arguments 1`] = ` "scrollX": 0, "scrollY": 0, "scrolledOutside": false, - "searchMatches": [], + "searchMatches": null, "selectedElementIds": {}, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, diff --git a/packages/utils/tests/withinBounds.test.ts b/packages/utils/tests/withinBounds.test.ts index d1af75de8..b05b5525b 100644 --- a/packages/utils/tests/withinBounds.test.ts +++ b/packages/utils/tests/withinBounds.test.ts @@ -1,6 +1,6 @@ import { API } from "@excalidraw/excalidraw/tests/helpers/api"; -import type { Bounds } from "@excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element"; import { elementPartiallyOverlapsWithOrContainsBBox,