@excalidraw/excalidraw 0.18.0-817d8c5 → 0.18.0-9036812b6

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 (298) hide show
  1. package/CHANGELOG.md +11 -11
  2. package/dist/dev/chunk-CP5DND7P.js +7 -0
  3. package/dist/dev/chunk-CP5DND7P.js.map +7 -0
  4. package/dist/dev/chunk-FB2NA5UG.js +4132 -0
  5. package/dist/dev/chunk-FB2NA5UG.js.map +7 -0
  6. package/dist/dev/chunk-FRLWKCNE.js +5668 -0
  7. package/dist/dev/chunk-FRLWKCNE.js.map +7 -0
  8. package/dist/dev/{chunk-LMHBUWQS.js → chunk-QF5FRM6O.js} +16 -5
  9. package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
  10. package/dist/dev/data/{image-V26YBSDB.js → image-T2LJEHDP.js} +3 -3
  11. package/dist/dev/index.css +3021 -2942
  12. package/dist/dev/index.css.map +3 -3
  13. package/dist/dev/index.js +30882 -24351
  14. package/dist/dev/index.js.map +4 -4
  15. package/dist/dev/locales/{en-OZCJJ2HN.js → en-SMAPCEOQ.js} +2 -2
  16. package/dist/dev/subset-shared.chunk.js +2 -2
  17. package/dist/dev/subset-worker.chunk.js +2 -2
  18. package/dist/prod/chunk-A66AFZZU.js +7 -0
  19. package/dist/prod/chunk-I4UNSFV6.js +12 -0
  20. package/dist/prod/chunk-LS7FJGPW.js +86 -0
  21. package/dist/prod/chunk-YZO7PSYQ.js +4 -0
  22. package/dist/prod/data/image-53OPA26C.js +1 -0
  23. package/dist/prod/index.css +1 -1
  24. package/dist/prod/index.js +27 -16
  25. package/dist/prod/locales/{en-B4ZKOASM.js → en-TYY6KWIJ.js} +1 -1
  26. package/dist/prod/subset-shared.chunk.js +1 -1
  27. package/dist/prod/subset-worker.chunk.js +1 -1
  28. package/dist/types/{excalidraw/binaryheap.d.ts → common/src/binary-heap.d.ts} +1 -1
  29. package/dist/types/{excalidraw → common/src}/colors.d.ts +1 -0
  30. package/dist/types/{excalidraw → common/src}/constants.d.ts +29 -8
  31. package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
  32. package/dist/types/{excalidraw/fonts/FontMetadata.d.ts → common/src/font-metadata.d.ts} +15 -5
  33. package/dist/types/common/src/index.d.ts +12 -0
  34. package/dist/types/{excalidraw → common/src}/points.d.ts +2 -0
  35. package/dist/types/common/src/promise-pool.d.ts +6 -0
  36. package/dist/types/{excalidraw → common/src}/utility-types.d.ts +5 -0
  37. package/dist/types/{excalidraw → common/src}/utils.d.ts +22 -11
  38. package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +14 -17
  39. package/dist/types/element/src/align.d.ts +8 -0
  40. package/dist/types/{excalidraw/element → element/src}/binding.d.ts +30 -19
  41. package/dist/types/{excalidraw/element → element/src}/bounds.d.ts +19 -6
  42. package/dist/types/element/src/collision.d.ts +32 -0
  43. package/dist/types/{excalidraw/scene → element/src}/comparisons.d.ts +1 -1
  44. package/dist/types/{excalidraw/element → element/src}/cropElement.d.ts +1 -1
  45. package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +74 -40
  46. package/dist/types/element/src/distance.d.ts +3 -0
  47. package/dist/types/{excalidraw → element/src}/distribute.d.ts +3 -2
  48. package/dist/types/{excalidraw/element → element/src}/dragElements.d.ts +5 -4
  49. package/dist/types/element/src/duplicate.d.ts +63 -0
  50. package/dist/types/{excalidraw/element → element/src}/elbowArrow.d.ts +1 -1
  51. package/dist/types/{excalidraw/element → element/src}/elementLink.d.ts +1 -1
  52. package/dist/types/element/src/embeddable.d.ts +10 -0
  53. package/dist/types/{excalidraw/element → element/src}/flowchart.d.ts +4 -3
  54. package/dist/types/{excalidraw → element/src}/fractionalIndex.d.ts +12 -3
  55. package/dist/types/{excalidraw → element/src}/frame.d.ts +8 -7
  56. package/dist/types/{excalidraw → element/src}/groups.d.ts +6 -5
  57. package/dist/types/{excalidraw/element → element/src}/heading.d.ts +1 -2
  58. package/dist/types/{excalidraw/element → element/src}/image.d.ts +2 -2
  59. package/dist/types/element/src/index.d.ts +57 -0
  60. package/dist/types/{excalidraw/element → element/src}/linearElementEditor.d.ts +24 -37
  61. package/dist/types/element/src/mutateElement.d.ts +21 -0
  62. package/dist/types/{excalidraw/element → element/src}/newElement.d.ts +4 -43
  63. package/dist/types/{excalidraw/renderer → element/src}/renderElement.d.ts +3 -3
  64. package/dist/types/{excalidraw/element → element/src}/resizeElements.d.ts +7 -6
  65. package/dist/types/{excalidraw/element → element/src}/resizeTest.d.ts +4 -4
  66. package/dist/types/{excalidraw/scene → element/src}/selection.d.ts +13 -7
  67. package/dist/types/element/src/shape.d.ts +42 -0
  68. package/dist/types/{excalidraw/element → element/src}/showSelectedShapeActions.d.ts +1 -1
  69. package/dist/types/{excalidraw/element → element/src}/sizeHelpers.d.ts +3 -3
  70. package/dist/types/element/src/store.d.ts +232 -0
  71. package/dist/types/{excalidraw/element → element/src}/textElement.d.ts +8 -7
  72. package/dist/types/{excalidraw/element → element/src}/transformHandles.d.ts +7 -7
  73. package/dist/types/{excalidraw/element → element/src}/typeChecks.d.ts +21 -3
  74. package/dist/types/{excalidraw/element → element/src}/types.d.ts +17 -4
  75. package/dist/types/element/src/utils.d.ts +31 -0
  76. package/dist/types/{excalidraw → element/src}/zindex.d.ts +5 -4
  77. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +97 -106
  78. package/dist/types/excalidraw/actions/actionAlign.d.ts +7 -7
  79. package/dist/types/excalidraw/actions/actionBoundText.d.ts +70 -76
  80. package/dist/types/excalidraw/actions/actionCanvas.d.ts +627 -490
  81. package/dist/types/excalidraw/actions/actionClipboard.d.ts +206 -222
  82. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +34 -37
  83. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +102 -110
  84. package/dist/types/excalidraw/actions/actionDistribute.d.ts +3 -3
  85. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -7
  86. package/dist/types/excalidraw/actions/actionElementLink.d.ts +37 -40
  87. package/dist/types/excalidraw/actions/actionElementLock.d.ts +82 -90
  88. package/dist/types/excalidraw/{element/embeddable.d.ts → actions/actionEmbeddable.d.ts} +34 -47
  89. package/dist/types/excalidraw/actions/actionExport.d.ts +351 -378
  90. package/dist/types/excalidraw/actions/actionFinalize.d.ts +100 -65
  91. package/dist/types/excalidraw/actions/actionFlip.d.ts +3 -3
  92. package/dist/types/excalidraw/actions/actionFrame.d.ts +252 -264
  93. package/dist/types/excalidraw/actions/actionGroup.d.ts +67 -73
  94. package/dist/types/excalidraw/actions/actionHistory.d.ts +2 -3
  95. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +561 -40
  96. package/dist/types/excalidraw/actions/actionLink.d.ts +35 -38
  97. package/dist/types/excalidraw/actions/actionMenu.d.ts +98 -107
  98. package/dist/types/excalidraw/actions/actionNavigate.d.ts +65 -71
  99. package/dist/types/excalidraw/actions/actionProperties.d.ts +469 -506
  100. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +35 -38
  101. package/dist/types/excalidraw/actions/actionStyles.d.ts +36 -39
  102. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  103. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +34 -37
  104. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +34 -37
  105. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +33 -208
  106. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  107. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +33 -37
  108. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +34 -38
  109. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +34 -38
  110. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  111. package/dist/types/excalidraw/actions/index.d.ts +1 -0
  112. package/dist/types/excalidraw/actions/manager.d.ts +2 -2
  113. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  114. package/dist/types/excalidraw/actions/types.d.ts +6 -5
  115. package/dist/types/excalidraw/animated-trail.d.ts +7 -1
  116. package/dist/types/excalidraw/appState.d.ts +38 -28
  117. package/dist/types/excalidraw/charts.d.ts +1 -1
  118. package/dist/types/excalidraw/clipboard.d.ts +7 -7
  119. package/dist/types/excalidraw/components/Actions.d.ts +3 -7
  120. package/dist/types/excalidraw/components/App.d.ts +45 -29
  121. package/dist/types/excalidraw/components/Avatar.d.ts +1 -1
  122. package/dist/types/excalidraw/components/ButtonIcon.d.ts +2 -1
  123. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  124. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -5
  125. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  126. package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +1 -2
  127. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +4 -5
  128. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +3 -4
  129. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +3 -3
  130. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  131. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +4 -4
  132. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
  133. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -1
  134. package/dist/types/excalidraw/components/ConfirmDialog.d.ts +1 -1
  135. package/dist/types/excalidraw/components/ContextMenu.d.ts +2 -2
  136. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  137. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  138. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +2 -2
  139. package/dist/types/excalidraw/components/DialogActionButton.d.ts +1 -1
  140. package/dist/types/excalidraw/{element → components}/ElementCanvasButtons.d.ts +1 -1
  141. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +5 -4
  142. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  143. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  144. package/dist/types/excalidraw/components/FixedSideContainer.d.ts +1 -1
  145. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +1 -1
  146. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +1 -1
  147. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +3 -3
  148. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +1 -1
  149. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +1 -1
  150. package/dist/types/excalidraw/components/HintViewer.d.ts +1 -1
  151. package/dist/types/excalidraw/components/IconPicker.d.ts +1 -1
  152. package/dist/types/excalidraw/components/ImageExportDialog.d.ts +2 -2
  153. package/dist/types/excalidraw/components/InitializeApp.d.ts +1 -1
  154. package/dist/types/excalidraw/components/Island.d.ts +1 -1
  155. package/dist/types/excalidraw/components/JSONExportDialog.d.ts +2 -2
  156. package/dist/types/excalidraw/components/LayerUI.d.ts +3 -3
  157. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -1
  158. package/dist/types/excalidraw/components/LibraryMenuItems.d.ts +1 -1
  159. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +3 -3
  160. package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -2
  161. package/dist/types/excalidraw/components/LoadingMessage.d.ts +1 -1
  162. package/dist/types/excalidraw/components/MagicButton.d.ts +1 -1
  163. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -3
  164. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +1 -1
  165. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
  166. package/dist/types/excalidraw/components/PublishLibrary.d.ts +1 -1
  167. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  168. package/dist/types/excalidraw/components/Range.d.ts +3 -3
  169. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  170. package/dist/types/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -1
  171. package/dist/types/excalidraw/components/Sidebar/common.d.ts +1 -1
  172. package/dist/types/excalidraw/components/Stack.d.ts +1 -1
  173. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  174. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  175. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  176. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  177. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +14 -4
  178. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +2 -2
  179. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  180. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +3 -3
  181. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +2 -2
  182. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  183. package/dist/types/excalidraw/components/Stats/Position.d.ts +2 -2
  184. package/dist/types/excalidraw/components/Stats/index.d.ts +2 -2
  185. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
  186. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
  187. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +1 -1
  188. package/dist/types/excalidraw/components/TextField.d.ts +1 -1
  189. package/dist/types/excalidraw/components/Toast.d.ts +1 -1
  190. package/dist/types/excalidraw/components/ToolButton.d.ts +2 -2
  191. package/dist/types/excalidraw/components/Tooltip.d.ts +1 -1
  192. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  193. package/dist/types/excalidraw/components/UserList.d.ts +1 -1
  194. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -3
  195. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -2
  196. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +3 -3
  197. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +1 -1
  198. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +2 -2
  199. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +1 -1
  200. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +5 -4
  201. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +3 -2
  202. package/dist/types/excalidraw/components/icons.d.ts +5 -1
  203. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -1
  204. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +4 -1
  205. package/dist/types/excalidraw/components/shapes.d.ts +62 -0
  206. package/dist/types/excalidraw/context/tunnels.d.ts +1 -1
  207. package/dist/types/excalidraw/data/EditorLocalStorage.d.ts +1 -1
  208. package/dist/types/excalidraw/data/blob.d.ts +4 -4
  209. package/dist/types/excalidraw/data/filesystem.d.ts +2 -2
  210. package/dist/types/excalidraw/data/index.d.ts +2 -2
  211. package/dist/types/excalidraw/data/json.d.ts +1 -1
  212. package/dist/types/excalidraw/data/library.d.ts +3 -3
  213. package/dist/types/excalidraw/data/reconcile.d.ts +3 -2
  214. package/dist/types/excalidraw/data/resave.d.ts +1 -1
  215. package/dist/types/excalidraw/data/restore.d.ts +1 -1
  216. package/dist/types/excalidraw/data/transform.d.ts +4 -4
  217. package/dist/types/excalidraw/data/types.d.ts +3 -3
  218. package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
  219. package/dist/types/excalidraw/eraser/index.d.ts +12 -0
  220. package/dist/types/excalidraw/errors.d.ts +0 -3
  221. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -13
  222. package/dist/types/excalidraw/history.d.ts +31 -23
  223. package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  224. package/dist/types/excalidraw/i18n.d.ts +1 -1
  225. package/dist/types/excalidraw/index.d.ts +17 -15
  226. package/dist/types/excalidraw/laser-trails.d.ts +1 -1
  227. package/dist/types/excalidraw/lasso/index.d.ts +16 -0
  228. package/dist/types/excalidraw/lasso/utils.d.ts +13 -0
  229. package/dist/types/excalidraw/renderer/helpers.d.ts +8 -3
  230. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  231. package/dist/types/excalidraw/renderer/staticSvgScene.d.ts +2 -2
  232. package/dist/types/excalidraw/scene/Renderer.d.ts +3 -4
  233. package/dist/types/excalidraw/scene/export.d.ts +1 -1
  234. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  235. package/dist/types/excalidraw/scene/scroll.d.ts +1 -1
  236. package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
  237. package/dist/types/excalidraw/scene/types.d.ts +6 -4
  238. package/dist/types/excalidraw/snapping.d.ts +5 -6
  239. package/dist/types/excalidraw/types.d.ts +44 -25
  240. package/dist/types/excalidraw/{element → wysiwyg}/textWysiwyg.d.ts +4 -2
  241. package/dist/types/math/{angle.d.ts → src/angle.d.ts} +2 -0
  242. package/dist/types/math/src/constants.d.ts +3 -0
  243. package/dist/types/math/src/curve.d.ts +74 -0
  244. package/dist/types/math/{index.d.ts → src/index.d.ts} +1 -0
  245. package/dist/types/math/{point.d.ts → src/point.d.ts} +3 -3
  246. package/dist/types/math/{polygon.d.ts → src/polygon.d.ts} +1 -0
  247. package/dist/types/math/{rectangle.d.ts → src/rectangle.d.ts} +2 -0
  248. package/dist/types/math/{segment.d.ts → src/segment.d.ts} +1 -1
  249. package/dist/types/math/{types.d.ts → src/types.d.ts} +1 -0
  250. package/dist/types/math/{vector.d.ts → src/vector.d.ts} +8 -2
  251. package/dist/types/utils/{bbox.d.ts → src/bbox.d.ts} +1 -1
  252. package/dist/types/utils/{export.d.ts → src/export.d.ts} +2 -2
  253. package/dist/types/utils/{index.d.ts → src/index.d.ts} +1 -1
  254. package/dist/types/utils/{geometry → src}/shape.d.ts +2 -15
  255. package/dist/types/utils/{withinBounds.d.ts → src/withinBounds.d.ts} +2 -2
  256. package/history.ts +149 -110
  257. package/package.json +25 -10
  258. package/dist/dev/chunk-3SN6HYVK.js +0 -25695
  259. package/dist/dev/chunk-3SN6HYVK.js.map +0 -7
  260. package/dist/dev/chunk-53KHN5WM.js +0 -7
  261. package/dist/dev/chunk-53KHN5WM.js.map +0 -7
  262. package/dist/dev/chunk-LMHBUWQS.js.map +0 -7
  263. package/dist/dev/chunk-OKSO7T74.js +0 -4132
  264. package/dist/dev/chunk-OKSO7T74.js.map +0 -7
  265. package/dist/prod/chunk-36CXSE6H.js +0 -34
  266. package/dist/prod/chunk-6U3AYISY.js +0 -12
  267. package/dist/prod/chunk-EIO257PC.js +0 -86
  268. package/dist/prod/chunk-G5N3DNGT.js +0 -7
  269. package/dist/prod/data/image-N4WCURRR.js +0 -1
  270. package/dist/types/excalidraw/align.d.ts +0 -7
  271. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  272. package/dist/types/excalidraw/element/collision.d.ts +0 -26
  273. package/dist/types/excalidraw/element/distance.d.ts +0 -3
  274. package/dist/types/excalidraw/element/index.d.ts +0 -26
  275. package/dist/types/excalidraw/element/mutateElement.d.ts +0 -13
  276. package/dist/types/excalidraw/element/utils.d.ts +0 -21
  277. package/dist/types/excalidraw/scene/Shape.d.ts +0 -17
  278. package/dist/types/excalidraw/scene/ShapeCache.d.ts +0 -25
  279. package/dist/types/excalidraw/shapes.d.ts +0 -85
  280. package/dist/types/excalidraw/store.d.ts +0 -129
  281. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  282. package/dist/types/math/curve.d.ts +0 -40
  283. package/dist/types/utils/collision.d.ts +0 -9
  284. /package/dist/dev/data/{image-V26YBSDB.js.map → image-T2LJEHDP.js.map} +0 -0
  285. /package/dist/dev/locales/{en-OZCJJ2HN.js.map → en-SMAPCEOQ.js.map} +0 -0
  286. /package/dist/types/{excalidraw → common/src}/keys.d.ts +0 -0
  287. /package/dist/types/{excalidraw → common/src}/queue.d.ts +0 -0
  288. /package/dist/types/{excalidraw → common/src}/random.d.ts +0 -0
  289. /package/dist/types/{excalidraw/data → common/src}/url.d.ts +0 -0
  290. /package/dist/types/{excalidraw/element → element/src}/containerCache.d.ts +0 -0
  291. /package/dist/types/{excalidraw/element → element/src}/sortElements.d.ts +0 -0
  292. /package/dist/types/{excalidraw/element → element/src}/textMeasurements.d.ts +0 -0
  293. /package/dist/types/{excalidraw/element → element/src}/textWrapping.d.ts +0 -0
  294. /package/dist/types/math/{ellipse.d.ts → src/ellipse.d.ts} +0 -0
  295. /package/dist/types/math/{line.d.ts → src/line.d.ts} +0 -0
  296. /package/dist/types/math/{range.d.ts → src/range.d.ts} +0 -0
  297. /package/dist/types/math/{triangle.d.ts → src/triangle.d.ts} +0 -0
  298. /package/dist/types/math/{utils.d.ts → src/utils.d.ts} +0 -0
@@ -1,15 +1,10 @@
1
1
  /// <reference types="react" />
2
- import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, SceneElementsMap, ExcalidrawElbowArrowElement } from "./types";
3
- import type { Bounds } from "./bounds";
4
- import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "../types";
5
- import type { Store } from "../store";
6
- import type Scene from "../scene/Scene";
7
2
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
8
- declare const editorMidPointsCache: {
9
- version: number | null;
10
- points: (GlobalPoint | null)[];
11
- zoom: number | null;
12
- };
3
+ import { type Store } from "@excalidraw/element";
4
+ import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
5
+ import type { Scene } from "./Scene";
6
+ import type { Bounds } from "./bounds";
7
+ import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
13
8
  export declare class LinearElementEditor {
14
9
  readonly elementId: ExcalidrawElement["id"] & {
15
10
  _brand: "excalidrawLinearElementId";
@@ -43,7 +38,9 @@ export declare class LinearElementEditor {
43
38
  readonly hoverPointIndex: number;
44
39
  readonly segmentMidPointHoveredCoords: GlobalPoint | null;
45
40
  readonly elbowed: boolean;
46
- constructor(element: NonDeleted<ExcalidrawLinearElement>);
41
+ readonly customLineAngle: number | null;
42
+ readonly isEditing: boolean;
43
+ constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, isEditing?: boolean);
47
44
  static POINT_HANDLE_SIZE: number;
48
45
  /**
49
46
  * @param id the `elementId` from the instance of this class (so that we can
@@ -54,19 +51,15 @@ export declare class LinearElementEditor {
54
51
  /**
55
52
  * @returns whether point was dragged
56
53
  */
57
- static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
58
- x: number;
59
- y: number;
60
- }[]) => void, linearElementEditor: LinearElementEditor, scene: Scene): boolean;
54
+ static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, keyof AppState> | null;
61
55
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
62
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
63
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
56
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
64
57
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
65
58
  x: number;
66
59
  y: number;
67
60
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
68
61
  static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
69
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
62
+ static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number): GlobalPoint;
70
63
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
71
64
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
72
65
  x: number;
@@ -77,7 +70,7 @@ export declare class LinearElementEditor {
77
70
  linearElementEditor: LinearElementEditor | null;
78
71
  };
79
72
  static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
80
- static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): LinearElementEditor | null;
73
+ static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
81
74
  /** scene coords */
82
75
  static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
83
76
  /** scene coords */
@@ -89,30 +82,25 @@ export declare class LinearElementEditor {
89
82
  static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
90
83
  /**
91
84
  * Normalizes line points so that the start point is at [0,0]. This is
92
- * expected in various parts of the codebase. Also returns new x/y to account
93
- * for the potential normalization.
85
+ * expected in various parts of the codebase.
86
+ *
87
+ * Also returns normalized x and y coords to account for the normalization
88
+ * of the points.
94
89
  */
95
- static getNormalizedPoints(element: ExcalidrawLinearElement): {
90
+ static getNormalizeElementPointsAndCoords(element: ExcalidrawLinearElement): {
96
91
  points: LocalPoint[];
97
92
  x: number;
98
93
  y: number;
99
94
  };
100
- static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>): void;
101
- static duplicateSelectedPoints(appState: AppState, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): AppState;
102
- static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]): void;
103
- static addPoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
104
- point: LocalPoint;
105
- }[]): void;
106
- static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
107
- index: number;
108
- point: LocalPoint;
109
- isDragging?: boolean;
110
- }[], otherUpdates?: {
95
+ static duplicateSelectedPoints(appState: AppState, scene: Scene): AppState;
96
+ static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
97
+ static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
98
+ static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
111
99
  startBinding?: PointBinding | null;
112
100
  endBinding?: PointBinding | null;
113
101
  }): void;
114
102
  static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
115
- static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, elementsMap: ElementsMap): {
103
+ static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
116
104
  pointerDownState: LinearElementEditor["pointerDownState"];
117
105
  selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
118
106
  } | undefined;
@@ -124,7 +112,6 @@ export declare class LinearElementEditor {
124
112
  };
125
113
  static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
126
114
  static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
127
- static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, elementsMap: ElementsMap): LinearElementEditor;
128
- static deleteFixedSegment(element: ExcalidrawElbowArrowElement, index: number): void;
115
+ static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
116
+ static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
129
117
  }
130
- export {};
@@ -0,0 +1,21 @@
1
+ import type { Mutable } from "@excalidraw/common/utility-types";
2
+ import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
4
+ /**
5
+ * This function tracks updates of text elements for the purposes for collaboration.
6
+ * The version is used to compare updates when more than one user is working in
7
+ * the same drawing.
8
+ *
9
+ * WARNING: this won't trigger the component to update, so if you need to trigger component update,
10
+ * use `scene.mutateElement` or `ExcalidrawImperativeAPI.mutateElement` instead.
11
+ */
12
+ export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, elementsMap: ElementsMap, updates: ElementUpdate<TElement>, options?: {
13
+ isDragging?: boolean;
14
+ }) => TElement;
15
+ export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;
16
+ /**
17
+ * Mutates element, bumping `version`, `versionNonce`, and `updated`.
18
+ *
19
+ * NOTE: does not trigger re-render.
20
+ */
21
+ export declare const bumpVersion: <T extends Mutable<ExcalidrawElement>>(element: T, version?: ExcalidrawElement["version"]) => T;
@@ -1,6 +1,5 @@
1
- import type { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, FixedSegment, ExcalidrawElbowArrowElement } from "./types";
2
- import type { AppState } from "../types";
3
- import type { MarkOptional, Mutable } from "../utility-types";
1
+ import type { MarkOptional } from "@excalidraw/common/utility-types";
2
+ import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement } from "./types";
4
3
  export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
5
4
  export declare const newElement: (opts: {
6
5
  type: ExcalidrawGenericElement["type"];
@@ -44,6 +43,7 @@ export declare const newFreeDrawElement: (opts: {
44
43
  export declare const newLinearElement: (opts: {
45
44
  type: ExcalidrawLinearElement["type"];
46
45
  points?: ExcalidrawLinearElement["points"];
46
+ polygon?: ExcalidrawLineElement["polygon"];
47
47
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
48
48
  export declare const newArrowElement: <T extends boolean>(opts: {
49
49
  type: ExcalidrawArrowElement["type"];
@@ -51,7 +51,7 @@ export declare const newArrowElement: <T extends boolean>(opts: {
51
51
  endArrowhead?: Arrowhead | null | undefined;
52
52
  points?: readonly import("@excalidraw/math").LocalPoint[] | undefined;
53
53
  elbowed?: T | undefined;
54
- fixedSegments?: FixedSegment[] | null | undefined;
54
+ fixedSegments?: readonly import("./types").FixedSegment[] | null | undefined;
55
55
  } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
56
56
  export declare const newImageElement: (opts: {
57
57
  type: ExcalidrawImageElement["type"];
@@ -60,42 +60,3 @@ export declare const newImageElement: (opts: {
60
60
  scale?: ExcalidrawImageElement["scale"];
61
61
  crop?: ExcalidrawImageElement["crop"];
62
62
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
63
- /**
64
- * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
65
- * any value. The purpose is to to break object references for immutability
66
- * reasons, whenever we want to keep the original element, but ensure it's not
67
- * mutated.
68
- *
69
- * Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
70
- * Typed arrays and other non-null objects.
71
- */
72
- export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
73
- /**
74
- * Duplicate an element, often used in the alt-drag operation.
75
- * Note that this method has gotten a bit complicated since the
76
- * introduction of gruoping/ungrouping elements.
77
- * @param editingGroupId The current group being edited. The new
78
- * element will inherit this group and its
79
- * parents.
80
- * @param groupIdMapForOperation A Map that maps old group IDs to
81
- * duplicated ones. If you are duplicating
82
- * multiple elements at once, share this map
83
- * amongst all of them
84
- * @param element Element to duplicate
85
- * @param overrides Any element properties to override
86
- */
87
- export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined) => Readonly<TElement>;
88
- /**
89
- * Clones elements, regenerating their ids (including bindings) and group ids.
90
- *
91
- * If bindings don't exist in the elements array, they are removed. Therefore,
92
- * it's advised to supply the whole elements array, or sets of elements that
93
- * are encapsulated (such as library items), if the purpose is to retain
94
- * bindings to the cloned elements intact.
95
- *
96
- * NOTE by default does not randomize or regenerate anything except the id.
97
- */
98
- export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
99
- /** NOTE also updates version flags and `updated` */
100
- randomizeSeed: boolean;
101
- }) => ExcalidrawElement[];
@@ -1,7 +1,7 @@
1
- import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
1
+ import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
+ import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "@excalidraw/excalidraw/scene/types";
3
+ import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "./types";
2
4
  import type { RoughCanvas } from "roughjs/bin/canvas";
3
- import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "../scene/types";
4
- import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure, PendingExcalidrawElements } from "../types";
5
5
  export declare const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
6
6
  export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure, pendingNodes: Readonly<PendingExcalidrawElements> | null, globalAlpha?: number) => number;
7
7
  export interface ExcalidrawElementWithCanvas {
@@ -1,10 +1,10 @@
1
- import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap, SceneElementsMap } from "./types";
1
+ import { type LocalPoint } from "@excalidraw/math";
2
+ import type { PointerDownState } from "@excalidraw/excalidraw/types";
3
+ import type { Scene } from "./Scene";
2
4
  import type { BoundingBox } from "./bounds";
3
5
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
4
- import type { PointerDownState } from "../types";
5
- import type Scene from "../scene/Scene";
6
- import { type LocalPoint } from "@excalidraw/math";
7
- export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: SceneElementsMap, scene: Scene, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
6
+ import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap } from "./types";
7
+ export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], scene: Scene, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
8
8
  export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
9
9
  points: LocalPoint[];
10
10
  } | {
@@ -13,9 +13,10 @@ export declare const rescalePointsInElement: (element: NonDeletedExcalidrawEleme
13
13
  export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTextElement>, elementsMap: ElementsMap, nextWidth: number) => {
14
14
  size: number;
15
15
  } | null;
16
+ export declare const resizeSingleTextElement: (origElement: NonDeleted<ExcalidrawTextElement>, element: NonDeleted<ExcalidrawTextElement>, scene: Scene, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, nextWidth: number, nextHeight: number) => void;
16
17
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
17
18
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
18
- export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, elementsMap: ElementsMap, originalElementsMap: ElementsMap, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
19
+ export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
19
20
  shouldMaintainAspectRatio?: boolean | undefined;
20
21
  shouldResizeFromCenter?: boolean | undefined;
21
22
  shouldInformMutation?: boolean | undefined;
@@ -1,8 +1,8 @@
1
- import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
2
- import type { MaybeTransformHandleType } from "./transformHandles";
3
- import type { AppState, Device, Zoom } from "../types";
4
- import type { Bounds } from "./bounds";
5
1
  import type { GlobalPoint, LocalPoint } from "@excalidraw/math";
2
+ import type { AppState, Device, Zoom } from "@excalidraw/excalidraw/types";
3
+ import type { Bounds } from "./bounds";
4
+ import type { MaybeTransformHandleType } from "./transformHandles";
5
+ import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
6
6
  export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
7
7
  export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
8
8
  element: NonDeletedExcalidrawElement;
@@ -1,5 +1,6 @@
1
- import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
2
- import type { AppState, InteractiveCanvasAppState } from "../types";
1
+ import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
+ import { LinearElementEditor } from "./linearElementEditor";
3
+ import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
3
4
  /**
4
5
  * Frames and their containing elements are not to be selected at the same time.
5
6
  * Given an array of selected elements, if there are frames and their containing elements
@@ -13,11 +14,6 @@ export declare const isSomeElementSelected: {
13
14
  (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
14
15
  clearCache(): void;
15
16
  };
16
- /**
17
- * Returns common attribute (picked by `getAttribute` callback) of selected
18
- * elements. If elements don't share the same value, returns `null`.
19
- */
20
- export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
21
17
  export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
22
18
  includeBoundTextElement?: boolean;
23
19
  includeElementsInFrames?: boolean;
@@ -30,3 +26,13 @@ export declare const getTargetElements: (elements: ElementsMapOrArray, appState:
30
26
  export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
31
27
  [id: string]: true;
32
28
  }>;
29
+ export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
30
+ editingGroupId: string | null;
31
+ selectedElementIds: Readonly<{
32
+ [id: string]: true;
33
+ }>;
34
+ selectedGroupIds: {
35
+ [groupId: string]: boolean;
36
+ };
37
+ selectedLinearElement: LinearElementEditor | null;
38
+ };
@@ -0,0 +1,42 @@
1
+ import { type GeometricShape } from "@excalidraw/utils/shape";
2
+ import { type LocalPoint } from "@excalidraw/math";
3
+ import type { GlobalPoint } from "@excalidraw/math";
4
+ import type { AppState, EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
5
+ import type { ElementShape, ElementShapes } from "@excalidraw/excalidraw/scene/types";
6
+ import type { ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawFreeDrawElement, ElementsMap, ExcalidrawLineElement } from "./types";
7
+ import type { Drawable, Options } from "roughjs/bin/core";
8
+ export declare class ShapeCache {
9
+ private static rg;
10
+ private static cache;
11
+ /**
12
+ * Retrieves shape from cache if available. Use this only if shape
13
+ * is optional and you have a fallback in case it's not cached.
14
+ */
15
+ static get: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined;
16
+ static set: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
17
+ static delete: (element: ExcalidrawElement) => boolean;
18
+ static destroy: () => void;
19
+ /**
20
+ * Generates & caches shape for element if not already cached, otherwise
21
+ * returns cached shape.
22
+ */
23
+ static generateElementShape: <T extends ExcalidrawLinearElement | 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 | ExcalidrawFreeDrawElement | import("./types").ExcalidrawArrowElement>(element: T, renderConfig: {
24
+ isExporting: boolean;
25
+ canvasBackgroundColor: AppState["viewBackgroundColor"];
26
+ embedsValidationStatus: EmbedsValidationStatus;
27
+ } | null) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
28
+ }
29
+ export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
30
+ export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement) => {
31
+ op: string;
32
+ data: number[];
33
+ }[];
34
+ /**
35
+ * get the pure geometric shape of an excalidraw elementw
36
+ * which is then used for hit detection
37
+ */
38
+ export declare const getElementShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point>;
39
+ export declare const toggleLinePolygonState: (element: ExcalidrawLineElement, nextPolygonState: boolean) => {
40
+ polygon: ExcalidrawLineElement["polygon"];
41
+ points: ExcalidrawLineElement["points"];
42
+ } | null;
@@ -1,3 +1,3 @@
1
+ import type { UIAppState } from "@excalidraw/excalidraw/types";
1
2
  import type { NonDeletedExcalidrawElement } from "./types";
2
- import type { UIAppState } from "../types";
3
3
  export declare const showSelectedShapeActions: (appState: UIAppState, elements: readonly NonDeletedExcalidrawElement[]) => boolean;
@@ -1,5 +1,6 @@
1
+ import type { AppState, Offsets, Zoom } from "@excalidraw/excalidraw/types";
1
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
2
- import type { AppState, Offsets, Zoom } from "../types";
3
+ export declare const INVISIBLY_SMALL_ELEMENT_SIZE = 0.1;
3
4
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
5
  export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
6
  zoom: Zoom;
@@ -22,11 +23,10 @@ export declare const getPerfectElementSize: (elementType: AppState["activeTool"]
22
23
  width: number;
23
24
  height: number;
24
25
  };
25
- export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number) => {
26
+ export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number, customAngle?: number) => {
26
27
  width: number;
27
28
  height: number;
28
29
  };
29
- export declare const resizePerfectLineForNWHandler: (element: ExcalidrawElement, x: number, y: number) => void;
30
30
  export declare const getNormalizedDimensions: (element: Pick<ExcalidrawElement, "width" | "height" | "x" | "y">) => {
31
31
  width: ExcalidrawElement["width"];
32
32
  height: ExcalidrawElement["height"];
@@ -0,0 +1,232 @@
1
+ import { Emitter } from "@excalidraw/common";
2
+ import type App from "@excalidraw/excalidraw/components/App";
3
+ import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
4
+ import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
5
+ import { ElementsDelta, AppStateDelta } from "./delta";
6
+ import type { ApplyToOptions } from "./delta";
7
+ import type { ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
8
+ export declare const CaptureUpdateAction: {
9
+ /**
10
+ * Immediately undoable.
11
+ *
12
+ * Use for updates which should be captured.
13
+ * Should be used for most of the local updates, except ephemerals such as dragging or resizing.
14
+ *
15
+ * These updates will _immediately_ make it to the local undo / redo stacks.
16
+ */
17
+ readonly IMMEDIATELY: "IMMEDIATELY";
18
+ /**
19
+ * Never undoable.
20
+ *
21
+ * Use for updates which should never be recorded, such as remote updates
22
+ * or scene initialization.
23
+ *
24
+ * These updates will _never_ make it to the local undo / redo stacks.
25
+ */
26
+ readonly NEVER: "NEVER";
27
+ /**
28
+ * Eventually undoable.
29
+ *
30
+ * Use for updates which should not be captured immediately - likely
31
+ * exceptions which are part of some async multi-step process. Otherwise, all
32
+ * such updates would end up being captured with the next
33
+ * `CaptureUpdateAction.IMMEDIATELY` - triggered either by the next `updateScene`
34
+ * or internally by the editor.
35
+ *
36
+ * These updates will _eventually_ make it to the local undo / redo stacks.
37
+ */
38
+ readonly EVENTUALLY: "EVENTUALLY";
39
+ };
40
+ export type CaptureUpdateActionType = ValueOf<typeof CaptureUpdateAction>;
41
+ /**
42
+ * Store which captures the observed changes and emits them as `StoreIncrement` events.
43
+ */
44
+ export declare class Store {
45
+ private readonly app;
46
+ readonly onDurableIncrementEmitter: Emitter<[DurableIncrement]>;
47
+ readonly onStoreIncrementEmitter: Emitter<[DurableIncrement | EphemeralIncrement]>;
48
+ private scheduledMacroActions;
49
+ private scheduledMicroActions;
50
+ private _snapshot;
51
+ get snapshot(): StoreSnapshot;
52
+ set snapshot(snapshot: StoreSnapshot);
53
+ constructor(app: App);
54
+ scheduleAction(action: CaptureUpdateActionType): void;
55
+ /**
56
+ * Use to schedule a delta calculation, which will consquentially be emitted as `DurableStoreIncrement` and pushed in the undo stack.
57
+ */
58
+ scheduleCapture(): void;
59
+ /**
60
+ * Schedule special "micro" actions, to-be executed before the next commit, before it executes a scheduled "macro" action.
61
+ */
62
+ scheduleMicroAction(params: {
63
+ action: CaptureUpdateActionType;
64
+ elements: readonly ExcalidrawElement[] | undefined;
65
+ appState: AppState | ObservedAppState | undefined;
66
+ } | {
67
+ action: typeof CaptureUpdateAction.IMMEDIATELY;
68
+ change: StoreChange;
69
+ delta: StoreDelta;
70
+ } | {
71
+ action: typeof CaptureUpdateAction.NEVER | typeof CaptureUpdateAction.EVENTUALLY;
72
+ change: StoreChange;
73
+ }): void;
74
+ /**
75
+ * Performs the incoming `CaptureUpdateAction` and emits the corresponding `StoreIncrement`.
76
+ * Emits `DurableStoreIncrement` when action is "capture", emits `EphemeralStoreIncrement` otherwise.
77
+ *
78
+ * @emits StoreIncrement
79
+ */
80
+ commit(elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): void;
81
+ /**
82
+ * Clears the store instance.
83
+ */
84
+ clear(): void;
85
+ /**
86
+ * Performs delta & change calculation and emits a durable increment.
87
+ *
88
+ * @emits StoreIncrement.
89
+ */
90
+ private emitDurableIncrement;
91
+ /**
92
+ * Performs change calculation and emits an ephemeral increment.
93
+ *
94
+ * @emits EphemeralStoreIncrement
95
+ */
96
+ private emitEphemeralIncrement;
97
+ private applyChangeToSnapshot;
98
+ /**
99
+ * Clones the snapshot if there are changes detected.
100
+ */
101
+ private maybeCloneSnapshot;
102
+ private flushMicroActions;
103
+ private processAction;
104
+ /**
105
+ * Returns the scheduled macro action.
106
+ */
107
+ private getScheduledMacroAction;
108
+ /**
109
+ * Ensures that the scheduled actions invariant is satisfied.
110
+ */
111
+ private satisfiesScheduledActionsInvariant;
112
+ }
113
+ /**
114
+ * Repsents a change to the store containing changed elements and appState.
115
+ */
116
+ export declare class StoreChange {
117
+ readonly elements: Record<string, OrderedExcalidrawElement>;
118
+ readonly appState: Partial<ObservedAppState>;
119
+ private constructor();
120
+ static create(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreChange;
121
+ }
122
+ /**
123
+ * Encpasulates any change to the store (durable or ephemeral).
124
+ */
125
+ export declare abstract class StoreIncrement {
126
+ readonly type: "durable" | "ephemeral";
127
+ readonly change: StoreChange;
128
+ protected constructor(type: "durable" | "ephemeral", change: StoreChange);
129
+ static isDurable(increment: StoreIncrement): increment is DurableIncrement;
130
+ static isEphemeral(increment: StoreIncrement): increment is EphemeralIncrement;
131
+ }
132
+ /**
133
+ * Represents a durable change to the store.
134
+ */
135
+ export declare class DurableIncrement extends StoreIncrement {
136
+ readonly change: StoreChange;
137
+ readonly delta: StoreDelta;
138
+ constructor(change: StoreChange, delta: StoreDelta);
139
+ }
140
+ /**
141
+ * Represents an ephemeral change to the store.
142
+ */
143
+ export declare class EphemeralIncrement extends StoreIncrement {
144
+ readonly change: StoreChange;
145
+ constructor(change: StoreChange);
146
+ }
147
+ /**
148
+ * Represents a captured delta by the Store.
149
+ */
150
+ export declare class StoreDelta {
151
+ readonly id: string;
152
+ readonly elements: ElementsDelta;
153
+ readonly appState: AppStateDelta;
154
+ protected constructor(id: string, elements: ElementsDelta, appState: AppStateDelta);
155
+ /**
156
+ * Create a new instance of `StoreDelta`.
157
+ */
158
+ static create(elements: ElementsDelta, appState: AppStateDelta, opts?: {
159
+ id: string;
160
+ }): StoreDelta;
161
+ /**
162
+ * Calculate the delta between the previous and next snapshot.
163
+ */
164
+ static calculate(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreDelta;
165
+ /**
166
+ * Restore a store delta instance from a DTO.
167
+ */
168
+ static restore(storeDeltaDTO: DTO<StoreDelta>): StoreDelta;
169
+ /**
170
+ * Parse and load the delta from the remote payload.
171
+ */
172
+ static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
173
+ /**
174
+ * Inverse store delta, creates new instance of `StoreDelta`.
175
+ */
176
+ static inverse(delta: StoreDelta): StoreDelta;
177
+ /**
178
+ * Apply the delta to the passed elements and appState, does not modify the snapshot.
179
+ */
180
+ static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState, options?: ApplyToOptions): [SceneElementsMap, AppState, boolean];
181
+ /**
182
+ * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
183
+ */
184
+ static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): StoreDelta;
185
+ isEmpty(): boolean;
186
+ }
187
+ /**
188
+ * Represents a snapshot of the captured or updated changes in the store,
189
+ * used for producing deltas and emitting `DurableStoreIncrement`s.
190
+ */
191
+ export declare class StoreSnapshot {
192
+ readonly elements: SceneElementsMap;
193
+ readonly appState: ObservedAppState;
194
+ readonly metadata: {
195
+ didElementsChange: boolean;
196
+ didAppStateChange: boolean;
197
+ isEmpty?: boolean;
198
+ };
199
+ private _lastChangedElementsHash;
200
+ private _lastChangedAppStateHash;
201
+ private constructor();
202
+ static create(elements: SceneElementsMap, appState: AppState | ObservedAppState, metadata?: {
203
+ didElementsChange: boolean;
204
+ didAppStateChange: boolean;
205
+ }): StoreSnapshot;
206
+ static empty(): StoreSnapshot;
207
+ getChangedElements(prevSnapshot: StoreSnapshot): Record<string, OrderedExcalidrawElement>;
208
+ getChangedAppState(prevSnapshot: StoreSnapshot): Partial<ObservedAppState>;
209
+ isEmpty(): boolean | undefined;
210
+ /**
211
+ * Apply the change and return a new snapshot instance.
212
+ */
213
+ applyChange(change: StoreChange): StoreSnapshot;
214
+ /**
215
+ * Efficiently clone the existing snapshot, only if we detected changes.
216
+ *
217
+ * @returns same instance if there are no changes detected, new instance otherwise.
218
+ */
219
+ maybeClone(action: CaptureUpdateActionType, elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): StoreSnapshot;
220
+ private maybeCreateAppStateSnapshot;
221
+ private maybeCreateElementsSnapshot;
222
+ private detectChangedAppState;
223
+ /**
224
+ * Detect if there are any changed elements.
225
+ */
226
+ private detectChangedElements;
227
+ /**
228
+ * Perform structural clone, deep cloning only elements that changed.
229
+ */
230
+ private createElementsSnapshot;
231
+ }
232
+ export declare const getObservedAppState: (appState: AppState | ObservedAppState) => ObservedAppState;
@@ -1,10 +1,11 @@
1
- import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
1
+ import type { AppState } from "@excalidraw/excalidraw/types";
2
+ import type { ExtractSetType } from "@excalidraw/common/utility-types";
3
+ import type { Radians } from "@excalidraw/math";
4
+ import type { Scene } from "./Scene";
2
5
  import type { MaybeTransformHandleType } from "./transformHandles";
3
- import type { AppState } from "../types";
4
- import type { ExtractSetType } from "../utility-types";
5
- export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
6
- export declare const bindTextToShapeAfterDuplication: (newElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
7
- export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, elementsMap: ElementsMap, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
6
+ import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
7
+ export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
8
+ export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
8
9
  export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
9
10
  x: number;
10
11
  y: number;
@@ -20,7 +21,7 @@ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement
20
21
  x: number;
21
22
  y: number;
22
23
  };
23
- export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => import("@excalidraw/math").Radians;
24
+ export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => 0 | Radians;
24
25
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
25
26
  x: number;
26
27
  y: number;