@excalidraw/excalidraw 0.18.0-6fc8502 → 0.18.0-a5d6939

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/dev/{chunk-KYBDXI6F.js → chunk-GBJ7S76A.js} +120 -260
  2. package/dist/dev/chunk-GBJ7S76A.js.map +7 -0
  3. package/dist/dev/{chunk-H7XJ5UVD.js → chunk-GIMGG4AT.js} +2 -2
  4. package/dist/dev/data/{image-NKFINVKH.js → image-JN3Y4CVN.js} +3 -3
  5. package/dist/dev/index.js +332 -229
  6. package/dist/dev/index.js.map +4 -4
  7. package/dist/dev/subset-shared.chunk.js +1 -1
  8. package/dist/dev/subset-worker.chunk.js +1 -1
  9. package/dist/prod/{chunk-KJYFYP64.js → chunk-GKI4RZ6C.js} +1 -1
  10. package/dist/prod/chunk-TVF64BAY.js +33 -0
  11. package/dist/prod/data/image-CZ2OEVDB.js +1 -0
  12. package/dist/prod/index.js +14 -14
  13. package/dist/prod/subset-shared.chunk.js +1 -1
  14. package/dist/prod/subset-worker.chunk.js +1 -1
  15. package/dist/types/common/src/constants.d.ts +2 -0
  16. package/dist/types/common/src/utils.d.ts +4 -1
  17. package/dist/types/element/src/binding.d.ts +1 -2
  18. package/dist/types/element/src/collision.d.ts +1 -1
  19. package/dist/types/element/src/duplicate.d.ts +10 -13
  20. package/dist/types/element/src/frame.d.ts +1 -1
  21. package/dist/types/element/src/selection.d.ts +11 -0
  22. package/dist/types/element/src/textElement.d.ts +2 -1
  23. package/dist/types/excalidraw/components/App.d.ts +19 -5
  24. package/dist/types/excalidraw/eraser/index.d.ts +14 -0
  25. package/dist/types/excalidraw/lasso/utils.d.ts +1 -2
  26. package/dist/types/excalidraw/types.d.ts +4 -0
  27. package/dist/types/math/src/types.d.ts +1 -0
  28. package/package.json +1 -1
  29. package/dist/dev/chunk-KYBDXI6F.js.map +0 -7
  30. package/dist/prod/chunk-CAN5RS4P.js +0 -31
  31. package/dist/prod/data/image-5XD47O4X.js +0 -1
  32. /package/dist/dev/{chunk-H7XJ5UVD.js.map → chunk-GIMGG4AT.js.map} +0 -0
  33. /package/dist/dev/data/{image-NKFINVKH.js.map → image-JN3Y4CVN.js.map} +0 -0
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-LS7FJGPW.js";import"./chunk-KJYFYP64.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
1
+ import{a,b,c,d}from"./chunk-LS7FJGPW.js";import"./chunk-GKI4RZ6C.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
@@ -1 +1 @@
1
- import{a as r,c as t}from"./chunk-LS7FJGPW.js";import"./chunk-KJYFYP64.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
1
+ import{a as r,c as t}from"./chunk-LS7FJGPW.js";import"./chunk-GKI4RZ6C.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
@@ -82,6 +82,7 @@ export declare const YOUTUBE_STATES: {
82
82
  export declare const ENV: {
83
83
  TEST: string;
84
84
  DEVELOPMENT: string;
85
+ PRODUCTION: string;
85
86
  };
86
87
  export declare const CLASSES: {
87
88
  SHAPE_ACTIONS_MENU: string;
@@ -224,6 +225,7 @@ export declare const DEFAULT_EXPORT_PADDING = 10;
224
225
  export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
225
226
  export declare const MAX_ALLOWED_FILE_BYTES: number;
226
227
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
228
+ export declare const SVG_DOCUMENT_PREAMBLE = "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
227
229
  export declare const ENCRYPTION_KEY_BITS = 128;
228
230
  export declare const VERSIONS: {
229
231
  readonly excalidraw: 2;
@@ -1,4 +1,5 @@
1
- import type { ExcalidrawBindableElement, FontFamilyValues, FontString } from "@excalidraw/element/types";
1
+ import { type GlobalPoint } from "@excalidraw/math";
2
+ import type { ExcalidrawBindableElement, FontFamilyValues, FontString, ExcalidrawElement } from "@excalidraw/element/types";
2
3
  import type { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "@excalidraw/excalidraw/types";
3
4
  import type { MaybePromise } from "./utility-types";
4
5
  import type { EVENT } from "./constants";
@@ -179,6 +180,7 @@ export type Node<T> = T & {
179
180
  export declare const arrayToList: <T>(array: readonly T[]) => Node<T>[];
180
181
  export declare const isTestEnv: () => boolean;
181
182
  export declare const isDevEnv: () => boolean;
183
+ export declare const isProdEnv: () => boolean;
182
184
  export declare const isServerEnv: () => boolean;
183
185
  export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
184
186
  nativeEvent: T;
@@ -248,4 +250,5 @@ export declare const safelyParseJSON: (json: string) => Record<string, any> | nu
248
250
  */
249
251
  export declare const escapeDoubleQuotes: (str: string) => string;
250
252
  export declare const castArray: <T>(value: T | T[]) => T[];
253
+ export declare const elementCenterPoint: (element: ExcalidrawElement, xOffset?: number, yOffset?: number) => GlobalPoint;
251
254
  export {};
@@ -45,8 +45,7 @@ export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPo
45
45
  export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
46
46
  fixedPoint: FixedPoint;
47
47
  };
48
- export declare const fixDuplicatedBindingsAfterDuplication: (newElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicatedElementsMap: NonDeletedSceneElementsMap) => void;
49
- export declare const fixReversedBindings: (originalElements: Map<string, ExcalidrawElement>, elementsWithClones: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
48
+ export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
50
49
  export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
51
50
  export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
52
51
  x: number;
@@ -1,5 +1,5 @@
1
+ import { type GeometricShape } from "@excalidraw/utils/shape";
1
2
  import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
2
- import type { GeometricShape } from "@excalidraw/utils/shape";
3
3
  import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
4
4
  import type { ElementsMap, ExcalidrawElement } from "./types";
5
5
  export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
@@ -13,13 +13,16 @@ import type { ExcalidrawElement, GroupId } from "./types";
13
13
  * multiple elements at once, share this map
14
14
  * amongst all of them
15
15
  * @param element Element to duplicate
16
- * @param overrides Any element properties to override
17
16
  */
18
- export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined, randomizeSeed?: boolean) => Readonly<TElement>;
17
+ export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, randomizeSeed?: boolean) => Readonly<TElement>;
19
18
  export declare const duplicateElements: (opts: {
20
19
  elements: readonly ExcalidrawElement[];
21
20
  randomizeSeed?: boolean | undefined;
22
- overrides?: ((originalElement: ExcalidrawElement) => Partial<ExcalidrawElement>) | undefined;
21
+ overrides?: ((data: {
22
+ duplicateElement: ExcalidrawElement;
23
+ origElement: ExcalidrawElement;
24
+ origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
25
+ }) => Partial<ExcalidrawElement>) | undefined;
23
26
  } & ({
24
27
  /**
25
28
  * Duplicates all elements in array.
@@ -42,17 +45,11 @@ export declare const duplicateElements: (opts: {
42
45
  editingGroupId: AppState["editingGroupId"];
43
46
  selectedGroupIds: AppState["selectedGroupIds"];
44
47
  };
45
- /**
46
- * If true, duplicated elements are inserted _before_ specified
47
- * elements. Case: alt-dragging elements to duplicate them.
48
- *
49
- * TODO: remove this once (if) we stop replacing the original element
50
- * with the duplicated one in the scene array.
51
- */
52
- reverseOrder: boolean;
53
48
  })) => {
54
- newElements: ExcalidrawElement[];
55
- elementsWithClones: ExcalidrawElement[];
49
+ duplicatedElements: ExcalidrawElement[];
50
+ duplicateElementsMap: Map<string, ExcalidrawElement>;
51
+ elementsWithDuplicates: ExcalidrawElement[];
52
+ origIdToDuplicateId: Map<string, string>;
56
53
  };
57
54
  /**
58
55
  * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
@@ -2,7 +2,7 @@ import type { ExcalidrawElementsIncludingDeleted } from "@excalidraw/excalidraw/
2
2
  import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
3
3
  import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
4
4
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
5
- export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
+ export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
6
6
  export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
7
7
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
8
8
  export declare const isElementContainingFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
@@ -1,4 +1,5 @@
1
1
  import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
+ import { LinearElementEditor } from "./linearElementEditor";
2
3
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
3
4
  /**
4
5
  * Frames and their containing elements are not to be selected at the same time.
@@ -30,3 +31,13 @@ export declare const getTargetElements: (elements: ElementsMapOrArray, appState:
30
31
  export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
31
32
  [id: string]: true;
32
33
  }>;
34
+ export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
35
+ editingGroupId: string | null;
36
+ selectedElementIds: Readonly<{
37
+ [id: string]: true;
38
+ }>;
39
+ selectedGroupIds: {
40
+ [groupId: string]: boolean;
41
+ };
42
+ selectedLinearElement: LinearElementEditor | null;
43
+ };
@@ -1,5 +1,6 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
2
  import type { ExtractSetType } from "@excalidraw/common/utility-types";
3
+ import type { Radians } from "../../math/src";
3
4
  import type { MaybeTransformHandleType } from "./transformHandles";
4
5
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
5
6
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
@@ -19,7 +20,7 @@ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement
19
20
  x: number;
20
21
  y: number;
21
22
  };
22
- export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => import("../../math/src").Radians;
23
+ export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => 0 | Radians;
23
24
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
24
25
  x: number;
25
26
  y: number;
@@ -11,9 +11,9 @@ import { Fonts } from "../fonts";
11
11
  import { Renderer } from "../scene/Renderer";
12
12
  import { Emitter } from "../emitter";
13
13
  import { Store } from "../store";
14
- import { AnimatedTrail } from "../animated-trail";
15
14
  import { LaserTrails } from "../laser-trails";
16
15
  import { LassoTrail } from "../lasso";
16
+ import { EraserTrail } from "../eraser";
17
17
  import type { ExportedElements } from "../data";
18
18
  import type { FileSystemHandle } from "../data/filesystem";
19
19
  import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
@@ -97,7 +97,7 @@ declare class App extends React.Component<AppProps, AppState> {
97
97
  };
98
98
  animationFrameHandler: AnimationFrameHandler;
99
99
  laserTrails: LaserTrails;
100
- eraserTrail: AnimatedTrail;
100
+ eraserTrail: EraserTrail;
101
101
  lassoTrail: LassoTrail;
102
102
  onChangeEmitter: Emitter<[elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles]>;
103
103
  onPointerDownEmitter: Emitter<[activeTool: {
@@ -150,6 +150,10 @@ declare class App extends React.Component<AppProps, AppState> {
150
150
  x: number;
151
151
  y: number;
152
152
  } | null;
153
+ origin: {
154
+ x: number;
155
+ y: number;
156
+ };
153
157
  };
154
158
  eventListeners: {
155
159
  onMove: {
@@ -162,7 +166,10 @@ declare class App extends React.Component<AppProps, AppState> {
162
166
  onKeyUp: ((event: KeyboardEvent) => void) | null;
163
167
  };
164
168
  boxSelection: {
165
- hasOccurred: boolean;
169
+ hasOccurred: boolean; /**
170
+ * Returns gridSize taking into account `gridModeEnabled`.
171
+ * If disabled, returns null.
172
+ */
166
173
  };
167
174
  }>, event: React.PointerEvent<HTMLElement>]>;
168
175
  onPointerUpEmitter: Emitter<[activeTool: {
@@ -215,6 +222,10 @@ declare class App extends React.Component<AppProps, AppState> {
215
222
  x: number;
216
223
  y: number;
217
224
  } | null;
225
+ origin: {
226
+ x: number;
227
+ y: number;
228
+ };
218
229
  };
219
230
  eventListeners: {
220
231
  onMove: {
@@ -227,7 +238,10 @@ declare class App extends React.Component<AppProps, AppState> {
227
238
  onKeyUp: ((event: KeyboardEvent) => void) | null;
228
239
  };
229
240
  boxSelection: {
230
- hasOccurred: boolean;
241
+ hasOccurred: boolean; /**
242
+ * Returns gridSize taking into account `gridModeEnabled`.
243
+ * If disabled, returns null.
244
+ */
231
245
  };
232
246
  }>, event: PointerEvent]>;
233
247
  onUserFollowEmitter: Emitter<[payload: OnUserFollowedPayload]>;
@@ -433,7 +447,7 @@ declare class App extends React.Component<AppProps, AppState> {
433
447
  private getTextElementAtPosition;
434
448
  private getElementAtPosition;
435
449
  private getElementsAtPosition;
436
- private getElementHitThreshold;
450
+ getElementHitThreshold(): number;
437
451
  private hitElement;
438
452
  private getTextBindableContainerAtPosition;
439
453
  private startTextEditing;
@@ -0,0 +1,14 @@
1
+ import { AnimatedTrail } from "../animated-trail";
2
+ import type { AnimationFrameHandler } from "../animation-frame-handler";
3
+ import type App from "../components/App";
4
+ export declare class EraserTrail extends AnimatedTrail {
5
+ private elementsToErase;
6
+ private groupsToErase;
7
+ private segmentsCache;
8
+ private geometricShapesCache;
9
+ constructor(animationFrameHandler: AnimationFrameHandler, app: App);
10
+ startPath(x: number, y: number): void;
11
+ addPointToPath(x: number, y: number, restore?: boolean): string[];
12
+ private updateElementsToBeErased;
13
+ endPath(): void;
14
+ }
@@ -1,6 +1,5 @@
1
- import type { GlobalPoint, LineSegment } from "@excalidraw/math/types";
1
+ import type { ElementsSegmentsMap, GlobalPoint } from "@excalidraw/math/types";
2
2
  import type { ExcalidrawElement } from "@excalidraw/element/types";
3
- export type ElementsSegmentsMap = Map<string, LineSegment<GlobalPoint>[]>;
4
3
  export declare const getLassoSelectedElementIds: (input: {
5
4
  lassoPath: GlobalPoint[];
6
5
  elements: readonly ExcalidrawElement[];
@@ -587,6 +587,10 @@ export type PointerDownState = Readonly<{
587
587
  x: number;
588
588
  y: number;
589
589
  } | null;
590
+ origin: {
591
+ x: number;
592
+ y: number;
593
+ };
590
594
  };
591
595
  eventListeners: {
592
596
  onMove: null | ReturnType<typeof throttleRAF>;
@@ -103,3 +103,4 @@ export type Ellipse<Point extends GlobalPoint | LocalPoint> = {
103
103
  } & {
104
104
  _brand: "excalimath_ellipse";
105
105
  };
106
+ export type ElementsSegmentsMap = Map<string, LineSegment<GlobalPoint>[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/excalidraw",
3
- "version": "0.18.0-6fc8502",
3
+ "version": "0.18.0-a5d6939",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",