@excalidraw/math 0.18.0-abeeaeb → 0.18.0-afa3a65

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 (79) hide show
  1. package/dist/dev/index.js +36 -42
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/colors.d.ts +8 -0
  5. package/dist/types/common/src/constants.d.ts +44 -0
  6. package/dist/types/common/src/keys.d.ts +2 -0
  7. package/dist/types/common/src/random.d.ts +7 -0
  8. package/dist/types/element/src/Scene.d.ts +1 -1
  9. package/dist/types/element/src/comparisons.d.ts +5 -3
  10. package/dist/types/element/src/delta.d.ts +23 -1
  11. package/dist/types/element/src/flowchart.d.ts +5 -1
  12. package/dist/types/element/src/frame.d.ts +2 -2
  13. package/dist/types/element/src/index.d.ts +1 -0
  14. package/dist/types/element/src/linearElementEditor.d.ts +10 -0
  15. package/dist/types/element/src/mutateElement.d.ts +1 -1
  16. package/dist/types/element/src/newElement.d.ts +24 -2
  17. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  18. package/dist/types/element/src/stickyNote.d.ts +183 -0
  19. package/dist/types/element/src/textElement.d.ts +2 -1
  20. package/dist/types/element/src/transform.d.ts +25 -6
  21. package/dist/types/element/src/typeChecks.d.ts +3 -2
  22. package/dist/types/element/src/types.d.ts +35 -6
  23. package/dist/types/element/src/utils.d.ts +7 -3
  24. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -0
  25. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  26. package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -0
  27. package/dist/types/excalidraw/actions/actionCanvas.d.ts +28 -0
  28. package/dist/types/excalidraw/actions/actionClipboard.d.ts +8 -0
  29. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -0
  30. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +13 -1
  31. package/dist/types/excalidraw/actions/actionDeselect.d.ts +4 -0
  32. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  33. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -0
  34. package/dist/types/excalidraw/actions/actionElementLock.d.ts +8 -0
  35. package/dist/types/excalidraw/actions/actionExport.d.ts +8 -0
  36. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  37. package/dist/types/excalidraw/actions/actionFrame.d.ts +63 -1
  38. package/dist/types/excalidraw/actions/actionGroup.d.ts +8 -0
  39. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +55 -1
  40. package/dist/types/excalidraw/actions/actionLink.d.ts +4 -0
  41. package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -0
  42. package/dist/types/excalidraw/actions/actionProperties.d.ts +18 -6
  43. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +4 -0
  44. package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
  45. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +4 -0
  46. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +4 -0
  47. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +4 -0
  48. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -0
  49. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -0
  50. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +4 -0
  51. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -0
  52. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -0
  53. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  54. package/dist/types/excalidraw/appState.d.ts +4 -0
  55. package/dist/types/excalidraw/components/App.arrowText.d.ts +40 -8
  56. package/dist/types/excalidraw/components/App.cursor.d.ts +8 -0
  57. package/dist/types/excalidraw/components/App.d.ts +92 -6
  58. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  59. package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
  60. package/dist/types/excalidraw/components/Tools.d.ts +7 -2
  61. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
  62. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  63. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
  64. package/dist/types/excalidraw/data/blob.d.ts +8 -0
  65. package/dist/types/excalidraw/data/json.d.ts +4 -0
  66. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
  67. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  68. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  69. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  70. package/dist/types/excalidraw/scene/Renderer.d.ts +50 -1
  71. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  72. package/dist/types/excalidraw/scene/types.d.ts +1 -0
  73. package/dist/types/excalidraw/types.d.ts +30 -2
  74. package/dist/types/excalidraw/viewport.d.ts +4 -0
  75. package/dist/types/math/src/curve.d.ts +19 -12
  76. package/dist/types/math/src/segment.d.ts +6 -0
  77. package/dist/types/utils/src/export.d.ts +1 -0
  78. package/dist/types/utils/src/shape.d.ts +2 -2
  79. package/package.json +2 -2
@@ -0,0 +1,63 @@
1
+ import type { ExcalidrawNonSelectionElement, NonDeleted } from "@excalidraw/element/types";
2
+ import type App from "./App";
3
+ import type { ToolType } from "../types";
4
+ type ScenePoint = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ /** what a drag places: any element the new-element canvas can preview */
9
+ type DraggedElement = NonDeleted<ExcalidrawNonSelectionElement>;
10
+ /**
11
+ * A tool the user can drag out of the toolbar to drop a default-sized element
12
+ * where the pointer is released.
13
+ */
14
+ type DraggableTool = {
15
+ /** the element the drop creates, centered on the pointer */
16
+ createElement: (app: App, center: ScenePoint) => DraggedElement;
17
+ /** what the tool does once its element is on the canvas (e.g. start editing) */
18
+ onDrop?: (app: App, element: DraggedElement) => void;
19
+ };
20
+ /**
21
+ * The tools that can be dragged out of the toolbar. Add an entry to make a
22
+ * tool's button draggable — the gesture, preview and drop are shared.
23
+ */
24
+ export declare const DRAGGABLE_TOOLS: Partial<Record<ToolType, DraggableTool>>;
25
+ /** CSS opacity of the preview canvas while dragging */
26
+ export declare const TOOL_DRAG_PREVIEW_OPACITY = 0.5;
27
+ /**
28
+ * Dragging a tool out of the toolbar. The preview element exists only here
29
+ * until the drop — it is not in the scene, the store or the history, so
30
+ * collaborators never see it and an aborted drag leaves nothing behind. It
31
+ * is painted by the `NewElementCanvas`, drawn exactly as it will land, with
32
+ * the canvas itself made translucent.
33
+ *
34
+ * The button arms on pointerdown; the drag starts once the pointer has
35
+ * moved `DRAGGING_THRESHOLD`, so a plain click still selects the tool. The
36
+ * gesture lives on the owner window (the pointer leaves the button at once),
37
+ * like the other pointer gestures in `App`.
38
+ */
39
+ export declare class AppToolDrag {
40
+ private app;
41
+ constructor(app: App);
42
+ /** the element under the pointer while dragging, `null` otherwise */
43
+ preview: DraggedElement | null;
44
+ private armed;
45
+ private tool;
46
+ private type;
47
+ static isDraggable: (type: ToolType) => boolean;
48
+ isDragging: () => boolean;
49
+ /**
50
+ * Arm a drag from a tool button's pointerdown. Returns whether the tool is
51
+ * draggable (the caller lets a non-draggable press fall through).
52
+ */
53
+ handleButtonPointerDown: (type: ToolType, event: PointerEvent) => boolean;
54
+ private onPointerMove;
55
+ private onPointerUp;
56
+ private onKeyDown;
57
+ /** drop the gesture without a trace */
58
+ cancel: () => void;
59
+ private isOverCanvas;
60
+ private addListeners;
61
+ private removeListeners;
62
+ }
63
+ export {};
@@ -41,6 +41,8 @@ type IconButtonProps = (IconButtonBaseProps & {
41
41
  onSelect?(data: {
42
42
  pointerType: PointerType | null;
43
43
  }): void;
44
+ /** the press that may become a click — e.g. to arm a drag out of the toolbar */
45
+ onPointerDown?(event: React.PointerEvent<HTMLButtonElement>): void;
44
46
  });
45
47
  export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<unknown>>;
46
48
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { AppClassProperties, AppState, ToolType, UIAppState } from "../types";
2
2
  export type ToolConfig = {
3
3
  icon: React.ReactNode;
4
- /** letter shortcut(s) — the first one is shown in tooltips */
4
+ /** letter shortcut(s) — the first one is shown in tooltips and badges */
5
5
  letterKey?: string | readonly string[];
6
6
  /** whether `letterKey` requires Shift to be held (e.g. Shift+X) */
7
7
  shiftKey?: boolean;
@@ -31,6 +31,7 @@ export declare const TOOLS: {
31
31
  line: ToolConfig;
32
32
  freedraw: ToolConfig;
33
33
  text: ToolConfig;
34
+ stickynote: ToolConfig;
34
35
  image: ToolConfig;
35
36
  eraser: ToolConfig;
36
37
  frame: ToolConfig;
@@ -49,7 +50,7 @@ export declare const TOGGLE_TOOLS: readonly (ToolType | "custom")[];
49
50
  export declare const getToolLetter: (type: ToolbarToolType) => string | undefined;
50
51
  /** human-readable shortcut hint, e.g. "R or 2", used in tooltips & aria */
51
52
  export declare const getToolShortcut: (type: ToolbarToolType) => string;
52
- export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
53
+ export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
53
54
  /**
54
55
  * Whether a toolbar entry activating the given tool renders disabled — true
55
56
  * when the active tool is host-controlled (`props.activeTool`) and the entry
@@ -99,6 +100,10 @@ export declare const TextToolButton: {
99
100
  ({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
100
101
  displayName: string;
101
102
  };
103
+ export declare const StickyNoteToolButton: {
104
+ ({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
105
+ displayName: string;
106
+ };
102
107
  export declare const ImageToolButton: {
103
108
  ({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
104
109
  displayName: string;
@@ -10,6 +10,8 @@ interface NewElementCanvasProps {
10
10
  scale: number;
11
11
  rc: RoughCanvas;
12
12
  renderConfig: StaticCanvasRenderConfig;
13
+ /** CSS opacity of the whole canvas — a translucent preview of a finished element */
14
+ opacity?: number;
13
15
  }
14
16
  declare const NewElementCanvas: (props: NewElementCanvasProps) => import("react/jsx-runtime").JSX.Element;
15
17
  export default NewElementCanvas;
@@ -200,6 +200,7 @@ export declare const alertTriangleIcon: import("react/jsx-runtime").JSX.Element;
200
200
  export declare const eyeDropperIconSvgPaths: readonly ["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z", "M11 7l6 6"];
201
201
  export declare const eyeDropperIcon: import("react/jsx-runtime").JSX.Element;
202
202
  export declare const frameToolIcon: import("react/jsx-runtime").JSX.Element;
203
+ export declare const stickyNoteToolIcon: import("react/jsx-runtime").JSX.Element;
203
204
  export declare const mermaidLogoIcon: import("react/jsx-runtime").JSX.Element;
204
205
  export declare const RetryIcon: import("react/jsx-runtime").JSX.Element;
205
206
  export declare const stackPushIcon: import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
- import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
1
+ import type { ElementsMap, ExcalidrawElement, NonDeletedElementsMap, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
2
2
  import type { AppClassProperties, UIAppState } from "../types";
3
3
  export declare const canChangeStrokeColor: (appState: UIAppState, targetElements: ExcalidrawElement[]) => boolean;
4
- export declare const canChangeBackgroundColor: (appState: UIAppState, targetElements: ExcalidrawElement[]) => boolean;
4
+ export declare const canChangeBackgroundColor: (appState: UIAppState, targetElements: ExcalidrawElement[], elementsMap: ElementsMap) => boolean;
5
5
  /**
6
6
  * Single source of truth for "which shape-action controls are relevant right
7
7
  * now". Each flag answers whether a given control should be shown, given the
@@ -125,6 +125,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
125
125
  exportEmbedScene: boolean;
126
126
  exportWithDarkMode: boolean;
127
127
  currentItemStrokeColor: string;
128
+ currentItemStickynoteStrokeColor: string;
129
+ currentItemStickynoteBackgroundColor: string;
128
130
  currentItemBackgroundColor: string;
129
131
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
130
132
  currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
@@ -179,6 +181,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
179
181
  elementStroke: readonly string[] | null;
180
182
  elementBackground: readonly string[] | null;
181
183
  bucketFill: readonly string[] | null;
184
+ stickyNoteStroke: readonly string[] | null;
185
+ stickyNoteBackground: readonly string[] | null;
182
186
  };
183
187
  };
184
188
  files: import("../types").BinaryFiles;
@@ -299,6 +303,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
299
303
  exportEmbedScene: boolean;
300
304
  exportWithDarkMode: boolean;
301
305
  currentItemStrokeColor: string;
306
+ currentItemStickynoteStrokeColor: string;
307
+ currentItemStickynoteBackgroundColor: string;
302
308
  currentItemBackgroundColor: string;
303
309
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
304
310
  currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
@@ -353,6 +359,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
353
359
  elementStroke: readonly string[] | null;
354
360
  elementBackground: readonly string[] | null;
355
361
  bucketFill: readonly string[] | null;
362
+ stickyNoteStroke: readonly string[] | null;
363
+ stickyNoteBackground: readonly string[] | null;
356
364
  };
357
365
  };
358
366
  files: import("../types").BinaryFiles;
@@ -123,6 +123,8 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
123
123
  exportEmbedScene: boolean;
124
124
  exportWithDarkMode: boolean;
125
125
  currentItemStrokeColor: string;
126
+ currentItemStickynoteStrokeColor: string;
127
+ currentItemStickynoteBackgroundColor: string;
126
128
  currentItemBackgroundColor: string;
127
129
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
128
130
  currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
@@ -177,6 +179,8 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
177
179
  elementStroke: readonly string[] | null;
178
180
  elementBackground: readonly string[] | null;
179
181
  bucketFill: readonly string[] | null;
182
+ stickyNoteStroke: readonly string[] | null;
183
+ stickyNoteBackground: readonly string[] | null;
180
184
  };
181
185
  };
182
186
  files: BinaryFiles;
@@ -15,7 +15,8 @@ export declare class Fonts {
15
15
  fontFaces: ExcalidrawFontFace[];
16
16
  }>;
17
17
  private readonly scene;
18
- constructor(scene: Scene);
18
+ private readonly ownerDocument;
19
+ constructor(scene: Scene, ownerDocument?: Document);
19
20
  /**
20
21
  * Get all the font families for the given scene.
21
22
  */
@@ -36,7 +37,7 @@ export declare class Fonts {
36
37
  /**
37
38
  * Load font faces for passed elements - use when the scene is unavailable (i.e. export).
38
39
  */
39
- static loadElementsFonts: (elements: readonly ExcalidrawElement[]) => Promise<FontFace[]>;
40
+ static loadElementsFonts: (elements: readonly ExcalidrawElement[], ownerDocument?: Document) => Promise<FontFace[]>;
40
41
  /**
41
42
  * Generate CSS @font-face declarations for the given elements.
42
43
  */
@@ -2,13 +2,13 @@ export type CaretPosition = {
2
2
  start: number;
3
3
  end: number;
4
4
  };
5
- export declare const saveCaretPosition: () => CaretPosition | null;
6
- export declare const restoreCaretPosition: (position: CaretPosition | null) => void;
7
- export declare const withCaretPositionPreservation: (callback: () => void, isCompactMode: boolean, isEditingText: boolean, onPreventClose?: () => void) => void;
8
- export declare const useTextEditorFocus: () => {
5
+ export declare const saveCaretPosition: (ownerDocument?: Document) => CaretPosition | null;
6
+ export declare const restoreCaretPosition: (position: CaretPosition | null, ownerDocument?: Document) => void;
7
+ export declare const withCaretPositionPreservation: (callback: () => void, isCompactMode: boolean, isEditingText: boolean, onPreventClose?: () => void, ownerDocument?: Document) => void;
8
+ export declare const useTextEditorFocus: (ownerDocument?: Document) => {
9
9
  saveCaretPosition: () => void;
10
10
  restoreCaretPosition: () => void;
11
11
  clearSavedPosition: () => void;
12
12
  hasSavedPosition: boolean;
13
13
  };
14
- export declare const temporarilyDisableTextEditorBlur: (duration?: number) => void;
14
+ export declare const temporarilyDisableTextEditorBlur: (ownerDocument?: Document, duration?: number) => void;
@@ -1,6 +1,31 @@
1
1
  import type { StaticCanvasRenderConfig } from "../scene/types";
2
2
  import type { AppState, StaticCanvasAppState } from "../types";
3
+ export declare const DEFAULT_SELECTION_COLOR = "#6965db";
4
+ /**
5
+ * Returns the theme's selection color (`--color-selection`), read from the
6
+ * computed style of any element inside the editor container so that host
7
+ * overrides are respected. Falls back to the default when unavailable.
8
+ */
9
+ export declare const getSelectionColor: (element: Element | null | undefined) => string;
3
10
  export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke: boolean, fill?: boolean) => void;
11
+ /**
12
+ * The scroll the renderers draw at: the real one, rounded to whole device
13
+ * pixels. Panning writes a fractional scroll (pointer delta ÷ zoom), and an
14
+ * element's cached bitmap blitted at a fractional device offset gets
15
+ * resampled — so as the fraction drifts under a pan, every element pulses
16
+ * between crisp and soft. A whole-pixel scroll moves the scene the way a
17
+ * browser scrolls a page: each element keeps its own, constant sub-pixel
18
+ * phase and a pan never changes how anything is filtered. The difference
19
+ * stays under half a device pixel, so hit-testing and DOM overlays keep
20
+ * using the real scroll. Identity when nothing needs to change.
21
+ */
22
+ export declare const snapScrollToDevicePixels: <T extends {
23
+ scrollX: number;
24
+ scrollY: number;
25
+ zoom: {
26
+ value: number;
27
+ };
28
+ }>(appState: T, scale: number) => T;
4
29
  export declare const getNormalizedCanvasDimensions: (canvas: HTMLCanvasElement, scale: number) => [number, number];
5
30
  export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normalizedHeight, theme, isExporting, viewBackgroundColor, }: {
6
31
  canvas: HTMLCanvasElement;
@@ -1,6 +1,6 @@
1
1
  import { getScrollBars } from "../scene/scrollbars";
2
2
  import type { InteractiveSceneRenderConfig } from "../scene/types";
3
- declare const _renderInteractiveScene: ({ app, canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, editorInterface, animationState, deltaTime, }: InteractiveSceneRenderConfig) => {
3
+ declare const _renderInteractiveScene: ({ app, canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState: unsnappedAppState, renderConfig, editorInterface, animationState, deltaTime, }: InteractiveSceneRenderConfig) => {
4
4
  scrollBars?: ReturnType<typeof getScrollBars>;
5
5
  animationState?: typeof animationState;
6
6
  };
@@ -53,6 +53,7 @@ export declare class Renderer {
53
53
  frameId: string | null;
54
54
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
55
55
  updated: number;
56
+ created: number | null;
56
57
  link: string | null;
57
58
  locked: boolean;
58
59
  customData?: Record<string, any>;
@@ -92,6 +93,7 @@ export declare class Renderer {
92
93
  frameId: string | null;
93
94
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
94
95
  updated: number;
96
+ created: number | null;
95
97
  link: string | null;
96
98
  locked: boolean;
97
99
  customData?: Record<string, any>;
@@ -126,6 +128,43 @@ export declare class Renderer {
126
128
  frameId: string | null;
127
129
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
128
130
  updated: number;
131
+ created: number | null;
132
+ link: string | null;
133
+ locked: boolean;
134
+ customData?: Record<string, any>;
135
+ }> & Readonly<{
136
+ type: "stickynote";
137
+ baseHeight: number;
138
+ }> & {
139
+ isDeleted: false;
140
+ }) | (Readonly<{
141
+ id: string;
142
+ x: number;
143
+ y: number;
144
+ strokeColor: string;
145
+ backgroundColor: string;
146
+ fillStyle: import("@excalidraw/element/types").FillStyle;
147
+ strokeWidth: number;
148
+ strokeStyle: import("@excalidraw/element/types").StrokeStyle;
149
+ roundness: null | {
150
+ type: import("@excalidraw/element/types").RoundnessType;
151
+ value?: number;
152
+ };
153
+ roughness: number;
154
+ opacity: number;
155
+ width: number;
156
+ height: number;
157
+ angle: import("@excalidraw/math").Radians;
158
+ seed: number;
159
+ version: number;
160
+ versionNonce: number;
161
+ index: import("@excalidraw/element/types").FractionalIndex | null;
162
+ isDeleted: boolean;
163
+ groupIds: readonly import("@excalidraw/element/types").GroupId[];
164
+ frameId: string | null;
165
+ boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
166
+ updated: number;
167
+ created: number | null;
129
168
  link: string | null;
130
169
  locked: boolean;
131
170
  customData?: Record<string, any>;
@@ -160,6 +199,7 @@ export declare class Renderer {
160
199
  frameId: string | null;
161
200
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
162
201
  updated: number;
202
+ created: number | null;
163
203
  link: string | null;
164
204
  locked: boolean;
165
205
  customData?: Record<string, any>;
@@ -194,6 +234,7 @@ export declare class Renderer {
194
234
  frameId: string | null;
195
235
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
196
236
  updated: number;
237
+ created: number | null;
197
238
  link: string | null;
198
239
  locked: boolean;
199
240
  customData?: Record<string, any>;
@@ -228,6 +269,7 @@ export declare class Renderer {
228
269
  frameId: string | null;
229
270
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
230
271
  updated: number;
272
+ created: number | null;
231
273
  link: string | null;
232
274
  locked: boolean;
233
275
  customData?: Record<string, any>;
@@ -265,6 +307,7 @@ export declare class Renderer {
265
307
  frameId: string | null;
266
308
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
267
309
  updated: number;
310
+ created: number | null;
268
311
  link: string | null;
269
312
  locked: boolean;
270
313
  customData?: Record<string, any>;
@@ -303,6 +346,7 @@ export declare class Renderer {
303
346
  frameId: string | null;
304
347
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
305
348
  updated: number;
349
+ created: number | null;
306
350
  link: string | null;
307
351
  locked: boolean;
308
352
  customData?: Record<string, any>;
@@ -338,6 +382,7 @@ export declare class Renderer {
338
382
  frameId: string | null;
339
383
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
340
384
  updated: number;
385
+ created: number | null;
341
386
  link: string | null;
342
387
  locked: boolean;
343
388
  customData?: Record<string, any>;
@@ -373,6 +418,7 @@ export declare class Renderer {
373
418
  frameId: string | null;
374
419
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
375
420
  updated: number;
421
+ created: number | null;
376
422
  link: string | null;
377
423
  locked: boolean;
378
424
  customData?: Record<string, any>;
@@ -380,15 +426,17 @@ export declare class Renderer {
380
426
  type: "text";
381
427
  fontSize: number;
382
428
  fontFamily: import("@excalidraw/element/types").FontFamilyValues;
429
+ baseFontSize: number | null;
383
430
  text: string;
384
431
  textAlign: import("@excalidraw/element/types").TextAlign;
385
432
  verticalAlign: import("@excalidraw/element/types").VerticalAlign;
386
- containerId: import("@excalidraw/element/types").ExcalidrawGenericElement["id"] | null;
433
+ containerId: import("@excalidraw/element/types").ExcalidrawTextContainer["id"] | null;
387
434
  originalText: string;
388
435
  autoResize: boolean;
389
436
  lineHeight: number & {
390
437
  _brand: "unitlessLineHeight";
391
438
  };
439
+ labelPosition?: number | null;
392
440
  }> & {
393
441
  isDeleted: false;
394
442
  }) | (Readonly<{
@@ -418,6 +466,7 @@ export declare class Renderer {
418
466
  frameId: string | null;
419
467
  boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
420
468
  updated: number;
469
+ created: number | null;
421
470
  link: string | null;
422
471
  locked: boolean;
423
472
  customData?: Record<string, any>;
@@ -1,4 +1,4 @@
1
1
  export { isSomeElementSelected, getElementsWithinSelection, getSelectedElements, getTargetElements, } from "@excalidraw/element";
2
2
  export { getScrollToContentState } from "../viewport";
3
- export { hasBackground, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
3
+ export { hasBackground, hasFillStyle, hasRoughness, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
4
4
  export { getNormalizedZoom, getNormalizedGridSize, getNormalizedGridStep, } from "./normalize";
@@ -132,6 +132,7 @@ export type ElementShapes = {
132
132
  arrow: Drawable[];
133
133
  line: Drawable[];
134
134
  text: null;
135
+ stickynote: null;
135
136
  image: null;
136
137
  frame: null;
137
138
  magicframe: null;
@@ -85,7 +85,7 @@ export type BinaryFileData = {
85
85
  };
86
86
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
87
87
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
88
- export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser" | "autoshape" | "bucketfill";
88
+ export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "stickynote" | "embeddable" | "laser" | "autoshape" | "bucketfill";
89
89
  export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
90
90
  export type ActiveTool = {
91
91
  type: ToolType;
@@ -308,6 +308,8 @@ export interface AppState {
308
308
  exportWithDarkMode: boolean;
309
309
  exportScale: number;
310
310
  currentItemStrokeColor: string;
311
+ currentItemStickynoteStrokeColor: string;
312
+ currentItemStickynoteBackgroundColor: string;
311
313
  currentItemBackgroundColor: string;
312
314
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
313
315
  currentItemStrokeWidthKey: StrokeWidthKey;
@@ -438,6 +440,9 @@ export interface AppState {
438
440
  * even though both drive `currentItemBackgroundColor` (its defaults and
439
441
  * use case differ — no transparent) */
440
442
  bucketFill: readonly string[] | null;
443
+ /** sticky notes are their own color domain (own defaults, own picks) */
444
+ stickyNoteStroke: readonly string[] | null;
445
+ stickyNoteBackground: readonly string[] | null;
441
446
  };
442
447
  }
443
448
  export type SearchMatch = {
@@ -632,6 +637,16 @@ export type UIConfig = {
632
637
  };
633
638
  export interface ExcalidrawProps {
634
639
  className?: string;
640
+ /**
641
+ * Document that owns Excalidraw's mounted DOM.
642
+ *
643
+ * Set only when it differs from the global `document`, such as when code
644
+ * executing in a parent window mounts Excalidraw into an iframe document.
645
+ * The value must remain stable for the editor's lifetime.
646
+ *
647
+ * @default document
648
+ */
649
+ ownerDocument?: Document;
635
650
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
636
651
  onThemeChange?: (theme: Theme | "system") => void;
637
652
  /**
@@ -821,7 +836,8 @@ export interface ExcalidrawProps {
821
836
  }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
822
837
  }
823
838
  export type SceneData = {
824
- elements?: ImportedDataState["elements"];
839
+ /** Expects normalized elements; restore imported data before updating the scene. */
840
+ elements?: readonly ExcalidrawElement[] | null;
825
841
  appState?: ImportedDataState["appState"];
826
842
  collaborators?: Map<SocketId, Collaborator>;
827
843
  captureUpdate?: CaptureUpdateActionType;
@@ -881,6 +897,8 @@ export type AppProps = Merge<ExcalidrawProps, {
881
897
  export type AppClassProperties = {
882
898
  props: AppProps;
883
899
  state: AppState;
900
+ readonly ownerDocument: Document;
901
+ readonly ownerWindow: Window & typeof globalThis;
884
902
  api: App["api"];
885
903
  sessionExportThemeOverride: App["sessionExportThemeOverride"];
886
904
  interactiveCanvas: HTMLCanvasElement | null;
@@ -914,8 +932,11 @@ export type AppClassProperties = {
914
932
  dismissLinearEditor: App["dismissLinearEditor"];
915
933
  flowchart: App["flowchart"];
916
934
  drawShape: App["drawShape"];
935
+ arrowText: App["arrowText"];
917
936
  cursor: App["cursor"];
918
937
  bucketFill: App["bucketFill"];
938
+ toolDrag: App["toolDrag"];
939
+ activeResizeHandle: App["activeResizeHandle"];
919
940
  isToolLocked: App["isToolLocked"];
920
941
  getEffectiveGridSize: App["getEffectiveGridSize"];
921
942
  setPlugins: App["setPlugins"];
@@ -970,6 +991,7 @@ export type PointerDownState = Readonly<{
970
991
  wasAddedToSelection: boolean;
971
992
  hasBeenDuplicated: boolean;
972
993
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
994
+ arrowLabel: boolean;
973
995
  };
974
996
  withCmdOrCtrl: boolean;
975
997
  drag: {
@@ -1077,6 +1099,12 @@ export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSi
1077
1099
  export type GenerateDiagramToCode = (props: {
1078
1100
  frame: NonDeleted<ExcalidrawMagicFrameElement>;
1079
1101
  children: readonly NonDeletedExcalidrawElement[];
1102
+ /**
1103
+ * Optional streaming hook. Call with the accumulated response text as it
1104
+ * streams in so the editor can progressively render the partial HTML
1105
+ * inside the generated frame.
1106
+ */
1107
+ onPartial?: (html: string) => void;
1080
1108
  }) => MaybePromise<{
1081
1109
  html: string;
1082
1110
  }>;
@@ -142,6 +142,8 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
142
142
  exportWithDarkMode: boolean;
143
143
  exportScale: number;
144
144
  currentItemStrokeColor: string;
145
+ currentItemStickynoteStrokeColor: string;
146
+ currentItemStickynoteBackgroundColor: string;
145
147
  currentItemBackgroundColor: string;
146
148
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
147
149
  currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
@@ -248,6 +250,8 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
248
250
  elementStroke: readonly string[] | null;
249
251
  elementBackground: readonly string[] | null;
250
252
  bucketFill: readonly string[] | null;
253
+ stickyNoteStroke: readonly string[] | null;
254
+ stickyNoteBackground: readonly string[] | null;
251
255
  };
252
256
  };
253
257
  captureUpdate: "EVENTUALLY";
@@ -16,20 +16,25 @@ export declare function curveIntersectLineSegment<Point extends GlobalPoint | Lo
16
16
  tolerance?: number;
17
17
  iterLimit?: number;
18
18
  }): Point[];
19
+ /**
20
+ * Finds the parameter on the Bezier curve whose point is closest to another
21
+ * point
22
+ *
23
+ * @param c The curve to test
24
+ * @param p The point to measure from
25
+ * @param tolerance The width of the search window under which the bisection
26
+ * stops refining the parameter
27
+ */
28
+ export declare function curveClosestParameter<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): number;
19
29
  /**
20
30
  * Finds the closest point on the Bezier curve from another point
21
31
  *
22
- * @param x
23
- * @param y
24
- * @param P0
25
- * @param P1
26
- * @param P2
27
- * @param P3
28
- * @param tolerance
29
- * @param maxLevel
30
- * @returns
32
+ * @param c The curve to test
33
+ * @param p The point to measure from
34
+ * @param tolerance The width of the search window under which the bisection
35
+ * stops refining the parameter
31
36
  */
32
- export declare function curveClosestPoint<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): Point | null;
37
+ export declare function curveClosestPoint<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): Point;
33
38
  /**
34
39
  * Determines the distance between a point and the closest point on the
35
40
  * Bezier curve.
@@ -37,7 +42,7 @@ export declare function curveClosestPoint<Point extends GlobalPoint | LocalPoint
37
42
  * @param c The curve to test
38
43
  * @param p The point to measure from
39
44
  */
40
- export declare function curvePointDistance<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point): number;
45
+ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): number;
41
46
  /**
42
47
  * Determines if the parameter is a Curve
43
48
  */
@@ -74,4 +79,6 @@ export declare function curveLengthAtParameter<P extends GlobalPoint | LocalPoin
74
79
  * @param percent A value between 0 and 1 representing the percentage of the curve's length
75
80
  * @returns The point at the specified percentage of curve length
76
81
  */
77
- export declare function curvePointAtLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>, percent: number): P;
82
+ export declare function curvePointAtLength<P extends GlobalPoint | LocalPoint>(c: Curve<P>, percent: number,
83
+ /** pass the curve's total length when already known to skip recomputing it */
84
+ totalLength?: number): P;
@@ -29,6 +29,11 @@ export declare const lineSegmentRotate: <Point extends LocalPoint | GlobalPoint>
29
29
  export declare const segmentsIntersectAt: <Point extends GlobalPoint | LocalPoint>(a: Readonly<LineSegment<Point>>, b: Readonly<LineSegment<Point>>) => Point | null;
30
30
  export declare const pointOnLineSegment: <Point extends LocalPoint | GlobalPoint>(point: Point, line: LineSegment<Point>, threshold?: number) => boolean;
31
31
  export declare const distanceToLineSegment: <Point extends LocalPoint | GlobalPoint>(point: Point, line: LineSegment<Point>) => number;
32
+ /**
33
+ * Returns the point at parameter `t` along the segment, where `t = 0` is the
34
+ * segment's start and `t = 1` its end. Not clamped.
35
+ */
36
+ export declare function lineSegmentPointAt<Point extends GlobalPoint | LocalPoint>(line: LineSegment<Point>, t: number): Point;
32
37
  /**
33
38
  * Returns the intersection point of a segment and a line
34
39
  *
@@ -38,3 +43,4 @@ export declare const distanceToLineSegment: <Point extends LocalPoint | GlobalPo
38
43
  */
39
44
  export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point>, threshold?: number): Point | null;
40
45
  export declare function lineSegmentsDistance<Point extends GlobalPoint | LocalPoint>(s1: LineSegment<Point>, s2: LineSegment<Point>): number;
46
+ export declare function lineSegmentClosestParameter<Point extends GlobalPoint | LocalPoint>(point: Point, line: LineSegment<Point>): number;
@@ -3,6 +3,7 @@ import type { ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElemen
3
3
  import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
4
4
  export { MIME_TYPES };
5
5
  type ExportOpts = {
6
+ /** restored before exporting */
6
7
  elements: readonly NonDeletedExcalidrawElement[];
7
8
  appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
8
9
  files: BinaryFiles | null;
@@ -1,5 +1,5 @@
1
1
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
2
- import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@excalidraw/element/types";
2
+ import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawStickyNoteElement, ExcalidrawTextElement } from "@excalidraw/element/types";
3
3
  import type { Curve, LineSegment, Polygon, Radians } from "@excalidraw/math";
4
4
  import type { Drawable, Op } from "roughjs/bin/core";
5
5
  export type Polyline<Point extends GlobalPoint | LocalPoint> = LineSegment<Point>[];
@@ -29,7 +29,7 @@ export type GeometricShape<Point extends GlobalPoint | LocalPoint> = {
29
29
  type: "polycurve";
30
30
  data: Polycurve<Point>;
31
31
  };
32
- type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
32
+ type RectangularElement = ExcalidrawRectangleElement | ExcalidrawStickyNoteElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
33
33
  export declare const getPolygonShape: <Point extends GlobalPoint | LocalPoint>(element: RectangularElement) => GeometricShape<Point>;
34
34
  export declare const getSelectionBoxShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap, padding?: number) => GeometricShape<Point>;
35
35
  export declare const getEllipseShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawEllipseElement) => GeometricShape<Point>;