@excalidraw/common 0.18.0-d9e8a33 → 0.18.0-dabd83c

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 (253) hide show
  1. package/dist/dev/index.js +237 -104
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/colors.d.ts +23 -1
  5. package/dist/types/common/src/constants.d.ts +68 -7
  6. package/dist/types/common/src/keys.d.ts +6 -0
  7. package/dist/types/common/src/points.d.ts +1 -1
  8. package/dist/types/common/src/random.d.ts +7 -0
  9. package/dist/types/common/src/utils.d.ts +13 -44
  10. package/dist/types/element/src/Scene.d.ts +7 -5
  11. package/dist/types/element/src/align.d.ts +5 -2
  12. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  13. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  14. package/dist/types/element/src/binding.d.ts +90 -13
  15. package/dist/types/element/src/bounds.d.ts +28 -7
  16. package/dist/types/element/src/bucketFill.d.ts +110 -0
  17. package/dist/types/element/src/collision.d.ts +21 -5
  18. package/dist/types/element/src/comparisons.d.ts +8 -5
  19. package/dist/types/element/src/convertToShape.d.ts +23 -0
  20. package/dist/types/element/src/cropElement.d.ts +36 -4
  21. package/dist/types/element/src/delta.d.ts +30 -2
  22. package/dist/types/element/src/distribute.d.ts +5 -2
  23. package/dist/types/element/src/dragElements.d.ts +34 -2
  24. package/dist/types/element/src/duplicate.d.ts +64 -3
  25. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  26. package/dist/types/element/src/embeddable.d.ts +3 -2
  27. package/dist/types/element/src/flowchart.d.ts +9 -11
  28. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  29. package/dist/types/element/src/frame.d.ts +30 -11
  30. package/dist/types/element/src/groups.d.ts +10 -15
  31. package/dist/types/element/src/image.d.ts +5 -2
  32. package/dist/types/element/src/index.d.ts +7 -1
  33. package/dist/types/element/src/linearElementEditor.d.ts +31 -11
  34. package/dist/types/element/src/listMarker.d.ts +39 -0
  35. package/dist/types/element/src/mutateElement.d.ts +1 -1
  36. package/dist/types/element/src/newElement.d.ts +55 -3
  37. package/dist/types/element/src/renderElement.d.ts +31 -7
  38. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  39. package/dist/types/element/src/resizeElements.d.ts +14 -4
  40. package/dist/types/element/src/selection.d.ts +7 -13
  41. package/dist/types/element/src/shape.d.ts +29 -1
  42. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  43. package/dist/types/element/src/sortElements.d.ts +10 -0
  44. package/dist/types/element/src/stickyNote.d.ts +191 -0
  45. package/dist/types/element/src/textElement.d.ts +22 -10
  46. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  47. package/dist/types/element/src/textWrapping.d.ts +3 -2
  48. package/dist/types/element/src/transform.d.ts +31 -8
  49. package/dist/types/element/src/typeChecks.d.ts +29 -27
  50. package/dist/types/element/src/types.d.ts +43 -7
  51. package/dist/types/element/src/utils.d.ts +15 -4
  52. package/dist/types/element/src/zindex.d.ts +2 -2
  53. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +98 -18
  54. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  55. package/dist/types/excalidraw/actions/actionBoundText.d.ts +79 -204
  56. package/dist/types/excalidraw/actions/actionCanvas.d.ts +306 -951
  57. package/dist/types/excalidraw/actions/actionClipboard.d.ts +68 -12
  58. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +34 -6
  59. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -521
  60. package/dist/types/excalidraw/actions/actionDeselect.d.ts +35 -7
  61. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  62. package/dist/types/excalidraw/actions/actionElementLink.d.ts +34 -6
  63. package/dist/types/excalidraw/actions/actionElementLock.d.ts +69 -13
  64. package/dist/types/excalidraw/actions/actionExport.d.ts +76 -20
  65. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  66. package/dist/types/excalidraw/actions/actionFrame.d.ts +132 -652
  67. package/dist/types/excalidraw/actions/actionGroup.d.ts +83 -27
  68. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +89 -9
  69. package/dist/types/excalidraw/actions/actionLink.d.ts +35 -7
  70. package/dist/types/excalidraw/actions/actionMenu.d.ts +34 -6
  71. package/dist/types/excalidraw/actions/actionProperties.d.ts +106 -34
  72. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +39 -11
  73. package/dist/types/excalidraw/actions/actionStyles.d.ts +31 -7
  74. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
  75. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +35 -7
  76. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +38 -11
  77. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +35 -7
  78. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +206 -0
  79. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +35 -7
  80. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +38 -11
  81. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  82. package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleShowHints.d.ts} +50 -19
  83. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +35 -7
  84. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +36 -8
  85. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  86. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +35 -7
  87. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  88. package/dist/types/excalidraw/actions/index.d.ts +4 -2
  89. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  90. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  91. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  92. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  93. package/dist/types/excalidraw/appState.d.ts +37 -12
  94. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  95. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  96. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  97. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  98. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  99. package/dist/types/excalidraw/components/Actions.d.ts +26 -13
  100. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  101. package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
  102. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  103. package/dist/types/excalidraw/components/App.clipboard.d.ts +59 -0
  104. package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
  105. package/dist/types/excalidraw/components/App.d.ts +335 -111
  106. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  107. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  108. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  109. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  110. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  111. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  112. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  113. package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
  114. package/dist/types/excalidraw/components/App.text.d.ts +194 -0
  115. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  116. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  117. package/dist/types/excalidraw/components/App.viewport.d.ts +133 -0
  118. package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
  119. package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
  120. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
  121. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  122. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
  123. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  124. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  125. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  126. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  127. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  128. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  129. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  130. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -3
  131. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  132. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  133. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  134. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  135. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  136. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  137. package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
  138. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  139. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  140. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  141. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  142. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  143. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  144. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  145. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  146. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  147. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  148. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  149. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  150. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  151. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  152. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  153. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  154. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  155. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  156. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  157. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  158. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  159. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  160. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  161. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  162. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  163. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  164. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  165. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  166. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  167. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  168. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  169. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  170. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  171. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  172. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  173. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  174. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  175. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  176. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  177. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  178. package/dist/types/excalidraw/components/Toast.d.ts +12 -1
  179. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  180. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  181. package/dist/types/excalidraw/components/Tools.d.ts +151 -0
  182. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  183. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  184. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  185. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  186. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  187. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  188. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  189. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
  190. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  191. package/dist/types/excalidraw/components/footer/Footer.d.ts +5 -1
  192. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  193. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +15 -4
  194. package/dist/types/excalidraw/components/icons.d.ts +8 -1
  195. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +10 -4
  196. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  197. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  198. package/dist/types/excalidraw/data/blob.d.ts +84 -28
  199. package/dist/types/excalidraw/data/index.d.ts +7 -7
  200. package/dist/types/excalidraw/data/json.d.ts +48 -20
  201. package/dist/types/excalidraw/data/library.d.ts +1 -1
  202. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  203. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  204. package/dist/types/excalidraw/fonts/Fonts.d.ts +12 -8
  205. package/dist/types/excalidraw/history.d.ts +10 -4
  206. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  207. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  208. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  209. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  210. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  211. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  212. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  213. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  214. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  215. package/dist/types/excalidraw/renderer/animation.d.ts +15 -4
  216. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  217. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
  218. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  219. package/dist/types/excalidraw/scene/Renderer.d.ts +490 -21
  220. package/dist/types/excalidraw/scene/export.d.ts +344 -21
  221. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  222. package/dist/types/excalidraw/scene/types.d.ts +30 -5
  223. package/dist/types/excalidraw/snapping.d.ts +7 -7
  224. package/dist/types/excalidraw/types.d.ts +617 -29
  225. package/dist/types/excalidraw/viewport.d.ts +308 -0
  226. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +13 -3
  227. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  228. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  229. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  230. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  231. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  232. package/dist/types/math/src/constants.d.ts +0 -1
  233. package/dist/types/math/src/curve.d.ts +19 -12
  234. package/dist/types/math/src/index.d.ts +1 -0
  235. package/dist/types/math/src/pca.d.ts +79 -0
  236. package/dist/types/math/src/point.d.ts +1 -0
  237. package/dist/types/math/src/polygon.d.ts +25 -1
  238. package/dist/types/math/src/segment.d.ts +6 -0
  239. package/dist/types/utils/src/index.d.ts +4 -3
  240. package/dist/types/utils/src/shape.d.ts +2 -2
  241. package/package.json +1 -1
  242. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  243. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  244. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  245. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
  246. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  247. package/dist/types/excalidraw/components/shapes.d.ts +0 -263
  248. package/dist/types/excalidraw/cursor.d.ts +0 -5
  249. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  250. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  251. package/dist/types/utils/src/bbox.d.ts +0 -9
  252. package/dist/types/utils/src/export.d.ts +0 -35
  253. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -1,13 +1,45 @@
1
- import type { TransformHandleType } from "./transformHandles";
2
- import type { ElementsMap, ExcalidrawImageElement, ImageCrop } from "./types";
1
+ import type { TransformHandleDirection } from "./transformHandles";
2
+ import type { ElementsMap, ExcalidrawImageElement } from "./types";
3
3
  export declare const MINIMAL_CROP_SIZE = 10;
4
- export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
4
+ /**
5
+ * Crops the image (as it was at the drag's start) as resizing it would
6
+ * resize it, as far as the image reaches.
7
+ */
8
+ export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleDirection, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, { shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
9
+ shouldMaintainAspectRatio?: boolean;
10
+ shouldResizeFromCenter?: boolean;
11
+ }) => {
5
12
  x: number;
6
13
  y: number;
7
14
  width: number;
8
15
  height: number;
9
- crop: ImageCrop | null;
16
+ crop: {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ naturalWidth: number;
22
+ naturalHeight: number;
23
+ } | null;
10
24
  };
25
+ /**
26
+ * Uncrops the image on the handle's side (a corner's two); mirrored, on the
27
+ * opposite side(s) too.
28
+ */
29
+ export declare const uncropElementSides: (element: ExcalidrawImageElement, elementsMap: ElementsMap, handle: TransformHandleDirection, mirrored?: boolean) => {
30
+ x: number;
31
+ y: number;
32
+ width: number;
33
+ height: number;
34
+ crop: {
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ naturalWidth: number;
40
+ naturalHeight: number;
41
+ } | null;
42
+ } | null;
11
43
  export declare const getUncroppedImageElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap) => ExcalidrawImageElement;
12
44
  export declare const getUncroppedWidthAndHeight: (element: ExcalidrawImageElement) => {
13
45
  width: number;
@@ -2,6 +2,7 @@ import type { ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElement
2
2
  import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
4
4
  import { StoreSnapshot } from "./store";
5
+ import type { RenderEnvironment } from "./renderEnvironment";
5
6
  /**
6
7
  * Represents the difference between two objects of the same type.
7
8
  *
@@ -146,6 +147,11 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
146
147
  type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
147
148
  export type ApplyToOptions = {
148
149
  excludedProperties?: Set<keyof ElementPartial>;
150
+ /**
151
+ * measures the labels re-laid out after applying (bound texts, and the
152
+ * labels of bound arrows) -- the editor passes the host's
153
+ */
154
+ renderEnvironment?: RenderEnvironment;
149
155
  };
150
156
  /**
151
157
  * Elements change is a low level primitive to capture a change between two sets of elements.
@@ -192,7 +198,29 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
192
198
  private static createGetter;
193
199
  private static applyDelta;
194
200
  /**
195
- * Check for visible changes regardless of whether they were removed, added or updated.
201
+ * Whether an element looks different after the delta — and the layout that
202
+ * followed it — was applied. The input to history's "skip entries with no
203
+ * visible change" loop.
204
+ *
205
+ * Both sides are first reduced to what actually paints:
206
+ * - a missing or deleted element paints nothing;
207
+ * - an empty text element paints nothing either — unless it carries arrow
208
+ * bindings (an arrow may end at it) or sits on an arrow (an empty label
209
+ * still cuts the arrow's gap);
210
+ * so an empty label's deletion or restoration compares as nothing against
211
+ * nothing. Two painting elements are then compared property by property:
212
+ * - `version`, `versionNonce`, `updated`, `created` are metadata, and
213
+ * `index` is covered by the separate z-order check (`reorderElements`);
214
+ * - `boundElements` is compared as `type:id` references with references to
215
+ * empty labels dropped, so adding or removing an empty label's reference
216
+ * is not visible on its own, and binding repair that rebuilt equal
217
+ * objects is not either;
218
+ * - everything else counts. Nested arrays (`points`, binding fixed points)
219
+ * compare by reference, which can only over-report a change — the safe
220
+ * direction, where undo stops one entry early.
221
+ *
222
+ * `previousElements` holds only `idsToCheck` (see `applyTo`); the label
223
+ * lookups it serves are for elements whose labels are in that set.
196
224
  */
197
225
  private static checkForVisibleDifference;
198
226
  /**
@@ -214,7 +242,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
214
242
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
215
243
  */
216
244
  private static rebindAffected;
217
- static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
245
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>, renderEnvironment?: RenderEnvironment): SceneElementsMap;
218
246
  private static redrawTextBoundingBoxes;
219
247
  private static redrawBoundArrows;
220
248
  private static reorderElements;
@@ -1,8 +1,11 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
+ import type { RenderEnvironment } from "./renderEnvironment";
2
3
  import type { Scene } from "./Scene";
3
- import type { ElementsMap, ExcalidrawElement } from "./types";
4
+ import type { ElementsMap, NonDeletedExcalidrawElement } from "./types";
4
5
  export interface Distribution {
5
6
  space: "between";
6
7
  axis: "x" | "y";
7
8
  }
8
- export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => ExcalidrawElement[];
9
+ export declare const distributeElements: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene,
10
+ /** measures the labels of the bound arrows the distribution moves */
11
+ renderEnvironment?: RenderEnvironment) => NonDeletedExcalidrawElement[];
@@ -1,15 +1,46 @@
1
1
  import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
2
2
  import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
3
4
  import type { Scene } from "./Scene";
5
+ import type { ExcalidrawTextElement } from "./types";
4
6
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
5
7
  x: number;
6
8
  y: number;
7
9
  }, scene: Scene, snapOffset: {
8
10
  x: number;
9
11
  y: number;
10
- }, gridSize: NullableGridSize) => void;
12
+ }, gridSize: NullableGridSize,
13
+ /** measures the labels of the bound arrows the drag moves */
14
+ renderEnvironment?: RenderEnvironment) => void;
11
15
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
12
- export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
16
+ /**
17
+ * Sizes a text element as it is dragged out.
18
+ *
19
+ * A dragged text pins one point and grows away from it; `anchorRatio` says
20
+ * where along the box that point sits — 0 for its left edge, 1 for its right,
21
+ * 0.5 for its centre.
22
+ *
23
+ * A free text pins the point the drag started from and takes the ratio from
24
+ * the drag direction, so it can be pulled either way. A text bound to an arrow
25
+ * endpoint instead pins whatever the binding placed it against and takes the
26
+ * ratio from its alignment — which is also what keeps it from growing back
27
+ * over the arrow, since dragging that way makes no progress rather than
28
+ * flipping the box around.
29
+ */
30
+ export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, renderEnvironment, informMutation, }: {
31
+ newElement: ExcalidrawTextElement;
32
+ anchorX: number;
33
+ /** 0 = anchored by its left edge, 1 = by its right, 0.5 = by its centre */
34
+ anchorRatio: number;
35
+ pointerX: number;
36
+ /** free text re-tops itself to the drag origin; a bound one must not move */
37
+ nextY?: number;
38
+ zoom: NormalizedZoomValue;
39
+ scene: Scene;
40
+ renderEnvironment?: RenderEnvironment;
41
+ informMutation?: boolean;
42
+ }) => void;
43
+ export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, renderEnvironment, widthAspectRatio, originOffset, informMutation, }: {
13
44
  newElement: NonDeletedExcalidrawElement;
14
45
  elementType: AppState["activeTool"]["type"];
15
46
  originX: number;
@@ -22,6 +53,7 @@ export declare const dragNewElement: ({ newElement, elementType, originX, origin
22
53
  shouldResizeFromCenter: boolean;
23
54
  zoom: NormalizedZoomValue;
24
55
  scene: Scene;
56
+ renderEnvironment?: RenderEnvironment;
25
57
  /** whether to keep given aspect ratio when `isResizeWithSidesSameLength` is
26
58
  true */
27
59
  widthAspectRatio?: number | null;
@@ -1,6 +1,32 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { AppState } from "@excalidraw/excalidraw/types";
3
- import type { ExcalidrawElement, GroupId } from "./types";
3
+ import type { ExcalidrawElement, GroupId, NonDeletedExcalidrawElement } from "./types";
4
+ /**
5
+ * Lookups supplied to the host's `props.onDuplicate`, covering just the
6
+ * elements taking part in the duplication.
7
+ */
8
+ export type OnDuplicateData = {
9
+ /** the duplicates, by their id */
10
+ duplicateElements: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement>;
11
+ /**
12
+ * The elements the duplicates were made from, by their id.
13
+ *
14
+ * On paste and library insert these are the inserted elements, which aren't
15
+ * part of the scene (though they may share ids with the scene elements they
16
+ * were copied from).
17
+ */
18
+ originalElements: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement>;
19
+ /**
20
+ * id of an original -> id of its duplicate (e.g. to remap element ids you
21
+ * keep in `customData`, which the duplicate copied from its original)
22
+ */
23
+ origIdToDuplicateId: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
24
+ /**
25
+ * id of a duplicate -> id of its original (e.g. to look up the original in
26
+ * `originalElements` while modifying the duplicate)
27
+ */
28
+ duplicateIdToOrigId: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
29
+ };
4
30
  /**
5
31
  * Duplicate an element, often used in the alt-drag operation.
6
32
  * Note that this method has gotten a bit complicated since the
@@ -31,6 +57,7 @@ export declare const duplicateElements: (opts: {
31
57
  * user interaction.
32
58
  */
33
59
  type: "everything";
60
+ preserveFrameChildrenOrder?: boolean;
34
61
  } | {
35
62
  /**
36
63
  * Duplicates specified elements and inserts them back into the array
@@ -46,10 +73,44 @@ export declare const duplicateElements: (opts: {
46
73
  selectedGroupIds: AppState["selectedGroupIds"];
47
74
  };
48
75
  })) => {
49
- duplicatedElements: ExcalidrawElement[];
50
- duplicateElementsMap: Map<string, ExcalidrawElement>;
76
+ duplicatedElements: NonDeletedExcalidrawElement[];
77
+ duplicateElementsMap: Map<string, NonDeletedExcalidrawElement>;
78
+ origElementsMap: Map<string, ExcalidrawElement>;
51
79
  elementsWithDuplicates: ExcalidrawElement[];
52
80
  origIdToDuplicateId: Map<string, string>;
81
+ duplicateIdToOrigId: Map<string, string>;
82
+ };
83
+ /**
84
+ * Folds the elements returned by the host (`props.onDuplicate`) back into the
85
+ * duplicates the editor created, so that everything that follows (frame
86
+ * assignment, bound text redraw, selection, alt-drag handover) can keep
87
+ * working with the editor's own objects, whether the host mutated the
88
+ * duplicates or returned new objects for them.
89
+ *
90
+ * - A returned element with a duplicate's id is shallow-merged into that
91
+ * duplicate, which takes its place in the returned array. Properties the
92
+ * host omits are kept, so that a partial element can't invalidate the
93
+ * duplicate. Safe only because the duplicates are fresh (not in the scene or
94
+ * the store snapshot yet), which is why nothing but the passed duplicates is
95
+ * ever merged into. Since the merge goes around `mutateElement`, what may
96
+ * have been cached for the duplicate by then is invalidated here.
97
+ * - A duplicate missing from the returned array (or returned as deleted) is
98
+ * vetoed. So is the bound text of a vetoed container. What the remaining
99
+ * duplicates reference of the vetoed ones is cleared, as if those were never
100
+ * part of the duplication (see `fixDuplicatedBindingsAfterDuplication`).
101
+ * - Any other returned element is used as is (existing elements must not be
102
+ * mutated, so the host replaces them).
103
+ * - `false` vetoes all the duplicates.
104
+ *
105
+ * @returns next elements, and the duplicates that weren't vetoed
106
+ */
107
+ export declare const reconcileDuplicatedElements: <TDuplicate extends ExcalidrawElement>(
108
+ /** what the host returned from `props.onDuplicate`, if anything */
109
+ hostElements: readonly ExcalidrawElement[] | void | false,
110
+ /** elements that were passed to the host */
111
+ nextElements: ExcalidrawElement[], duplicatedElements: TDuplicate[]) => {
112
+ elements: ExcalidrawElement[];
113
+ duplicatedElements: TDuplicate[];
53
114
  };
54
115
  /**
55
116
  * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
@@ -16,4 +16,9 @@ export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArr
16
16
  isBindingEnabled?: boolean;
17
17
  isMidpointSnappingEnabled?: boolean;
18
18
  }) => ElementUpdate<ExcalidrawElbowArrowElement>;
19
+ /**
20
+ * The update routing an elbow arrow again where it is, e.g. once its
21
+ * arrowheads change, as its route makes room for them
22
+ */
23
+ export declare const updateElbowArrowRoute: <T extends ExcalidrawElbowArrowElement>(arrow: Readonly<T>, elementsMap: NonDeletedSceneElementsMap) => ElementUpdate<T>;
19
24
  export declare const validateElbowPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], tolerance?: number) => boolean;
@@ -1,10 +1,11 @@
1
1
  import type { ExcalidrawProps } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkRequired } from "@excalidraw/common/utility-types";
3
- import type { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
4
+ import type { ExcalidrawIframeLikeElement, IframeData, NonDeletedExcalidrawElement } from "./types";
4
5
  type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
5
6
  export declare const createSrcDoc: (body: string) => string;
6
7
  export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
7
- export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => ExcalidrawElement;
8
+ export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement, renderEnvironment?: RenderEnvironment) => NonDeletedExcalidrawElement;
8
9
  export declare const maybeParseEmbedSrc: (str: string) => string;
9
10
  export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
10
11
  export {};
@@ -1,26 +1,24 @@
1
1
  import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
- import { type ElementsMap, type ExcalidrawBindableElement, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
2
+ import { type NonDeleted, type ElementsMap, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement, type NonDeletedExcalidrawElement } from "./types";
3
3
  import type { Scene } from "./Scene";
4
- type LinkDirection = "up" | "right" | "down" | "left";
5
- export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
6
- export declare const getPredecessors: (node: ExcalidrawBindableElement, elementsMap: ElementsMap, direction: LinkDirection) => ExcalidrawBindableElement[];
7
- export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number) => ExcalidrawElement[];
4
+ export type LinkDirection = "up" | "right" | "down" | "left";
5
+ export declare const addNewNodes: (startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number, stickyCrossStart?: number | null) => {
6
+ nodes: NonDeletedExcalidrawElement[];
7
+ crossStart: number;
8
+ };
8
9
  export declare class FlowChartNavigator {
9
10
  isExploring: boolean;
10
- private sameLevelNodes;
11
- private sameLevelIndex;
12
- private direction;
13
- private visitedNodes;
14
11
  clear(): void;
15
12
  exploreByDirection(element: ExcalidrawElement, elementsMap: ElementsMap, direction: LinkDirection): ExcalidrawElement["id"] | null;
13
+ private static findNodeInDirection;
16
14
  }
17
15
  export declare class FlowChartCreator {
18
16
  isCreatingChart: boolean;
19
17
  private numberOfNodes;
20
18
  private direction;
19
+ private clusterCrossStart;
21
20
  pendingNodes: PendingExcalidrawElements | null;
22
- createNodes(startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene): void;
21
+ createNodes(startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene): void;
23
22
  clear(): void;
24
23
  }
25
24
  export declare const isNodeInFlowchart: (element: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap) => boolean;
26
- export {};
@@ -1,4 +1,4 @@
1
- import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
1
+ import type { ElementsMap, ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  export declare class InvalidFractionalIndexError extends Error {
3
3
  code: "ELEMENT_HAS_INVALID_INDEX";
4
4
  }
@@ -48,7 +48,7 @@ export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[],
48
48
  *
49
49
  * WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
50
50
  */
51
- export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
51
+ export declare const syncInvalidIndices: <T extends ExcalidrawElement>(elements: readonly T[]) => Ordered<T>[];
52
52
  /**
53
53
  * Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
54
54
  *
@@ -1,7 +1,7 @@
1
1
  import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
2
2
  import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
3
3
  import type { ExcalidrawElementsIncludingDeleted } from "./Scene";
4
- import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
4
+ import type { ElementsMap, ElementsMapOrArray, ExcalidrawArrowElement, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
5
5
  export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
6
6
  export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
7
7
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
@@ -29,24 +29,43 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
29
29
  *
30
30
  * Considers non-frame bound elements (container or arrow labels) as root.
31
31
  */
32
- export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
32
+ export declare const getRootElements: <T extends ExcalidrawElement>(allElements: readonly T[]) => T[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
- export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
- export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
34
+ export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawStickyNoteElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
+ export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawStickyNoteElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
36
36
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
37
+ /**
38
+ * Whether frames clip the element to their bounds (as their child, or when
39
+ * dragged into them). Arrows (with their labels) aren't, so that they can
40
+ * connect elements across and out of frames.
41
+ */
42
+ export declare const isFrameClippable: (element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
37
43
  /** */
38
44
  export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
45
+ export declare const getCommonFrameId: (elements: readonly ExcalidrawElement[]) => string | null;
46
+ export declare const getFrameChildrenInsertionIndex: (elements: readonly ExcalidrawElement[], frameId: ExcalidrawFrameLikeElement["id"]) => number | null;
39
47
  /**
40
- * Retains (or repairs for target frame) the ordering invriant where children
41
- * elements come right before the parent frame:
42
- * [el, el, child, child, frame, el]
48
+ * Adds elements and their bound elements to frame. Reorders added elements to
49
+ * be just below frame, or just above its highest child (whichever is higher).
43
50
  *
44
51
  * @returns mutated allElements (same data structure)
45
52
  */
46
- export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameLikeElement, appState: AppState) => T;
47
- export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<NonDeletedExcalidrawElement>, elementsMap: ElementsMap) => void;
53
+ export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T;
54
+ export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<ExcalidrawElement>, elementsMap: ElementsMap) => void;
55
+ /**
56
+ * Whether one of the arrow's ends is in the frame: bound to an element in it,
57
+ * or, unbound, inside it. An arrow belongs to a frame only while one is.
58
+ */
59
+ export declare const isArrowEndInFrame: (arrow: ExcalidrawArrowElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
60
+ /**
61
+ * Takes the arrows among `elements`, and those bound to them, that have no end
62
+ * in their frame (see `isArrowEndInFrame()`) out of it. Call it once their ends
63
+ * (and the elements they're bound to) may have left it. Arrows in groups are
64
+ * left to their group.
65
+ */
66
+ export declare const removeArrowsWithoutEndInFrame: (elements: Iterable<ExcalidrawElement>, elementsMap: ElementsMap) => void;
48
67
  export declare const removeAllElementsFromFrame: <T extends ExcalidrawElement>(allElements: readonly T[], frame: ExcalidrawFrameLikeElement) => readonly T[];
49
- export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, app: AppClassProperties) => T[];
68
+ export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T[];
50
69
  /** does not mutate elements, but returns new ones */
51
70
  export declare const updateFrameMembershipOfSelectedElements: <T extends ElementsMapOrArray>(allElements: T, appState: AppState, app: AppClassProperties) => T;
52
71
  /**
@@ -70,5 +89,5 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
70
89
  export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
71
90
  export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
72
91
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
73
- export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
92
+ export declare const getElementsOverlappingFrame: <T extends ExcalidrawElement>(elements: readonly T[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => T[];
74
93
  export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
@@ -1,24 +1,19 @@
1
- import type { AppClassProperties, AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
- import type { Mutable } from "@excalidraw/common/utility-types";
3
- import type { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ElementsMapOrArray, ElementsMap } from "./types";
4
- export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
5
- export declare const selectGroupsForSelectedElements: {
6
- (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
7
- clearCache(): void;
8
- };
1
+ import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
+ import type { GroupId, ExcalidrawElement, NonDeleted, ElementsMapOrArray, ElementsMap, NonDeletedExcalidrawElement, NonDeletedElementsMapOrArray } from "./types";
3
+ export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeletedExcalidrawElement[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
9
4
  /**
10
5
  * If the element's group is selected, don't render an individual
11
6
  * selection border around it.
12
7
  */
13
- export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
8
+ export declare const isSelectedViaGroup: (appState: Pick<InteractiveCanvasAppState, "editingGroupId" | "selectedGroupIds">, element: ExcalidrawElement) => boolean;
14
9
  export declare const getSelectedGroupForElement: (appState: Pick<InteractiveCanvasAppState, "editingGroupId" | "selectedGroupIds">, element: ExcalidrawElement) => string | undefined;
15
- export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
16
- export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
10
+ export declare const getSelectedGroupIds: (appState: Pick<InteractiveCanvasAppState, "selectedGroupIds">) => GroupId[];
11
+ export declare const selectGroupsFromGivenElements: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => {
17
12
  [groupId: string]: boolean;
18
13
  };
19
14
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
20
15
  export declare const isElementInGroup: (element: ExcalidrawElement, groupId: string) => boolean;
21
- export declare const getElementsInGroup: (elements: ElementsMapOrArray, groupId: string) => ExcalidrawElement[];
16
+ export declare const getElementsInGroup: <P extends NonDeletedExcalidrawElement | ExcalidrawElement>(elements: P extends NonDeletedExcalidrawElement ? NonDeletedElementsMapOrArray : ElementsMapOrArray, groupId: string) => P[];
22
17
  export declare const getSelectedGroupIdForElement: (element: ExcalidrawElement, selectedGroupIds: {
23
18
  [groupId: string]: boolean;
24
19
  }) => string | undefined;
@@ -26,9 +21,9 @@ export declare const addToGroup: (prevGroupIds: ExcalidrawElement["groupIds"], n
26
21
  export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["groupIds"], selectedGroupIds: {
27
22
  [groupId: string]: boolean;
28
23
  }) => string[];
29
- export declare const getMaximumGroups: (elements: ExcalidrawElement[], elementsMap: ElementsMap) => ExcalidrawElement[][];
24
+ export declare const getMaximumGroups: <T extends NonDeletedExcalidrawElement | ExcalidrawElement>(elements: T[], elementsMap: ElementsMap) => T[][];
30
25
  export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<string>;
31
26
  export declare const elementsAreInSameGroup: (elements: readonly ExcalidrawElement[]) => boolean;
32
- export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
27
+ export declare const isInGroup: (element: ExcalidrawElement) => boolean;
33
28
  export declare const getNewGroupIdsForDuplication: (groupIds: ExcalidrawElement["groupIds"], editingGroupId: AppState["editingGroupId"], mapper: (groupId: GroupId) => GroupId) => string[];
34
- export declare const getSelectedElementsByGroup: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, appState: Readonly<AppState>) => ExcalidrawElement[][];
29
+ export declare const getSelectedElementsByGroup: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, appState: Readonly<Pick<AppState, "selectedGroupIds" | "editingGroupId">>) => NonDeletedExcalidrawElement[][];
@@ -1,12 +1,15 @@
1
1
  import type { AppClassProperties, DataURL, BinaryFiles } from "@excalidraw/excalidraw/types";
2
2
  import type { ExcalidrawElement, FileId, InitializedExcalidrawImageElement } from "./types";
3
- export declare const loadHTMLImageElement: (dataURL: DataURL) => Promise<HTMLImageElement>;
3
+ export declare const loadHTMLImageElement: (dataURL: DataURL, createImage?: () => HTMLImageElement) => Promise<HTMLImageElement>;
4
4
  /** NOTE: updates cache even if already populated with given image. Thus,
5
5
  * you should filter out the images upstream if you want to optimize this. */
6
- export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
6
+ export declare const updateImageCache: ({ fileIds, files, imageCache, createImage, }: {
7
7
  fileIds: FileId[];
8
8
  files: BinaryFiles;
9
9
  imageCache: AppClassProperties["imageCache"];
10
+ /** creates images in the owner window so cross-document scenes keep
11
+ * runtime ownership of their HTMLImageElements */
12
+ createImage?: () => HTMLImageElement;
10
13
  }) => Promise<{
11
14
  imageCache: Map<FileId, {
12
15
  image: HTMLImageElement | Promise<HTMLImageElement>;
@@ -8,12 +8,14 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
8
8
  */
9
9
  export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
10
10
  export declare const hashString: (s: string) => number;
11
+ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
11
12
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
12
13
  export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
13
- export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
14
14
  export * from "./align";
15
+ export * from "./arrowEndpointText";
15
16
  export * from "./binding";
16
17
  export * from "./bounds";
18
+ export * from "./bucketFill";
17
19
  export * from "./collision";
18
20
  export * from "./comparisons";
19
21
  export * from "./containerCache";
@@ -34,10 +36,12 @@ export * from "./groups";
34
36
  export * from "./heading";
35
37
  export * from "./image";
36
38
  export * from "./linearElementEditor";
39
+ export * from "./listMarker";
37
40
  export * from "./mutateElement";
38
41
  export * from "./newElement";
39
42
  export * from "./positionElementsOnGrid";
40
43
  export * from "./renderElement";
44
+ export * from "./renderEnvironment";
41
45
  export * from "./resizeElements";
42
46
  export * from "./resizeTest";
43
47
  export * from "./Scene";
@@ -47,6 +51,7 @@ export * from "./showSelectedShapeActions";
47
51
  export * from "./sizeHelpers";
48
52
  export * from "./sortElements";
49
53
  export * from "./store";
54
+ export * from "./stickyNote";
50
55
  export * from "./textElement";
51
56
  export * from "./textMeasurements";
52
57
  export * from "./textWrapping";
@@ -57,3 +62,4 @@ export * from "./utils";
57
62
  export * from "./zindex";
58
63
  export * from "./arrows/helpers";
59
64
  export * from "./arrowheads";
65
+ export * from "./convertToShape";