mirror of
https://github.com/excalidraw/excalidraw.git
synced 2026-11-30 17:11:01 +03:00
fix: common package circular dependencies
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
26 files changed
+205
-172
No files matched your search
Vendored
+5
-2
@@ -1,3 +1,6 @@
|
||||
/// <reference types="vite/client" />
|
||||
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;
|
||||
}
|
||||
@@ -81,8 +81,6 @@
|
||||
"tinycolor2": "1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@excalidraw/element": "workspace:*",
|
||||
"@excalidraw/excalidraw": "workspace:*",
|
||||
"@types/tinycolor2": "1.4.6"
|
||||
}
|
||||
}
|
||||
@@ -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<string, unknown[]>;
|
||||
|
||||
export type AppEventBehavior = {
|
||||
|
||||
@@ -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 = `<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
@@ -484,7 +464,7 @@ export const STROKE_WIDTH_KEYS: readonly StrokeWidthKey[] = [
|
||||
];
|
||||
|
||||
export const STROKE_WIDTH: Readonly<
|
||||
Record<StrokeWidthKey | "extraBold", ExcalidrawElement["strokeWidth"]>
|
||||
Record<StrokeWidthKey | "extraBold", number>
|
||||
> = {
|
||||
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<StrokeWidthKey | "extraBold", ExcalidrawElement["strokeWidth"]>
|
||||
Record<StrokeWidthKey | "extraBold", number>
|
||||
> = {
|
||||
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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { UnsubscribeCallback } from "@excalidraw/excalidraw/types";
|
||||
import type { UnsubscribeCallback } from "./types";
|
||||
|
||||
type Subscriber<T extends any[]> = (...payload: T) => void;
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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";
|
||||
|
||||
@@ -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)[],
|
||||
|
||||
@@ -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<typeof ROUNDNESS>;
|
||||
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;
|
||||
@@ -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<AppState, "activeTool">,
|
||||
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";
|
||||
|
||||
|
||||
@@ -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<typeof ROUNDNESS>;
|
||||
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
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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"> =>
|
||||
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<AppState, "activeTool">,
|
||||
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,
|
||||
};
|
||||
};
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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<ExcalidrawElement["id"]>;
|
||||
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<ExcalidrawMagicFrameElement>;
|
||||
children: readonly NonDeletedExcalidrawElement[];
|
||||
|
||||
Generated
-6
@@ -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
|
||||
|
||||
+3
-2
@@ -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
|
||||
Reference in new issue
Block a user