@excalidraw/excalidraw 0.18.0-143b5b6 → 0.18.0-1440f2d

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 (153) hide show
  1. package/CHANGELOG.md +56 -4
  2. package/dist/dev/chunk-CB5LBNRX.js +385 -0
  3. package/dist/dev/chunk-CB5LBNRX.js.map +7 -0
  4. package/dist/dev/{chunk-FEJNYWVA.js → chunk-KPU35SWX.js} +14 -4
  5. package/dist/dev/chunk-KPU35SWX.js.map +7 -0
  6. package/dist/dev/{chunk-KMZYJ2CN.js → chunk-PMHQMXJL.js} +2423 -1556
  7. package/dist/dev/chunk-PMHQMXJL.js.map +7 -0
  8. package/dist/dev/data/{image-GQWXOMCO.js → image-MEFJ53NR.js} +2 -2
  9. package/dist/dev/index.css +192 -97
  10. package/dist/dev/index.css.map +3 -3
  11. package/dist/dev/index.js +6833 -5181
  12. package/dist/dev/index.js.map +4 -4
  13. package/dist/dev/locales/{en-XCQUEBFE.js → en-DIYR7LJM.js} +2 -2
  14. package/dist/dev/minimap-controller.chunk.js +516 -0
  15. package/dist/dev/minimap-controller.chunk.js.map +7 -0
  16. package/dist/dev/minimap-shared.chunk.js +19 -0
  17. package/dist/dev/minimap-shared.chunk.js.map +7 -0
  18. package/dist/dev/minimap-worker.chunk.js +20 -0
  19. package/dist/dev/minimap-worker.chunk.js.map +7 -0
  20. package/dist/prod/{chunk-3UZ67F5C.js → chunk-GJMJGXMI.js} +4 -4
  21. package/dist/prod/chunk-HMEZQHLQ.js +5 -0
  22. package/dist/prod/chunk-TLY2GM7R.js +1 -0
  23. package/dist/prod/data/image-CRT43OWP.js +1 -0
  24. package/dist/prod/index.css +1 -1
  25. package/dist/prod/index.js +37 -34
  26. package/dist/prod/locales/{en-APPZPZFQ.js → en-JHONSSC3.js} +1 -1
  27. package/dist/prod/minimap-controller.chunk.js +1 -0
  28. package/dist/prod/minimap-shared.chunk.js +1 -0
  29. package/dist/prod/minimap-worker.chunk.js +1 -0
  30. package/dist/types/common/src/constants.d.ts +1 -0
  31. package/dist/types/common/src/utils.d.ts +7 -1
  32. package/dist/types/element/src/align.d.ts +4 -1
  33. package/dist/types/element/src/binding.d.ts +62 -0
  34. package/dist/types/element/src/bounds.d.ts +10 -2
  35. package/dist/types/element/src/collision.d.ts +7 -0
  36. package/dist/types/element/src/cropElement.d.ts +36 -4
  37. package/dist/types/element/src/delta.d.ts +7 -1
  38. package/dist/types/element/src/distribute.d.ts +4 -1
  39. package/dist/types/element/src/dragElements.d.ts +8 -3
  40. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  41. package/dist/types/element/src/embeddable.d.ts +2 -1
  42. package/dist/types/element/src/flowchart.d.ts +1 -7
  43. package/dist/types/element/src/frame.d.ts +19 -1
  44. package/dist/types/element/src/groups.d.ts +1 -6
  45. package/dist/types/element/src/image.d.ts +5 -2
  46. package/dist/types/element/src/index.d.ts +1 -0
  47. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  48. package/dist/types/element/src/listMarker.d.ts +7 -2
  49. package/dist/types/element/src/newElement.d.ts +3 -1
  50. package/dist/types/element/src/renderElement.d.ts +10 -0
  51. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  52. package/dist/types/element/src/resizeElements.d.ts +15 -5
  53. package/dist/types/element/src/selection.d.ts +1 -7
  54. package/dist/types/element/src/shape.d.ts +2 -0
  55. package/dist/types/element/src/stickyNote.d.ts +8 -0
  56. package/dist/types/element/src/textElement.d.ts +3 -2
  57. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  58. package/dist/types/element/src/textWrapping.d.ts +3 -2
  59. package/dist/types/element/src/transform.d.ts +5 -1
  60. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -0
  61. package/dist/types/excalidraw/actions/actionBoundText.d.ts +47 -221
  62. package/dist/types/excalidraw/actions/actionCanvas.d.ts +13 -9
  63. package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -0
  64. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -0
  65. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -588
  66. package/dist/types/excalidraw/actions/actionDeselect.d.ts +2 -1
  67. package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -0
  68. package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -0
  69. package/dist/types/excalidraw/actions/actionExport.d.ts +9 -7
  70. package/dist/types/excalidraw/actions/actionFrame.d.ts +44 -525
  71. package/dist/types/excalidraw/actions/actionGroup.d.ts +4 -2
  72. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -0
  73. package/dist/types/excalidraw/actions/actionLink.d.ts +1 -0
  74. package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -0
  75. package/dist/types/excalidraw/actions/actionProperties.d.ts +2 -0
  76. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +2 -1
  77. package/dist/types/excalidraw/actions/actionStyles.d.ts +1 -0
  78. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -0
  79. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -0
  80. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -0
  81. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  82. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -0
  83. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -0
  84. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +1 -0
  85. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -0
  86. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -0
  87. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  88. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -0
  89. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  90. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  91. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  92. package/dist/types/excalidraw/appState.d.ts +8 -7
  93. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  94. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  95. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  96. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  97. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  98. package/dist/types/excalidraw/components/Actions.d.ts +9 -2
  99. package/dist/types/excalidraw/components/App.d.ts +23 -8
  100. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  101. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  102. package/dist/types/excalidraw/components/App.selectionTool.d.ts +42 -6
  103. package/dist/types/excalidraw/components/App.viewport.d.ts +23 -3
  104. package/dist/types/excalidraw/components/App.wheel.d.ts +6 -2
  105. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  106. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  107. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  108. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  109. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  110. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  111. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  112. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  113. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  114. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  115. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  116. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  117. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  118. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  119. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  120. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  121. package/dist/types/excalidraw/components/Tooltip.d.ts +11 -1
  122. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  123. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  124. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  125. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  126. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  127. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  128. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -0
  129. package/dist/types/excalidraw/data/blob.d.ts +16 -14
  130. package/dist/types/excalidraw/data/index.d.ts +3 -3
  131. package/dist/types/excalidraw/data/json.d.ts +8 -7
  132. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  133. package/dist/types/excalidraw/history.d.ts +10 -4
  134. package/dist/types/excalidraw/index.d.ts +3 -1
  135. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  136. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  137. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  138. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  139. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  140. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  141. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  142. package/dist/types/excalidraw/types.d.ts +48 -1
  143. package/dist/types/excalidraw/viewport.d.ts +1 -0
  144. package/dist/types/utils/src/index.d.ts +3 -1
  145. package/history.ts +29 -4
  146. package/package.json +6 -6
  147. package/dist/dev/chunk-FEJNYWVA.js.map +0 -7
  148. package/dist/dev/chunk-KMZYJ2CN.js.map +0 -7
  149. package/dist/prod/chunk-H5A3YXKD.js +0 -4
  150. package/dist/prod/data/image-6XY3GD3F.js +0 -1
  151. package/dist/types/utils/src/export.d.ts +0 -36
  152. /package/dist/dev/data/{image-GQWXOMCO.js.map → image-MEFJ53NR.js.map} +0 -0
  153. /package/dist/dev/locales/{en-XCQUEBFE.js.map → en-DIYR7LJM.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -13,12 +13,58 @@ 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
+ ### Arrows aren't clipped to frames (2026-10-31) [#12516](https://github.com/excalidraw/excalidraw/pull/12516)
17
+
18
+ - Arrows and their labels are no longer clipped to the frame they belong to, so they can connect elements across and out of frames, and their part outside the frame can be selected. They still belong to their frame, so they're moved, copied and deleted with it, but only while one of their ends is in it (bound to an element in the frame, or inside it). An arrow whose ends both leave its frame (moved, bound to elements outside it, or with the elements it's bound to) leaves the frame.
19
+ - Exporting a frame (and `getElementsOverlappingFrame`) now includes other frames' arrows that reach into it, like other elements overlapping it.
20
+ - Moving a frame (dragging it, with the arrow keys or from the stats panel) keeps its arrows bound to the elements that don't move with it, instead of unbinding them.
21
+
22
+ ### Flowchart navigation (2026-10-30) [#12502](https://github.com/excalidraw/excalidraw/pull/12502)
23
+
24
+ - Alt+arrow keys move the selection to the flowchart node that's visually next in that direction, whether or not it's linked to the selected node. They used to follow only the arrows bound to the pressed side, cycle through siblings on repeated presses, and fall back to any linked node when nothing was that way.
25
+ - The nearest node of the first non-empty tier wins: nodes in line (sharing the row for ←/→, the column for ↑/↓), then linked nodes whose center lies past the selected node's edge, then nodes whose center lies within the 45° cone of the pressed direction, then any node whose center lies past that edge. Near-ties go to linked nodes, then the node more level with the selected one's center, then reading order.
26
+ - Nodes connected by plain (non-elbow) arrows now count as part of the flowchart too, both for Alt+arrow navigation and for the nodes Ctrl+arrows keeps new nodes clear of.
27
+
28
+ ### Export API: `exportScene` (2026-10-18) [#12347](https://github.com/excalidraw/excalidraw/pull/12347)
29
+
30
+ 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`.
31
+
32
+ - `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`.
33
+ - `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.
34
+ - Migration:
35
+
36
+ | Before | Now |
37
+ | --- | --- |
38
+ | `exportToCanvas({ elements, appState, files, … })` | `exportScene({ type: "canvas", data: { elements, appState, files }, config })` |
39
+ | `exportToBlob({ …, mimeType, quality })` | `exportScene({ type: "png" \| "jpeg", …, config })` — `quality` is JPEG-only |
40
+ | `exportToSvg({ … })` | `exportScene({ type: "svg", … })` |
41
+ | `appState.exportBackground: false` | `config.canvasBackgroundColor: false` (a color string overrides the background; JPEG always gets one) |
42
+ | `appState.exportWithDarkMode` | `config.theme: "dark"` |
43
+ | `appState.exportScale` | `config.scale` (also multiplies a `maxWidthOrHeight` result) |
44
+ | `appState.exportEmbedScene` | `config.embedScene` (png, svg) |
45
+ | `appState.frameRendering` | `config.frames: { name?, outline?, clip? }` |
46
+ | `exportPadding` | `config.padding` (default 10, as before) |
47
+ | `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 |
48
+ | `maxWidthOrHeight`, `exportingFrame`, `renderEmbeddables`, `skipInliningFonts`, `reuseImages` | same names, in `config` |
49
+
50
+ - 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`.
51
+ - `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`.
52
+ - 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).
53
+ - In dark exports, frame names now use the editor's dark frame-name color (they were dark-filtered twice and came out lighter).
54
+
55
+ ### Selection API (2026-10-10) [#12258](https://github.com/excalidraw/excalidraw/pull/12258)
56
+
57
+ - 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.
58
+ - 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.
59
+ - 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.
60
+ - 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.
61
+
62
+ ### Wheel navigation (2026-09-13) [#12099](https://github.com/excalidraw/excalidraw/pull/12099)
17
63
 
18
64
  - 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
65
  - 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
66
 
21
- ### Sticky notes (2026-09-06) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
67
+ ### Sticky notes (2026-09-06) [#12064](https://github.com/excalidraw/excalidraw/pull/12064)
22
68
 
23
69
  - 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
70
  - 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 +77,11 @@ Please add the latest change on the top under the correct section.
31
77
 
32
78
  ## Excalidraw API
33
79
 
34
- ### `setViewport` stops following a collaborator (2026-09-26) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
80
+ ### `setViewport` stops following a collaborator (2026-09-26) [#12184](https://github.com/excalidraw/excalidraw/pull/12184)
35
81
 
36
82
  - `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
83
 
38
- ### `onDuplicate` can replace and veto duplicates (2026-09-18) [#XXXX](https://github.com/excalidraw/excalidraw/pull/XXXX)
84
+ ### `onDuplicate` can replace and veto duplicates (2026-09-18) [#12124](https://github.com/excalidraw/excalidraw/pull/12124)
39
85
 
40
86
  - `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
87
  - 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 +174,8 @@ The toolbar UI was rewritten from hidden radio/checkbox inputs to real `<button>
128
174
 
129
175
  ### Other Breaking changes
130
176
 
177
+ - `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)
178
+
131
179
  - `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
180
 
133
181
  ```tsx
@@ -161,6 +209,10 @@ The toolbar UI was rewritten from hidden radio/checkbox inputs to real `<button>
161
209
 
162
210
  ### Other Features
163
211
 
212
+ - 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, `swimlane-beta` diagrams are supported, and Gantt charts, quadrant charts and timelines are converted to elements instead of an image. Each diagram type's code is loaded the first time one is converted. Flowchart edges are elbow arrows, unless the definition sets its own curve (in its front matter or `%%{init}%%`), and class diagram namespaces are drawn as boxes like flowchart subgraphs. [#12480](https://github.com/excalidraw/excalidraw/pull/12480), [#12481](https://github.com/excalidraw/excalidraw/pull/12481), [#12535](https://github.com/excalidraw/excalidraw/pull/12535)
213
+
214
+ - `label.labelPosition` (0–1) of skeleton arrows places their label along the arrow, instead of halfway. [#12425](https://github.com/excalidraw/excalidraw/pull/12425)
215
+
164
216
  - 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
217
 
166
218
  - 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.
@@ -0,0 +1,385 @@
1
+ import {
2
+ __publicField
3
+ } from "./chunk-XDFCUUT6.js";
4
+
5
+ // components/Minimap/minimap-shared.chunk.ts
6
+ var MinimapRecord = {
7
+ /** drawn as a filled block */
8
+ BOX: 0,
9
+ /** drawn as an outline, so that it doesn't cover its children */
10
+ FRAME: 1,
11
+ /** drawn as a polyline */
12
+ PATH: 2
13
+ };
14
+ var MINIMAP_BOX_RECORD_SIZE = 6;
15
+ var MINIMAP_PATH_RECORD_HEADER_SIZE = 5;
16
+ var PADDING = 8;
17
+ var MIN_BLOCK_SIZE = 1.5;
18
+ var MINIMAP_MIN_VIEWPORT_SIZE = 6;
19
+ var PATH_WIDTH = 1.25;
20
+ var VIEWPORT_ALPHA = 0.25;
21
+ var VIEWPORT_OPAQUE_SIZE = 0.05;
22
+ var VIEWPORT_TRANSLUCENT_SIZE = 0.12;
23
+ var isSameTransform = (a, b) => !!a && a.scale === b.scale && a.translateX === b.translateX && a.translateY === b.translateY;
24
+ var getMinimapViewportRect = (viewport, transform) => {
25
+ const width = Math.max(
26
+ viewport.width * transform.scale,
27
+ MINIMAP_MIN_VIEWPORT_SIZE
28
+ );
29
+ const height = Math.max(
30
+ viewport.height * transform.scale,
31
+ MINIMAP_MIN_VIEWPORT_SIZE
32
+ );
33
+ return {
34
+ x: (viewport.x + viewport.width / 2) * transform.scale + transform.translateX - width / 2,
35
+ y: (viewport.y + viewport.height / 2) * transform.scale + transform.translateY - height / 2,
36
+ width,
37
+ height
38
+ };
39
+ };
40
+ var getRecordsBounds = (records) => {
41
+ let minX = Infinity;
42
+ let minY = Infinity;
43
+ let maxX = -Infinity;
44
+ let maxY = -Infinity;
45
+ const extend = (x1, y1, x2, y2, angle) => {
46
+ if (angle) {
47
+ const cos = Math.abs(Math.cos(angle));
48
+ const sin = Math.abs(Math.sin(angle));
49
+ const cx = (x1 + x2) / 2;
50
+ const cy = (y1 + y2) / 2;
51
+ const halfWidth = (x2 - x1) / 2;
52
+ const halfHeight = (y2 - y1) / 2;
53
+ const extentX = halfWidth * cos + halfHeight * sin;
54
+ const extentY = halfWidth * sin + halfHeight * cos;
55
+ x1 = cx - extentX;
56
+ x2 = cx + extentX;
57
+ y1 = cy - extentY;
58
+ y2 = cy + extentY;
59
+ }
60
+ minX = Math.min(minX, x1);
61
+ minY = Math.min(minY, y1);
62
+ maxX = Math.max(maxX, x2);
63
+ maxY = Math.max(maxY, y2);
64
+ };
65
+ let i = 0;
66
+ while (i < records.length) {
67
+ if (records[i] === MinimapRecord.PATH) {
68
+ const [x1, y1, x2, y2] = getPathBounds(records, i);
69
+ extend(x1, y1, x2, y2, records[i + 3]);
70
+ i += MINIMAP_PATH_RECORD_HEADER_SIZE + records[i + 4] * 2;
71
+ } else {
72
+ const x = records[i + 1];
73
+ const y = records[i + 2];
74
+ const width = records[i + 3];
75
+ const height = records[i + 4];
76
+ extend(
77
+ Math.min(x, x + width),
78
+ Math.min(y, y + height),
79
+ Math.max(x, x + width),
80
+ Math.max(y, y + height),
81
+ records[i + 5]
82
+ );
83
+ i += MINIMAP_BOX_RECORD_SIZE;
84
+ }
85
+ }
86
+ return Number.isFinite(minX) ? [minX, minY, maxX, maxY] : null;
87
+ };
88
+ var getPathBounds = (records, offset) => {
89
+ const x = records[offset + 1];
90
+ const y = records[offset + 2];
91
+ const count = records[offset + 4];
92
+ let minX = Infinity;
93
+ let minY = Infinity;
94
+ let maxX = -Infinity;
95
+ let maxY = -Infinity;
96
+ for (let p = 0; p < count; p++) {
97
+ const px = records[offset + MINIMAP_PATH_RECORD_HEADER_SIZE + p * 2];
98
+ const py = records[offset + MINIMAP_PATH_RECORD_HEADER_SIZE + p * 2 + 1];
99
+ minX = Math.min(minX, px);
100
+ minY = Math.min(minY, py);
101
+ maxX = Math.max(maxX, px);
102
+ maxY = Math.max(maxY, py);
103
+ }
104
+ if (!count) {
105
+ return [x, y, x, y];
106
+ }
107
+ return [x + minX, y + minY, x + maxX, y + maxY];
108
+ };
109
+ var MinimapRenderer = class {
110
+ constructor(canvas, config) {
111
+ this.canvas = canvas;
112
+ this.config = config;
113
+ __publicField(this, "context");
114
+ /**
115
+ * The elements rendered with `layerTransform`, so that viewport-only
116
+ * changes (panning, zooming) don't redraw every element.
117
+ */
118
+ __publicField(this, "layer");
119
+ __publicField(this, "layerContext");
120
+ __publicField(this, "layerTransform", null);
121
+ __publicField(this, "records", new Float32Array(0));
122
+ __publicField(this, "contentBounds", null);
123
+ __publicField(this, "viewport", null);
124
+ __publicField(this, "lockedTransform", null);
125
+ this.context = canvas.getContext("2d");
126
+ this.layer = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(1, 1) : canvas.ownerDocument.createElement("canvas");
127
+ this.layerContext = this.layer.getContext("2d");
128
+ this.resize();
129
+ }
130
+ setConfig(config) {
131
+ this.config = config;
132
+ this.resize();
133
+ }
134
+ setElements(records) {
135
+ this.records = records;
136
+ this.contentBounds = getRecordsBounds(records);
137
+ this.layerTransform = null;
138
+ }
139
+ setViewport(viewport) {
140
+ this.viewport = viewport;
141
+ }
142
+ getContentBounds() {
143
+ return this.contentBounds;
144
+ }
145
+ setLockedTransform(transform) {
146
+ this.lockedTransform = transform;
147
+ }
148
+ resize() {
149
+ const { width, height, devicePixelRatio } = this.config;
150
+ for (const canvas of [this.canvas, this.layer]) {
151
+ canvas.width = Math.max(1, Math.round(width * devicePixelRatio));
152
+ canvas.height = Math.max(1, Math.round(height * devicePixelRatio));
153
+ }
154
+ this.layerTransform = null;
155
+ }
156
+ /** fits the content along with the viewport into the minimap */
157
+ getTransform() {
158
+ if (this.lockedTransform) {
159
+ return this.lockedTransform;
160
+ }
161
+ let [minX, minY, maxX, maxY] = this.contentBounds ?? [
162
+ Infinity,
163
+ Infinity,
164
+ -Infinity,
165
+ -Infinity
166
+ ];
167
+ if (this.viewport) {
168
+ minX = Math.min(minX, this.viewport.x);
169
+ minY = Math.min(minY, this.viewport.y);
170
+ maxX = Math.max(maxX, this.viewport.x + this.viewport.width);
171
+ maxY = Math.max(maxY, this.viewport.y + this.viewport.height);
172
+ }
173
+ const { width, height } = this.config;
174
+ if (!Number.isFinite(minX)) {
175
+ return { scale: 1, translateX: width / 2, translateY: height / 2 };
176
+ }
177
+ const scale = Math.min(
178
+ Math.max(width - PADDING * 2, 1) / Math.max(maxX - minX, 1),
179
+ Math.max(height - PADDING * 2, 1) / Math.max(maxY - minY, 1)
180
+ );
181
+ return {
182
+ scale,
183
+ translateX: width / 2 - (minX + maxX) / 2 * scale,
184
+ translateY: height / 2 - (minY + maxY) / 2 * scale
185
+ };
186
+ }
187
+ renderLayer(transform) {
188
+ const context = this.layerContext;
189
+ if (!context) {
190
+ return;
191
+ }
192
+ const { devicePixelRatio, colors } = this.config;
193
+ const { scale, translateX, translateY } = transform;
194
+ const { records } = this;
195
+ context.setTransform(1, 0, 0, 1, 0, 0);
196
+ context.clearRect(0, 0, this.layer.width, this.layer.height);
197
+ context.fillStyle = colors.element;
198
+ context.strokeStyle = colors.element;
199
+ context.lineWidth = PATH_WIDTH;
200
+ context.lineJoin = "round";
201
+ context.lineCap = "round";
202
+ const resetTransform = () => context.setTransform(devicePixelRatio, 0, 0, devicePixelRatio, 0, 0);
203
+ const rotate = (angle, cx, cy) => {
204
+ context.translate(cx, cy);
205
+ context.rotate(angle);
206
+ context.translate(-cx, -cy);
207
+ };
208
+ resetTransform();
209
+ let i = 0;
210
+ while (i < records.length) {
211
+ const kind = records[i];
212
+ if (kind === MinimapRecord.PATH) {
213
+ const count = records[i + 4];
214
+ const angle2 = records[i + 3];
215
+ const originX = records[i + 1] * scale + translateX;
216
+ const originY = records[i + 2] * scale + translateY;
217
+ const points = i + MINIMAP_PATH_RECORD_HEADER_SIZE;
218
+ if (angle2) {
219
+ const [x1, y1, x2, y2] = getPathBounds(records, i);
220
+ rotate(
221
+ angle2,
222
+ (x1 + x2) / 2 * scale + translateX,
223
+ (y1 + y2) / 2 * scale + translateY
224
+ );
225
+ }
226
+ context.beginPath();
227
+ for (let p = 0; p < count; p++) {
228
+ const x = originX + records[points + p * 2] * scale;
229
+ const y = originY + records[points + p * 2 + 1] * scale;
230
+ if (p === 0) {
231
+ context.moveTo(x, y);
232
+ } else {
233
+ context.lineTo(x, y);
234
+ }
235
+ }
236
+ if (count === 1) {
237
+ context.lineTo(originX, originY);
238
+ }
239
+ context.stroke();
240
+ if (angle2) {
241
+ resetTransform();
242
+ }
243
+ i += MINIMAP_PATH_RECORD_HEADER_SIZE + count * 2;
244
+ continue;
245
+ }
246
+ const angle = records[i + 5];
247
+ const width = Math.max(Math.abs(records[i + 3]) * scale, MIN_BLOCK_SIZE);
248
+ const height = Math.max(Math.abs(records[i + 4]) * scale, MIN_BLOCK_SIZE);
249
+ const cx = (records[i + 1] + records[i + 3] / 2) * scale + translateX;
250
+ const cy = (records[i + 2] + records[i + 4] / 2) * scale + translateY;
251
+ if (angle) {
252
+ rotate(angle, cx, cy);
253
+ }
254
+ if (kind === MinimapRecord.FRAME) {
255
+ context.strokeRect(cx - width / 2, cy - height / 2, width, height);
256
+ } else {
257
+ context.fillRect(cx - width / 2, cy - height / 2, width, height);
258
+ }
259
+ if (angle) {
260
+ resetTransform();
261
+ }
262
+ i += MINIMAP_BOX_RECORD_SIZE;
263
+ }
264
+ this.layerTransform = transform;
265
+ }
266
+ render() {
267
+ const transform = this.getTransform();
268
+ const context = this.context;
269
+ if (!context) {
270
+ return transform;
271
+ }
272
+ if (!isSameTransform(this.layerTransform, transform)) {
273
+ this.renderLayer(transform);
274
+ }
275
+ const { devicePixelRatio, colors } = this.config;
276
+ context.setTransform(1, 0, 0, 1, 0, 0);
277
+ context.clearRect(0, 0, this.canvas.width, this.canvas.height);
278
+ context.drawImage(this.layer, 0, 0);
279
+ if (this.viewport) {
280
+ const { x, y, width, height } = getMinimapViewportRect(
281
+ this.viewport,
282
+ transform
283
+ );
284
+ const size = Math.max(
285
+ width / this.config.width,
286
+ height / this.config.height
287
+ );
288
+ const translucency = Math.min(
289
+ Math.max(
290
+ (size - VIEWPORT_OPAQUE_SIZE) / (VIEWPORT_TRANSLUCENT_SIZE - VIEWPORT_OPAQUE_SIZE),
291
+ 0
292
+ ),
293
+ 1
294
+ );
295
+ context.setTransform(devicePixelRatio, 0, 0, devicePixelRatio, 0, 0);
296
+ context.globalAlpha = 1 - translucency * (1 - VIEWPORT_ALPHA);
297
+ context.fillStyle = colors.viewport;
298
+ context.beginPath();
299
+ if (context.roundRect) {
300
+ context.roundRect(x, y, width, height, 2);
301
+ } else {
302
+ context.rect(x, y, width, height);
303
+ }
304
+ context.fill();
305
+ context.globalAlpha = 1;
306
+ }
307
+ return transform;
308
+ }
309
+ };
310
+ var defaultScheduler = {
311
+ requestFrame: (callback) => typeof requestAnimationFrame === "function" ? requestAnimationFrame(callback) : setTimeout(callback, 16),
312
+ cancelFrame: (id) => {
313
+ if (typeof cancelAnimationFrame === "function") {
314
+ cancelAnimationFrame(id);
315
+ } else {
316
+ clearTimeout(id);
317
+ }
318
+ }
319
+ };
320
+ var createMinimapEndpoint = (postMessage, { requestFrame, cancelFrame } = defaultScheduler) => {
321
+ let renderer = null;
322
+ let frameId = null;
323
+ let elementsSeq = -1;
324
+ let reportedSeq = -1;
325
+ let reportedTransform = null;
326
+ const render = () => {
327
+ frameId = null;
328
+ if (!renderer || elementsSeq < 0) {
329
+ return;
330
+ }
331
+ const transform = renderer.render();
332
+ if (reportedSeq !== elementsSeq || !isSameTransform(reportedTransform, transform)) {
333
+ reportedSeq = elementsSeq;
334
+ reportedTransform = transform;
335
+ postMessage({
336
+ type: "frame",
337
+ transform,
338
+ elementsSeq,
339
+ contentBounds: renderer.getContentBounds()
340
+ });
341
+ }
342
+ };
343
+ return {
344
+ handle: (message) => {
345
+ switch (message.type) {
346
+ case "init":
347
+ renderer = new MinimapRenderer(message.canvas, message.config);
348
+ break;
349
+ case "config":
350
+ renderer?.setConfig(message.config);
351
+ break;
352
+ case "elements":
353
+ elementsSeq = message.seq;
354
+ renderer?.setElements(message.records);
355
+ break;
356
+ case "viewport":
357
+ renderer?.setViewport(message.viewport);
358
+ break;
359
+ case "lock":
360
+ renderer?.setLockedTransform(message.transform);
361
+ break;
362
+ }
363
+ if (frameId === null) {
364
+ frameId = requestFrame(render);
365
+ }
366
+ },
367
+ destroy: () => {
368
+ if (frameId !== null) {
369
+ cancelFrame(frameId);
370
+ frameId = null;
371
+ }
372
+ renderer = null;
373
+ }
374
+ };
375
+ };
376
+
377
+ export {
378
+ MinimapRecord,
379
+ MINIMAP_BOX_RECORD_SIZE,
380
+ MINIMAP_PATH_RECORD_HEADER_SIZE,
381
+ MINIMAP_MIN_VIEWPORT_SIZE,
382
+ getMinimapViewportRect,
383
+ createMinimapEndpoint
384
+ };
385
+ //# sourceMappingURL=chunk-CB5LBNRX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../components/Minimap/minimap-shared.chunk.ts"],
4
+ "sourcesContent": ["/**\n * Minimap renderer & message protocol, shared by the worker and by the\n * main-thread fallback.\n *\n * DON'T depend on anything from the outside, as this module is part of a\n * separate lazy-loaded chunk that's also loaded by the worker \u2014 including\n * anything from the main chunk would pull the whole editor into the worker.\n */\n\n// -----------------------------------------------------------------------------\n// protocol\n// -----------------------------------------------------------------------------\n\n/**\n * Elements are sent as a flat Float32Array of records, so that the main\n * thread only copies a few numbers per element and everything else (bounds,\n * transform, drawing) happens off the main thread. Each record starts with\n * its kind:\n *\n * - `BOX` & `FRAME`: `kind, x, y, width, height, angle`\n * - `PATH`: `kind, x, y, angle, pointsCount, ...[pointX, pointY]` (points\n * are relative to `x`/`y`, same as on linear elements)\n */\nexport const MinimapRecord = {\n /** drawn as a filled block */\n BOX: 0,\n /** drawn as an outline, so that it doesn't cover its children */\n FRAME: 1,\n /** drawn as a polyline */\n PATH: 2,\n} as const;\n\nexport const MINIMAP_BOX_RECORD_SIZE = 6;\nexport const MINIMAP_PATH_RECORD_HEADER_SIZE = 5;\n\n/** scene \u2192 minimap (CSS pixels): `minimap = scene * scale + translate` */\nexport type MinimapTransform = {\n scale: number;\n translateX: number;\n translateY: number;\n};\n\n/** in scene coordinates */\nexport type MinimapViewport = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nexport type MinimapColors = {\n element: string;\n viewport: string;\n};\n\nexport type MinimapConfig = {\n /** CSS pixels */\n width: number;\n /** CSS pixels */\n height: number;\n devicePixelRatio: number;\n colors: MinimapColors;\n};\n\ntype MinimapCanvas = OffscreenCanvas | HTMLCanvasElement;\n\nexport type MinimapInMessage =\n | { type: \"init\"; canvas: MinimapCanvas; config: MinimapConfig }\n | { type: \"config\"; config: MinimapConfig }\n | { type: \"elements\"; seq: number; records: Float32Array }\n | { type: \"viewport\"; viewport: MinimapViewport }\n /**\n * While a transform is supplied, it's used as is instead of being fitted\n * to the content. Used while dragging the viewport of a locked (scroll-\n * constrained) editor, so that the minimap doesn't rescale as the viewport\n * rubberbands past the lock.\n */\n | { type: \"lock\"; transform: MinimapTransform | null };\n\nexport type MinimapOutMessage = {\n type: \"frame\";\n /** the transform the frame was rendered with */\n transform: MinimapTransform;\n /** `seq` of the elements the frame was rendered with */\n elementsSeq: number;\n /** bounds of those elements, in scene coordinates (null if there are none) */\n contentBounds: MinimapBounds | null;\n};\n\n// -----------------------------------------------------------------------------\n// renderer\n// -----------------------------------------------------------------------------\n\n/** CSS pixels */\nconst PADDING = 8;\n/** CSS pixels. Keeps tiny elements visible. */\nconst MIN_BLOCK_SIZE = 1.5;\n/** CSS pixels. Keeps the viewport visible (and grabbable) when tiny. */\nexport const MINIMAP_MIN_VIEWPORT_SIZE = 6;\n/** CSS pixels */\nconst PATH_WIDTH = 1.25;\n/**\n * The viewport is a translucent overlay, so that the elements in it show\n * through...\n */\nconst VIEWPORT_ALPHA = 0.25;\n/**\n * ...but the smaller it is, the more opaque \u2014 it'd otherwise get lost among\n * the elements. As fractions of the minimap's size (the viewport's larger\n * side to the minimap's respective one): fully opaque at the first and below,\n * at the regular opacity from the second up.\n */\nconst VIEWPORT_OPAQUE_SIZE = 0.05;\nconst VIEWPORT_TRANSLUCENT_SIZE = 0.12;\nexport type MinimapBounds = [\n minX: number,\n minY: number,\n maxX: number,\n maxY: number,\n];\ntype Bounds = MinimapBounds;\n\nconst isSameTransform = (a: MinimapTransform | null, b: MinimapTransform) =>\n !!a &&\n a.scale === b.scale &&\n a.translateX === b.translateX &&\n a.translateY === b.translateY;\n\n/**\n * The on-minimap rect of the viewport, grown to the minimum size around its\n * center.\n */\nexport const getMinimapViewportRect = (\n viewport: MinimapViewport,\n transform: MinimapTransform,\n) => {\n const width = Math.max(\n viewport.width * transform.scale,\n MINIMAP_MIN_VIEWPORT_SIZE,\n );\n const height = Math.max(\n viewport.height * transform.scale,\n MINIMAP_MIN_VIEWPORT_SIZE,\n );\n return {\n x:\n (viewport.x + viewport.width / 2) * transform.scale +\n transform.translateX -\n width / 2,\n y:\n (viewport.y + viewport.height / 2) * transform.scale +\n transform.translateY -\n height / 2,\n width,\n height,\n };\n};\n\nconst getRecordsBounds = (records: Float32Array): Bounds | null => {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n const extend = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n angle: number,\n ) => {\n if (angle) {\n // AABB of the rect rotated around its center\n const cos = Math.abs(Math.cos(angle));\n const sin = Math.abs(Math.sin(angle));\n const cx = (x1 + x2) / 2;\n const cy = (y1 + y2) / 2;\n const halfWidth = (x2 - x1) / 2;\n const halfHeight = (y2 - y1) / 2;\n const extentX = halfWidth * cos + halfHeight * sin;\n const extentY = halfWidth * sin + halfHeight * cos;\n x1 = cx - extentX;\n x2 = cx + extentX;\n y1 = cy - extentY;\n y2 = cy + extentY;\n }\n minX = Math.min(minX, x1);\n minY = Math.min(minY, y1);\n maxX = Math.max(maxX, x2);\n maxY = Math.max(maxY, y2);\n };\n\n let i = 0;\n while (i < records.length) {\n if (records[i] === MinimapRecord.PATH) {\n const [x1, y1, x2, y2] = getPathBounds(records, i);\n extend(x1, y1, x2, y2, records[i + 3]);\n i += MINIMAP_PATH_RECORD_HEADER_SIZE + records[i + 4] * 2;\n } else {\n const x = records[i + 1];\n const y = records[i + 2];\n const width = records[i + 3];\n const height = records[i + 4];\n // elements being drawn can have negative dimensions\n extend(\n Math.min(x, x + width),\n Math.min(y, y + height),\n Math.max(x, x + width),\n Math.max(y, y + height),\n records[i + 5],\n );\n i += MINIMAP_BOX_RECORD_SIZE;\n }\n }\n\n return Number.isFinite(minX) ? [minX, minY, maxX, maxY] : null;\n};\n\n/** unrotated bounds of the PATH record at `offset` */\nconst getPathBounds = (records: Float32Array, offset: number): Bounds => {\n const x = records[offset + 1];\n const y = records[offset + 2];\n const count = records[offset + 4];\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let p = 0; p < count; p++) {\n const px = records[offset + MINIMAP_PATH_RECORD_HEADER_SIZE + p * 2];\n const py = records[offset + MINIMAP_PATH_RECORD_HEADER_SIZE + p * 2 + 1];\n minX = Math.min(minX, px);\n minY = Math.min(minY, py);\n maxX = Math.max(maxX, px);\n maxY = Math.max(maxY, py);\n }\n if (!count) {\n return [x, y, x, y];\n }\n return [x + minX, y + minY, x + maxX, y + maxY];\n};\n\ntype Context2D =\n | OffscreenCanvasRenderingContext2D\n | CanvasRenderingContext2D\n | null;\n\nclass MinimapRenderer {\n private context: Context2D;\n /**\n * The elements rendered with `layerTransform`, so that viewport-only\n * changes (panning, zooming) don't redraw every element.\n */\n private layer: MinimapCanvas;\n private layerContext: Context2D;\n private layerTransform: MinimapTransform | null = null;\n\n private records: Float32Array = new Float32Array(0);\n private contentBounds: Bounds | null = null;\n private viewport: MinimapViewport | null = null;\n private lockedTransform: MinimapTransform | null = null;\n\n constructor(private canvas: MinimapCanvas, private config: MinimapConfig) {\n this.context = canvas.getContext(\"2d\") as Context2D;\n this.layer =\n typeof OffscreenCanvas !== \"undefined\"\n ? new OffscreenCanvas(1, 1)\n : (canvas as HTMLCanvasElement).ownerDocument.createElement(\"canvas\");\n this.layerContext = this.layer.getContext(\"2d\") as Context2D;\n this.resize();\n }\n\n setConfig(config: MinimapConfig) {\n this.config = config;\n this.resize();\n }\n\n setElements(records: Float32Array) {\n this.records = records;\n this.contentBounds = getRecordsBounds(records);\n this.layerTransform = null;\n }\n\n setViewport(viewport: MinimapViewport) {\n this.viewport = viewport;\n }\n\n getContentBounds() {\n return this.contentBounds;\n }\n\n setLockedTransform(transform: MinimapTransform | null) {\n this.lockedTransform = transform;\n }\n\n private resize() {\n const { width, height, devicePixelRatio } = this.config;\n for (const canvas of [this.canvas, this.layer]) {\n canvas.width = Math.max(1, Math.round(width * devicePixelRatio));\n canvas.height = Math.max(1, Math.round(height * devicePixelRatio));\n }\n this.layerTransform = null;\n }\n\n /** fits the content along with the viewport into the minimap */\n private getTransform(): MinimapTransform {\n if (this.lockedTransform) {\n return this.lockedTransform;\n }\n\n let [minX, minY, maxX, maxY] = this.contentBounds ?? [\n Infinity,\n Infinity,\n -Infinity,\n -Infinity,\n ];\n if (this.viewport) {\n minX = Math.min(minX, this.viewport.x);\n minY = Math.min(minY, this.viewport.y);\n maxX = Math.max(maxX, this.viewport.x + this.viewport.width);\n maxY = Math.max(maxY, this.viewport.y + this.viewport.height);\n }\n\n const { width, height } = this.config;\n if (!Number.isFinite(minX)) {\n return { scale: 1, translateX: width / 2, translateY: height / 2 };\n }\n\n const scale = Math.min(\n Math.max(width - PADDING * 2, 1) / Math.max(maxX - minX, 1),\n Math.max(height - PADDING * 2, 1) / Math.max(maxY - minY, 1),\n );\n\n return {\n scale,\n translateX: width / 2 - ((minX + maxX) / 2) * scale,\n translateY: height / 2 - ((minY + maxY) / 2) * scale,\n };\n }\n\n private renderLayer(transform: MinimapTransform) {\n const context = this.layerContext;\n if (!context) {\n return;\n }\n const { devicePixelRatio, colors } = this.config;\n const { scale, translateX, translateY } = transform;\n const { records } = this;\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, this.layer.width, this.layer.height);\n context.fillStyle = colors.element;\n context.strokeStyle = colors.element;\n context.lineWidth = PATH_WIDTH;\n context.lineJoin = \"round\";\n context.lineCap = \"round\";\n\n const resetTransform = () =>\n context.setTransform(devicePixelRatio, 0, 0, devicePixelRatio, 0, 0);\n const rotate = (angle: number, cx: number, cy: number) => {\n context.translate(cx, cy);\n context.rotate(angle);\n context.translate(-cx, -cy);\n };\n resetTransform();\n\n let i = 0;\n while (i < records.length) {\n const kind = records[i];\n\n if (kind === MinimapRecord.PATH) {\n const count = records[i + 4];\n const angle = records[i + 3];\n const originX = records[i + 1] * scale + translateX;\n const originY = records[i + 2] * scale + translateY;\n const points = i + MINIMAP_PATH_RECORD_HEADER_SIZE;\n\n if (angle) {\n const [x1, y1, x2, y2] = getPathBounds(records, i);\n rotate(\n angle,\n ((x1 + x2) / 2) * scale + translateX,\n ((y1 + y2) / 2) * scale + translateY,\n );\n }\n context.beginPath();\n for (let p = 0; p < count; p++) {\n const x = originX + records[points + p * 2] * scale;\n const y = originY + records[points + p * 2 + 1] * scale;\n if (p === 0) {\n context.moveTo(x, y);\n } else {\n context.lineTo(x, y);\n }\n }\n if (count === 1) {\n // a dot\n context.lineTo(originX, originY);\n }\n context.stroke();\n if (angle) {\n resetTransform();\n }\n\n i += MINIMAP_PATH_RECORD_HEADER_SIZE + count * 2;\n continue;\n }\n\n const angle = records[i + 5];\n const width = Math.max(Math.abs(records[i + 3]) * scale, MIN_BLOCK_SIZE);\n const height = Math.max(Math.abs(records[i + 4]) * scale, MIN_BLOCK_SIZE);\n const cx = (records[i + 1] + records[i + 3] / 2) * scale + translateX;\n const cy = (records[i + 2] + records[i + 4] / 2) * scale + translateY;\n\n if (angle) {\n rotate(angle, cx, cy);\n }\n if (kind === MinimapRecord.FRAME) {\n context.strokeRect(cx - width / 2, cy - height / 2, width, height);\n } else {\n context.fillRect(cx - width / 2, cy - height / 2, width, height);\n }\n if (angle) {\n resetTransform();\n }\n\n i += MINIMAP_BOX_RECORD_SIZE;\n }\n\n this.layerTransform = transform;\n }\n\n render(): MinimapTransform {\n const transform = this.getTransform();\n const context = this.context;\n if (!context) {\n return transform;\n }\n\n if (!isSameTransform(this.layerTransform, transform)) {\n this.renderLayer(transform);\n }\n\n const { devicePixelRatio, colors } = this.config;\n\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n context.drawImage(this.layer, 0, 0);\n\n if (this.viewport) {\n const { x, y, width, height } = getMinimapViewportRect(\n this.viewport,\n transform,\n );\n const size = Math.max(\n width / this.config.width,\n height / this.config.height,\n );\n const translucency = Math.min(\n Math.max(\n (size - VIEWPORT_OPAQUE_SIZE) /\n (VIEWPORT_TRANSLUCENT_SIZE - VIEWPORT_OPAQUE_SIZE),\n 0,\n ),\n 1,\n );\n\n context.setTransform(devicePixelRatio, 0, 0, devicePixelRatio, 0, 0);\n context.globalAlpha = 1 - translucency * (1 - VIEWPORT_ALPHA);\n context.fillStyle = colors.viewport;\n context.beginPath();\n if (context.roundRect) {\n context.roundRect(x, y, width, height, 2);\n } else {\n context.rect(x, y, width, height);\n }\n context.fill();\n context.globalAlpha = 1;\n }\n\n return transform;\n }\n}\n\n// -----------------------------------------------------------------------------\n// endpoint\n// -----------------------------------------------------------------------------\n\nexport type MinimapScheduler = {\n requestFrame: (callback: () => void) => number;\n cancelFrame: (id: number) => void;\n};\n\n/** that of the global scope, i.e. of the worker */\nconst defaultScheduler: MinimapScheduler = {\n requestFrame: (callback) =>\n typeof requestAnimationFrame === \"function\"\n ? requestAnimationFrame(callback)\n : (setTimeout(callback, 16) as unknown as number),\n cancelFrame: (id) => {\n if (typeof cancelAnimationFrame === \"function\") {\n cancelAnimationFrame(id);\n } else {\n clearTimeout(id);\n }\n },\n};\n\n/**\n * Receives the messages of the editor and renders at most once per frame.\n * Runs in the worker, or on the main thread where workers (or\n * OffscreenCanvas) aren't available \u2014 there, supply the scheduler of the\n * window the minimap is rendered in, which may not be the one the code runs\n * in (an editor mounted into a pop-out window).\n */\nexport const createMinimapEndpoint = (\n postMessage: (message: MinimapOutMessage) => void,\n { requestFrame, cancelFrame }: MinimapScheduler = defaultScheduler,\n) => {\n let renderer: MinimapRenderer | null = null;\n let frameId: number | null = null;\n let elementsSeq = -1;\n let reportedSeq = -1;\n let reportedTransform: MinimapTransform | null = null;\n\n const render = () => {\n frameId = null;\n // nothing is drawn (nor reported) until the first elements arrive: a\n // minimap fitted to the viewport alone would only flash by, and couldn't\n // be dragged in for the lack of content bounds\n if (!renderer || elementsSeq < 0) {\n return;\n }\n const transform = renderer.render();\n // the editor only needs to know about new elements being rendered (so it\n // can send the next ones) and about the transform changing (to map the\n // pointer). Don't wake it up otherwise, e.g. on each panned frame.\n if (\n reportedSeq !== elementsSeq ||\n !isSameTransform(reportedTransform, transform)\n ) {\n reportedSeq = elementsSeq;\n reportedTransform = transform;\n postMessage({\n type: \"frame\",\n transform,\n elementsSeq,\n contentBounds: renderer.getContentBounds(),\n });\n }\n };\n\n return {\n handle: (message: MinimapInMessage) => {\n switch (message.type) {\n case \"init\":\n renderer = new MinimapRenderer(message.canvas, message.config);\n break;\n case \"config\":\n renderer?.setConfig(message.config);\n break;\n case \"elements\":\n elementsSeq = message.seq;\n renderer?.setElements(message.records);\n break;\n case \"viewport\":\n renderer?.setViewport(message.viewport);\n break;\n case \"lock\":\n renderer?.setLockedTransform(message.transform);\n break;\n }\n if (frameId === null) {\n frameId = requestFrame(render);\n }\n },\n destroy: () => {\n if (frameId !== null) {\n cancelFrame(frameId);\n frameId = null;\n }\n renderer = null;\n },\n };\n};\n"],
5
+ "mappings": ";;;;;AAuBO,IAAM,gBAAgB;AAAA;AAAA,EAE3B,KAAK;AAAA;AAAA,EAEL,OAAO;AAAA;AAAA,EAEP,MAAM;AACR;AAEO,IAAM,0BAA0B;AAChC,IAAM,kCAAkC;AA6D/C,IAAM,UAAU;AAEhB,IAAM,iBAAiB;AAEhB,IAAM,4BAA4B;AAEzC,IAAM,aAAa;AAKnB,IAAM,iBAAiB;AAOvB,IAAM,uBAAuB;AAC7B,IAAM,4BAA4B;AASlC,IAAM,kBAAkB,CAAC,GAA4B,MACnD,CAAC,CAAC,KACF,EAAE,UAAU,EAAE,SACd,EAAE,eAAe,EAAE,cACnB,EAAE,eAAe,EAAE;AAMd,IAAM,yBAAyB,CACpC,UACA,cACG;AACH,QAAM,QAAQ,KAAK;AAAA,IACjB,SAAS,QAAQ,UAAU;AAAA,IAC3B;AAAA,EACF;AACA,QAAM,SAAS,KAAK;AAAA,IAClB,SAAS,SAAS,UAAU;AAAA,IAC5B;AAAA,EACF;AACA,SAAO;AAAA,IACL,IACG,SAAS,IAAI,SAAS,QAAQ,KAAK,UAAU,QAC9C,UAAU,aACV,QAAQ;AAAA,IACV,IACG,SAAS,IAAI,SAAS,SAAS,KAAK,UAAU,QAC/C,UAAU,aACV,SAAS;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;AAEA,IAAM,mBAAmB,CAAC,YAAyC;AACjE,MAAI,OAAO;AACX,MAAI,OAAO;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AgB,QAAQ,QAAQ,QAAQ,MAAM;AAC7D;AAAA,QACF,KAAK;AACH,oBAAU,UAAU,QAAQ,MAAM;AAClC;AAAA,QACF,KAAK;AACH,wBAAc,QAAQ;AACtB,oBAAU,YAAY,QAAQ,OAAO;AACrC;AAAA,QACF,KAAK;AACH,oBAAU,YAAY,QAAQ,QAAQ;AACtC;AAAA,QACF,KAAK;AACH,oBAAU,mBAAmB,QAAQ,SAAS;AAC9C;AAAA,MACJ;AACA,UAAI,YAAY,MAAM;AACpB,kBAAU,aAAa,MAAM;AAAA,MAC/B;AAAA,IACF;AAAA,IACA,SAAS,MAAM;AACb,UAAI,YAAY,MAAM;AACpB,oBAAY,OAAO;AACnB,kBAAU;AAAA,MACZ;AACA,iBAAW;AAAA,IACb;AAAA,EACF;AACF;",
6
+ "names": ["angle"]
7
+ }
@@ -3,6 +3,8 @@ var labels = {
3
3
  signUp: "Sign up",
4
4
  signIn: "Sign in",
5
5
  upgrade: "Upgrade",
6
+ tryExcalidrawPlus: "Try Excalidraw+",
7
+ plusFreeTrial: "14-day free trial",
6
8
  paste: "Paste",
7
9
  pasteAsPlaintext: "Paste as plaintext",
8
10
  pasteCharts: "Paste charts",
@@ -115,6 +117,8 @@ var labels = {
115
117
  collaborators: "Collaborators",
116
118
  you: "You",
117
119
  toggleGrid: "Toggle grid",
120
+ minimap: "Minimap",
121
+ zoom: "Zoom",
118
122
  addToLibrary: "Add to library",
119
123
  removeFromLibrary: "Remove from library",
120
124
  libraryLoadingMessage: "Loading library\u2026",
@@ -189,6 +193,8 @@ var labels = {
189
193
  copyElementLink: "Copy link to object",
190
194
  linkToElement: "Link to object",
191
195
  wrapSelectionInFrame: "Wrap selection in frame",
196
+ removeFrame: "Remove frame",
197
+ toggleWrap: "Wrap or unwrap selection",
192
198
  tab: "Tab",
193
199
  shapeSwitch: "Switch shape",
194
200
  preferences: "Preferences",
@@ -198,7 +204,7 @@ var labels = {
198
204
  boxSelectionOverlap: "Overlap",
199
205
  arrowBinding: "Arrow binding",
200
206
  midpointSnapping: "Snap to midpoints",
201
- showHints: "Show hints",
207
+ showHints: "Toolbar hints",
202
208
  inputDevice: "Input",
203
209
  inputDeviceTrackpad: "Trackpad",
204
210
  inputDeviceMouse: "Mouse"
@@ -245,6 +251,7 @@ var buttons = {
245
251
  zoomIn: "Zoom in",
246
252
  zoomOut: "Zoom out",
247
253
  resetZoom: "Reset zoom",
254
+ zoomToFit: "Zoom to fit",
248
255
  menu: "Menu",
249
256
  done: "Done",
250
257
  edit: "Edit",
@@ -673,12 +680,15 @@ var fileDrop = {
673
680
  var mermaid = {
674
681
  title: "Mermaid to Excalidraw",
675
682
  button: "Insert",
676
- description: "Currently only <flowchartLink>Flowchart</flowchartLink>, <sequenceLink>Sequence</sequenceLink>, <classLink>Class</classLink>, and <erdLink>Entity Relationship</erdLink> Diagrams are supported. The other types will be rendered as image in Excalidraw.",
683
+ description: "<flowchartLink>Flowcharts</flowchartLink>, <sequenceLink>Sequence</sequenceLink>, <classLink>Class</classLink>, <stateLink>State</stateLink> and <erdLink>Entity Relationship</erdLink> diagrams, <ganttLink>Gantt charts</ganttLink>, <quadrantLink>Quadrant charts</quadrantLink> and <timelineLink>Timelines</timelineLink> are converted to Excalidraw elements. Other types are inserted as an image.",
677
684
  syntax: "Mermaid Syntax",
678
685
  preview: "Preview",
679
686
  label: "Mermaid",
680
687
  inputPlaceholder: "Write Mermaid diagram definition here...",
681
- autoFixAvailable: "Auto-fix is available"
688
+ autoFixAvailable: "Auto-fix is available",
689
+ loadError: "Couldn't load Mermaid. Check your internet connection and try again.",
690
+ loadErrorReload: "Couldn't load Mermaid. Reload the page to try again.",
691
+ reload: "Reload"
682
692
  };
683
693
  var ttd = {
684
694
  error: "Error!"
@@ -864,4 +874,4 @@ export {
864
874
  keys,
865
875
  en_default
866
876
  };
867
- //# sourceMappingURL=chunk-FEJNYWVA.js.map
877
+ //# sourceMappingURL=chunk-KPU35SWX.js.map