@excalidraw/excalidraw 0.17.1-88812e0 → 0.17.1-96eeec5

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 (316) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/browser/dev/excalidraw-assets-dev/{chunk-47LVF2XL.js → chunk-DEYXWPUO.js} +4933 -1520
  3. package/dist/browser/dev/excalidraw-assets-dev/chunk-DEYXWPUO.js.map +7 -0
  4. package/dist/browser/dev/excalidraw-assets-dev/{chunk-XOM7LNOU.js → chunk-EM6LVGFW.js} +27 -4
  5. package/dist/browser/dev/excalidraw-assets-dev/chunk-EM6LVGFW.js.map +7 -0
  6. package/dist/browser/dev/excalidraw-assets-dev/{dist-ITJNUBZF.js → dist-6QVAH5JA.js} +36 -14
  7. package/dist/browser/dev/excalidraw-assets-dev/dist-6QVAH5JA.js.map +7 -0
  8. package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js → en-AZFA5HJJ.js} +4 -2
  9. package/dist/browser/dev/excalidraw-assets-dev/{image-LHMGJWTI.js → image-5XCR4WHS.js} +2 -2
  10. package/dist/browser/dev/index.css +157 -62
  11. package/dist/browser/dev/index.css.map +3 -3
  12. package/dist/browser/dev/index.js +12016 -7663
  13. package/dist/browser/dev/index.js.map +4 -4
  14. package/dist/browser/prod/excalidraw-assets/{chunk-5SYIAZGL.js → chunk-7DXALCB2.js} +5 -5
  15. package/dist/browser/prod/excalidraw-assets/chunk-ODWTVSS7.js +68 -0
  16. package/dist/browser/prod/excalidraw-assets/dist-567JAXHK.js +7 -0
  17. package/dist/browser/prod/excalidraw-assets/en-6E7MYLWO.js +1 -0
  18. package/dist/browser/prod/excalidraw-assets/image-LQAMCFQI.js +1 -0
  19. package/dist/browser/prod/index.css +1 -1
  20. package/dist/browser/prod/index.js +69 -51
  21. package/dist/dev/{en-XW4JO6VX.json → en-EB2MBPAV.json} +24 -3
  22. package/dist/dev/index.css +157 -62
  23. package/dist/dev/index.css.map +3 -3
  24. package/dist/dev/index.js +18250 -16114
  25. package/dist/dev/index.js.map +4 -4
  26. package/dist/excalidraw/actions/actionAddToLibrary.d.ts +15 -6
  27. package/dist/excalidraw/actions/actionAlign.d.ts +8 -8
  28. package/dist/excalidraw/actions/actionBoundText.d.ts +14 -8
  29. package/dist/excalidraw/actions/actionBoundText.js +3 -1
  30. package/dist/excalidraw/actions/actionCanvas.d.ts +64 -28
  31. package/dist/excalidraw/actions/actionCanvas.js +1 -1
  32. package/dist/excalidraw/actions/actionClipboard.d.ts +40 -19
  33. package/dist/excalidraw/actions/actionDeleteSelected.d.ts +17 -8
  34. package/dist/excalidraw/actions/actionDistribute.d.ts +4 -4
  35. package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +3 -3
  36. package/dist/excalidraw/actions/actionElementLock.d.ts +11 -5
  37. package/dist/excalidraw/actions/actionExport.d.ts +48 -21
  38. package/dist/excalidraw/actions/actionFinalize.d.ts +11 -5
  39. package/dist/excalidraw/actions/actionFinalize.js +1 -1
  40. package/dist/excalidraw/actions/actionFlip.d.ts +4 -4
  41. package/dist/excalidraw/actions/actionFlip.js +5 -6
  42. package/dist/excalidraw/actions/actionFrame.d.ts +328 -8
  43. package/dist/excalidraw/actions/actionGroup.d.ts +320 -4
  44. package/dist/excalidraw/actions/actionHistory.d.ts +3 -3
  45. package/dist/excalidraw/actions/actionHistory.js +4 -4
  46. package/dist/excalidraw/actions/actionLinearEditor.d.ts +9 -4
  47. package/dist/excalidraw/actions/actionLinearEditor.js +19 -4
  48. package/dist/excalidraw/actions/actionLink.d.ts +5 -2
  49. package/dist/excalidraw/actions/actionMenu.d.ts +15 -6
  50. package/dist/excalidraw/actions/actionNavigate.d.ts +11 -5
  51. package/dist/excalidraw/actions/actionProperties.d.ts +67 -28
  52. package/dist/excalidraw/actions/actionProperties.js +1 -1
  53. package/dist/excalidraw/actions/actionSelectAll.d.ts +6 -3
  54. package/dist/excalidraw/actions/actionStyles.d.ts +9 -3
  55. package/dist/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
  56. package/dist/excalidraw/actions/actionTextAutoResize.js +38 -0
  57. package/dist/excalidraw/actions/actionToggleGridMode.d.ts +6 -3
  58. package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -2
  59. package/dist/excalidraw/actions/actionToggleStats.d.ts +6 -2
  60. package/dist/excalidraw/actions/actionToggleStats.js +4 -3
  61. package/dist/excalidraw/actions/actionToggleViewMode.d.ts +5 -2
  62. package/dist/excalidraw/actions/actionToggleZenMode.d.ts +5 -2
  63. package/dist/excalidraw/actions/actionZindex.d.ts +8 -4
  64. package/dist/excalidraw/actions/actionZindex.js +4 -0
  65. package/dist/excalidraw/actions/manager.d.ts +3 -3
  66. package/dist/excalidraw/actions/register.d.ts +1 -1
  67. package/dist/excalidraw/actions/shortcuts.d.ts +2 -2
  68. package/dist/excalidraw/actions/types.d.ts +6 -6
  69. package/dist/excalidraw/align.d.ts +1 -1
  70. package/dist/excalidraw/animated-trail.d.ts +2 -2
  71. package/dist/excalidraw/appState.d.ts +5 -2
  72. package/dist/excalidraw/appState.js +6 -3
  73. package/dist/excalidraw/change.d.ts +4 -4
  74. package/dist/excalidraw/change.js +14 -7
  75. package/dist/excalidraw/charts.d.ts +1 -1
  76. package/dist/excalidraw/clients.d.ts +2 -2
  77. package/dist/excalidraw/clients.js +1 -1
  78. package/dist/excalidraw/clipboard.d.ts +3 -3
  79. package/dist/excalidraw/colors.d.ts +1 -1
  80. package/dist/excalidraw/components/Actions.d.ts +3 -3
  81. package/dist/excalidraw/components/Actions.js +9 -6
  82. package/dist/excalidraw/components/App.d.ts +10 -16
  83. package/dist/excalidraw/components/App.js +190 -142
  84. package/dist/excalidraw/components/ButtonIconSelect.js +1 -1
  85. package/dist/excalidraw/components/CheckboxItem.js +1 -1
  86. package/dist/excalidraw/components/ColorPicker/ColorInput.d.ts +1 -1
  87. package/dist/excalidraw/components/ColorPicker/ColorInput.js +1 -1
  88. package/dist/excalidraw/components/ColorPicker/ColorPicker.d.ts +4 -4
  89. package/dist/excalidraw/components/ColorPicker/ColorPicker.js +1 -1
  90. package/dist/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
  91. package/dist/excalidraw/components/ColorPicker/PickerColorList.d.ts +1 -1
  92. package/dist/excalidraw/components/ColorPicker/PickerHeading.d.ts +1 -1
  93. package/dist/excalidraw/components/ColorPicker/ShadeList.d.ts +1 -1
  94. package/dist/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  95. package/dist/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
  96. package/dist/excalidraw/components/ColorPicker/colorPickerUtils.js +1 -1
  97. package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
  98. package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.js +1 -1
  99. package/dist/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -1
  100. package/dist/excalidraw/components/CommandPalette/CommandPalette.js +5 -5
  101. package/dist/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -1
  102. package/dist/excalidraw/components/CommandPalette/types.d.ts +3 -3
  103. package/dist/excalidraw/components/ConfirmDialog.d.ts +1 -1
  104. package/dist/excalidraw/components/ContextMenu.d.ts +2 -2
  105. package/dist/excalidraw/components/ContextMenu.js +2 -2
  106. package/dist/excalidraw/components/DarkModeToggle.d.ts +1 -1
  107. package/dist/excalidraw/components/DefaultSidebar.d.ts +2 -2
  108. package/dist/excalidraw/components/Dialog.js +1 -1
  109. package/dist/excalidraw/components/DialogActionButton.d.ts +1 -1
  110. package/dist/excalidraw/components/EyeDropper.d.ts +2 -2
  111. package/dist/excalidraw/components/FollowMode/FollowMode.d.ts +1 -1
  112. package/dist/excalidraw/components/FollowMode/FollowMode.js +1 -1
  113. package/dist/excalidraw/components/HelpDialog.js +1 -1
  114. package/dist/excalidraw/components/HintViewer.d.ts +1 -1
  115. package/dist/excalidraw/components/IconPicker.js +2 -2
  116. package/dist/excalidraw/components/ImageExportDialog.d.ts +1 -1
  117. package/dist/excalidraw/components/InitializeApp.d.ts +2 -2
  118. package/dist/excalidraw/components/JSONExportDialog.d.ts +3 -3
  119. package/dist/excalidraw/components/LayerUI.d.ts +4 -4
  120. package/dist/excalidraw/components/LayerUI.js +10 -7
  121. package/dist/excalidraw/components/LibraryMenu.d.ts +2 -2
  122. package/dist/excalidraw/components/LibraryMenuBrowseButton.d.ts +1 -1
  123. package/dist/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  124. package/dist/excalidraw/components/LibraryMenuHeaderContent.d.ts +2 -2
  125. package/dist/excalidraw/components/LibraryMenuItems.d.ts +1 -1
  126. package/dist/excalidraw/components/LibraryMenuSection.d.ts +5 -4
  127. package/dist/excalidraw/components/LibraryUnit.d.ts +2 -2
  128. package/dist/excalidraw/components/LoadingMessage.d.ts +1 -1
  129. package/dist/excalidraw/components/MagicSettings.js +2 -2
  130. package/dist/excalidraw/components/MobileMenu.d.ts +3 -3
  131. package/dist/excalidraw/components/MobileMenu.js +2 -6
  132. package/dist/excalidraw/components/Modal.d.ts +1 -1
  133. package/dist/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  134. package/dist/excalidraw/components/PasteChartDialog.d.ts +1 -1
  135. package/dist/excalidraw/components/PasteChartDialog.js +1 -1
  136. package/dist/excalidraw/components/PublishLibrary.d.ts +1 -1
  137. package/dist/excalidraw/components/SVGLayer.d.ts +1 -1
  138. package/dist/excalidraw/components/Sidebar/Sidebar.js +1 -1
  139. package/dist/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -1
  140. package/dist/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -1
  141. package/dist/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -1
  142. package/dist/excalidraw/components/Sidebar/common.d.ts +1 -1
  143. package/dist/excalidraw/components/Stats/Angle.d.ts +12 -0
  144. package/dist/excalidraw/components/Stats/Angle.js +52 -0
  145. package/dist/excalidraw/components/Stats/Collapsible.d.ts +9 -0
  146. package/dist/excalidraw/components/Stats/Collapsible.js +12 -0
  147. package/dist/excalidraw/components/Stats/Dimension.d.ts +12 -0
  148. package/dist/excalidraw/components/Stats/Dimension.js +67 -0
  149. package/dist/excalidraw/components/Stats/DragInput.d.ts +32 -0
  150. package/dist/excalidraw/components/Stats/DragInput.js +174 -0
  151. package/dist/excalidraw/components/Stats/FontSize.d.ts +12 -0
  152. package/dist/excalidraw/components/Stats/FontSize.js +50 -0
  153. package/dist/excalidraw/components/Stats/MultiAngle.d.ts +12 -0
  154. package/dist/excalidraw/components/Stats/MultiAngle.js +66 -0
  155. package/dist/excalidraw/components/Stats/MultiDimension.d.ts +15 -0
  156. package/dist/excalidraw/components/Stats/MultiDimension.js +197 -0
  157. package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +13 -0
  158. package/dist/excalidraw/components/Stats/MultiFontSize.js +72 -0
  159. package/dist/excalidraw/components/Stats/MultiPosition.d.ts +15 -0
  160. package/dist/excalidraw/components/Stats/MultiPosition.js +100 -0
  161. package/dist/excalidraw/components/Stats/Position.d.ts +13 -0
  162. package/dist/excalidraw/components/Stats/Position.js +39 -0
  163. package/dist/excalidraw/components/Stats/index.d.ts +16 -0
  164. package/dist/excalidraw/components/Stats/index.js +78 -0
  165. package/dist/excalidraw/components/Stats/utils.d.ts +25 -0
  166. package/dist/excalidraw/components/Stats/utils.js +158 -0
  167. package/dist/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -1
  168. package/dist/excalidraw/components/TTDDialog/TTDDialog.js +2 -2
  169. package/dist/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +1 -1
  170. package/dist/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +1 -1
  171. package/dist/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +1 -1
  172. package/dist/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +1 -1
  173. package/dist/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
  174. package/dist/excalidraw/components/TTDDialog/common.d.ts +4 -4
  175. package/dist/excalidraw/components/TextField.d.ts +1 -1
  176. package/dist/excalidraw/components/Toast.d.ts +1 -1
  177. package/dist/excalidraw/components/ToolButton.d.ts +3 -2
  178. package/dist/excalidraw/components/Trans.d.ts +1 -1
  179. package/dist/excalidraw/components/UserList.d.ts +1 -1
  180. package/dist/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  181. package/dist/excalidraw/components/canvases/InteractiveCanvas.js +4 -2
  182. package/dist/excalidraw/components/canvases/StaticCanvas.d.ts +2 -2
  183. package/dist/excalidraw/components/canvases/StaticCanvas.js +2 -2
  184. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +2 -2
  185. package/dist/excalidraw/components/footer/Footer.d.ts +2 -2
  186. package/dist/excalidraw/components/hyperlink/Hyperlink.d.ts +2 -2
  187. package/dist/excalidraw/components/hyperlink/helpers.d.ts +3 -3
  188. package/dist/excalidraw/components/icons.d.ts +6 -2
  189. package/dist/excalidraw/components/icons.js +22 -6
  190. package/dist/excalidraw/constants.d.ts +8 -2
  191. package/dist/excalidraw/constants.js +8 -1
  192. package/dist/excalidraw/context/ui-appState.d.ts +1 -1
  193. package/dist/excalidraw/cursor.d.ts +1 -1
  194. package/dist/excalidraw/data/EditorLocalStorage.d.ts +2 -2
  195. package/dist/excalidraw/data/blob.d.ts +5 -5
  196. package/dist/excalidraw/data/filesystem.d.ts +2 -1
  197. package/dist/excalidraw/data/index.d.ts +4 -4
  198. package/dist/excalidraw/data/json.d.ts +3 -3
  199. package/dist/excalidraw/data/library.d.ts +3 -3
  200. package/dist/excalidraw/data/magic.d.ts +3 -3
  201. package/dist/excalidraw/data/reconcile.d.ts +3 -3
  202. package/dist/excalidraw/data/resave.d.ts +2 -2
  203. package/dist/excalidraw/data/restore.d.ts +3 -3
  204. package/dist/excalidraw/data/restore.js +16 -1
  205. package/dist/excalidraw/data/transform.d.ts +3 -3
  206. package/dist/excalidraw/data/types.d.ts +3 -3
  207. package/dist/excalidraw/element/ElementCanvasButtons.d.ts +1 -1
  208. package/dist/excalidraw/element/binding.d.ts +7 -21
  209. package/dist/excalidraw/element/binding.js +127 -102
  210. package/dist/excalidraw/element/bounds.d.ts +3 -3
  211. package/dist/excalidraw/element/collision.d.ts +3 -3
  212. package/dist/excalidraw/element/collision.js +1 -1
  213. package/dist/excalidraw/element/containerCache.d.ts +1 -1
  214. package/dist/excalidraw/element/dragElements.d.ts +4 -4
  215. package/dist/excalidraw/element/dragElements.js +27 -3
  216. package/dist/excalidraw/element/embeddable.d.ts +8 -5
  217. package/dist/excalidraw/element/image.d.ts +2 -2
  218. package/dist/excalidraw/element/index.d.ts +2 -2
  219. package/dist/excalidraw/element/index.js +1 -1
  220. package/dist/excalidraw/element/linearElementEditor.d.ts +8 -5
  221. package/dist/excalidraw/element/linearElementEditor.js +7 -4
  222. package/dist/excalidraw/element/mutateElement.d.ts +2 -2
  223. package/dist/excalidraw/element/mutateElement.js +1 -1
  224. package/dist/excalidraw/element/newElement.d.ts +5 -8
  225. package/dist/excalidraw/element/newElement.js +16 -14
  226. package/dist/excalidraw/element/resizeElements.d.ts +11 -3
  227. package/dist/excalidraw/element/resizeElements.js +75 -23
  228. package/dist/excalidraw/element/resizeTest.d.ts +4 -4
  229. package/dist/excalidraw/element/resizeTest.js +2 -4
  230. package/dist/excalidraw/element/showSelectedShapeActions.d.ts +2 -2
  231. package/dist/excalidraw/element/sizeHelpers.d.ts +2 -2
  232. package/dist/excalidraw/element/sortElements.d.ts +1 -1
  233. package/dist/excalidraw/element/textElement.d.ts +5 -4
  234. package/dist/excalidraw/element/textElement.js +11 -3
  235. package/dist/excalidraw/element/textWysiwyg.d.ts +12 -6
  236. package/dist/excalidraw/element/textWysiwyg.js +38 -17
  237. package/dist/excalidraw/element/transformHandles.d.ts +3 -3
  238. package/dist/excalidraw/element/transformHandles.js +0 -10
  239. package/dist/excalidraw/element/typeChecks.d.ts +4 -4
  240. package/dist/excalidraw/element/types.d.ts +11 -4
  241. package/dist/excalidraw/emitter.d.ts +1 -1
  242. package/dist/excalidraw/fractionalIndex.d.ts +1 -1
  243. package/dist/excalidraw/fractionalIndex.js +2 -4
  244. package/dist/excalidraw/frame.d.ts +3 -3
  245. package/dist/excalidraw/gatransforms.d.ts +1 -1
  246. package/dist/excalidraw/gesture.d.ts +1 -1
  247. package/dist/excalidraw/groups.d.ts +4 -4
  248. package/dist/excalidraw/history.d.ts +4 -4
  249. package/dist/excalidraw/hooks/useEmitter.d.ts +1 -1
  250. package/dist/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  251. package/dist/excalidraw/i18n.d.ts +1 -1
  252. package/dist/excalidraw/index.d.ts +1 -1
  253. package/dist/excalidraw/jotai.d.ts +1 -1
  254. package/dist/excalidraw/laser-trails.d.ts +3 -2
  255. package/dist/excalidraw/locales/en.json +24 -3
  256. package/dist/excalidraw/math.d.ts +4 -2
  257. package/dist/excalidraw/math.js +6 -0
  258. package/dist/excalidraw/mermaid.d.ts +2 -0
  259. package/dist/excalidraw/mermaid.js +28 -0
  260. package/dist/excalidraw/points.d.ts +1 -1
  261. package/dist/excalidraw/queue.d.ts +1 -1
  262. package/dist/excalidraw/renderer/helpers.d.ts +2 -2
  263. package/dist/excalidraw/renderer/interactiveScene.d.ts +2 -2
  264. package/dist/excalidraw/renderer/interactiveScene.js +32 -6
  265. package/dist/excalidraw/renderer/renderElement.d.ts +4 -4
  266. package/dist/excalidraw/renderer/renderElement.js +5 -5
  267. package/dist/excalidraw/renderer/renderSnaps.d.ts +1 -1
  268. package/dist/excalidraw/renderer/staticScene.d.ts +1 -1
  269. package/dist/excalidraw/renderer/staticSvgScene.d.ts +4 -4
  270. package/dist/excalidraw/scene/Fonts.d.ts +2 -4
  271. package/dist/excalidraw/scene/Fonts.js +12 -15
  272. package/dist/excalidraw/scene/Renderer.d.ts +4 -4
  273. package/dist/excalidraw/scene/Renderer.js +2 -3
  274. package/dist/excalidraw/scene/Scene.d.ts +16 -7
  275. package/dist/excalidraw/scene/Scene.js +17 -8
  276. package/dist/excalidraw/scene/Shape.d.ts +1 -1
  277. package/dist/excalidraw/scene/ShapeCache.d.ts +4 -4
  278. package/dist/excalidraw/scene/comparisons.d.ts +2 -2
  279. package/dist/excalidraw/scene/export.d.ts +2 -2
  280. package/dist/excalidraw/scene/export.js +2 -2
  281. package/dist/excalidraw/scene/scroll.d.ts +2 -2
  282. package/dist/excalidraw/scene/scrollbars.d.ts +3 -3
  283. package/dist/excalidraw/scene/selection.d.ts +2 -2
  284. package/dist/excalidraw/scene/types.d.ts +6 -8
  285. package/dist/excalidraw/scene/zoom.d.ts +1 -1
  286. package/dist/excalidraw/shapes.d.ts +7 -0
  287. package/dist/excalidraw/shapes.js +40 -0
  288. package/dist/excalidraw/snapping.d.ts +4 -4
  289. package/dist/excalidraw/snapping.js +2 -1
  290. package/dist/excalidraw/store.d.ts +34 -4
  291. package/dist/excalidraw/store.js +27 -0
  292. package/dist/excalidraw/types.d.ts +25 -20
  293. package/dist/excalidraw/utils.d.ts +4 -4
  294. package/dist/excalidraw/zindex.d.ts +2 -2
  295. package/dist/prod/{en-XW4JO6VX.json → en-EB2MBPAV.json} +24 -3
  296. package/dist/prod/index.css +1 -1
  297. package/dist/prod/index.js +39 -39
  298. package/dist/utils/bbox.d.ts +2 -2
  299. package/dist/utils/collision.d.ts +1 -1
  300. package/dist/utils/export.d.ts +2 -2
  301. package/dist/utils/geometry/geometry.d.ts +1 -1
  302. package/dist/utils/geometry/shape.d.ts +1 -1
  303. package/dist/utils/withinBounds.d.ts +1 -1
  304. package/history.ts +4 -4
  305. package/package.json +2 -2
  306. package/dist/browser/dev/excalidraw-assets-dev/chunk-47LVF2XL.js.map +0 -7
  307. package/dist/browser/dev/excalidraw-assets-dev/chunk-XOM7LNOU.js.map +0 -7
  308. package/dist/browser/dev/excalidraw-assets-dev/dist-ITJNUBZF.js.map +0 -7
  309. package/dist/browser/prod/excalidraw-assets/chunk-4SNEEDZH.js +0 -55
  310. package/dist/browser/prod/excalidraw-assets/dist-54276HPL.js +0 -6
  311. package/dist/browser/prod/excalidraw-assets/en-7GPZE2Y2.js +0 -1
  312. package/dist/browser/prod/excalidraw-assets/image-ISQJGWLB.js +0 -1
  313. package/dist/excalidraw/components/Stats.d.ts +0 -11
  314. package/dist/excalidraw/components/Stats.js +0 -13
  315. /package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js.map → en-AZFA5HJJ.js.map} +0 -0
  316. /package/dist/browser/dev/excalidraw-assets-dev/{image-LHMGJWTI.js.map → image-5XCR4WHS.js.map} +0 -0
@@ -1,7 +1,7 @@
1
- import { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource, LibraryItems_anyVersion } from "../types";
1
+ import type { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource, LibraryItems_anyVersion } from "../types";
2
2
  import type App from "../components/App";
3
- import { ExcalidrawElement } from "../element/types";
4
- import { MaybePromise } from "../utility-types";
3
+ import type { ExcalidrawElement } from "../element/types";
4
+ import type { MaybePromise } from "../utility-types";
5
5
  export type LibraryPersistedData = {
6
6
  libraryItems: LibraryItems;
7
7
  };
@@ -1,6 +1,6 @@
1
- import { Theme } from "../element/types";
2
- import { DataURL } from "../types";
3
- import { OpenAIOutput } from "./ai/types";
1
+ import type { Theme } from "../element/types";
2
+ import type { DataURL } from "../types";
3
+ import type { OpenAIOutput } from "./ai/types";
4
4
  export type MagicCacheData = {
5
5
  status: "pending";
6
6
  } | {
@@ -1,6 +1,6 @@
1
- import { OrderedExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
3
- import { MakeBrand } from "../utility-types";
1
+ import type { OrderedExcalidrawElement } from "../element/types";
2
+ import type { AppState } from "../types";
3
+ import type { MakeBrand } from "../utility-types";
4
4
  export type ReconciledExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"ReconciledElement">;
5
5
  export type RemoteExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"RemoteExcalidrawElement">;
6
6
  export declare const reconcileElements: (localElements: readonly OrderedExcalidrawElement[], remoteElements: readonly RemoteExcalidrawElement[], localAppState: AppState) => ReconciledExcalidrawElement[];
@@ -1,5 +1,5 @@
1
- import { ExcalidrawElement } from "../element/types";
2
- import { AppState, BinaryFiles } from "../types";
1
+ import type { ExcalidrawElement } from "../element/types";
2
+ import type { AppState, BinaryFiles } from "../types";
3
3
  export declare const resaveAsImageWithScene: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, name: string) => Promise<{
4
4
  fileHandle: import("browser-fs-access").FileSystemHandle;
5
5
  }>;
@@ -1,6 +1,6 @@
1
- import { ExcalidrawElement, OrderedExcalidrawElement } from "../element/types";
2
- import { AppState, BinaryFiles, LibraryItem } from "../types";
3
- import { ImportedDataState } from "./types";
1
+ import type { ExcalidrawElement, OrderedExcalidrawElement } from "../element/types";
2
+ import type { AppState, BinaryFiles, LibraryItem } from "../types";
3
+ import type { ImportedDataState } from "./types";
4
4
  type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
5
5
  export declare const AllowedExcalidrawActiveTools: Record<AppState["activeTool"]["type"], boolean>;
6
6
  export type RestoredDataState = {
@@ -1,5 +1,5 @@
1
1
  import { getNonDeletedElements, getNormalizedDimensions, isInvisiblySmallElement, refreshTextDimensions, } from "../element";
2
- import { isTextElement, isUsingAdaptiveRadius } from "../element/typeChecks";
2
+ import { isArrowElement, isLinearElement, isTextElement, isUsingAdaptiveRadius, } from "../element/typeChecks";
3
3
  import { randomId } from "../random";
4
4
  import { DEFAULT_FONT_FAMILY, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, FONT_FAMILY, ROUNDNESS, DEFAULT_SIDEBAR, DEFAULT_ELEMENT_PROPS, } from "../constants";
5
5
  import { getDefaultAppState } from "../appState";
@@ -10,6 +10,7 @@ import { arrayToMap } from "../utils";
10
10
  import { detectLineHeight, getContainerElement, getDefaultLineHeight, } from "../element/textElement";
11
11
  import { normalizeLink } from "./url";
12
12
  import { syncInvalidIndices } from "../fractionalIndex";
13
+ import { getSizeFromPoints } from "../points";
13
14
  export const AllowedExcalidrawActiveTools = {
14
15
  selection: true,
15
16
  text: true,
@@ -124,6 +125,7 @@ const restoreElement = (element) => {
124
125
  verticalAlign: element.verticalAlign || DEFAULT_VERTICAL_ALIGN,
125
126
  containerId: element.containerId ?? null,
126
127
  originalText: element.originalText || text,
128
+ autoResize: element.autoResize ?? true,
127
129
  lineHeight,
128
130
  });
129
131
  // if empty text, mark as deleted. We keep in array
@@ -177,6 +179,7 @@ const restoreElement = (element) => {
177
179
  points,
178
180
  x,
179
181
  y,
182
+ ...getSizeFromPoints(points),
180
183
  });
181
184
  }
182
185
  // generic elements
@@ -311,6 +314,18 @@ localElements, opts) => {
311
314
  if (opts.refreshDimensions && isTextElement(element)) {
312
315
  Object.assign(element, refreshTextDimensions(element, getContainerElement(element, restoredElementsMap), restoredElementsMap));
313
316
  }
317
+ if (isLinearElement(element)) {
318
+ if (element.startBinding &&
319
+ (!restoredElementsMap.has(element.startBinding.elementId) ||
320
+ !isArrowElement(element))) {
321
+ element.startBinding = null;
322
+ }
323
+ if (element.endBinding &&
324
+ (!restoredElementsMap.has(element.endBinding.elementId) ||
325
+ !isArrowElement(element))) {
326
+ element.endBinding = null;
327
+ }
328
+ }
314
329
  }
315
330
  return restoredElements;
316
331
  };
@@ -1,6 +1,6 @@
1
- import { ElementConstructorOpts } from "../element/newElement";
2
- import { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawFrameElement, ExcalidrawFreeDrawElement, ExcalidrawGenericElement, ExcalidrawIframeLikeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawMagicFrameElement, ExcalidrawSelectionElement, ExcalidrawTextElement, FileId, FontFamilyValues, TextAlign, VerticalAlign } from "../element/types";
3
- import { MarkOptional } from "../utility-types";
1
+ import type { ElementConstructorOpts } from "../element/newElement";
2
+ import type { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawFrameElement, ExcalidrawFreeDrawElement, ExcalidrawGenericElement, ExcalidrawIframeLikeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawMagicFrameElement, ExcalidrawSelectionElement, ExcalidrawTextElement, FileId, FontFamilyValues, TextAlign, VerticalAlign } from "../element/types";
3
+ import type { MarkOptional } from "../utility-types";
4
4
  export type ValidLinearElement = {
5
5
  type: "arrow" | "line";
6
6
  x: number;
@@ -1,7 +1,7 @@
1
- import { ExcalidrawElement } from "../element/types";
2
- import { AppState, BinaryFiles, LibraryItems, LibraryItems_anyVersion } from "../types";
1
+ import type { ExcalidrawElement } from "../element/types";
2
+ import type { AppState, BinaryFiles, LibraryItems, LibraryItems_anyVersion } from "../types";
3
3
  import type { cleanAppStateForExport } from "../appState";
4
- import { VERSIONS } from "../constants";
4
+ import type { VERSIONS } from "../constants";
5
5
  export interface ExportedDataState {
6
6
  type: string;
7
7
  version: number;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ElementsMap, NonDeletedExcalidrawElement } from "./types";
2
+ import type { ElementsMap, NonDeletedExcalidrawElement } from "./types";
3
3
  import "./ElementCanvasButtons.scss";
4
4
  export declare const ElementCanvasButtons: ({ children, element, elementsMap, }: {
5
5
  children: React.ReactNode;
@@ -1,7 +1,6 @@
1
- import * as GA from "../ga";
2
- import { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawEllipseElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, ExcalidrawIframeLikeElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawTextElement } from "./types";
3
- import { AppClassProperties, AppState, Point } from "../types";
4
- import { ElementUpdate } from "./mutateElement";
1
+ import type { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap } from "./types";
2
+ import type { AppState } from "../types";
3
+ import type { ElementUpdate } from "./mutateElement";
5
4
  export type SuggestedBinding = NonDeleted<ExcalidrawBindableElement> | SuggestedPointBinding;
6
5
  export type SuggestedPointBinding = [
7
6
  NonDeleted<ExcalidrawLinearElement>,
@@ -11,18 +10,18 @@ export type SuggestedPointBinding = [
11
10
  export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
12
11
  export declare const isBindingEnabled: (appState: AppState) => boolean;
13
12
  export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", elementsMap: NonDeletedSceneElementsMap) => void;
14
- export declare const bindOrUnbindSelectedElements: (selectedElements: NonDeleted<ExcalidrawElement>[], app: AppClassProperties) => void;
13
+ export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], elementsMap: NonDeletedSceneElementsMap, isBindingEnabled: boolean, draggingPoints: readonly number[] | null) => void;
14
+ export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap) => SuggestedBinding[];
15
15
  export declare const maybeBindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, appState: AppState, pointerCoords: {
16
16
  x: number;
17
17
  y: number;
18
- }, app: AppClassProperties) => void;
18
+ }, elementsMap: NonDeletedSceneElementsMap) => void;
19
19
  export declare const bindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: NonDeletedSceneElementsMap) => void;
20
20
  export declare const isLinearElementSimpleAndAlreadyBound: (linearElement: NonDeleted<ExcalidrawLinearElement>, alreadyBoundToId: ExcalidrawBindableElement["id"] | undefined, bindableElement: ExcalidrawBindableElement) => boolean;
21
- export declare const unbindLinearElements: (elements: readonly NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap) => void;
22
21
  export declare const getHoveredElementForBinding: (pointerCoords: {
23
22
  x: number;
24
23
  y: number;
25
- }, app: AppClassProperties) => NonDeleted<ExcalidrawBindableElement> | null;
24
+ }, elementsMap: NonDeletedSceneElementsMap) => NonDeleted<ExcalidrawBindableElement> | null;
26
25
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, elementsMap: ElementsMap, options?: {
27
26
  simultaneouslyUpdated?: readonly ExcalidrawElement[];
28
27
  newSize?: {
@@ -30,22 +29,9 @@ export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawE
30
29
  height: number;
31
30
  };
32
31
  }) => void;
33
- export declare const getEligibleElementsForBinding: (selectedElements: NonDeleted<ExcalidrawElement>[], app: AppClassProperties) => SuggestedBinding[];
34
32
  export declare const fixBindingsAfterDuplication: (sceneElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicatesServeAsOld?: "duplicatesServeAsOld" | undefined) => void;
35
33
  export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
36
- export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
37
- x: number;
38
- y: number;
39
- }, app: AppClassProperties) => boolean;
40
34
  export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number) => number;
41
- export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, point: readonly [number, number], elementsMap: ElementsMap) => number;
42
- export declare const distanceToEllipse: (element: ExcalidrawEllipseElement, point: readonly [number, number], elementsMap: ElementsMap) => number;
43
- export declare const determineFocusDistance: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], elementsMap: ElementsMap) => number;
44
- export declare const determineFocusPoint: (element: ExcalidrawBindableElement, focus: number, adjecentPoint: readonly [number, number], elementsMap: ElementsMap) => readonly [number, number];
45
- export declare const intersectElementWithLine: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], gap: number | undefined, elementsMap: ElementsMap) => Point[];
46
- export declare const getCircleIntersections: (center: readonly [number, number, number, number, number, number, number, number], radius: number, line: readonly [number, number, number, number, number, number, number, number]) => GA.Point[];
47
- export declare const findFocusPointForEllipse: (ellipse: ExcalidrawEllipseElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
48
- export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
49
35
  export declare const bindingProperties: Set<BindableProp | BindingProp>;
50
36
  export type BindableProp = "boundElements";
51
37
  export type BindingProp = "frameId" | "containerId" | "startBinding" | "endBinding";
@@ -13,6 +13,7 @@ import { LinearElementEditor } from "./linearElementEditor";
13
13
  import { arrayToMap, tupleToCoors } from "../utils";
14
14
  import { KEYS } from "../keys";
15
15
  import { getBoundTextElement, handleBindTextResize } from "./textElement";
16
+ import { getElementShape } from "../shapes";
16
17
  export const shouldEnableBindingForPointerEvent = (event) => {
17
18
  return !event[KEYS.CTRL_OR_CMD];
18
19
  };
@@ -46,51 +47,125 @@ const bindOrUnbindLinearElementEdge = (linearElement, bindableElement, otherEdge
46
47
  boundToElementIds,
47
48
  // Is mutated
48
49
  unboundFromElementIds, elementsMap) => {
49
- if (bindableElement !== "keep") {
50
- if (bindableElement != null) {
51
- // Don't bind if we're trying to bind or are already bound to the same
52
- // element on the other edge already ("start" edge takes precedence).
53
- if (otherEdgeBindableElement == null ||
54
- (otherEdgeBindableElement === "keep"
55
- ? !isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, bindableElement, startOrEnd)
56
- : startOrEnd === "start" ||
57
- otherEdgeBindableElement.id !== bindableElement.id)) {
58
- bindLinearElement(linearElement, bindableElement, startOrEnd, elementsMap);
59
- boundToElementIds.add(bindableElement.id);
60
- }
50
+ // "keep" is for method chaining convenience, a "no-op", so just bail out
51
+ if (bindableElement === "keep") {
52
+ return;
53
+ }
54
+ // null means break the bind, so nothing to consider here
55
+ if (bindableElement === null) {
56
+ const unbound = unbindLinearElement(linearElement, startOrEnd);
57
+ if (unbound != null) {
58
+ unboundFromElementIds.add(unbound);
61
59
  }
62
- else {
63
- const unbound = unbindLinearElement(linearElement, startOrEnd);
64
- if (unbound != null) {
65
- unboundFromElementIds.add(unbound);
66
- }
60
+ return;
61
+ }
62
+ // While complext arrows can do anything, simple arrow with both ends trying
63
+ // to bind to the same bindable should not be allowed, start binding takes
64
+ // precedence
65
+ if (isLinearElementSimple(linearElement)) {
66
+ if (otherEdgeBindableElement == null ||
67
+ (otherEdgeBindableElement === "keep"
68
+ ? // TODO: Refactor - Needlessly complex
69
+ !isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, bindableElement, startOrEnd)
70
+ : startOrEnd === "start" ||
71
+ otherEdgeBindableElement.id !== bindableElement.id)) {
72
+ bindLinearElement(linearElement, bindableElement, startOrEnd, elementsMap);
73
+ boundToElementIds.add(bindableElement.id);
67
74
  }
68
75
  }
76
+ else {
77
+ bindLinearElement(linearElement, bindableElement, startOrEnd, elementsMap);
78
+ boundToElementIds.add(bindableElement.id);
79
+ }
69
80
  };
70
- export const bindOrUnbindSelectedElements = (selectedElements, app) => {
71
- selectedElements.forEach((selectedElement) => {
72
- if (isBindingElement(selectedElement)) {
73
- bindOrUnbindLinearElement(selectedElement, getElligibleElementForBindingElement(selectedElement, "start", app), getElligibleElementForBindingElement(selectedElement, "end", app), app.scene.getNonDeletedElementsMap());
74
- }
75
- else if (isBindableElement(selectedElement)) {
76
- maybeBindBindableElement(selectedElement, app.scene.getNonDeletedElementsMap(), app);
81
+ const getOriginalBindingIfStillCloseOfLinearElementEdge = (linearElement, edge, elementsMap) => {
82
+ const coors = getLinearElementEdgeCoors(linearElement, edge, elementsMap);
83
+ const elementId = edge === "start"
84
+ ? linearElement.startBinding?.elementId
85
+ : linearElement.endBinding?.elementId;
86
+ if (elementId) {
87
+ const element = elementsMap.get(elementId);
88
+ if (isBindableElement(element) &&
89
+ bindingBorderTest(element, coors, elementsMap)) {
90
+ return element;
77
91
  }
92
+ }
93
+ return null;
94
+ };
95
+ const getOriginalBindingsIfStillCloseToArrowEnds = (linearElement, elementsMap) => ["start", "end"].map((edge) => getOriginalBindingIfStillCloseOfLinearElementEdge(linearElement, edge, elementsMap));
96
+ const getBindingStrategyForDraggingArrowEndpoints = (selectedElement, isBindingEnabled, draggingPoints, elementsMap) => {
97
+ const startIdx = 0;
98
+ const endIdx = selectedElement.points.length - 1;
99
+ const startDragged = draggingPoints.findIndex((i) => i === startIdx) > -1;
100
+ const endDragged = draggingPoints.findIndex((i) => i === endIdx) > -1;
101
+ const start = startDragged
102
+ ? isBindingEnabled
103
+ ? getElligibleElementForBindingElement(selectedElement, "start", elementsMap)
104
+ : null // If binding is disabled and start is dragged, break all binds
105
+ : // We have to update the focus and gap of the binding, so let's rebind
106
+ getElligibleElementForBindingElement(selectedElement, "start", elementsMap);
107
+ const end = endDragged
108
+ ? isBindingEnabled
109
+ ? getElligibleElementForBindingElement(selectedElement, "end", elementsMap)
110
+ : null // If binding is disabled and end is dragged, break all binds
111
+ : // We have to update the focus and gap of the binding, so let's rebind
112
+ getElligibleElementForBindingElement(selectedElement, "end", elementsMap);
113
+ return [start, end];
114
+ };
115
+ const getBindingStrategyForDraggingArrowOrJoints = (selectedElement, elementsMap, isBindingEnabled) => {
116
+ const [startIsClose, endIsClose] = getOriginalBindingsIfStillCloseToArrowEnds(selectedElement, elementsMap);
117
+ const start = startIsClose
118
+ ? isBindingEnabled
119
+ ? getElligibleElementForBindingElement(selectedElement, "start", elementsMap)
120
+ : null
121
+ : null;
122
+ const end = endIsClose
123
+ ? isBindingEnabled
124
+ ? getElligibleElementForBindingElement(selectedElement, "end", elementsMap)
125
+ : null
126
+ : null;
127
+ return [start, end];
128
+ };
129
+ export const bindOrUnbindLinearElements = (selectedElements, elementsMap, isBindingEnabled, draggingPoints) => {
130
+ selectedElements.forEach((selectedElement) => {
131
+ const [start, end] = draggingPoints?.length
132
+ ? // The arrow edge points are dragged (i.e. start, end)
133
+ getBindingStrategyForDraggingArrowEndpoints(selectedElement, isBindingEnabled, draggingPoints ?? [], elementsMap)
134
+ : // The arrow itself (the shaft) or the inner joins are dragged
135
+ getBindingStrategyForDraggingArrowOrJoints(selectedElement, elementsMap, isBindingEnabled);
136
+ bindOrUnbindLinearElement(selectedElement, start, end, elementsMap);
78
137
  });
79
138
  };
80
- const maybeBindBindableElement = (bindableElement, elementsMap, app) => {
81
- getElligibleElementsForBindableElementAndWhere(bindableElement, app).forEach(([linearElement, where]) => bindOrUnbindLinearElement(linearElement, where === "end" ? "keep" : bindableElement, where === "start" ? "keep" : bindableElement, elementsMap));
82
- };
83
- export const maybeBindLinearElement = (linearElement, appState, pointerCoords, app) => {
139
+ export const getSuggestedBindingsForArrows = (selectedElements, elementsMap) => {
140
+ // HOT PATH: Bail out if selected elements list is too large
141
+ if (selectedElements.length > 50) {
142
+ return [];
143
+ }
144
+ return (selectedElements
145
+ .filter(isLinearElement)
146
+ .flatMap((element) => getOriginalBindingsIfStillCloseToArrowEnds(element, elementsMap))
147
+ .filter((element) => element !== null)
148
+ // Filter out bind candidates which are in the
149
+ // same selection / group with the arrow
150
+ //
151
+ // TODO: Is it worth turning the list into a set to avoid dupes?
152
+ .filter((element) => selectedElements.filter((selected) => selected.id === element?.id)
153
+ .length === 0));
154
+ };
155
+ export const maybeBindLinearElement = (linearElement, appState, pointerCoords, elementsMap) => {
84
156
  if (appState.startBoundElement != null) {
85
- bindLinearElement(linearElement, appState.startBoundElement, "start", app.scene.getNonDeletedElementsMap());
157
+ bindLinearElement(linearElement, appState.startBoundElement, "start", elementsMap);
86
158
  }
87
- const hoveredElement = getHoveredElementForBinding(pointerCoords, app);
159
+ const hoveredElement = getHoveredElementForBinding(pointerCoords, elementsMap);
88
160
  if (hoveredElement != null &&
89
161
  !isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, hoveredElement, "end")) {
90
- bindLinearElement(linearElement, hoveredElement, "end", app.scene.getNonDeletedElementsMap());
162
+ bindLinearElement(linearElement, hoveredElement, "end", elementsMap);
91
163
  }
92
164
  };
93
165
  export const bindLinearElement = (linearElement, hoveredElement, startOrEnd, elementsMap) => {
166
+ if (!isArrowElement(linearElement)) {
167
+ return;
168
+ }
94
169
  mutateElement(linearElement, {
95
170
  [startOrEnd === "start" ? "startBinding" : "endBinding"]: {
96
171
  elementId: hoveredElement.id,
@@ -113,20 +188,10 @@ const isLinearElementSimpleAndAlreadyBoundOnOppositeEdge = (linearElement, binda
113
188
  return isLinearElementSimpleAndAlreadyBound(linearElement, otherBinding?.elementId, bindableElement);
114
189
  };
115
190
  export const isLinearElementSimpleAndAlreadyBound = (linearElement, alreadyBoundToId, bindableElement) => {
116
- return (alreadyBoundToId === bindableElement.id && linearElement.points.length < 3);
117
- };
118
- export const unbindLinearElements = (elements, elementsMap) => {
119
- elements.forEach((element) => {
120
- if (isBindingElement(element)) {
121
- if (element.startBinding !== null && element.endBinding !== null) {
122
- bindOrUnbindLinearElement(element, null, null, elementsMap);
123
- }
124
- else {
125
- bindOrUnbindLinearElement(element, element.startBinding ? "keep" : null, element.endBinding ? "keep" : null, elementsMap);
126
- }
127
- }
128
- });
191
+ return (alreadyBoundToId === bindableElement.id &&
192
+ isLinearElementSimple(linearElement));
129
193
  };
194
+ const isLinearElementSimple = (linearElement) => linearElement.points.length < 3;
130
195
  const unbindLinearElement = (linearElement, startOrEnd) => {
131
196
  const field = startOrEnd === "start" ? "startBinding" : "endBinding";
132
197
  const binding = linearElement[field];
@@ -136,9 +201,9 @@ const unbindLinearElement = (linearElement, startOrEnd) => {
136
201
  mutateElement(linearElement, { [field]: null });
137
202
  return binding.elementId;
138
203
  };
139
- export const getHoveredElementForBinding = (pointerCoords, app) => {
140
- const hoveredElement = getElementAtPosition(app.scene.getNonDeletedElements(), (element) => isBindableElement(element, false) &&
141
- bindingBorderTest(element, pointerCoords, app));
204
+ export const getHoveredElementForBinding = (pointerCoords, elementsMap) => {
205
+ const hoveredElement = getElementAtPosition([...elementsMap].map(([_, value]) => value), (element) => isBindableElement(element, false) &&
206
+ bindingBorderTest(element, pointerCoords, elementsMap));
142
207
  return hoveredElement;
143
208
  };
144
209
  const calculateFocusAndGap = (linearElement, hoveredElement, startOrEnd, elementsMap) => {
@@ -247,55 +312,13 @@ const maybeCalculateNewGapWhenScaling = (changedElement, currentBinding, newSize
247
312
  const newGap = Math.max(1, Math.min(maxBindingGap(changedElement, newWidth, newHeight), gap * (newWidth < newHeight ? newWidth / width : newHeight / height)));
248
313
  return { elementId, gap: newGap, focus };
249
314
  };
250
- // TODO: this is a bottleneck, optimise
251
- export const getEligibleElementsForBinding = (selectedElements, app) => {
252
- const includedElementIds = new Set(selectedElements.map(({ id }) => id));
253
- return selectedElements.flatMap((selectedElement) => isBindingElement(selectedElement, false)
254
- ? getElligibleElementsForBindingElement(selectedElement, app).filter((element) => !includedElementIds.has(element.id))
255
- : isBindableElement(selectedElement, false)
256
- ? getElligibleElementsForBindableElementAndWhere(selectedElement, app).filter((binding) => !includedElementIds.has(binding[0].id))
257
- : []);
258
- };
259
- const getElligibleElementsForBindingElement = (linearElement, app) => {
260
- return [
261
- getElligibleElementForBindingElement(linearElement, "start", app),
262
- getElligibleElementForBindingElement(linearElement, "end", app),
263
- ].filter((element) => element != null);
264
- };
265
- const getElligibleElementForBindingElement = (linearElement, startOrEnd, app) => {
266
- return getHoveredElementForBinding(getLinearElementEdgeCoors(linearElement, startOrEnd, app.scene.getNonDeletedElementsMap()), app);
315
+ const getElligibleElementForBindingElement = (linearElement, startOrEnd, elementsMap) => {
316
+ return getHoveredElementForBinding(getLinearElementEdgeCoors(linearElement, startOrEnd, elementsMap), elementsMap);
267
317
  };
268
318
  const getLinearElementEdgeCoors = (linearElement, startOrEnd, elementsMap) => {
269
319
  const index = startOrEnd === "start" ? 0 : -1;
270
320
  return tupleToCoors(LinearElementEditor.getPointAtIndexGlobalCoordinates(linearElement, index, elementsMap));
271
321
  };
272
- const getElligibleElementsForBindableElementAndWhere = (bindableElement, app) => {
273
- const scene = Scene.getScene(bindableElement);
274
- return scene
275
- .getNonDeletedElements()
276
- .map((element) => {
277
- if (!isBindingElement(element, false)) {
278
- return null;
279
- }
280
- const canBindStart = isLinearElementEligibleForNewBindingByBindable(element, "start", bindableElement, scene.getNonDeletedElementsMap(), app);
281
- const canBindEnd = isLinearElementEligibleForNewBindingByBindable(element, "end", bindableElement, scene.getNonDeletedElementsMap(), app);
282
- if (!canBindStart && !canBindEnd) {
283
- return null;
284
- }
285
- return [
286
- element,
287
- canBindStart && canBindEnd ? "both" : canBindStart ? "start" : "end",
288
- bindableElement,
289
- ];
290
- })
291
- .filter((maybeElement) => maybeElement != null);
292
- };
293
- const isLinearElementEligibleForNewBindingByBindable = (linearElement, startOrEnd, bindableElement, elementsMap, app) => {
294
- const existingBinding = linearElement[startOrEnd === "start" ? "startBinding" : "endBinding"];
295
- return (existingBinding == null &&
296
- !isLinearElementSimpleAndAlreadyBoundOnOppositeEdge(linearElement, bindableElement, startOrEnd) &&
297
- bindingBorderTest(bindableElement, getLinearElementEdgeCoors(linearElement, startOrEnd, elementsMap), app));
298
- };
299
322
  // We need to:
300
323
  // 1: Update elements not selected to point to duplicated elements
301
324
  // 2: Update duplicated elements to point to other duplicated elements
@@ -310,6 +333,7 @@ duplicatesServeAsOld) => {
310
333
  const allBoundElementIds = new Set();
311
334
  const allBindableElementIds = new Set();
312
335
  const shouldReverseRoles = duplicatesServeAsOld === "duplicatesServeAsOld";
336
+ const duplicateIdToOldId = new Map([...oldIdToDuplicatedId].map(([key, value]) => [value, key]));
313
337
  oldElements.forEach((oldElement) => {
314
338
  const { boundElements } = oldElement;
315
339
  if (boundElements != null && boundElements.length > 0) {
@@ -350,7 +374,8 @@ duplicatesServeAsOld) => {
350
374
  sceneElements
351
375
  .filter(({ id }) => allBindableElementIds.has(id))
352
376
  .forEach((bindableElement) => {
353
- const { boundElements } = bindableElement;
377
+ const oldElementId = duplicateIdToOldId.get(bindableElement.id);
378
+ const { boundElements } = sceneElements.find(({ id }) => id === oldElementId);
354
379
  if (boundElements != null && boundElements.length > 0) {
355
380
  mutateElement(bindableElement, {
356
381
  boundElements: boundElements.map((boundElement) => oldIdToDuplicatedId.has(boundElement.id)
@@ -389,9 +414,9 @@ const newBoundElements = (boundElements, idsToRemove, elementsToAdd = []) => {
389
414
  nextBoundElements.push(...elementsToAdd.map((x) => ({ id: x.id, type: x.type })));
390
415
  return nextBoundElements;
391
416
  };
392
- export const bindingBorderTest = (element, { x, y }, app) => {
417
+ const bindingBorderTest = (element, { x, y }, elementsMap) => {
393
418
  const threshold = maxBindingGap(element, element.width, element.height);
394
- const shape = app.getElementShape(element);
419
+ const shape = getElementShape(element, elementsMap);
395
420
  return isPointOnShape([x, y], shape, threshold);
396
421
  };
397
422
  export const maxBindingGap = (element, elementWidth, elementHeight) => {
@@ -401,7 +426,7 @@ export const maxBindingGap = (element, elementWidth, elementHeight) => {
401
426
  // We make the bindable boundary bigger for bigger elements
402
427
  return Math.max(16, Math.min(0.25 * smallerDimension, 32));
403
428
  };
404
- export const distanceToBindableElement = (element, point, elementsMap) => {
429
+ const distanceToBindableElement = (element, point, elementsMap) => {
405
430
  switch (element.type) {
406
431
  case "rectangle":
407
432
  case "image":
@@ -426,7 +451,7 @@ const distanceToDiamond = (element, point, elementsMap) => {
426
451
  const side = GALine.equation(hheight, hwidth, -hheight * hwidth);
427
452
  return GAPoint.distanceToLine(pointRel, side);
428
453
  };
429
- export const distanceToEllipse = (element, point, elementsMap) => {
454
+ const distanceToEllipse = (element, point, elementsMap) => {
430
455
  const [pointRel, tangent] = ellipseParamsForTest(element, point, elementsMap);
431
456
  return -GALine.sign(tangent) * GAPoint.distanceToLine(pointRel, tangent);
432
457
  };
@@ -504,7 +529,7 @@ const coordsCenter = (x1, y1, x2, y2) => {
504
529
  // all focus points lie, so it's a number between -1 and 1.
505
530
  // The line going through `a` and `b` is a tangent to the "focus image"
506
531
  // of the element.
507
- export const determineFocusDistance = (element,
532
+ const determineFocusDistance = (element,
508
533
  // Point on the line, in absolute coordinates
509
534
  a,
510
535
  // Another point on the line, in absolute coordinates (closer to element)
@@ -541,7 +566,7 @@ b, elementsMap) => {
541
566
  }
542
567
  return ret || 0;
543
568
  };
544
- export const determineFocusPoint = (element,
569
+ const determineFocusPoint = (element,
545
570
  // The oriented, relative distance from the center of `element` of the
546
571
  // returned focusPoint
547
572
  focus, adjecentPoint, elementsMap) => {
@@ -573,7 +598,7 @@ focus, adjecentPoint, elementsMap) => {
573
598
  };
574
599
  // Returns 2 or 0 intersection points between line going through `a` and `b`
575
600
  // and the `element`, in ascending order of distance from `a`.
576
- export const intersectElementWithLine = (element,
601
+ const intersectElementWithLine = (element,
577
602
  // Point on the line, in absolute coordinates
578
603
  a,
579
604
  // Another point on the line, in absolute coordinates
@@ -688,7 +713,7 @@ const getEllipseIntersections = (element, gap, line) => {
688
713
  GA.point((xn - a * b * n * discrRoot) / squares, (yn + a * b * m * discrRoot) / squares),
689
714
  ];
690
715
  };
691
- export const getCircleIntersections = (center, radius, line) => {
716
+ const getCircleIntersections = (center, radius, line) => {
692
717
  if (radius === 0) {
693
718
  return GAPoint.distanceToLine(line, center) === 0 ? [center] : [];
694
719
  }
@@ -712,7 +737,7 @@ export const getCircleIntersections = (center, radius, line) => {
712
737
  };
713
738
  // The focus point is the tangent point of the "focus image" of the
714
739
  // `element`, where the tangent goes through `point`.
715
- export const findFocusPointForEllipse = (ellipse,
740
+ const findFocusPointForEllipse = (ellipse,
716
741
  // Between -1 and 1 (not 0) the relative size of the "focus image" of
717
742
  // the element on which the focus point lies
718
743
  relativeDistance,
@@ -739,7 +764,7 @@ point) => {
739
764
  const x = -(a ** 2 * m) / (n ** 2 * b ** 2 + m ** 2 * a ** 2);
740
765
  return GA.point(x, (-m * x - 1) / n);
741
766
  };
742
- export const findFocusPointForRectangulars = (element,
767
+ const findFocusPointForRectangulars = (element,
743
768
  // Between -1 and 1 for how far away should the focus point be relative
744
769
  // to the size of the element. Sign determines orientation.
745
770
  relativeDistance,
@@ -1,6 +1,6 @@
1
- import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, ExcalidrawFreeDrawElement, NonDeleted, ElementsMap } from "./types";
2
- import { Drawable, Op } from "roughjs/bin/core";
3
- import { AppState, Point } from "../types";
1
+ import type { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, ExcalidrawFreeDrawElement, NonDeleted, ElementsMap } from "./types";
2
+ import type { Drawable, Op } from "roughjs/bin/core";
3
+ import type { AppState, Point } from "../types";
4
4
  export type RectangleBox = {
5
5
  x: number;
6
6
  y: number;
@@ -1,6 +1,6 @@
1
- import { ElementsMap, ExcalidrawElement } from "./types";
2
- import { FrameNameBounds } from "../types";
3
- import { GeometricShape } from "../../utils/geometry/shape";
1
+ import type { ElementsMap, ExcalidrawElement } from "./types";
2
+ import type { FrameNameBounds } from "../types";
3
+ import type { GeometricShape } from "../../utils/geometry/shape";
4
4
  export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
5
5
  export type HitTestArgs = {
6
6
  x: number;
@@ -1,6 +1,6 @@
1
1
  import { isPathALoop, isPointWithinBounds } from "../math";
2
2
  import { getElementBounds } from "./bounds";
3
- import { getPolygonShape, } from "../../utils/geometry/shape";
3
+ import { getPolygonShape } from "../../utils/geometry/shape";
4
4
  import { isPointInShape, isPointOnShape } from "../../utils/collision";
5
5
  import { isTransparent } from "../utils";
6
6
  import { hasBoundTextElement, isIframeLikeElement, isImageElement, isTextElement, } from "./typeChecks";
@@ -1,4 +1,4 @@
1
- import { ExcalidrawTextContainer } from "./types";
1
+ import type { ExcalidrawTextContainer } from "./types";
2
2
  export declare const originalContainerCache: {
3
3
  [id: ExcalidrawTextContainer["id"]]: {
4
4
  height: ExcalidrawTextContainer["height"];
@@ -1,6 +1,6 @@
1
- import { NonDeletedExcalidrawElement } from "./types";
2
- import { AppState, PointerDownState } from "../types";
3
- import Scene from "../scene/Scene";
1
+ import type { NonDeletedExcalidrawElement } from "./types";
2
+ import type { AppState, NormalizedZoomValue, PointerDownState } from "../types";
3
+ import type Scene from "../scene/Scene";
4
4
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, selectedElements: NonDeletedExcalidrawElement[], offset: {
5
5
  x: number;
6
6
  y: number;
@@ -9,7 +9,7 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
9
9
  y: number;
10
10
  }, gridSize: AppState["gridSize"]) => void;
11
11
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
12
- export declare const dragNewElement: (draggingElement: NonDeletedExcalidrawElement, elementType: AppState["activeTool"]["type"], originX: number, originY: number, x: number, y: number, width: number, height: number, shouldMaintainAspectRatio: boolean, shouldResizeFromCenter: boolean, widthAspectRatio?: number | null, originOffset?: {
12
+ export declare const dragNewElement: (draggingElement: NonDeletedExcalidrawElement, elementType: AppState["activeTool"]["type"], originX: number, originY: number, x: number, y: number, width: number, height: number, shouldMaintainAspectRatio: boolean, shouldResizeFromCenter: boolean, zoom: NormalizedZoomValue, widthAspectRatio?: number | null, originOffset?: {
13
13
  x: number;
14
14
  y: number;
15
15
  } | null) => void;