@excalidraw/excalidraw 0.18.0-4ce38fb → 0.18.0-4ce8305

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 (105) hide show
  1. package/CHANGELOG.md +44 -4
  2. package/dist/dev/{chunk-KMZYJ2CN.js → chunk-CVOYRGLH.js} +2417 -1553
  3. package/dist/dev/chunk-CVOYRGLH.js.map +7 -0
  4. package/dist/dev/{chunk-QS4IP4I2.js → chunk-YD2YRM57.js} +10 -2
  5. package/dist/dev/chunk-YD2YRM57.js.map +7 -0
  6. package/dist/dev/data/{image-GQWXOMCO.js → image-3LWDGIXT.js} +2 -2
  7. package/dist/dev/index.js +5767 -4020
  8. package/dist/dev/index.js.map +4 -4
  9. package/dist/dev/locales/{en-RLKKKTGS.js → en-WX2OLU4V.js} +2 -2
  10. package/dist/prod/chunk-3QRAWHSF.js +5 -0
  11. package/dist/prod/chunk-OELYWRPZ.js +12 -0
  12. package/dist/prod/data/image-ZCXJNUOU.js +1 -0
  13. package/dist/prod/index.js +39 -36
  14. package/dist/prod/locales/{en-7ZVUCEYH.js → en-ZUDBUUE3.js} +1 -1
  15. package/dist/types/common/src/utils.d.ts +7 -1
  16. package/dist/types/element/src/align.d.ts +4 -1
  17. package/dist/types/element/src/binding.d.ts +36 -0
  18. package/dist/types/element/src/bounds.d.ts +10 -2
  19. package/dist/types/element/src/collision.d.ts +7 -0
  20. package/dist/types/element/src/cropElement.d.ts +36 -4
  21. package/dist/types/element/src/delta.d.ts +7 -1
  22. package/dist/types/element/src/distribute.d.ts +4 -1
  23. package/dist/types/element/src/dragElements.d.ts +8 -3
  24. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  25. package/dist/types/element/src/embeddable.d.ts +2 -1
  26. package/dist/types/element/src/groups.d.ts +1 -6
  27. package/dist/types/element/src/image.d.ts +5 -2
  28. package/dist/types/element/src/index.d.ts +1 -0
  29. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  30. package/dist/types/element/src/listMarker.d.ts +7 -2
  31. package/dist/types/element/src/newElement.d.ts +3 -1
  32. package/dist/types/element/src/renderElement.d.ts +10 -0
  33. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  34. package/dist/types/element/src/resizeElements.d.ts +15 -5
  35. package/dist/types/element/src/selection.d.ts +1 -7
  36. package/dist/types/element/src/shape.d.ts +2 -0
  37. package/dist/types/element/src/stickyNote.d.ts +8 -0
  38. package/dist/types/element/src/textElement.d.ts +3 -2
  39. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  40. package/dist/types/element/src/textWrapping.d.ts +3 -2
  41. package/dist/types/element/src/transform.d.ts +5 -1
  42. package/dist/types/excalidraw/actions/actionBoundText.d.ts +46 -221
  43. package/dist/types/excalidraw/actions/actionCanvas.d.ts +6 -6
  44. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -588
  45. package/dist/types/excalidraw/actions/actionDeselect.d.ts +1 -1
  46. package/dist/types/excalidraw/actions/actionExport.d.ts +7 -7
  47. package/dist/types/excalidraw/actions/actionFrame.d.ts +41 -525
  48. package/dist/types/excalidraw/actions/actionGroup.d.ts +2 -2
  49. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
  50. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  51. package/dist/types/excalidraw/actions/index.d.ts +1 -0
  52. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  53. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  54. package/dist/types/excalidraw/appState.d.ts +7 -7
  55. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  56. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  57. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  58. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  59. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  60. package/dist/types/excalidraw/components/App.d.ts +34 -20
  61. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  62. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  63. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  64. package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
  65. package/dist/types/excalidraw/components/App.viewport.d.ts +13 -3
  66. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  67. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  68. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  69. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  70. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  71. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  72. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  73. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  74. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  75. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  76. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +27 -1
  77. package/dist/types/excalidraw/components/Tooltip.d.ts +11 -1
  78. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  79. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  80. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  81. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  82. package/dist/types/excalidraw/data/blob.d.ts +14 -14
  83. package/dist/types/excalidraw/data/index.d.ts +3 -3
  84. package/dist/types/excalidraw/data/json.d.ts +7 -7
  85. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  86. package/dist/types/excalidraw/history.d.ts +10 -4
  87. package/dist/types/excalidraw/index.d.ts +3 -1
  88. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  89. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  90. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  91. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  92. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  93. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  94. package/dist/types/excalidraw/types.d.ts +49 -1
  95. package/dist/types/utils/src/index.d.ts +3 -1
  96. package/history.ts +29 -4
  97. package/package.json +6 -6
  98. package/dist/dev/chunk-KMZYJ2CN.js.map +0 -7
  99. package/dist/dev/chunk-QS4IP4I2.js.map +0 -7
  100. package/dist/prod/chunk-FLFP27SU.js +0 -12
  101. package/dist/prod/chunk-H5A3YXKD.js +0 -4
  102. package/dist/prod/data/image-6XY3GD3F.js +0 -1
  103. package/dist/types/utils/src/export.d.ts +0 -36
  104. /package/dist/dev/data/{image-GQWXOMCO.js.map → image-3LWDGIXT.js.map} +0 -0
  105. /package/dist/dev/locales/{en-RLKKKTGS.js.map → en-WX2OLU4V.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -13,12 +13,46 @@ Please add the latest change on the top under the correct section.
13
13
 
14
14
  ## Unreleased
15
15
 
16
- ### Wheel navigation (2026-09-13) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
16
+ ### Export API: `exportScene` (2026-10-18) [#12347](https://github.com/excalidraw/excalidraw/pull/12347)
17
+
18
+ Breaking. `exportToCanvas`, `exportToBlob` and `exportToSvg` (in both `@excalidraw/excalidraw` and `@excalidraw/utils`) are replaced by a single `exportScene`, and every rendering option moved from `appState` into an explicit `config`.
19
+
20
+ - `exportScene({ type, data, config })` with `type` `"canvas"`, `"png"`, `"jpeg"` or `"svg"` resolves to an `HTMLCanvasElement`, a `Blob` or an `SVGSVGElement`. `exportToClipboard({ type: "png" | "svg" | "json", data, config })` stays. Types: `ExportSceneData`, `ExportSceneConfig`, `ExportSceneOptions`.
21
+ - `data` is `{ elements, appState?, files? }`, the shape of a `.excalidraw` file. Only the scene settings a file stores are read from `appState`: `viewBackgroundColor` as the default background, and the grid settings that `embedScene` embeds. Any other key is ignored, so passing a live `appState` can't affect the output.
22
+ - Migration:
23
+
24
+ | Before | Now |
25
+ | --- | --- |
26
+ | `exportToCanvas({ elements, appState, files, … })` | `exportScene({ type: "canvas", data: { elements, appState, files }, config })` |
27
+ | `exportToBlob({ …, mimeType, quality })` | `exportScene({ type: "png" \| "jpeg", …, config })` — `quality` is JPEG-only |
28
+ | `exportToSvg({ … })` | `exportScene({ type: "svg", … })` |
29
+ | `appState.exportBackground: false` | `config.canvasBackgroundColor: false` (a color string overrides the background; JPEG always gets one) |
30
+ | `appState.exportWithDarkMode` | `config.theme: "dark"` |
31
+ | `appState.exportScale` | `config.scale` (also multiplies a `maxWidthOrHeight` result) |
32
+ | `appState.exportEmbedScene` | `config.embedScene` (png, svg) |
33
+ | `appState.frameRendering` | `config.frames: { name?, outline?, clip? }` |
34
+ | `exportPadding` | `config.padding` (default 10, as before) |
35
+ | `getDimensions: (w, h) => ({ width, height, scale })` | `config.width`/`height`, `maxWidthOrHeight` or `widthOrHeight`, plus `config.scale` — a number, or `(width, height) => number` receiving the export size at scale 1 (padding included), e.g. to cap the output by a pixel budget |
36
+ | `maxWidthOrHeight`, `exportingFrame`, `renderEmbeddables`, `skipInliningFonts`, `reuseImages` | same names, in `config` |
37
+
38
+ - New sizing options: `width`/`height` (only one given: the other follows the content's aspect ratio), `widthOrHeight` (scales the longest side to exactly that size), `fit: "contain" | "none"` and `position: "center" | "topLeft"` within a `width`/`height` frame, and `x`/`y`/`origin` to export a region (cropped, with padding on all sides). The size options are mutually exclusive in the types, and `fit`, `position` and `x`/`y` only combine with `width`/`height`.
39
+ - `config.environment` for non-browser hosts and other windows, the same for every format: `createCanvas` (e.g. `node-canvas`), `createImage`, `createPath`, `document` (the one SVG is built in, e.g. `linkedom`), `textMetrics` and `loadFonts`.
40
+ - Canvas dimensions are rounded instead of truncated, so float noise no longer costs a pixel (a 20.5px frame-label band now rounds up), and are at least 1px (flat content with no padding used to produce an empty canvas that couldn't be encoded).
41
+ - In dark exports, frame names now use the editor's dark frame-name color (they were dark-filtered twice and came out lighter).
42
+
43
+ ### Selection API (2026-10-10) [#12258](https://github.com/excalidraw/excalidraw/pull/12258)
44
+
45
+ - New `excalidrawAPI.selection`: `select(elements, opts?)`, `add(elements, opts?)`, `remove(elements, opts?)` and `clear(opts?)`, taking elements or their ids, one or many. Missing and deleted elements are skipped.
46
+ - It follows the editor's rules: an element is selected with its group, a frame and its children aren't selected at the same time, and locked elements are skipped. Text editing and cropping end, and the link popup of a lone selected element with a link shows.
47
+ - Options: `deep` selects the elements themselves rather than their groups, editing their group if they share one (as Ctrl/Cmd+click does); `includeLocked` selects locked elements too; `captureUpdate` records the change for undo as for `updateScene()` — by default it's recorded along with the next undoable change.
48
+ - Like `updateScene()`, the change applies on the next render: read it back through `onChange()` or `getAppState()` after that. It works in view mode too, where the selection shows without the transform handles.
49
+
50
+ ### Wheel navigation (2026-09-13) [#12099](https://github.com/excalidraw/excalidraw/pull/12099)
17
51
 
18
52
  - Scrolling while holding the wheel (middle) mouse button zooms the canvas around the pointer, the same as ctrl/cmd+wheel — a wheel-button pan can be zoomed one-handed, without reaching for a modifier.
19
53
  - New `appState.inputDevice` preference (`"auto" | "mouse" | "trackpad"`, default `"auto"`, persisted in browser storage) selecting the wheel mappings. With `"trackpad"` a plain wheel pans; with `"mouse"` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is delivered) zooms with either device. Shift+wheel pans horizontally, and ctrl/cmd+shift+wheel pans vertically. The wheel-button zoom above is unaffected. `"auto"` is reserved for detecting the device from the wheel events and resolves to `"trackpad"` until that is implemented (`resolveInputDevice()`). Set it from the new "Input device" radio in the main menu's preferences submenu, also exposed as `MainMenu.DefaultItems.Preferences.InputDevice`.
20
54
 
21
- ### Sticky notes (2026-09-06) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
55
+ ### Sticky notes (2026-09-06) [#12064](https://github.com/excalidraw/excalidraw/pull/12064)
22
56
 
23
57
  - New `stickynote` element type and toolbar tool (`N`): an always-filled, flat-rendered note whose label auto-fits — the font shrinks from the user's size down to a minimum, and only then does the note grow in height (it never shrinks below the height the user gave it). Click to place a 250×250 note, drag to size it (previewed at the dragged size, snapped to a font-aware minimum on release); text editing starts right away.
24
58
  - Element model: the note carries `baseHeight` (the user's height; `height ≥ baseHeight`), its label carries `baseFontSize` (the user's font ceiling, `null`/absent on any other text) while `fontSize` holds the fitted size. Read a text element's user-facing size through `getBaseFontSize(text, elementsMap)`.
@@ -31,11 +65,11 @@ Please add the latest change on the top under the correct section.
31
65
 
32
66
  ## Excalidraw API
33
67
 
34
- ### `setViewport` stops following a collaborator (2026-09-26) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
68
+ ### `setViewport` stops following a collaborator (2026-09-26) [#12184](https://github.com/excalidraw/excalidraw/pull/12184)
35
69
 
36
70
  - `setViewport` now asks to stop following a collaborator whenever it navigates (`onUserFollow` with `action: "UNFOLLOW"`, if `userToFollow` is set), as a user's pan or zoom does. `setViewport(null)` (clearing a lock) and a target that doesn't resolve don't navigate, and leave following alone.
37
71
 
38
- ### `onDuplicate` can replace and veto duplicates (2026-09-18) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
72
+ ### `onDuplicate` can replace and veto duplicates (2026-09-18) [#12124](https://github.com/excalidraw/excalidraw/pull/12124)
39
73
 
40
74
  - `props.onDuplicate` may now return new objects for the duplicated elements in every duplication path. Previously the editor kept using the objects it created, so on paste (and library insert) the frame assignment and bound text redraw went to objects that were no longer in the scene, and alt-drag dragged an element that wasn't in the scene. The returned changes are now merged into the editor's duplicates, so they're part of the duplication's own undo entry and durable increment (no follow-up `updateScene` needed).
41
75
  - When pasting or inserting onto a frame, the duplicates passed to `onDuplicate` already have their `frameId` set (and are ordered under the frame).
@@ -128,6 +162,8 @@ The toolbar UI was rewritten from hidden radio/checkbox inputs to real `<button>
128
162
 
129
163
  ### Other Breaking changes
130
164
 
165
+ - `convertToExcalidrawElements()` places bound arrows where their bindings put them, as the editor does whenever it updates their bindings (e.g. on undo/redo, or moving what they're bound to), instead of keeping their ends exactly where given. An end given just short of what it's bound to is extended onto it, and one beyond its binding area is unbound. Shapes created from an arrow's `start`/`end` are placed along its end segment. [#12425](https://github.com/excalidraw/excalidraw/pull/12425)
166
+
131
167
  - `UIAppState` no longer includes `zoom`, `shouldCacheIgnoreZoom`, and the canvas-interaction transients `snapLines`, `originSnapOffset`, `suggestedBinding`, `frameToHighlight`, and `elementsToHighlight`. These update per pointermove or per animation frame and no longer re-render the editor UI, so UI render props receiving `UIAppState` (`renderCustomStats`, custom `<Footer/>` content, etc.) don't receive them anymore and would render stale values if they read them off the full `AppState`. Subscribe through `useExcalidrawStateValue` instead — the component re-renders only when the selected value changes:
132
168
 
133
169
  ```tsx
@@ -161,6 +197,10 @@ The toolbar UI was rewritten from hidden radio/checkbox inputs to real `<button>
161
197
 
162
198
  ### Other Features
163
199
 
200
+ - Mermaid diagrams (in the TTD dialog and on paste) are converted with `@excalidraw/mermaid-to-excalidraw` v3, which lays them out with [Pele](https://pele.run) instead of Mermaid, no longer bundled. Layouts differ from before, and `swimlane-beta` diagrams are supported. [#12480](https://github.com/excalidraw/excalidraw/pull/12480)
201
+
202
+ - `label.labelPosition` (0–1) of skeleton arrows places their label along the arrow, instead of halfway. [#12425](https://github.com/excalidraw/excalidraw/pull/12425)
203
+
164
204
  - Added `ExcalidrawAPI.isDestroyed` flag. Set to `true` once the editor unmounts. Calling any `get*` method, `onStateChange`, or `onEvent` on a destroyed API instance will throw in development and `console.error` in production. The `ExcalidrawAPI` will be reset to `null` on unmount, but to be extra safe, you should check `ExcalidrawAPI.isDestroyed` before calling these methods to guard against subtle race conditions in your code.
165
205
 
166
206
  - Added `onMount`, `onInitialize`, and `onUnmount` props. `onMount` receives `{ excalidrawAPI, container }` once the editor root is mounted. `onInitialize` fires once the initial scene has loaded. `onUnmount` fires just before unmounting.