feat: use @excalidraw/utils as a workspace in the codebase

This commit is contained in:
Aakansha Doshi 2024-05-03 15:54:06 +05:30
parent d9bbf1eda6
commit 6a1477a55c
12 changed files with 151 additions and 73 deletions

View file

@ -405,7 +405,7 @@ import {
import { Emitter } from "../emitter";
import { ElementCanvasButtons } from "../element/ElementCanvasButtons";
import { MagicCacheData, diagramToHTML } from "../data/magic";
import { exportToBlob } from "../../utils/export";
import { exportToBlob } from "@excalidraw/utils";
import { COLOR_PALETTE } from "../colors";
import { ElementCanvasButton } from "./MagicButton";
import { MagicIcon, copyIcon, fullscreenIcon } from "./icons";

View file

@ -23,7 +23,7 @@ import { nativeFileSystemSupported } from "../data/filesystem";
import { NonDeletedExcalidrawElement } from "../element/types";
import { t } from "../i18n";
import { isSomeElementSelected } from "../scene";
import { exportToCanvas } from "../../utils/export";
import { exportToCanvas } from "@excalidraw/utils";
import { copyIcon, downloadIcon, helpIcon } from "./icons";
import { Dialog } from "./Dialog";

View file

@ -6,7 +6,7 @@ import { t } from "../i18n";
import Trans from "./Trans";
import { LibraryItems, LibraryItem, UIAppState } from "../types";
import { exportToCanvas, exportToSvg } from "../../utils/export";
import { exportToCanvas, exportToSvg } from "@excalidraw/utils";
import {
EDITOR_LS_KEYS,
EXPORT_DATA_TYPES,

View file

@ -23,7 +23,10 @@ import { getElementsWithinSelection, getSelectedElements } from "./scene";
import { getElementsInGroup, selectGroupsFromGivenElements } from "./groups";
import type { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
import { getElementLineSegments } from "./element/bounds";
import { doLineSegmentsIntersect, elementsOverlappingBBox } from "../utils/";
import {
doLineSegmentsIntersect,
elementsOverlappingBBox,
} from "@excalidraw/utils";
import { isFrameElement, isFrameLikeElement } from "./element/typeChecks";
import { ReadonlySetLike } from "./utility-types";

View file

@ -2,7 +2,7 @@ import { atom, useAtom } from "jotai";
import { useEffect, useState } from "react";
import { COLOR_PALETTE } from "../colors";
import { jotaiScope } from "../jotai";
import { exportToSvg } from "../../utils/export";
import { exportToSvg } from "@excalidraw/utils";
import { LibraryItem } from "../types";
export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;

View file

@ -227,7 +227,7 @@ export {
exportToBlob,
exportToSvg,
exportToClipboard,
} from "../utils/export";
} from "@excalidraw/utils";
export { serializeAsJSON, serializeLibraryAsJSON } from "./data/json";
export {
@ -283,4 +283,4 @@ export {
elementsOverlappingBBox,
isElementInsideBBox,
elementPartiallyOverlapsWithOrContainsBBox,
} from "../utils/withinBounds";
} from "@excalidraw/utils";

View file

@ -59,6 +59,7 @@
"@braintree/sanitize-url": "6.0.2",
"@excalidraw/laser-pointer": "1.3.1",
"@excalidraw/mermaid-to-excalidraw": "0.3.0",
"@excalidraw/utils": "workspace:^",
"@excalidraw/random-username": "1.1.0",
"@radix-ui/react-popover": "1.0.3",
"@radix-ui/react-tabs": "1.0.2",

View file

@ -1,5 +1,5 @@
import { Bounds } from "../excalidraw/element/bounds";
import { Point } from "../excalidraw/types";
import type { Bounds } from "../excalidraw/element/bounds";
import type { Point } from "../excalidraw/types";
export type LineSegment = [Point, Point];

View file

@ -1,4 +1,4 @@
import { Point, Polygon, GeometricShape } from "./geometry/shape";
import type { Point, Polygon, GeometricShape } from "./geometry/shape";
import {
pointInEllipse,
pointInPolygon,

View file

@ -3,12 +3,6 @@ import {
exportToSvg as _exportToSvg,
} from "../excalidraw/scene/export";
import { getDefaultAppState } from "../excalidraw/appState";
import { AppState, BinaryFiles } from "../excalidraw/types";
import {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeleted,
} from "../excalidraw/element/types";
import { restore } from "../excalidraw/data/restore";
import { MIME_TYPES } from "../excalidraw/constants";
import { encodePngMetadata } from "../excalidraw/data/image";
@ -19,6 +13,13 @@ import {
copyToClipboard,
} from "../excalidraw/clipboard";
import type { AppState, BinaryFiles } from "../excalidraw/types";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeleted,
} from "../excalidraw/element/types";
export { MIME_TYPES };
type ExportOpts = {