diff --git a/packages/common/global.d.ts b/packages/common/global.d.ts
index 16ade7a7df..56b7116ce9 100644
--- a/packages/common/global.d.ts
+++ b/packages/common/global.d.ts
@@ -1,3 +1,6 @@
///
-import "@excalidraw/excalidraw/global";
-import "@excalidraw/excalidraw/css";
+
+interface Window {
+ // set by the host app to override the source recorded in exported data
+ EXCALIDRAW_EXPORT_SOURCE: string;
+}
diff --git a/packages/common/package.json b/packages/common/package.json
index 94c1e99c50..dbb657c8bf 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -81,8 +81,6 @@
"tinycolor2": "1.6.0"
},
"devDependencies": {
- "@excalidraw/element": "workspace:*",
- "@excalidraw/excalidraw": "workspace:*",
"@types/tinycolor2": "1.4.6"
}
}
diff --git a/packages/common/src/appEventBus.ts b/packages/common/src/appEventBus.ts
index e561419fed..a528b31453 100644
--- a/packages/common/src/appEventBus.ts
+++ b/packages/common/src/appEventBus.ts
@@ -1,8 +1,8 @@
-import type { UnsubscribeCallback } from "@excalidraw/excalidraw/types";
-
import { Emitter } from "./emitter";
import { isProdEnv } from "./utils";
+import type { UnsubscribeCallback } from "./types";
+
export type AppEventPayloadMap = Record;
export type AppEventBehavior = {
diff --git a/packages/common/src/constants.ts b/packages/common/src/constants.ts
index cf04e8a31c..2e503713b3 100644
--- a/packages/common/src/constants.ts
+++ b/packages/common/src/constants.ts
@@ -1,15 +1,15 @@
-import type {
- ExcalidrawElement,
- FontFamilyValues,
-} from "@excalidraw/element/types";
-import type {
- AppProps,
- AppState,
- NormalizedZoomValue,
-} from "@excalidraw/excalidraw/types";
-
import { COLOR_PALETTE } from "./colors";
+import type {
+ ArrowType,
+ FillStyle,
+ FontFamilyValues,
+ NormalizedZoomValue,
+ RoundnessType,
+ StrokeStyle,
+ Zoom,
+} from "./types";
+
export { DEFAULT_STICKY_NOTE_BG } from "./colors";
export const supportsResizeObserver =
@@ -210,13 +210,13 @@ export const THEME = {
export const DARK_THEME_FILTER = "invert(93%) hue-rotate(180deg)";
export const FRAME_STYLE = {
- strokeColor: "#bbb" as ExcalidrawElement["strokeColor"],
- strokeWidth: 2 as ExcalidrawElement["strokeWidth"],
- strokeStyle: "solid" as ExcalidrawElement["strokeStyle"],
- fillStyle: "solid" as ExcalidrawElement["fillStyle"],
- roughness: 0 as ExcalidrawElement["roughness"],
- roundness: null as ExcalidrawElement["roundness"],
- backgroundColor: "transparent" as ExcalidrawElement["backgroundColor"],
+ strokeColor: "#bbb" as string,
+ strokeWidth: 2 as number,
+ strokeStyle: "solid" as StrokeStyle,
+ fillStyle: "solid" as FillStyle,
+ roughness: 0 as number,
+ roundness: null as null | { type: RoundnessType; value?: number },
+ backgroundColor: "transparent" as string,
radius: 8,
nameOffsetY: 3,
nameColorLightTheme: "#999999",
@@ -369,7 +369,7 @@ export const ZOOM_STEP = 0.1;
export const MIN_ZOOM = 0.1;
export const MAX_ZOOM = 30;
/** 100% zoom, for computations that have no editor zoom to go by */
-export const DEFAULT_ZOOM: AppState["zoom"] = Object.freeze({
+export const DEFAULT_ZOOM: Zoom = Object.freeze({
value: 1 as NormalizedZoomValue,
});
export const HYPERLINK_TOOLTIP_DELAY = 300;
@@ -387,31 +387,11 @@ export const URL_HASH_KEYS = {
addLibrary: "addLibrary",
} as const;
-export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = {
- canvasActions: {
- changeViewBackgroundColor: true,
- clearCanvas: true,
- export: { saveFileToDisk: true },
- loadScene: true,
- saveToActiveFile: true,
- toggleTheme: null,
- saveAsImage: true,
- },
- tools: {
- image: true,
- },
-};
-
export const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
export const EXPORT_SCALES = [1, 2, 3];
export const DEFAULT_EXPORT_PADDING = 10; // px
-export const DEFAULT_IMAGE_OPTIONS: AppProps["imageOptions"] = {
- maxWidthOrHeight: 1440,
- maxFileSizeBytes: 4 * 1024 * 1024,
-};
-
export const SVG_NS = "http://www.w3.org/2000/svg";
export const SVG_DOCUMENT_PREAMBLE = `
@@ -484,7 +464,7 @@ export const STROKE_WIDTH_KEYS: readonly StrokeWidthKey[] = [
];
export const STROKE_WIDTH: Readonly<
- Record
+ Record
> = {
thin: 1,
medium: 2,
@@ -498,7 +478,7 @@ export const STROKE_WIDTH: Readonly<
//
// note that in the UI, STROKE_WIDTH.thin == FREEDRAW_STROKE_WIDTH.thin still
export const FREEDRAW_STROKE_WIDTH: Readonly<
- Record
+ Record
> = {
thin: 0.5,
medium: 1,
@@ -507,9 +487,9 @@ export const FREEDRAW_STROKE_WIDTH: Readonly<
};
export const getStrokeWidthByKey = (
- elementType: ExcalidrawElement["type"],
+ elementType: string,
strokeWidthKey: StrokeWidthKey,
-): ExcalidrawElement["strokeWidth"] => {
+): number => {
return elementType === "freedraw"
? FREEDRAW_STROKE_WIDTH[strokeWidthKey]
: STROKE_WIDTH[strokeWidthKey];
@@ -518,14 +498,14 @@ export const getStrokeWidthByKey = (
export const DEFAULT_ELEMENT_STROKE_WIDTH_KEY: StrokeWidthKey = "medium";
export const DEFAULT_ELEMENT_PROPS: {
- strokeColor: ExcalidrawElement["strokeColor"];
- backgroundColor: ExcalidrawElement["backgroundColor"];
- fillStyle: ExcalidrawElement["fillStyle"];
- strokeWidth: ExcalidrawElement["strokeWidth"];
- strokeStyle: ExcalidrawElement["strokeStyle"];
- roughness: ExcalidrawElement["roughness"];
- opacity: ExcalidrawElement["opacity"];
- locked: ExcalidrawElement["locked"];
+ strokeColor: string;
+ backgroundColor: string;
+ fillStyle: FillStyle;
+ strokeWidth: number;
+ strokeStyle: StrokeStyle;
+ roughness: number;
+ opacity: number;
+ locked: boolean;
} = {
strokeColor: COLOR_PALETTE.black,
backgroundColor: COLOR_PALETTE.transparent,
@@ -593,7 +573,7 @@ export const STATS_PANELS = { generalStats: 1, elementProperties: 2 } as const;
export const MIN_WIDTH_OR_HEIGHT = 1;
-export const ARROW_TYPE: { [T in AppState["currentItemArrowType"]]: T } = {
+export const ARROW_TYPE: { [T in ArrowType]: T } = {
sharp: "sharp",
round: "round",
elbow: "elbow",
diff --git a/packages/common/src/emitter.ts b/packages/common/src/emitter.ts
index 7c069a5a05..938269728e 100644
--- a/packages/common/src/emitter.ts
+++ b/packages/common/src/emitter.ts
@@ -1,4 +1,4 @@
-import type { UnsubscribeCallback } from "@excalidraw/excalidraw/types";
+import type { UnsubscribeCallback } from "./types";
type Subscriber = (...payload: T) => void;
diff --git a/packages/common/src/font-metadata.ts b/packages/common/src/font-metadata.ts
index 7382aa70f0..9df3fd2cfb 100644
--- a/packages/common/src/font-metadata.ts
+++ b/packages/common/src/font-metadata.ts
@@ -1,10 +1,7 @@
-import type {
- ExcalidrawTextElement,
- FontFamilyValues,
-} from "@excalidraw/element/types";
-
import { FONT_FAMILY, FONT_FAMILY_FALLBACKS } from "./constants";
+import type { FontFamilyValues, UnitlessLineHeight } from "./types";
+
/**
* Encapsulates font metrics with additional font metadata.
* */
@@ -153,8 +150,8 @@ export const LOCAL_FONT_PROTOCOL = "local:";
* Calculates vertical offset for a text with alphabetic baseline.
*/
export const getVerticalOffset = (
- fontFamily: ExcalidrawTextElement["fontFamily"],
- fontSize: ExcalidrawTextElement["fontSize"],
+ fontFamily: FontFamilyValues,
+ fontSize: number,
lineHeightPx: number,
) => {
const { unitsPerEm, ascender, descender } =
@@ -177,5 +174,5 @@ export const getLineHeight = (fontFamily: FontFamilyValues) => {
FONT_METADATA[fontFamily]?.metrics ||
FONT_METADATA[FONT_FAMILY.Excalifont].metrics;
- return lineHeight as ExcalidrawTextElement["lineHeight"];
+ return lineHeight as UnitlessLineHeight;
};
diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts
index 022f7714bb..df5dec7133 100644
--- a/packages/common/src/index.ts
+++ b/packages/common/src/index.ts
@@ -10,6 +10,7 @@ export * from "./promise-pool";
export * from "./random";
export * from "./url";
export * from "./utils";
+export * from "./types";
export * from "./emitter";
export * from "./appEventBus";
export * from "./editorInterface";
diff --git a/packages/common/src/points.ts b/packages/common/src/points.ts
index 5eac4fc52d..9176efa9e4 100644
--- a/packages/common/src/points.ts
+++ b/packages/common/src/points.ts
@@ -5,7 +5,7 @@ import {
type LocalPoint,
} from "@excalidraw/math";
-import type { NullableGridSize } from "@excalidraw/excalidraw/types";
+import type { NullableGridSize } from "./types";
export const getSizeFromPoints = (
points: readonly (GlobalPoint | LocalPoint)[],
diff --git a/packages/common/src/types.ts b/packages/common/src/types.ts
new file mode 100644
index 0000000000..4e3625f73b
--- /dev/null
+++ b/packages/common/src/types.ts
@@ -0,0 +1,25 @@
+// Basic element and editor types that every package shares. They live here,
+// at the bottom of the package graph, and are re-exported from
+// `@excalidraw/element/types` and `@excalidraw/excalidraw/types`.
+
+import type { FONT_FAMILY, ROUNDNESS } from "./constants";
+import type { MakeBrand, ValueOf } from "./utility-types";
+
+export type FontFamilyKeys = keyof typeof FONT_FAMILY;
+export type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
+export type FontString = string & { _brand: "fontString" };
+/** unitless text line height (multiplier of the font size) */
+export type UnitlessLineHeight = number & { _brand: "unitlessLineHeight" };
+
+export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
+export type StrokeStyle = "solid" | "dashed" | "dotted";
+export type RoundnessType = ValueOf;
+export type ArrowType = "sharp" | "round" | "elbow";
+
+export type NormalizedZoomValue = number & { _brand: "normalizedZoom" };
+export type Zoom = Readonly<{
+ value: NormalizedZoomValue;
+}>;
+export type NullableGridSize = (number & MakeBrand<"NullableGridSize">) | null;
+
+export type UnsubscribeCallback = () => void;
diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts
index be2e4b1384..e45aeca276 100644
--- a/packages/common/src/utils.ts
+++ b/packages/common/src/utils.ts
@@ -2,16 +2,6 @@ import { average } from "@excalidraw/math";
import type { GlobalCoord } from "@excalidraw/math";
-import type { FontFamilyValues, FontString } from "@excalidraw/element/types";
-
-import type {
- ActiveTool,
- AppState,
- ToolType,
- UnsubscribeCallback,
- Zoom,
-} from "@excalidraw/excalidraw/types";
-
import {
DEFAULT_VERSION,
ENV,
@@ -21,6 +11,12 @@ import {
} from "./constants";
import type { MaybePromise, ResolutionType } from "./utility-types";
+import type {
+ FontFamilyValues,
+ FontString,
+ UnsubscribeCallback,
+ Zoom,
+} from "./types";
import type { EVENT } from "./constants";
@@ -290,43 +286,6 @@ export const removeSelection = () => {
export const distance = (x: number, y: number) => Math.abs(x - y);
-export const isSelectionLikeTool = (type: ToolType | "custom") => {
- return type === "selection" || type === "lasso";
-};
-
-export const updateActiveTool = (
- appState: Pick,
- data: ((
- | {
- type: ToolType;
- }
- | { type: "custom"; customType: string }
- ) & { locked?: boolean; fromSelection?: boolean }) & {
- lastActiveTool?: ActiveTool | null;
- },
-): AppState["activeTool"] => {
- if (data.type === "custom") {
- return {
- ...appState.activeTool,
- type: "custom",
- customType: data.customType,
- locked: data.locked ?? appState.activeTool.locked,
- };
- }
-
- return {
- ...appState.activeTool,
- lastActiveTool:
- data.lastActiveTool === undefined
- ? appState.activeTool.lastActiveTool
- : data.lastActiveTool,
- type: data.type,
- customType: null,
- locked: data.locked ?? appState.activeTool.locked,
- fromSelection: data.fromSelection ?? false,
- };
-};
-
export const isFullScreen = () =>
document.fullscreenElement?.nodeName === "HTML";
diff --git a/packages/element/src/types.ts b/packages/element/src/types.ts
index 68891be19f..bbcd3c142c 100644
--- a/packages/element/src/types.ts
+++ b/packages/element/src/types.ts
@@ -1,9 +1,14 @@
import type { LocalPoint, Radians } from "@excalidraw/math";
import type {
- FONT_FAMILY,
- ROUNDNESS,
+ FillStyle,
+ FontFamilyKeys,
+ FontFamilyValues,
+ FontString,
+ RoundnessType,
+ StrokeStyle,
TEXT_ALIGN,
+ UnitlessLineHeight,
THEME,
VERTICAL_ALIGN,
} from "@excalidraw/common";
@@ -12,20 +17,22 @@ import type {
MakeBrand,
MarkNonNullable,
Merge,
- ValueOf,
} from "@excalidraw/common/utility-types";
+export type {
+ FillStyle,
+ FontFamilyKeys,
+ FontFamilyValues,
+ FontString,
+ RoundnessType,
+ StrokeStyle,
+};
+
export type ChartType = "bar" | "line" | "radar";
-export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
-export type FontFamilyKeys = keyof typeof FONT_FAMILY;
-export type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
export type Theme = typeof THEME[keyof typeof THEME];
-export type FontString = string & { _brand: "fontString" };
export type GroupId = string;
export type PointerType = "mouse" | "pen" | "touch";
export type StrokeRoundness = "round" | "sharp";
-export type RoundnessType = ValueOf;
-export type StrokeStyle = "solid" | "dashed" | "dotted";
export type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
@@ -280,7 +287,7 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase &
* Unitless line height (aligned to W3C). To get line height in px, multiply
* with font size (using `getLineHeightInPx` helper).
*/
- lineHeight: number & { _brand: "unitlessLineHeight" };
+ lineHeight: UnitlessLineHeight;
/**
* Position of text bound to a linear element (such as an arrow),
* expressed as a normalized arc-length parameter (0–1) along the
diff --git a/packages/excalidraw/actions/actionDeleteSelected.tsx b/packages/excalidraw/actions/actionDeleteSelected.tsx
index 11c0f2b86b..f4b65341d6 100644
--- a/packages/excalidraw/actions/actionDeleteSelected.tsx
+++ b/packages/excalidraw/actions/actionDeleteSelected.tsx
@@ -1,8 +1,4 @@
-import {
- KEYS,
- MOBILE_ACTION_BUTTON_BG,
- updateActiveTool,
-} from "@excalidraw/common";
+import { KEYS, MOBILE_ACTION_BUTTON_BG } from "@excalidraw/common";
import { getNonDeletedElements } from "@excalidraw/element";
import { fixBindingsAfterDeletion } from "@excalidraw/element";
@@ -31,6 +27,8 @@ import { useStylesPanelMode } from "../components/App";
import { selectGroupsForSelectedElements } from "../components/App.selection";
+import { updateActiveTool } from "../appState";
+
import { register } from "./register";
import type { AppClassProperties, AppState } from "../types";
diff --git a/packages/excalidraw/actions/actionDeselect.ts b/packages/excalidraw/actions/actionDeselect.ts
index 8bc26502ff..f90d06abfa 100644
--- a/packages/excalidraw/actions/actionDeselect.ts
+++ b/packages/excalidraw/actions/actionDeselect.ts
@@ -4,7 +4,7 @@ import {
makeNextSelectedElementIds,
} from "@excalidraw/element";
import { CaptureUpdateAction } from "@excalidraw/element";
-import { KEYS, isWritableElement, updateActiveTool } from "@excalidraw/common";
+import { KEYS, isWritableElement } from "@excalidraw/common";
import type { GroupId } from "@excalidraw/element/types";
@@ -12,6 +12,8 @@ import { TOGGLE_TOOLS } from "../components/Tools";
import { selectGroupsForSelectedElements } from "../components/App.selection";
+import { updateActiveTool } from "../appState";
+
import { register } from "./register";
import type { AppClassProperties, AppState } from "../types";
diff --git a/packages/excalidraw/actions/actionFinalize.tsx b/packages/excalidraw/actions/actionFinalize.tsx
index 50b2e56a74..1ee70a45f5 100644
--- a/packages/excalidraw/actions/actionFinalize.tsx
+++ b/packages/excalidraw/actions/actionFinalize.tsx
@@ -20,7 +20,6 @@ import {
arrayToMap,
invariant,
shouldRotateWithDiscreteAngle,
- updateActiveTool,
} from "@excalidraw/common";
import { isPathALoop } from "@excalidraw/element";
@@ -41,6 +40,8 @@ import { done } from "../components/icons";
import { TOGGLE_TOOLS } from "../components/Tools";
import { IconButton } from "../components/IconButton";
+import { updateActiveTool } from "../appState";
+
import { register } from "./register";
import type { AppState } from "../types";
diff --git a/packages/excalidraw/appState.ts b/packages/excalidraw/appState.ts
index 7ded8d47f7..10abc9c291 100644
--- a/packages/excalidraw/appState.ts
+++ b/packages/excalidraw/appState.ts
@@ -15,7 +15,14 @@ import {
DEFAULT_STICKY_NOTE_BG,
} from "@excalidraw/common";
-import type { AppState, InputDevice, NormalizedZoomValue } from "./types";
+import type {
+ ActiveTool,
+ AppProps,
+ AppState,
+ InputDevice,
+ NormalizedZoomValue,
+ ToolType,
+} from "./types";
/**
* Resolved lazily rather than at module scope: this module is pulled in by the
@@ -361,3 +368,60 @@ export const resolveInputDevice = (
inputDevice: InputDevice,
): Exclude =>
inputDevice === "auto" ? "trackpad" : inputDevice;
+
+export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = {
+ canvasActions: {
+ changeViewBackgroundColor: true,
+ clearCanvas: true,
+ export: { saveFileToDisk: true },
+ loadScene: true,
+ saveToActiveFile: true,
+ toggleTheme: null,
+ saveAsImage: true,
+ },
+ tools: {
+ image: true,
+ },
+};
+
+export const DEFAULT_IMAGE_OPTIONS: AppProps["imageOptions"] = {
+ maxWidthOrHeight: 1440,
+ maxFileSizeBytes: 4 * 1024 * 1024,
+};
+
+export const isSelectionLikeTool = (type: ToolType | "custom") => {
+ return type === "selection" || type === "lasso";
+};
+
+export const updateActiveTool = (
+ appState: Pick,
+ data: ((
+ | {
+ type: ToolType;
+ }
+ | { type: "custom"; customType: string }
+ ) & { locked?: boolean; fromSelection?: boolean }) & {
+ lastActiveTool?: ActiveTool | null;
+ },
+): AppState["activeTool"] => {
+ if (data.type === "custom") {
+ return {
+ ...appState.activeTool,
+ type: "custom",
+ customType: data.customType,
+ locked: data.locked ?? appState.activeTool.locked,
+ };
+ }
+
+ return {
+ ...appState.activeTool,
+ lastActiveTool:
+ data.lastActiveTool === undefined
+ ? appState.activeTool.lastActiveTool
+ : data.lastActiveTool,
+ type: data.type,
+ customType: null,
+ locked: data.locked ?? appState.activeTool.locked,
+ fromSelection: data.fromSelection ?? false,
+ };
+};
diff --git a/packages/excalidraw/components/App.selectionTool.ts b/packages/excalidraw/components/App.selectionTool.ts
index b50fd17883..44edfa6e97 100644
--- a/packages/excalidraw/components/App.selectionTool.ts
+++ b/packages/excalidraw/components/App.selectionTool.ts
@@ -2,7 +2,6 @@ import {
CURSOR_TYPE,
DRAGGING_THRESHOLD,
getGridPoint,
- isSelectionLikeTool,
KEYS,
shouldMaintainAspectRatio,
shouldResizeFromCenter,
@@ -78,6 +77,8 @@ import {
import { snapDraggedElements, snapResizingElements } from "../snapping";
+import { isSelectionLikeTool } from "../appState";
+
import { selectGroupsForSelectedElements } from "./App.selection";
import type React from "react";
diff --git a/packages/excalidraw/components/App.textTool.ts b/packages/excalidraw/components/App.textTool.ts
index 353ac0949d..2929ad1544 100644
--- a/packages/excalidraw/components/App.textTool.ts
+++ b/packages/excalidraw/components/App.textTool.ts
@@ -5,7 +5,6 @@ import {
EVENT,
KEYS,
TEXT_AUTOWRAP_THRESHOLD,
- updateActiveTool,
viewportCoordsToSceneCoords,
} from "@excalidraw/common";
@@ -23,6 +22,8 @@ import type {
NonDeleted,
} from "@excalidraw/element/types";
+import { updateActiveTool } from "../appState";
+
import type React from "react";
import type App from "./App";
diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx
index 6f7ec057b1..eb694fffdc 100644
--- a/packages/excalidraw/components/App.tsx
+++ b/packages/excalidraw/components/App.tsx
@@ -59,7 +59,6 @@ import {
viewportCoordsToSceneCoords,
wrapEvent,
updateObject,
- updateActiveTool,
isTransparent,
muteFSAbortError,
isTestEnv,
@@ -89,7 +88,6 @@ import {
type StylesPanelMode,
loadDesktopUIModePreference,
setDesktopUIMode,
- isSelectionLikeTool,
oneOf,
getStrokeWidthByKey,
} from "@excalidraw/common";
@@ -376,6 +374,8 @@ import {
resolveColorTarget,
} from "../actions/colorTargets";
+import { updateActiveTool, isSelectionLikeTool } from "../appState";
+
import ConvertElementTypePopup, {
getConversionTypeFromElements,
convertElementTypePopupAtom,
diff --git a/packages/excalidraw/components/ConvertElementTypePopup.tsx b/packages/excalidraw/components/ConvertElementTypePopup.tsx
index 88de719051..1250e8f3a8 100644
--- a/packages/excalidraw/components/ConvertElementTypePopup.tsx
+++ b/packages/excalidraw/components/ConvertElementTypePopup.tsx
@@ -41,7 +41,6 @@ import {
reduceToCommonValue,
ROUNDNESS,
sceneCoordsToViewportCoords,
- updateActiveTool,
} from "@excalidraw/common";
import { measureText } from "@excalidraw/element";
@@ -86,6 +85,8 @@ import type { RenderEnvironment } from "@excalidraw/element/renderEnvironment";
import { trackEvent } from "../analytics";
import { atom } from "../editor-jotai";
+import { updateActiveTool } from "../appState";
+
import "./ConvertElementTypePopup.scss";
import { IconButton } from "./IconButton";
import {
diff --git a/packages/excalidraw/components/HintViewer.tsx b/packages/excalidraw/components/HintViewer.tsx
index 55db2f8736..9fa4c9a16f 100644
--- a/packages/excalidraw/components/HintViewer.tsx
+++ b/packages/excalidraw/components/HintViewer.tsx
@@ -1,8 +1,4 @@
-import {
- CANVAS_SEARCH_TAB,
- DEFAULT_SIDEBAR,
- isSelectionLikeTool,
-} from "@excalidraw/common";
+import { CANVAS_SEARCH_TAB, DEFAULT_SIDEBAR } from "@excalidraw/common";
import {
isArrowElement,
@@ -24,6 +20,8 @@ import { getShortcutKey } from "../shortcut";
import { isEraserActive } from "../appState";
import { isGridModeEnabled } from "../snapping";
+import { isSelectionLikeTool } from "../appState";
+
import "./HintViewer.scss";
import type { AppClassProperties, UIAppState } from "../types";
diff --git a/packages/excalidraw/data/restore.ts b/packages/excalidraw/data/restore.ts
index 51201b773c..1bc3b3428b 100644
--- a/packages/excalidraw/data/restore.ts
+++ b/packages/excalidraw/data/restore.ts
@@ -24,7 +24,6 @@ import {
DEFAULT_GRID_STEP,
randomId,
getUpdatedTimestamp,
- updateActiveTool,
arrayToMap,
getSizeFromPoints,
normalizeLink,
@@ -115,6 +114,8 @@ import {
getNormalizedZoom,
} from "../scene";
+import { updateActiveTool } from "../appState";
+
import type { AppState, BinaryFiles, LibraryItem } from "../types";
import type { ImportedDataState, LegacyAppState } from "./types";
diff --git a/packages/excalidraw/index.tsx b/packages/excalidraw/index.tsx
index 44df155558..12c3d10d40 100644
--- a/packages/excalidraw/index.tsx
+++ b/packages/excalidraw/index.tsx
@@ -8,8 +8,6 @@ import React, {
import {
applyDarkModeFilter,
- DEFAULT_IMAGE_OPTIONS,
- DEFAULT_UI_OPTIONS,
getStrokeWidthByKey,
isShallowEqual,
} from "@excalidraw/common";
@@ -35,6 +33,8 @@ import "./css/app.scss";
import "./css/styles.scss";
import "./fonts/fonts.css";
+import { DEFAULT_IMAGE_OPTIONS, DEFAULT_UI_OPTIONS } from "./appState";
+
import type {
AppProps,
AppState,
diff --git a/packages/excalidraw/tests/tool.test.tsx b/packages/excalidraw/tests/tool.test.tsx
index 02c1104610..1bf70d5dbb 100644
--- a/packages/excalidraw/tests/tool.test.tsx
+++ b/packages/excalidraw/tests/tool.test.tsx
@@ -1,16 +1,14 @@
import React from "react";
import { vi } from "vitest";
-import {
- CURSOR_TYPE,
- resolvablePromise,
- updateActiveTool,
-} from "@excalidraw/common";
+import { CURSOR_TYPE, resolvablePromise } from "@excalidraw/common";
import { Excalidraw } from "../index";
import { findShapeByKey } from "../components/Tools";
+import { updateActiveTool } from "../appState";
+
import { API } from "./helpers/api";
import { Pointer } from "./helpers/ui";
import { act, fireEvent, GlobalTestState, render } from "./test-utils";
diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.ts
index 2bda19f3fc..a3a9086d48 100644
--- a/packages/excalidraw/types.ts
+++ b/packages/excalidraw/types.ts
@@ -45,7 +45,6 @@ import type {
Merge,
MaybePromise,
ValueOf,
- MakeBrand,
} from "@excalidraw/common/utility-types";
import type {
@@ -57,6 +56,14 @@ import type {
} from "@excalidraw/element";
import type { GlobalPoint } from "@excalidraw/math";
+import type {
+ ArrowType,
+ NormalizedZoomValue,
+ NullableGridSize,
+ UnsubscribeCallback,
+ Zoom,
+} from "@excalidraw/common";
+
import type { Action } from "./actions/types";
import type { Spreadsheet } from "./charts";
import type { ClipboardData } from "./clipboard";
@@ -72,6 +79,14 @@ import type { isOverScrollBars } from "./scene/scrollbars";
import type React from "react";
import type { JSX } from "react";
+export type {
+ ArrowType,
+ NormalizedZoomValue,
+ NullableGridSize,
+ UnsubscribeCallback,
+ Zoom,
+};
+
export type { App };
export type SocketId = string & { _brand: "SocketId" };
@@ -465,7 +480,7 @@ export interface AppState {
currentItemEndArrowhead: Arrowhead | null;
currentHoveredFontFamily: FontFamilyValues | null;
currentItemRoundness: StrokeRoundness;
- currentItemArrowType: "sharp" | "round" | "elbow";
+ currentItemArrowType: ArrowType;
viewBackgroundColor: string;
scrollX: number;
scrollY: number;
@@ -623,12 +638,6 @@ export type UIAppState = Omit<
| "elementsToHighlight"
>;
-export type NormalizedZoomValue = number & { _brand: "normalizedZoom" };
-
-export type Zoom = Readonly<{
- value: NormalizedZoomValue;
-}>;
-
export type PointerCoords = Readonly<{
x: number;
y: number;
@@ -1402,8 +1411,6 @@ export type PointerDownState = Readonly<{
};
}>;
-export type UnsubscribeCallback = () => void;
-
export type ExcalidrawMountPayload = {
excalidrawAPI: ExcalidrawImperativeAPI;
/*
@@ -1576,10 +1583,6 @@ export type ElementsPendingErasure = Set;
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
/** Runtime gridSize value. Null indicates disabled grid. */
-export type NullableGridSize =
- | (AppState["gridSize"] & MakeBrand<"NullableGridSize">)
- | null;
-
export type GenerateDiagramToCode = (props: {
frame: NonDeleted;
children: readonly NonDeletedExcalidrawElement[];
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6f9b475880..3c1eec8bce 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -309,12 +309,6 @@ importers:
specifier: 1.6.0
version: 1.6.0
devDependencies:
- '@excalidraw/element':
- specifier: workspace:*
- version: link:../element
- '@excalidraw/excalidraw':
- specifier: workspace:*
- version: link:../excalidraw
'@types/tinycolor2':
specifier: 1.4.6
version: 1.4.6
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 0449f7a475..7eda269226 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -13,6 +13,7 @@ onlyBuiltDependencies:
- esbuild
- protobufjs
-# Type- and test-only edges close cycles (common/element import shared types
-# from excalidraw; element tests use its test harness). Runtime deps are acyclic.
+# Type- and test-only edges close a cycle (element imports editor types from
+# excalidraw, and its tests use excalidraw's test harness). Runtime deps are
+# acyclic.
ignoreWorkspaceCycles: true