@excalidraw/element 0.18.0-4872083 → 0.18.0-4ce38fb

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 (119) hide show
  1. package/dist/dev/index.js +5645 -3994
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +16 -15
  4. package/dist/types/common/src/colors.d.ts +13 -7
  5. package/dist/types/common/src/constants.d.ts +54 -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/common/src/utils.d.ts +5 -0
  9. package/dist/types/element/src/Scene.d.ts +1 -1
  10. package/dist/types/element/src/binding.d.ts +13 -7
  11. package/dist/types/element/src/collision.d.ts +14 -5
  12. package/dist/types/element/src/comparisons.d.ts +5 -3
  13. package/dist/types/element/src/delta.d.ts +23 -1
  14. package/dist/types/element/src/duplicate.d.ts +60 -0
  15. package/dist/types/element/src/flowchart.d.ts +5 -1
  16. package/dist/types/element/src/frame.d.ts +2 -2
  17. package/dist/types/element/src/index.d.ts +2 -0
  18. package/dist/types/element/src/linearElementEditor.d.ts +10 -0
  19. package/dist/types/element/src/listMarker.d.ts +34 -0
  20. package/dist/types/element/src/mutateElement.d.ts +1 -1
  21. package/dist/types/element/src/newElement.d.ts +39 -3
  22. package/dist/types/element/src/renderElement.d.ts +21 -4
  23. package/dist/types/element/src/shape.d.ts +15 -1
  24. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  25. package/dist/types/element/src/stickyNote.d.ts +183 -0
  26. package/dist/types/element/src/textElement.d.ts +9 -1
  27. package/dist/types/element/src/transform.d.ts +25 -6
  28. package/dist/types/element/src/typeChecks.d.ts +3 -2
  29. package/dist/types/element/src/types.d.ts +35 -6
  30. package/dist/types/element/src/utils.d.ts +15 -4
  31. package/dist/types/element/src/zindex.d.ts +1 -1
  32. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +60 -3
  33. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  34. package/dist/types/excalidraw/actions/actionBoundText.d.ts +40 -2
  35. package/dist/types/excalidraw/actions/actionCanvas.d.ts +140 -7
  36. package/dist/types/excalidraw/actions/actionClipboard.d.ts +40 -2
  37. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +20 -1
  38. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +61 -4
  39. package/dist/types/excalidraw/actions/actionDeselect.d.ts +23 -1
  40. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  41. package/dist/types/excalidraw/actions/actionElementLink.d.ts +20 -1
  42. package/dist/types/excalidraw/actions/actionElementLock.d.ts +40 -2
  43. package/dist/types/excalidraw/actions/actionExport.d.ts +40 -2
  44. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  45. package/dist/types/excalidraw/actions/actionFrame.d.ts +111 -4
  46. package/dist/types/excalidraw/actions/actionGroup.d.ts +40 -2
  47. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +71 -2
  48. package/dist/types/excalidraw/actions/actionLink.d.ts +20 -1
  49. package/dist/types/excalidraw/actions/actionMenu.d.ts +20 -1
  50. package/dist/types/excalidraw/actions/actionProperties.d.ts +50 -8
  51. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +20 -1
  52. package/dist/types/excalidraw/actions/actionStyles.d.ts +21 -2
  53. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +20 -1
  54. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +20 -1
  55. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +20 -1
  56. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +20 -1
  57. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +20 -1
  58. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
  59. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +20 -1
  60. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +20 -1
  61. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +20 -1
  62. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  63. package/dist/types/excalidraw/actions/index.d.ts +1 -0
  64. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  65. package/dist/types/excalidraw/appState.d.ts +23 -1
  66. package/dist/types/excalidraw/components/App.arrowText.d.ts +28 -30
  67. package/dist/types/excalidraw/components/App.bucketFill.d.ts +10 -0
  68. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  69. package/dist/types/excalidraw/components/App.cursor.d.ts +8 -0
  70. package/dist/types/excalidraw/components/App.d.ts +110 -199
  71. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  72. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  73. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  74. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  75. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  76. package/dist/types/excalidraw/components/App.viewport.d.ts +41 -1
  77. package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
  78. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +6 -2
  79. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  80. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +4 -1
  81. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +4 -2
  82. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  83. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  84. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  85. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  86. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  87. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  88. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  89. package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
  90. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  91. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  92. package/dist/types/excalidraw/components/Tools.d.ts +7 -2
  93. package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
  94. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  95. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  96. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  97. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
  98. package/dist/types/excalidraw/components/icons.d.ts +2 -0
  99. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  100. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
  101. package/dist/types/excalidraw/data/blob.d.ts +40 -2
  102. package/dist/types/excalidraw/data/json.d.ts +20 -1
  103. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
  104. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  105. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  106. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  107. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  108. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  109. package/dist/types/excalidraw/scene/Renderer.d.ts +64 -2
  110. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  111. package/dist/types/excalidraw/scene/types.d.ts +3 -1
  112. package/dist/types/excalidraw/types.d.ts +140 -18
  113. package/dist/types/excalidraw/viewport.d.ts +33 -1
  114. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  115. package/dist/types/math/src/curve.d.ts +19 -12
  116. package/dist/types/math/src/segment.d.ts +6 -0
  117. package/dist/types/utils/src/export.d.ts +1 -0
  118. package/dist/types/utils/src/shape.d.ts +2 -2
  119. package/package.json +4 -4
@@ -1,7 +1,7 @@
1
1
  import type { UserIdleState, EditorInterface } from "@excalidraw/common";
2
2
  import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
3
3
  import type { MakeBrand } from "@excalidraw/common/utility-types";
4
- import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, PendingExcalidrawElements } from "../types";
4
+ import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementRenderOverrides, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, PendingExcalidrawElements } from "../types";
5
5
  import type { RoughCanvas } from "roughjs/bin/canvas";
6
6
  import type { Drawable } from "roughjs/bin/core";
7
7
  export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
@@ -19,6 +19,7 @@ export type StaticCanvasRenderConfig = {
19
19
  elementsPendingErasure: ElementsPendingErasure;
20
20
  pendingFlowchartNodes: PendingExcalidrawElements | null;
21
21
  theme: AppState["theme"];
22
+ elementRenderOverrides?: ElementRenderOverrides;
22
23
  };
23
24
  export type SVGRenderConfig = {
24
25
  offsetX: number;
@@ -132,6 +133,7 @@ export type ElementShapes = {
132
133
  arrow: Drawable[];
133
134
  line: Drawable[];
134
135
  text: null;
136
+ stickynote: null;
135
137
  image: null;
136
138
  frame: null;
137
139
  magicframe: null;
@@ -1,9 +1,9 @@
1
1
  import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
2
2
  import type { LinearElementEditor } from "@excalidraw/element";
3
- import type { MaybeTransformHandleType } from "@excalidraw/element";
3
+ import type { ListMarkerAdvance, MaybeTransformHandleType } from "@excalidraw/element";
4
4
  import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, ExcalidrawArrowElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
5
5
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
6
- import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
6
+ import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement, OnDuplicateData } from "@excalidraw/element";
7
7
  import type { GlobalPoint } from "@excalidraw/math";
8
8
  import type { Action } from "./actions/types";
9
9
  import type { Spreadsheet } from "./charts";
@@ -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;
@@ -141,7 +141,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
141
141
  isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
142
142
  gridModeEnabled: AppState["gridModeEnabled"];
143
143
  suggestedBinding: AppState["suggestedBinding"];
144
- hoveredArrowTextAnchor: AppState["hoveredArrowTextAnchor"];
144
+ textToolHover: AppState["textToolHover"];
145
145
  isRotating: AppState["isRotating"];
146
146
  elementsToHighlight: AppState["elementsToHighlight"];
147
147
  collaborators: AppState["collaborators"];
@@ -176,6 +176,11 @@ export type ObservedElementsAppState = {
176
176
  activeLockedId: AppState["activeLockedId"];
177
177
  };
178
178
  export type BoxSelectionMode = "contain" | "overlap";
179
+ /**
180
+ * The pointing device the wheel mappings are tuned for. `auto` is reserved
181
+ * for detecting it from the wheel events; see `resolveInputDevice`.
182
+ */
183
+ export type InputDevice = "auto" | "mouse" | "trackpad";
179
184
  /**
180
185
  * A box, in scene coordinates, that pan & zoom are constrained to.
181
186
  *
@@ -255,6 +260,16 @@ export interface AppState {
255
260
  bindingPreference: "enabled" | "disabled";
256
261
  /** user preference whether arrow snap to midpoints while binding */
257
262
  isMidpointSnappingEnabled: boolean;
263
+ /** user preference whether to show contextual hints above the toolbar */
264
+ showHints: boolean;
265
+ /**
266
+ * user preference for what the wheel does: with a `trackpad` a plain wheel
267
+ * pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
268
+ * delivered) zooms with either device. Shift+wheel pans horizontally;
269
+ * ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
270
+ * device detection exists — see `resolveInputDevice`
271
+ */
272
+ inputDevice: InputDevice;
258
273
  /**
259
274
  * The bindable element the UI highlights for the user when an arrow is
260
275
  * dragged or otherwise its endpoint being close to said element.
@@ -264,11 +279,20 @@ export interface AppState {
264
279
  midPoint?: GlobalPoint;
265
280
  } | null;
266
281
  /**
267
- * Where on a hovered arrow the text tool would attach text if clicked —
268
- * a free endpoint (binds the arrow to a new text element positioned against
269
- * that endpoint) or the arrow's midpoint (adds a label bound to the arrow).
282
+ * What a text-tool click at the hovered position would act on — the text
283
+ * it would edit, the empty container it would label, or the arrow anchor
284
+ * (a free endpoint, or the midpoint for a label) it would attach text to.
285
+ * `null` when the click would create free text, or the tool isn't active.
286
+ * Drives the hover affordance only.
270
287
  */
271
- hoveredArrowTextAnchor: {
288
+ textToolHover: {
289
+ type: "text";
290
+ elementId: ExcalidrawElement["id"];
291
+ } | {
292
+ type: "container";
293
+ elementId: ExcalidrawElement["id"];
294
+ } | {
295
+ type: "arrow";
272
296
  elementId: ExcalidrawArrowElement["id"];
273
297
  anchor: "start" | "end" | "label";
274
298
  } | null;
@@ -283,6 +307,10 @@ export interface AppState {
283
307
  * frame-like element whose name is currently being edited
284
308
  */
285
309
  editingFrame: ExcalidrawFrameLikeElement["id"] | null;
310
+ /**
311
+ * Elements the UI highlights with a bounding-box outline — those that
312
+ * would get added to a frame being dragged/resized.
313
+ */
286
314
  elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
287
315
  /**
288
316
  * set when a new text is created or when an existing text is being edited
@@ -308,6 +336,8 @@ export interface AppState {
308
336
  exportWithDarkMode: boolean;
309
337
  exportScale: number;
310
338
  currentItemStrokeColor: string;
339
+ currentItemStickynoteStrokeColor: string;
340
+ currentItemStickynoteBackgroundColor: string;
311
341
  currentItemBackgroundColor: string;
312
342
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
313
343
  currentItemStrokeWidthKey: StrokeWidthKey;
@@ -428,6 +458,23 @@ export interface AppState {
428
458
  [groupId: string]: true;
429
459
  };
430
460
  bindMode: BindMode;
461
+ /** user-customized color-picker top picks (pinned via drag & drop from the
462
+ * color picker popup). `null` means no customization (defaults, or
463
+ * host-supplied `topPicks`, are used). Kept per picker. */
464
+ colorTopPicks: {
465
+ elementStroke: readonly string[] | null;
466
+ elementBackground: readonly string[] | null;
467
+ /** the bucket-fill tool keeps a list separate from `elementBackground`
468
+ * even though both drive `currentItemBackgroundColor` (its defaults and
469
+ * use case differ — no transparent) */
470
+ bucketFill: readonly string[] | null;
471
+ /** sticky notes are their own color domain (own defaults, own picks) */
472
+ stickyNoteStroke: readonly string[] | null;
473
+ stickyNoteBackground: readonly string[] | null;
474
+ };
475
+ /** user-customized font-picker top picks (pinned via drag & drop from the
476
+ * font picker popup). `null` means no customization (defaults are used) */
477
+ fontTopPicks: readonly FontFamilyValues[] | null;
431
478
  }
432
479
  export type SearchMatch = {
433
480
  id: string;
@@ -440,7 +487,7 @@ export type SearchMatch = {
440
487
  showOnCanvas: boolean;
441
488
  }[];
442
489
  };
443
- export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "hoveredArrowTextAnchor" | "frameToHighlight" | "elementsToHighlight">;
490
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
444
491
  export type NormalizedZoomValue = number & {
445
492
  _brand: "normalizedZoom";
446
493
  };
@@ -619,8 +666,32 @@ export type UIConfig = {
619
666
  scrollBackToContent?: boolean;
620
667
  };
621
668
  };
669
+ /** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
670
+ export type ElementRenderOverride = Readonly<{
671
+ /** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
672
+ opacity?: number;
673
+ /** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
674
+ offset?: Readonly<{
675
+ x: number;
676
+ y: number;
677
+ }>;
678
+ }>;
679
+ /** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
680
+ export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
681
+ /** The translation part of a snapshot: only the entries that carry an offset. */
682
+ export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
622
683
  export interface ExcalidrawProps {
623
684
  className?: string;
685
+ /**
686
+ * Document that owns Excalidraw's mounted DOM.
687
+ *
688
+ * Set only when it differs from the global `document`, such as when code
689
+ * executing in a parent window mounts Excalidraw into an iframe document.
690
+ * The value must remain stable for the editor's lifetime.
691
+ *
692
+ * @default document
693
+ */
694
+ ownerDocument?: Document;
624
695
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
625
696
  onThemeChange?: (theme: Theme | "system") => void;
626
697
  /**
@@ -666,11 +737,27 @@ export interface ExcalidrawProps {
666
737
  *
667
738
  * Returned elements will be used in place of the next elements
668
739
  * (you should return all elements, including deleted, and not mutate
669
- * the element if changes are made)
740
+ * the element if changes are made).
741
+ *
742
+ * The duplicates are the elements in `nextElements` which are not in
743
+ * `prevElements` (see also `data.duplicateElements`). When pasting or
744
+ * inserting onto a frame, their `frameId` is already set. To change a
745
+ * duplicate, return a new object with the same `id`. It is shallow-merged
746
+ * into the duplicate (omitted properties are kept), and your changes are
747
+ * part of the duplication itself (same undo entry, same durable increment).
748
+ *
749
+ * To prevent an element from being duplicated, omit its duplicate from the
750
+ * returned array. References to it from the remaining duplicates are
751
+ * cleared, and a bound text isn't duplicated without its container. To
752
+ * prevent the duplication as a whole, return `false`. If no duplicate
753
+ * remains, the duplication is cancelled and the returned elements are
754
+ * ignored (alt-drag then moves the original elements instead).
670
755
  */
671
756
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
672
757
  /** excludes the duplicated elements */
673
- prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
758
+ prevElements: readonly ExcalidrawElement[],
759
+ /** lookups covering just the elements taking part in the duplication */
760
+ data: OnDuplicateData) => ExcalidrawElement[] | void | false;
674
761
  renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
675
762
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
676
763
  langCode?: Language["code"];
@@ -810,7 +897,8 @@ export interface ExcalidrawProps {
810
897
  }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
811
898
  }
812
899
  export type SceneData = {
813
- elements?: ImportedDataState["elements"];
900
+ /** Expects normalized elements; restore imported data before updating the scene. */
901
+ elements?: readonly ExcalidrawElement[] | null;
814
902
  appState?: ImportedDataState["appState"];
815
903
  collaborators?: Map<SocketId, Collaborator>;
816
904
  captureUpdate?: CaptureUpdateActionType;
@@ -870,6 +958,8 @@ export type AppProps = Merge<ExcalidrawProps, {
870
958
  export type AppClassProperties = {
871
959
  props: AppProps;
872
960
  state: AppState;
961
+ readonly ownerDocument: Document;
962
+ readonly ownerWindow: Window & typeof globalThis;
873
963
  api: App["api"];
874
964
  sessionExportThemeOverride: App["sessionExportThemeOverride"];
875
965
  interactiveCanvas: HTMLCanvasElement | null;
@@ -886,7 +976,7 @@ export type AppClassProperties = {
886
976
  scene: App["scene"];
887
977
  syncActionResult: App["syncActionResult"];
888
978
  fonts: App["fonts"];
889
- pasteFromClipboard: App["pasteFromClipboard"];
979
+ clipboard: App["clipboard"];
890
980
  id: App["id"];
891
981
  onInsertElements: App["onInsertElements"];
892
982
  onExportImage: App["onExportImage"];
@@ -903,7 +993,13 @@ export type AppClassProperties = {
903
993
  dismissLinearEditor: App["dismissLinearEditor"];
904
994
  flowchart: App["flowchart"];
905
995
  drawShape: App["drawShape"];
996
+ arrowText: App["arrowText"];
997
+ textTool: App["textTool"];
906
998
  cursor: App["cursor"];
999
+ bucketFill: App["bucketFill"];
1000
+ duplicate: App["duplicate"];
1001
+ toolDrag: App["toolDrag"];
1002
+ activeResizeHandle: App["activeResizeHandle"];
907
1003
  isToolLocked: App["isToolLocked"];
908
1004
  getEffectiveGridSize: App["getEffectiveGridSize"];
909
1005
  setPlugins: App["setPlugins"];
@@ -957,7 +1053,10 @@ export type PointerDownState = Readonly<{
957
1053
  allHitElements: NonDeleted<ExcalidrawElement>[];
958
1054
  wasAddedToSelection: boolean;
959
1055
  hasBeenDuplicated: boolean;
1056
+ advancedListMarkers: readonly ListMarkerAdvance[];
1057
+ editedTextId: ExcalidrawTextElement["id"] | null;
960
1058
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
1059
+ arrowLabel: boolean;
961
1060
  };
962
1061
  withCmdOrCtrl: boolean;
963
1062
  drag: {
@@ -1011,6 +1110,22 @@ export interface ExcalidrawImperativeAPI {
1011
1110
  getName: InstanceType<typeof App>["getName"];
1012
1111
  setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
1013
1112
  getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
1113
+ /**
1114
+ * Atomically replaces all transient visual overrides. Values are copied;
1115
+ * omitted IDs/fields use document values, except for inherited label offsets.
1116
+ * null clears the snapshot.
1117
+ * Repaints without document changes, history entries or onChange events;
1118
+ * an equivalent snapshot may still repaint (clearing an already clear
1119
+ * snapshot does not), so submit only when something changed.
1120
+ * Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
1121
+ * Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
1122
+ * Bound labels inherit their container's offset; offsets targeting them are
1123
+ * ignored. Label opacity remains independent. Target frame children explicitly.
1124
+ * Frame opacity still multiplies child opacity. Decorations follow their owner.
1125
+ * Exports and interactive geometry (hit tests, selection, editing) use document
1126
+ * values, including while authoring an animation preview in edit mode.
1127
+ */
1128
+ setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
1014
1129
  registerAction: (action: Action) => void;
1015
1130
  refresh: InstanceType<typeof App>["refresh"];
1016
1131
  setToast: InstanceType<typeof App>["setToast"];
@@ -1065,6 +1180,12 @@ export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSi
1065
1180
  export type GenerateDiagramToCode = (props: {
1066
1181
  frame: NonDeleted<ExcalidrawMagicFrameElement>;
1067
1182
  children: readonly NonDeletedExcalidrawElement[];
1183
+ /**
1184
+ * Optional streaming hook. Call with the accumulated response text as it
1185
+ * streams in so the editor can progressively render the partial HTML
1186
+ * inside the generated frame.
1187
+ */
1188
+ onPartial?: (html: string) => void;
1068
1189
  }) => MaybePromise<{
1069
1190
  html: string;
1070
1191
  }>;
@@ -1167,9 +1288,10 @@ export type ViewportOffsets = Offsets & {
1167
1288
  /**
1168
1289
  * Value of the `data-viewport-ui-name` attribute, identifying a
1169
1290
  * conditionally-rendered surface (marked with `data-viewport-ui`) so that
1170
- * `getViewportOffsets` can reserve space for it while it's hidden (see the
1171
- * `reserve` option). Whenever a named surface is rendered, its measured
1172
- * footprint is remembered; reserving uses that remembered footprint, or an
1173
- * approximate default if the surface hasn't been rendered yet.
1291
+ * it can be measured on its own, and so that `getViewportOffsets` can
1292
+ * reserve space for it while it's hidden (see the `reserve` option).
1293
+ * Whenever a named surface is rendered, its measured footprint is
1294
+ * remembered; reserving uses that remembered footprint, or an approximate
1295
+ * default if the surface hasn't been rendered yet.
1174
1296
  */
1175
- export type ViewportUIName = "sidebar" | "stylesPanel";
1297
+ export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";
@@ -108,11 +108,20 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
108
108
  boxSelectionMode: import("./types").BoxSelectionMode;
109
109
  bindingPreference: "enabled" | "disabled";
110
110
  isMidpointSnappingEnabled: boolean;
111
+ showHints: boolean;
112
+ inputDevice: import("./types").InputDevice;
111
113
  suggestedBinding: {
112
114
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
113
115
  midPoint?: import("@excalidraw/math").GlobalPoint;
114
116
  } | null;
115
- hoveredArrowTextAnchor: {
117
+ textToolHover: {
118
+ type: "text";
119
+ elementId: ExcalidrawElement["id"];
120
+ } | {
121
+ type: "container";
122
+ elementId: ExcalidrawElement["id"];
123
+ } | {
124
+ type: "arrow";
116
125
  elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
117
126
  anchor: "start" | "end" | "label";
118
127
  } | null;
@@ -142,6 +151,8 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
142
151
  exportWithDarkMode: boolean;
143
152
  exportScale: number;
144
153
  currentItemStrokeColor: string;
154
+ currentItemStickynoteStrokeColor: string;
155
+ currentItemStickynoteBackgroundColor: string;
145
156
  currentItemBackgroundColor: string;
146
157
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
147
158
  currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
@@ -244,6 +255,14 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fit, m
244
255
  [groupId: string]: true;
245
256
  };
246
257
  bindMode: import("@excalidraw/element/types").BindMode;
258
+ colorTopPicks: {
259
+ elementStroke: readonly string[] | null;
260
+ elementBackground: readonly string[] | null;
261
+ bucketFill: readonly string[] | null;
262
+ stickyNoteStroke: readonly string[] | null;
263
+ stickyNoteBackground: readonly string[] | null;
264
+ };
265
+ fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
247
266
  };
248
267
  captureUpdate: "EVENTUALLY";
249
268
  };
@@ -263,6 +282,19 @@ export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, of
263
282
  scrollX: number;
264
283
  scrollY: number;
265
284
  };
285
+ /**
286
+ * The scroll that brings `bounds` into the viewport — less `offsets` (screen
287
+ * px: UI covering its edges, room to leave) — by the least movement, keeping
288
+ * the zoom; `null` when they're in view already. Along an axis where they
289
+ * don't fit, their start (left / top) is brought in instead, or, with
290
+ * `tooLarge: "leave"`, that axis keeps its scroll.
291
+ */
292
+ export declare const scrollBoundsIntoView: ({ bounds: [x1, y1, x2, y2], appState: { scrollX, scrollY, zoom, width, height }, offsets, tooLarge, }: {
293
+ bounds: Bounds;
294
+ appState: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height">;
295
+ offsets?: Offsets;
296
+ tooLarge?: "alignStart" | "leave";
297
+ }) => Pick<AppState, "scrollX" | "scrollY"> | null;
266
298
  export declare const getScrollToContentState: (elements: readonly ExcalidrawElement[], appState: AppState) => {
267
299
  scrollX: number;
268
300
  scrollY: number;
@@ -1,7 +1,13 @@
1
1
  import type { ExcalidrawTextElement } from "@excalidraw/element/types";
2
2
  import type App from "../components/App";
3
+ /**
4
+ * How much further than the browser's caret reveal the canvas pans, in
5
+ * screen px: text typed past the viewport's edge comes back with this much
6
+ * room to spare, instead of flush against the edge.
7
+ */
8
+ export declare const CARET_FOLLOW_PADDING = 5;
3
9
  type SubmitHandler = () => void;
4
- export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, }: {
10
+ export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, initialSelection, }: {
5
11
  /**
6
12
  * textWysiwyg only deals with `originalText`
7
13
  *
@@ -23,5 +29,10 @@ export declare const textWysiwyg: ({ onChange, onSubmit, getViewportCoords, elem
23
29
  x: number;
24
30
  y: number;
25
31
  } | null;
32
+ /** range of `originalText` to select (takes precedence over the caret) */
33
+ initialSelection?: {
34
+ start: number;
35
+ end: number;
36
+ } | null;
26
37
  }) => SubmitHandler;
27
38
  export {};
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/element",
3
- "version": "0.18.0-4872083",
3
+ "version": "0.18.0-4ce38fb",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -63,8 +63,8 @@
63
63
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
64
64
  },
65
65
  "dependencies": {
66
- "@excalidraw/common": "0.18.0-4872083",
67
- "@excalidraw/math": "0.18.0-4872083",
68
- "@excalidraw/fractional-indexing": "0.18.0-4872083"
66
+ "@excalidraw/common": "0.18.0-4ce38fb",
67
+ "@excalidraw/math": "0.18.0-4ce38fb",
68
+ "@excalidraw/fractional-indexing": "0.18.0-4ce38fb"
69
69
  }
70
70
  }