@excalidraw/excalidraw 0.17.1-7441-0269e5a → 0.17.1-7441-4c9a6f4

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 (660) hide show
  1. package/dist/browser/excalidraw-assets/{chunk-V52YQ6TH.js → chunk-LZCCI7PN.js} +1181 -1675
  2. package/dist/browser/excalidraw-assets/{image-MZHH7VY4.js → image-CG4AV2NT.js} +1 -1
  3. package/dist/browser/excalidraw-assets/{image-2MHILQWB.css → image-EO7USLQY.css} +1 -1
  4. package/dist/browser/index.css +1 -1
  5. package/dist/browser/index.js +1 -1
  6. package/dist/packages/excalidraw/actions/actionAddToLibrary.js +59 -0
  7. package/dist/packages/excalidraw/actions/actionAlign.js +124 -0
  8. package/dist/packages/excalidraw/actions/actionBoundText.js +213 -0
  9. package/dist/packages/excalidraw/actions/actionCanvas.js +354 -0
  10. package/dist/packages/excalidraw/actions/actionClipboard.js +221 -0
  11. package/dist/packages/excalidraw/actions/actionDeleteSelected.js +129 -0
  12. package/dist/packages/excalidraw/actions/actionDistribute.js +56 -0
  13. package/dist/packages/excalidraw/actions/actionDuplicateSelection.js +181 -0
  14. package/dist/packages/excalidraw/actions/actionElementLock.js +89 -0
  15. package/dist/packages/excalidraw/actions/actionExport.js +195 -0
  16. package/dist/packages/excalidraw/actions/actionFinalize.js +150 -0
  17. package/dist/packages/excalidraw/actions/actionFlip.js +52 -0
  18. package/dist/packages/excalidraw/actions/actionFrame.js +113 -0
  19. package/dist/packages/excalidraw/actions/actionGroup.js +162 -0
  20. package/dist/packages/excalidraw/actions/actionHistory.js +57 -0
  21. package/dist/packages/excalidraw/actions/actionLinearEditor.js +41 -0
  22. package/dist/packages/excalidraw/actions/actionMenu.js +53 -0
  23. package/dist/packages/excalidraw/actions/actionNavigate.js +43 -0
  24. package/dist/packages/excalidraw/actions/actionProperties.js +683 -0
  25. package/dist/packages/excalidraw/actions/actionSelectAll.js +40 -0
  26. package/dist/packages/excalidraw/actions/actionStyles.js +118 -0
  27. package/dist/packages/excalidraw/actions/actionToggleGridMode.js +27 -0
  28. package/dist/packages/excalidraw/actions/actionToggleObjectsSnapMode.js +26 -0
  29. package/dist/packages/excalidraw/actions/actionToggleStats.js +19 -0
  30. package/dist/packages/excalidraw/actions/actionToggleViewMode.js +25 -0
  31. package/dist/packages/excalidraw/actions/actionToggleZenMode.js +25 -0
  32. package/dist/packages/excalidraw/actions/actionZindex.js +86 -0
  33. package/dist/packages/excalidraw/actions/index.js +25 -0
  34. package/dist/packages/excalidraw/actions/manager.js +110 -0
  35. package/dist/packages/excalidraw/actions/register.js +5 -0
  36. package/dist/packages/excalidraw/actions/shortcuts.js +52 -0
  37. package/dist/packages/excalidraw/align.js +36 -0
  38. package/dist/packages/excalidraw/analytics.js +30 -0
  39. package/dist/packages/excalidraw/appState.js +222 -0
  40. package/dist/packages/excalidraw/charts.js +365 -0
  41. package/dist/packages/excalidraw/clients.js +34 -0
  42. package/dist/packages/excalidraw/clipboard.js +351 -0
  43. package/dist/packages/excalidraw/colors.js +124 -0
  44. package/dist/packages/excalidraw/components/Actions.js +127 -0
  45. package/dist/packages/excalidraw/components/Actions.scss +92 -0
  46. package/dist/packages/excalidraw/components/ActiveConfirmDialog.js +22 -0
  47. package/dist/packages/excalidraw/components/App.js +6177 -0
  48. package/dist/packages/excalidraw/components/Avatar.js +15 -0
  49. package/dist/packages/excalidraw/components/Avatar.scss +7 -0
  50. package/dist/packages/excalidraw/components/BraveMeasureTextError.js +6 -0
  51. package/dist/packages/excalidraw/components/Button.js +14 -0
  52. package/dist/packages/excalidraw/components/Button.scss +7 -0
  53. package/dist/packages/excalidraw/components/ButtonIconCycle.js +11 -0
  54. package/dist/packages/excalidraw/components/ButtonIconSelect.js +6 -0
  55. package/dist/packages/excalidraw/components/ButtonSelect.js +3 -0
  56. package/dist/packages/excalidraw/components/Card.js +14 -0
  57. package/dist/packages/excalidraw/components/Card.scss +57 -0
  58. package/dist/packages/excalidraw/components/CheckboxItem.js +10 -0
  59. package/dist/packages/excalidraw/components/CheckboxItem.scss +91 -0
  60. package/dist/packages/excalidraw/components/ColorPicker/ColorInput.js +67 -0
  61. package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.js +138 -0
  62. package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.scss +441 -0
  63. package/dist/packages/excalidraw/components/ColorPicker/CustomColorList.js +24 -0
  64. package/dist/packages/excalidraw/components/ColorPicker/HotkeyLabel.js +8 -0
  65. package/dist/packages/excalidraw/components/ColorPicker/Picker.js +86 -0
  66. package/dist/packages/excalidraw/components/ColorPicker/PickerColorList.js +33 -0
  67. package/dist/packages/excalidraw/components/ColorPicker/PickerHeading.js +3 -0
  68. package/dist/packages/excalidraw/components/ColorPicker/ShadeList.js +44 -0
  69. package/dist/packages/excalidraw/components/ColorPicker/TopPicks.js +27 -0
  70. package/dist/packages/excalidraw/components/ColorPicker/colorPickerUtils.js +83 -0
  71. package/dist/packages/excalidraw/components/ColorPicker/keyboardNavHandlers.js +174 -0
  72. package/dist/packages/excalidraw/components/ConfirmDialog.js +27 -0
  73. package/dist/packages/excalidraw/components/ConfirmDialog.scss +11 -0
  74. package/dist/packages/excalidraw/components/ContextMenu.js +56 -0
  75. package/dist/packages/excalidraw/components/ContextMenu.scss +98 -0
  76. package/dist/packages/excalidraw/components/DarkModeToggle.js +16 -0
  77. package/dist/packages/excalidraw/components/DefaultSidebar.js +48 -0
  78. package/dist/packages/excalidraw/components/Dialog.js +74 -0
  79. package/dist/packages/excalidraw/components/Dialog.scss +48 -0
  80. package/dist/packages/excalidraw/components/DialogActionButton.js +9 -0
  81. package/dist/packages/excalidraw/components/DialogActionButton.scss +47 -0
  82. package/dist/packages/excalidraw/components/ErrorDialog.js +18 -0
  83. package/dist/packages/excalidraw/components/ExcalidrawLogo.js +7 -0
  84. package/dist/packages/excalidraw/components/ExcalidrawLogo.scss +73 -0
  85. package/dist/packages/excalidraw/components/ExportDialog.scss +129 -0
  86. package/dist/packages/excalidraw/components/EyeDropper.js +130 -0
  87. package/dist/packages/excalidraw/components/EyeDropper.scss +48 -0
  88. package/dist/packages/excalidraw/components/FilledButton.js +7 -0
  89. package/dist/packages/excalidraw/components/FilledButton.scss +191 -0
  90. package/dist/packages/excalidraw/components/FixedSideContainer.js +4 -0
  91. package/dist/packages/excalidraw/components/FixedSideContainer.scss +40 -0
  92. package/dist/packages/excalidraw/components/FollowMode/FollowMode.js +7 -0
  93. package/dist/packages/excalidraw/components/FollowMode/FollowMode.scss +59 -0
  94. package/dist/packages/excalidraw/components/HandButton.js +9 -0
  95. package/dist/packages/excalidraw/components/HelpButton.js +4 -0
  96. package/dist/packages/excalidraw/components/HelpDialog.js +79 -0
  97. package/dist/packages/excalidraw/components/HelpDialog.scss +130 -0
  98. package/dist/packages/excalidraw/components/HintViewer.js +97 -0
  99. package/dist/packages/excalidraw/components/HintViewer.scss +37 -0
  100. package/dist/packages/excalidraw/components/IconPicker.js +99 -0
  101. package/dist/packages/excalidraw/components/IconPicker.scss +143 -0
  102. package/dist/packages/excalidraw/components/ImageExportDialog.js +127 -0
  103. package/dist/packages/excalidraw/components/ImageExportDialog.scss +173 -0
  104. package/dist/packages/excalidraw/components/InitializeApp.js +16 -0
  105. package/dist/packages/excalidraw/components/InlineIcon.js +10 -0
  106. package/dist/packages/excalidraw/components/Island.js +5 -0
  107. package/dist/packages/excalidraw/components/Island.scss +16 -0
  108. package/dist/packages/excalidraw/components/JSONExportDialog.js +35 -0
  109. package/dist/packages/excalidraw/components/LaserTool/LaserPathManager.js +225 -0
  110. package/dist/packages/excalidraw/components/LaserTool/LaserPointerButton.js +10 -0
  111. package/dist/packages/excalidraw/components/LaserTool/LaserTool.js +15 -0
  112. package/dist/packages/excalidraw/components/LaserTool/LaserToolOverlay.scss +20 -0
  113. package/dist/packages/excalidraw/components/LayerUI.js +189 -0
  114. package/dist/packages/excalidraw/components/LayerUI.scss +112 -0
  115. package/dist/packages/excalidraw/components/LibraryMenu.js +99 -0
  116. package/dist/packages/excalidraw/components/LibraryMenu.scss +150 -0
  117. package/dist/packages/excalidraw/components/LibraryMenuBrowseButton.js +8 -0
  118. package/dist/packages/excalidraw/components/LibraryMenuControlButtons.js +6 -0
  119. package/dist/packages/excalidraw/components/LibraryMenuHeaderContent.js +126 -0
  120. package/dist/packages/excalidraw/components/LibraryMenuItems.js +138 -0
  121. package/dist/packages/excalidraw/components/LibraryMenuItems.scss +99 -0
  122. package/dist/packages/excalidraw/components/LibraryMenuSection.js +21 -0
  123. package/dist/packages/excalidraw/components/LibraryUnit.js +52 -0
  124. package/dist/packages/excalidraw/components/LibraryUnit.scss +185 -0
  125. package/dist/packages/excalidraw/components/LoadingMessage.js +24 -0
  126. package/dist/packages/excalidraw/components/LockButton.js +14 -0
  127. package/dist/packages/excalidraw/components/MagicButton.js +9 -0
  128. package/dist/packages/excalidraw/components/MagicSettings.js +46 -0
  129. package/dist/packages/excalidraw/components/MagicSettings.scss +18 -0
  130. package/dist/packages/excalidraw/components/MobileMenu.js +45 -0
  131. package/dist/packages/excalidraw/components/Modal.js +23 -0
  132. package/dist/packages/excalidraw/components/Modal.scss +121 -0
  133. package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.js +31 -0
  134. package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.scss +126 -0
  135. package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.js +32 -0
  136. package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.js +19 -0
  137. package/dist/packages/excalidraw/components/Paragraph.js +4 -0
  138. package/dist/packages/excalidraw/components/PasteChartDialog.js +63 -0
  139. package/dist/packages/excalidraw/components/PasteChartDialog.scss +46 -0
  140. package/dist/packages/excalidraw/components/PenModeButton.js +13 -0
  141. package/dist/packages/excalidraw/components/Popover.js +111 -0
  142. package/dist/packages/excalidraw/components/Popover.scss +8 -0
  143. package/dist/packages/excalidraw/components/ProjectName.js +30 -0
  144. package/dist/packages/excalidraw/components/ProjectName.scss +25 -0
  145. package/dist/packages/excalidraw/components/PublishLibrary.js +214 -0
  146. package/dist/packages/excalidraw/components/PublishLibrary.scss +172 -0
  147. package/dist/packages/excalidraw/components/RadioGroup.js +8 -0
  148. package/dist/packages/excalidraw/components/RadioGroup.scss +91 -0
  149. package/dist/packages/excalidraw/components/Section.js +8 -0
  150. package/dist/packages/excalidraw/components/ShareableLinkDialog.js +33 -0
  151. package/dist/packages/excalidraw/components/ShareableLinkDialog.scss +91 -0
  152. package/dist/packages/excalidraw/components/Sidebar/Sidebar.js +145 -0
  153. package/dist/packages/excalidraw/components/Sidebar/Sidebar.scss +176 -0
  154. package/dist/packages/excalidraw/components/Sidebar/SidebarHeader.js +16 -0
  155. package/dist/packages/excalidraw/components/Sidebar/SidebarTab.js +6 -0
  156. package/dist/packages/excalidraw/components/Sidebar/SidebarTabTrigger.js +6 -0
  157. package/dist/packages/excalidraw/components/Sidebar/SidebarTabTriggers.js +6 -0
  158. package/dist/packages/excalidraw/components/Sidebar/SidebarTabs.js +17 -0
  159. package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.js +18 -0
  160. package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.scss +37 -0
  161. package/dist/packages/excalidraw/components/Sidebar/common.js +2 -0
  162. package/dist/packages/excalidraw/components/Spinner.js +14 -0
  163. package/dist/packages/excalidraw/components/Spinner.scss +49 -0
  164. package/dist/packages/excalidraw/components/Stack.js +24 -0
  165. package/dist/packages/excalidraw/components/Stack.scss +19 -0
  166. package/dist/packages/excalidraw/components/Stats.js +13 -0
  167. package/dist/packages/excalidraw/components/Stats.scss +54 -0
  168. package/dist/packages/excalidraw/components/Switch.js +10 -0
  169. package/dist/packages/excalidraw/components/Switch.scss +118 -0
  170. package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.js +58 -0
  171. package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.scss +10 -0
  172. package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.js +194 -0
  173. package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.scss +315 -0
  174. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogInput.js +28 -0
  175. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogOutput.js +8 -0
  176. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanel.js +11 -0
  177. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanels.js +4 -0
  178. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.js +5 -0
  179. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTab.js +6 -0
  180. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTrigger.js +6 -0
  181. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTriggers.js +6 -0
  182. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabs.js +39 -0
  183. package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTrigger.js +16 -0
  184. package/dist/packages/excalidraw/components/TTDDialog/common.js +88 -0
  185. package/dist/packages/excalidraw/components/TextField.js +25 -0
  186. package/dist/packages/excalidraw/components/TextField.scss +109 -0
  187. package/dist/packages/excalidraw/components/TextInput.scss +7 -0
  188. package/dist/packages/excalidraw/components/Toast.js +30 -0
  189. package/dist/packages/excalidraw/components/Toast.scss +49 -0
  190. package/dist/packages/excalidraw/components/ToolButton.js +72 -0
  191. package/dist/packages/excalidraw/components/ToolIcon.scss +184 -0
  192. package/dist/packages/excalidraw/components/Toolbar.scss +50 -0
  193. package/dist/packages/excalidraw/components/Tooltip.js +60 -0
  194. package/dist/packages/excalidraw/components/Tooltip.scss +47 -0
  195. package/dist/packages/excalidraw/components/Trans.js +139 -0
  196. package/dist/packages/excalidraw/components/UserList.js +96 -0
  197. package/dist/packages/excalidraw/components/UserList.scss +136 -0
  198. package/dist/packages/excalidraw/components/canvases/InteractiveCanvas.js +120 -0
  199. package/dist/packages/excalidraw/components/canvases/StaticCanvas.js +85 -0
  200. package/dist/packages/excalidraw/components/canvases/index.js +3 -0
  201. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.js +24 -0
  202. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.scss +148 -0
  203. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuContent.js +21 -0
  204. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuGroup.js +6 -0
  205. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItem.js +23 -0
  206. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +7 -0
  207. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.js +5 -0
  208. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemLink.js +9 -0
  209. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuSeparator.js +8 -0
  210. package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuTrigger.js +12 -0
  211. package/dist/packages/excalidraw/components/dropdownMenu/common.js +20 -0
  212. package/dist/packages/excalidraw/components/dropdownMenu/dropdownMenuUtils.js +27 -0
  213. package/dist/packages/excalidraw/components/footer/Footer.js +25 -0
  214. package/dist/packages/excalidraw/components/footer/FooterCenter.js +14 -0
  215. package/dist/packages/excalidraw/components/footer/FooterCenter.scss +11 -0
  216. package/dist/packages/excalidraw/components/hoc/withInternalFallback.js +57 -0
  217. package/dist/packages/excalidraw/components/icons.js +220 -0
  218. package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.js +13 -0
  219. package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.scss +72 -0
  220. package/dist/packages/excalidraw/components/main-menu/DefaultItems.js +116 -0
  221. package/dist/packages/excalidraw/components/main-menu/DefaultItems.scss +21 -0
  222. package/dist/packages/excalidraw/components/main-menu/MainMenu.js +36 -0
  223. package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +69 -0
  224. package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +20 -0
  225. package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.js +11 -0
  226. package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.scss +285 -0
  227. package/dist/packages/excalidraw/constants.js +312 -0
  228. package/dist/packages/excalidraw/context/tunnels.js +21 -0
  229. package/dist/packages/excalidraw/context/ui-appState.js +3 -0
  230. package/dist/packages/excalidraw/css/app.scss +39 -0
  231. package/dist/packages/excalidraw/css/styles.scss +757 -0
  232. package/dist/packages/excalidraw/css/theme.scss +252 -0
  233. package/dist/packages/excalidraw/css/variables.module.scss +174 -0
  234. package/dist/packages/excalidraw/cursor.js +72 -0
  235. package/dist/packages/excalidraw/data/EditorLocalStorage.js +42 -0
  236. package/dist/packages/excalidraw/data/ai/types.js +1 -0
  237. package/dist/packages/excalidraw/data/blob.js +378 -0
  238. package/dist/packages/excalidraw/data/encode.js +231 -0
  239. package/dist/packages/excalidraw/data/encryption.js +53 -0
  240. package/dist/packages/excalidraw/data/filesystem.js +65 -0
  241. package/dist/packages/excalidraw/data/image.js +91 -0
  242. package/dist/packages/excalidraw/data/index.js +120 -0
  243. package/dist/packages/excalidraw/data/json.js +93 -0
  244. package/dist/packages/excalidraw/data/library.js +376 -0
  245. package/dist/packages/excalidraw/data/magic.js +73 -0
  246. package/dist/packages/excalidraw/data/resave.js +22 -0
  247. package/dist/packages/excalidraw/data/restore.js +438 -0
  248. package/dist/packages/excalidraw/data/transform.js +442 -0
  249. package/dist/packages/excalidraw/data/types.js +1 -0
  250. package/dist/packages/excalidraw/data/url.js +30 -0
  251. package/dist/packages/excalidraw/distribute.js +58 -0
  252. package/dist/packages/excalidraw/element/ElementCanvasButtons.js +31 -0
  253. package/dist/packages/excalidraw/element/ElementCanvasButtons.scss +14 -0
  254. package/dist/packages/excalidraw/element/Hyperlink.js +350 -0
  255. package/dist/packages/excalidraw/element/Hyperlink.scss +70 -0
  256. package/dist/packages/excalidraw/element/binding.js +412 -0
  257. package/dist/packages/excalidraw/element/bounds.js +613 -0
  258. package/dist/packages/excalidraw/element/collision.js +727 -0
  259. package/dist/packages/excalidraw/element/dragElements.js +119 -0
  260. package/dist/packages/excalidraw/element/embeddable.js +305 -0
  261. package/dist/packages/excalidraw/element/image.js +91 -0
  262. package/dist/packages/excalidraw/element/index.js +24 -0
  263. package/dist/packages/excalidraw/element/linearElementEditor.js +867 -0
  264. package/dist/packages/excalidraw/element/mutateElement.js +112 -0
  265. package/dist/packages/excalidraw/element/newElement.js +389 -0
  266. package/dist/packages/excalidraw/element/resizeElements.js +597 -0
  267. package/dist/packages/excalidraw/element/resizeTest.js +95 -0
  268. package/dist/packages/excalidraw/element/showSelectedShapeActions.js +9 -0
  269. package/dist/packages/excalidraw/element/sizeHelpers.js +131 -0
  270. package/dist/packages/excalidraw/element/sortElements.js +104 -0
  271. package/dist/packages/excalidraw/element/textElement.js +716 -0
  272. package/dist/packages/excalidraw/element/textWysiwyg.js +500 -0
  273. package/dist/packages/excalidraw/element/transformHandles.js +155 -0
  274. package/dist/packages/excalidraw/element/typeChecks.js +141 -0
  275. package/dist/packages/excalidraw/element/types.js +1 -0
  276. package/dist/packages/excalidraw/emitter.js +36 -0
  277. package/dist/packages/excalidraw/errors.js +20 -0
  278. package/dist/packages/excalidraw/frame.js +373 -0
  279. package/dist/packages/excalidraw/ga.js +268 -0
  280. package/dist/packages/excalidraw/gadirections.js +18 -0
  281. package/dist/packages/excalidraw/galines.js +32 -0
  282. package/dist/packages/excalidraw/gapoints.js +30 -0
  283. package/dist/packages/excalidraw/gatransforms.js +23 -0
  284. package/dist/packages/excalidraw/gesture.js +9 -0
  285. package/dist/packages/excalidraw/groups.js +225 -0
  286. package/dist/packages/excalidraw/history.js +190 -0
  287. package/dist/packages/excalidraw/hooks/useCallbackRefState.js +6 -0
  288. package/dist/packages/excalidraw/hooks/useCreatePortalContainer.js +32 -0
  289. package/dist/packages/excalidraw/hooks/useLibraryItemSvg.js +62 -0
  290. package/dist/packages/excalidraw/hooks/useOutsideClick.js +67 -0
  291. package/dist/packages/excalidraw/hooks/useScrollPosition.js +23 -0
  292. package/dist/packages/excalidraw/hooks/useStable.js +6 -0
  293. package/dist/packages/excalidraw/hooks/useTransition.js +7 -0
  294. package/dist/packages/excalidraw/i18n.js +137 -0
  295. package/dist/packages/excalidraw/index-node.d.ts +1 -0
  296. package/dist/packages/excalidraw/index-node.js +73 -0
  297. package/{types → dist/packages}/excalidraw/index.d.ts +1 -1
  298. package/dist/packages/excalidraw/index.js +116 -0
  299. package/dist/packages/excalidraw/jotai.js +18 -0
  300. package/dist/packages/excalidraw/keys.js +84 -0
  301. package/dist/packages/excalidraw/locales/ar-SA.json +525 -0
  302. package/dist/packages/excalidraw/locales/az-AZ.json +525 -0
  303. package/dist/packages/excalidraw/locales/bg-BG.json +525 -0
  304. package/dist/packages/excalidraw/locales/bn-BD.json +525 -0
  305. package/dist/packages/excalidraw/locales/ca-ES.json +525 -0
  306. package/dist/packages/excalidraw/locales/cs-CZ.json +525 -0
  307. package/dist/packages/excalidraw/locales/da-DK.json +525 -0
  308. package/dist/packages/excalidraw/locales/de-DE.json +525 -0
  309. package/dist/packages/excalidraw/locales/el-GR.json +525 -0
  310. package/dist/packages/excalidraw/locales/en.json +535 -0
  311. package/dist/packages/excalidraw/locales/es-ES.json +525 -0
  312. package/dist/packages/excalidraw/locales/eu-ES.json +525 -0
  313. package/dist/packages/excalidraw/locales/fa-IR.json +525 -0
  314. package/dist/packages/excalidraw/locales/fi-FI.json +525 -0
  315. package/dist/packages/excalidraw/locales/fr-FR.json +525 -0
  316. package/dist/packages/excalidraw/locales/gl-ES.json +525 -0
  317. package/dist/packages/excalidraw/locales/he-IL.json +525 -0
  318. package/dist/packages/excalidraw/locales/hi-IN.json +525 -0
  319. package/dist/packages/excalidraw/locales/hu-HU.json +525 -0
  320. package/dist/packages/excalidraw/locales/id-ID.json +525 -0
  321. package/dist/packages/excalidraw/locales/it-IT.json +525 -0
  322. package/dist/packages/excalidraw/locales/ja-JP.json +525 -0
  323. package/dist/packages/excalidraw/locales/kaa.json +525 -0
  324. package/dist/packages/excalidraw/locales/kab-KAB.json +525 -0
  325. package/dist/packages/excalidraw/locales/kk-KZ.json +525 -0
  326. package/dist/packages/excalidraw/locales/km-KH.json +525 -0
  327. package/dist/packages/excalidraw/locales/ko-KR.json +525 -0
  328. package/dist/packages/excalidraw/locales/ku-TR.json +525 -0
  329. package/dist/packages/excalidraw/locales/lt-LT.json +525 -0
  330. package/dist/packages/excalidraw/locales/lv-LV.json +525 -0
  331. package/dist/packages/excalidraw/locales/mr-IN.json +525 -0
  332. package/dist/packages/excalidraw/locales/my-MM.json +525 -0
  333. package/dist/packages/excalidraw/locales/nb-NO.json +525 -0
  334. package/dist/packages/excalidraw/locales/nl-NL.json +525 -0
  335. package/dist/packages/excalidraw/locales/nn-NO.json +525 -0
  336. package/dist/packages/excalidraw/locales/oc-FR.json +525 -0
  337. package/dist/packages/excalidraw/locales/pa-IN.json +525 -0
  338. package/dist/packages/excalidraw/locales/percentages.json +56 -0
  339. package/dist/packages/excalidraw/locales/pl-PL.json +525 -0
  340. package/dist/packages/excalidraw/locales/pt-BR.json +525 -0
  341. package/dist/packages/excalidraw/locales/pt-PT.json +525 -0
  342. package/dist/packages/excalidraw/locales/ro-RO.json +525 -0
  343. package/dist/packages/excalidraw/locales/ru-RU.json +525 -0
  344. package/dist/packages/excalidraw/locales/si-LK.json +525 -0
  345. package/dist/packages/excalidraw/locales/sk-SK.json +525 -0
  346. package/dist/packages/excalidraw/locales/sl-SI.json +525 -0
  347. package/dist/packages/excalidraw/locales/sv-SE.json +525 -0
  348. package/dist/packages/excalidraw/locales/ta-IN.json +525 -0
  349. package/dist/packages/excalidraw/locales/th-TH.json +525 -0
  350. package/dist/packages/excalidraw/locales/tr-TR.json +525 -0
  351. package/dist/packages/excalidraw/locales/uk-UA.json +525 -0
  352. package/dist/packages/excalidraw/locales/vi-VN.json +525 -0
  353. package/dist/packages/excalidraw/locales/zh-CN.json +525 -0
  354. package/dist/packages/excalidraw/locales/zh-HK.json +525 -0
  355. package/dist/packages/excalidraw/locales/zh-TW.json +525 -0
  356. package/dist/packages/excalidraw/math.js +364 -0
  357. package/dist/packages/excalidraw/points.js +38 -0
  358. package/dist/packages/excalidraw/polyfill.js +32 -0
  359. package/dist/packages/excalidraw/random.js +11 -0
  360. package/dist/packages/excalidraw/renderer/renderElement.js +871 -0
  361. package/dist/packages/excalidraw/renderer/renderScene.js +859 -0
  362. package/dist/packages/excalidraw/renderer/renderSnaps.js +114 -0
  363. package/dist/packages/excalidraw/renderer/roundRect.js +28 -0
  364. package/dist/packages/excalidraw/scene/Fonts.js +71 -0
  365. package/dist/packages/excalidraw/scene/Renderer.js +65 -0
  366. package/dist/packages/excalidraw/scene/Scene.js +230 -0
  367. package/dist/packages/excalidraw/scene/Shape.js +322 -0
  368. package/dist/packages/excalidraw/scene/ShapeCache.js +42 -0
  369. package/dist/packages/excalidraw/scene/comparisons.js +67 -0
  370. package/dist/packages/excalidraw/scene/export.js +304 -0
  371. package/dist/packages/excalidraw/scene/index.js +5 -0
  372. package/dist/packages/excalidraw/scene/scroll.js +35 -0
  373. package/dist/packages/excalidraw/scene/scrollbars.js +85 -0
  374. package/dist/packages/excalidraw/scene/selection.js +134 -0
  375. package/dist/packages/excalidraw/scene/types.js +1 -0
  376. package/dist/packages/excalidraw/scene/zoom.js +22 -0
  377. package/dist/packages/excalidraw/shapes.js +84 -0
  378. package/dist/packages/excalidraw/snapping.js +838 -0
  379. package/dist/packages/excalidraw/types.js +6 -0
  380. package/dist/packages/excalidraw/utility-types.js +1 -0
  381. package/dist/packages/excalidraw/utils.js +668 -0
  382. package/dist/packages/excalidraw/zindex.js +349 -0
  383. package/dist/packages/utils/bbox.js +42 -0
  384. package/dist/packages/utils/export.js +109 -0
  385. package/dist/packages/utils/withinBounds.js +125 -0
  386. package/dist/public/fonts/Assistant-Bold.woff2 +0 -0
  387. package/dist/public/fonts/Assistant-Medium.woff2 +0 -0
  388. package/dist/public/fonts/Assistant-Regular.woff2 +0 -0
  389. package/dist/public/fonts/Assistant-SemiBold.woff2 +0 -0
  390. package/dist/public/fonts/Cascadia.ttf +0 -0
  391. package/dist/public/fonts/Cascadia.woff2 +0 -0
  392. package/dist/public/fonts/FG_Virgil.ttf +0 -0
  393. package/dist/public/fonts/FG_Virgil.woff2 +0 -0
  394. package/dist/public/fonts/Virgil.woff2 +0 -0
  395. package/dist/public/fonts/fonts.css +38 -0
  396. package/package.json +8 -5
  397. package/dist/index.css +0 -5796
  398. package/dist/index.js +0 -71898
  399. /package/{types → dist/packages}/excalidraw/actions/actionAddToLibrary.d.ts +0 -0
  400. /package/{types → dist/packages}/excalidraw/actions/actionAlign.d.ts +0 -0
  401. /package/{types → dist/packages}/excalidraw/actions/actionBoundText.d.ts +0 -0
  402. /package/{types → dist/packages}/excalidraw/actions/actionCanvas.d.ts +0 -0
  403. /package/{types → dist/packages}/excalidraw/actions/actionClipboard.d.ts +0 -0
  404. /package/{types → dist/packages}/excalidraw/actions/actionDeleteSelected.d.ts +0 -0
  405. /package/{types → dist/packages}/excalidraw/actions/actionDistribute.d.ts +0 -0
  406. /package/{types → dist/packages}/excalidraw/actions/actionDuplicateSelection.d.ts +0 -0
  407. /package/{types → dist/packages}/excalidraw/actions/actionElementLock.d.ts +0 -0
  408. /package/{types → dist/packages}/excalidraw/actions/actionExport.d.ts +0 -0
  409. /package/{types → dist/packages}/excalidraw/actions/actionFinalize.d.ts +0 -0
  410. /package/{types → dist/packages}/excalidraw/actions/actionFlip.d.ts +0 -0
  411. /package/{types → dist/packages}/excalidraw/actions/actionFrame.d.ts +0 -0
  412. /package/{types → dist/packages}/excalidraw/actions/actionGroup.d.ts +0 -0
  413. /package/{types → dist/packages}/excalidraw/actions/actionHistory.d.ts +0 -0
  414. /package/{types → dist/packages}/excalidraw/actions/actionLinearEditor.d.ts +0 -0
  415. /package/{types → dist/packages}/excalidraw/actions/actionMenu.d.ts +0 -0
  416. /package/{types → dist/packages}/excalidraw/actions/actionNavigate.d.ts +0 -0
  417. /package/{types → dist/packages}/excalidraw/actions/actionProperties.d.ts +0 -0
  418. /package/{types → dist/packages}/excalidraw/actions/actionSelectAll.d.ts +0 -0
  419. /package/{types → dist/packages}/excalidraw/actions/actionStyles.d.ts +0 -0
  420. /package/{types → dist/packages}/excalidraw/actions/actionToggleGridMode.d.ts +0 -0
  421. /package/{types → dist/packages}/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -0
  422. /package/{types → dist/packages}/excalidraw/actions/actionToggleStats.d.ts +0 -0
  423. /package/{types → dist/packages}/excalidraw/actions/actionToggleViewMode.d.ts +0 -0
  424. /package/{types → dist/packages}/excalidraw/actions/actionToggleZenMode.d.ts +0 -0
  425. /package/{types → dist/packages}/excalidraw/actions/actionZindex.d.ts +0 -0
  426. /package/{types → dist/packages}/excalidraw/actions/index.d.ts +0 -0
  427. /package/{types → dist/packages}/excalidraw/actions/manager.d.ts +0 -0
  428. /package/{types → dist/packages}/excalidraw/actions/register.d.ts +0 -0
  429. /package/{types → dist/packages}/excalidraw/actions/shortcuts.d.ts +0 -0
  430. /package/{types → dist/packages}/excalidraw/actions/types.d.ts +0 -0
  431. /package/{types/excalidraw/index-node.d.ts → dist/packages/excalidraw/actions/types.js} +0 -0
  432. /package/{types → dist/packages}/excalidraw/align.d.ts +0 -0
  433. /package/{types → dist/packages}/excalidraw/analytics.d.ts +0 -0
  434. /package/{types → dist/packages}/excalidraw/appState.d.ts +0 -0
  435. /package/{types → dist/packages}/excalidraw/charts.d.ts +0 -0
  436. /package/{types → dist/packages}/excalidraw/clients.d.ts +0 -0
  437. /package/{types → dist/packages}/excalidraw/clipboard.d.ts +0 -0
  438. /package/{types → dist/packages}/excalidraw/colors.d.ts +0 -0
  439. /package/{types → dist/packages}/excalidraw/components/Actions.d.ts +0 -0
  440. /package/{types → dist/packages}/excalidraw/components/ActiveConfirmDialog.d.ts +0 -0
  441. /package/{types → dist/packages}/excalidraw/components/App.d.ts +0 -0
  442. /package/{types → dist/packages}/excalidraw/components/Avatar.d.ts +0 -0
  443. /package/{types → dist/packages}/excalidraw/components/BraveMeasureTextError.d.ts +0 -0
  444. /package/{types → dist/packages}/excalidraw/components/Button.d.ts +0 -0
  445. /package/{types → dist/packages}/excalidraw/components/ButtonIconCycle.d.ts +0 -0
  446. /package/{types → dist/packages}/excalidraw/components/ButtonIconSelect.d.ts +0 -0
  447. /package/{types → dist/packages}/excalidraw/components/ButtonSelect.d.ts +0 -0
  448. /package/{types → dist/packages}/excalidraw/components/Card.d.ts +0 -0
  449. /package/{types → dist/packages}/excalidraw/components/CheckboxItem.d.ts +0 -0
  450. /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorInput.d.ts +0 -0
  451. /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorPicker.d.ts +0 -0
  452. /package/{types → dist/packages}/excalidraw/components/ColorPicker/CustomColorList.d.ts +0 -0
  453. /package/{types → dist/packages}/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +0 -0
  454. /package/{types → dist/packages}/excalidraw/components/ColorPicker/Picker.d.ts +0 -0
  455. /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerColorList.d.ts +0 -0
  456. /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerHeading.d.ts +0 -0
  457. /package/{types → dist/packages}/excalidraw/components/ColorPicker/ShadeList.d.ts +0 -0
  458. /package/{types → dist/packages}/excalidraw/components/ColorPicker/TopPicks.d.ts +0 -0
  459. /package/{types → dist/packages}/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +0 -0
  460. /package/{types → dist/packages}/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -0
  461. /package/{types → dist/packages}/excalidraw/components/ConfirmDialog.d.ts +0 -0
  462. /package/{types → dist/packages}/excalidraw/components/ContextMenu.d.ts +0 -0
  463. /package/{types → dist/packages}/excalidraw/components/DarkModeToggle.d.ts +0 -0
  464. /package/{types → dist/packages}/excalidraw/components/DefaultSidebar.d.ts +0 -0
  465. /package/{types → dist/packages}/excalidraw/components/Dialog.d.ts +0 -0
  466. /package/{types → dist/packages}/excalidraw/components/DialogActionButton.d.ts +0 -0
  467. /package/{types → dist/packages}/excalidraw/components/ErrorDialog.d.ts +0 -0
  468. /package/{types → dist/packages}/excalidraw/components/ExcalidrawLogo.d.ts +0 -0
  469. /package/{types → dist/packages}/excalidraw/components/EyeDropper.d.ts +0 -0
  470. /package/{types → dist/packages}/excalidraw/components/FilledButton.d.ts +0 -0
  471. /package/{types → dist/packages}/excalidraw/components/FixedSideContainer.d.ts +0 -0
  472. /package/{types → dist/packages}/excalidraw/components/FollowMode/FollowMode.d.ts +0 -0
  473. /package/{types → dist/packages}/excalidraw/components/HandButton.d.ts +0 -0
  474. /package/{types → dist/packages}/excalidraw/components/HelpButton.d.ts +0 -0
  475. /package/{types → dist/packages}/excalidraw/components/HelpDialog.d.ts +0 -0
  476. /package/{types → dist/packages}/excalidraw/components/HintViewer.d.ts +0 -0
  477. /package/{types → dist/packages}/excalidraw/components/IconPicker.d.ts +0 -0
  478. /package/{types → dist/packages}/excalidraw/components/ImageExportDialog.d.ts +0 -0
  479. /package/{types → dist/packages}/excalidraw/components/InitializeApp.d.ts +0 -0
  480. /package/{types → dist/packages}/excalidraw/components/InlineIcon.d.ts +0 -0
  481. /package/{types → dist/packages}/excalidraw/components/Island.d.ts +0 -0
  482. /package/{types → dist/packages}/excalidraw/components/JSONExportDialog.d.ts +0 -0
  483. /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -0
  484. /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPointerButton.d.ts +0 -0
  485. /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserTool.d.ts +0 -0
  486. /package/{types → dist/packages}/excalidraw/components/LayerUI.d.ts +0 -0
  487. /package/{types → dist/packages}/excalidraw/components/LibraryMenu.d.ts +0 -0
  488. /package/{types → dist/packages}/excalidraw/components/LibraryMenuBrowseButton.d.ts +0 -0
  489. /package/{types → dist/packages}/excalidraw/components/LibraryMenuControlButtons.d.ts +0 -0
  490. /package/{types → dist/packages}/excalidraw/components/LibraryMenuHeaderContent.d.ts +0 -0
  491. /package/{types → dist/packages}/excalidraw/components/LibraryMenuItems.d.ts +0 -0
  492. /package/{types → dist/packages}/excalidraw/components/LibraryMenuSection.d.ts +0 -0
  493. /package/{types → dist/packages}/excalidraw/components/LibraryUnit.d.ts +0 -0
  494. /package/{types → dist/packages}/excalidraw/components/LoadingMessage.d.ts +0 -0
  495. /package/{types → dist/packages}/excalidraw/components/LockButton.d.ts +0 -0
  496. /package/{types → dist/packages}/excalidraw/components/MagicButton.d.ts +0 -0
  497. /package/{types → dist/packages}/excalidraw/components/MagicSettings.d.ts +0 -0
  498. /package/{types → dist/packages}/excalidraw/components/MobileMenu.d.ts +0 -0
  499. /package/{types → dist/packages}/excalidraw/components/Modal.d.ts +0 -0
  500. /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +0 -0
  501. /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +0 -0
  502. /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +0 -0
  503. /package/{types → dist/packages}/excalidraw/components/Paragraph.d.ts +0 -0
  504. /package/{types → dist/packages}/excalidraw/components/PasteChartDialog.d.ts +0 -0
  505. /package/{types → dist/packages}/excalidraw/components/PenModeButton.d.ts +0 -0
  506. /package/{types → dist/packages}/excalidraw/components/Popover.d.ts +0 -0
  507. /package/{types → dist/packages}/excalidraw/components/ProjectName.d.ts +0 -0
  508. /package/{types → dist/packages}/excalidraw/components/PublishLibrary.d.ts +0 -0
  509. /package/{types → dist/packages}/excalidraw/components/RadioGroup.d.ts +0 -0
  510. /package/{types → dist/packages}/excalidraw/components/Section.d.ts +0 -0
  511. /package/{types → dist/packages}/excalidraw/components/ShareableLinkDialog.d.ts +0 -0
  512. /package/{types → dist/packages}/excalidraw/components/Sidebar/Sidebar.d.ts +0 -0
  513. /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarHeader.d.ts +0 -0
  514. /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTab.d.ts +0 -0
  515. /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +0 -0
  516. /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +0 -0
  517. /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabs.d.ts +0 -0
  518. /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTrigger.d.ts +0 -0
  519. /package/{types → dist/packages}/excalidraw/components/Sidebar/common.d.ts +0 -0
  520. /package/{types → dist/packages}/excalidraw/components/Spinner.d.ts +0 -0
  521. /package/{types → dist/packages}/excalidraw/components/Stack.d.ts +0 -0
  522. /package/{types → dist/packages}/excalidraw/components/Stats.d.ts +0 -0
  523. /package/{types → dist/packages}/excalidraw/components/Switch.d.ts +0 -0
  524. /package/{types → dist/packages}/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +0 -0
  525. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialog.d.ts +0 -0
  526. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +0 -0
  527. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +0 -0
  528. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +0 -0
  529. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +0 -0
  530. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +0 -0
  531. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +0 -0
  532. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +0 -0
  533. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +0 -0
  534. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +0 -0
  535. /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -0
  536. /package/{types → dist/packages}/excalidraw/components/TTDDialog/common.d.ts +0 -0
  537. /package/{types → dist/packages}/excalidraw/components/TextField.d.ts +0 -0
  538. /package/{types → dist/packages}/excalidraw/components/Toast.d.ts +0 -0
  539. /package/{types → dist/packages}/excalidraw/components/ToolButton.d.ts +0 -0
  540. /package/{types → dist/packages}/excalidraw/components/Tooltip.d.ts +0 -0
  541. /package/{types → dist/packages}/excalidraw/components/Trans.d.ts +0 -0
  542. /package/{types → dist/packages}/excalidraw/components/UserList.d.ts +0 -0
  543. /package/{types → dist/packages}/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -0
  544. /package/{types → dist/packages}/excalidraw/components/canvases/StaticCanvas.d.ts +0 -0
  545. /package/{types → dist/packages}/excalidraw/components/canvases/index.d.ts +0 -0
  546. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +0 -0
  547. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +0 -0
  548. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +0 -0
  549. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +0 -0
  550. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +0 -0
  551. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +0 -0
  552. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +0 -0
  553. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +0 -0
  554. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -0
  555. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/common.d.ts +0 -0
  556. /package/{types → dist/packages}/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +0 -0
  557. /package/{types → dist/packages}/excalidraw/components/footer/Footer.d.ts +0 -0
  558. /package/{types → dist/packages}/excalidraw/components/footer/FooterCenter.d.ts +0 -0
  559. /package/{types → dist/packages}/excalidraw/components/hoc/withInternalFallback.d.ts +0 -0
  560. /package/{types → dist/packages}/excalidraw/components/icons.d.ts +0 -0
  561. /package/{types → dist/packages}/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -0
  562. /package/{types → dist/packages}/excalidraw/components/main-menu/DefaultItems.d.ts +0 -0
  563. /package/{types → dist/packages}/excalidraw/components/main-menu/MainMenu.d.ts +0 -0
  564. /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -0
  565. /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -0
  566. /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -0
  567. /package/{types → dist/packages}/excalidraw/constants.d.ts +0 -0
  568. /package/{types → dist/packages}/excalidraw/context/tunnels.d.ts +0 -0
  569. /package/{types → dist/packages}/excalidraw/context/ui-appState.d.ts +0 -0
  570. /package/{types → dist/packages}/excalidraw/cursor.d.ts +0 -0
  571. /package/{types → dist/packages}/excalidraw/data/EditorLocalStorage.d.ts +0 -0
  572. /package/{types → dist/packages}/excalidraw/data/ai/types.d.ts +0 -0
  573. /package/{types → dist/packages}/excalidraw/data/blob.d.ts +0 -0
  574. /package/{types → dist/packages}/excalidraw/data/encode.d.ts +0 -0
  575. /package/{types → dist/packages}/excalidraw/data/encryption.d.ts +0 -0
  576. /package/{types → dist/packages}/excalidraw/data/filesystem.d.ts +0 -0
  577. /package/{types → dist/packages}/excalidraw/data/image.d.ts +0 -0
  578. /package/{types → dist/packages}/excalidraw/data/index.d.ts +0 -0
  579. /package/{types → dist/packages}/excalidraw/data/json.d.ts +0 -0
  580. /package/{types → dist/packages}/excalidraw/data/library.d.ts +0 -0
  581. /package/{types → dist/packages}/excalidraw/data/magic.d.ts +0 -0
  582. /package/{types → dist/packages}/excalidraw/data/resave.d.ts +0 -0
  583. /package/{types → dist/packages}/excalidraw/data/restore.d.ts +0 -0
  584. /package/{types → dist/packages}/excalidraw/data/transform.d.ts +0 -0
  585. /package/{types → dist/packages}/excalidraw/data/types.d.ts +0 -0
  586. /package/{types → dist/packages}/excalidraw/data/url.d.ts +0 -0
  587. /package/{types → dist/packages}/excalidraw/distribute.d.ts +0 -0
  588. /package/{types → dist/packages}/excalidraw/element/ElementCanvasButtons.d.ts +0 -0
  589. /package/{types → dist/packages}/excalidraw/element/Hyperlink.d.ts +0 -0
  590. /package/{types → dist/packages}/excalidraw/element/binding.d.ts +0 -0
  591. /package/{types → dist/packages}/excalidraw/element/bounds.d.ts +0 -0
  592. /package/{types → dist/packages}/excalidraw/element/collision.d.ts +0 -0
  593. /package/{types → dist/packages}/excalidraw/element/dragElements.d.ts +0 -0
  594. /package/{types → dist/packages}/excalidraw/element/embeddable.d.ts +0 -0
  595. /package/{types → dist/packages}/excalidraw/element/image.d.ts +0 -0
  596. /package/{types → dist/packages}/excalidraw/element/index.d.ts +0 -0
  597. /package/{types → dist/packages}/excalidraw/element/linearElementEditor.d.ts +0 -0
  598. /package/{types → dist/packages}/excalidraw/element/mutateElement.d.ts +0 -0
  599. /package/{types → dist/packages}/excalidraw/element/newElement.d.ts +0 -0
  600. /package/{types → dist/packages}/excalidraw/element/resizeElements.d.ts +0 -0
  601. /package/{types → dist/packages}/excalidraw/element/resizeTest.d.ts +0 -0
  602. /package/{types → dist/packages}/excalidraw/element/showSelectedShapeActions.d.ts +0 -0
  603. /package/{types → dist/packages}/excalidraw/element/sizeHelpers.d.ts +0 -0
  604. /package/{types → dist/packages}/excalidraw/element/sortElements.d.ts +0 -0
  605. /package/{types → dist/packages}/excalidraw/element/textElement.d.ts +0 -0
  606. /package/{types → dist/packages}/excalidraw/element/textWysiwyg.d.ts +0 -0
  607. /package/{types → dist/packages}/excalidraw/element/transformHandles.d.ts +0 -0
  608. /package/{types → dist/packages}/excalidraw/element/typeChecks.d.ts +0 -0
  609. /package/{types → dist/packages}/excalidraw/element/types.d.ts +0 -0
  610. /package/{types → dist/packages}/excalidraw/emitter.d.ts +0 -0
  611. /package/{types → dist/packages}/excalidraw/errors.d.ts +0 -0
  612. /package/{types → dist/packages}/excalidraw/frame.d.ts +0 -0
  613. /package/{types → dist/packages}/excalidraw/ga.d.ts +0 -0
  614. /package/{types → dist/packages}/excalidraw/gadirections.d.ts +0 -0
  615. /package/{types → dist/packages}/excalidraw/galines.d.ts +0 -0
  616. /package/{types → dist/packages}/excalidraw/gapoints.d.ts +0 -0
  617. /package/{types → dist/packages}/excalidraw/gatransforms.d.ts +0 -0
  618. /package/{types → dist/packages}/excalidraw/gesture.d.ts +0 -0
  619. /package/{types → dist/packages}/excalidraw/groups.d.ts +0 -0
  620. /package/{types → dist/packages}/excalidraw/history.d.ts +0 -0
  621. /package/{types → dist/packages}/excalidraw/hooks/useCallbackRefState.d.ts +0 -0
  622. /package/{types → dist/packages}/excalidraw/hooks/useCreatePortalContainer.d.ts +0 -0
  623. /package/{types → dist/packages}/excalidraw/hooks/useLibraryItemSvg.d.ts +0 -0
  624. /package/{types → dist/packages}/excalidraw/hooks/useOutsideClick.d.ts +0 -0
  625. /package/{types → dist/packages}/excalidraw/hooks/useScrollPosition.d.ts +0 -0
  626. /package/{types → dist/packages}/excalidraw/hooks/useStable.d.ts +0 -0
  627. /package/{types → dist/packages}/excalidraw/hooks/useTransition.d.ts +0 -0
  628. /package/{types → dist/packages}/excalidraw/i18n.d.ts +0 -0
  629. /package/{types → dist/packages}/excalidraw/jotai.d.ts +0 -0
  630. /package/{types → dist/packages}/excalidraw/keys.d.ts +0 -0
  631. /package/{types → dist/packages}/excalidraw/math.d.ts +0 -0
  632. /package/{types → dist/packages}/excalidraw/points.d.ts +0 -0
  633. /package/{types → dist/packages}/excalidraw/polyfill.d.ts +0 -0
  634. /package/{types → dist/packages}/excalidraw/random.d.ts +0 -0
  635. /package/{types → dist/packages}/excalidraw/renderer/renderElement.d.ts +0 -0
  636. /package/{types → dist/packages}/excalidraw/renderer/renderScene.d.ts +0 -0
  637. /package/{types → dist/packages}/excalidraw/renderer/renderSnaps.d.ts +0 -0
  638. /package/{types → dist/packages}/excalidraw/renderer/roundRect.d.ts +0 -0
  639. /package/{types → dist/packages}/excalidraw/scene/Fonts.d.ts +0 -0
  640. /package/{types → dist/packages}/excalidraw/scene/Renderer.d.ts +0 -0
  641. /package/{types → dist/packages}/excalidraw/scene/Scene.d.ts +0 -0
  642. /package/{types → dist/packages}/excalidraw/scene/Shape.d.ts +0 -0
  643. /package/{types → dist/packages}/excalidraw/scene/ShapeCache.d.ts +0 -0
  644. /package/{types → dist/packages}/excalidraw/scene/comparisons.d.ts +0 -0
  645. /package/{types → dist/packages}/excalidraw/scene/export.d.ts +0 -0
  646. /package/{types → dist/packages}/excalidraw/scene/index.d.ts +0 -0
  647. /package/{types → dist/packages}/excalidraw/scene/scroll.d.ts +0 -0
  648. /package/{types → dist/packages}/excalidraw/scene/scrollbars.d.ts +0 -0
  649. /package/{types → dist/packages}/excalidraw/scene/selection.d.ts +0 -0
  650. /package/{types → dist/packages}/excalidraw/scene/types.d.ts +0 -0
  651. /package/{types → dist/packages}/excalidraw/scene/zoom.d.ts +0 -0
  652. /package/{types → dist/packages}/excalidraw/shapes.d.ts +0 -0
  653. /package/{types → dist/packages}/excalidraw/snapping.d.ts +0 -0
  654. /package/{types → dist/packages}/excalidraw/types.d.ts +0 -0
  655. /package/{types → dist/packages}/excalidraw/utility-types.d.ts +0 -0
  656. /package/{types → dist/packages}/excalidraw/utils.d.ts +0 -0
  657. /package/{types → dist/packages}/excalidraw/zindex.d.ts +0 -0
  658. /package/{types → dist/packages}/utils/bbox.d.ts +0 -0
  659. /package/{types → dist/packages}/utils/export.d.ts +0 -0
  660. /package/{types → dist/packages}/utils/withinBounds.d.ts +0 -0
@@ -0,0 +1,716 @@
1
+ import { getFontString, arrayToMap, isTestEnv } from "../utils";
2
+ import { mutateElement } from "./mutateElement";
3
+ import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, FONT_FAMILY, isSafari, TEXT_ALIGN, VERTICAL_ALIGN, } from "../constants";
4
+ import Scene from "../scene/Scene";
5
+ import { isTextElement } from ".";
6
+ import { isBoundToContainer, isArrowElement } from "./typeChecks";
7
+ import { LinearElementEditor } from "./linearElementEditor";
8
+ import { isTextBindableContainer } from "./typeChecks";
9
+ import { getElementAbsoluteCoords } from ".";
10
+ import { getSelectedElements } from "../scene";
11
+ import { isHittingElementNotConsideringBoundingBox } from "./collision";
12
+ import { resetOriginalContainerCache, updateOriginalContainerCache, } from "./textWysiwyg";
13
+ export const normalizeText = (text) => {
14
+ return (text
15
+ // replace tabs with spaces so they render and measure correctly
16
+ .replace(/\t/g, " ")
17
+ // normalize newlines
18
+ .replace(/\r?\n|\r/g, "\n"));
19
+ };
20
+ export const splitIntoLines = (text) => {
21
+ return normalizeText(text).split("\n");
22
+ };
23
+ export const redrawTextBoundingBox = (textElement, container) => {
24
+ let maxWidth = undefined;
25
+ const boundTextUpdates = {
26
+ x: textElement.x,
27
+ y: textElement.y,
28
+ text: textElement.text,
29
+ width: textElement.width,
30
+ height: textElement.height,
31
+ baseline: textElement.baseline,
32
+ };
33
+ boundTextUpdates.text = textElement.text;
34
+ if (container) {
35
+ maxWidth = getBoundTextMaxWidth(container, textElement);
36
+ boundTextUpdates.text = wrapText(textElement.originalText, getFontString(textElement), maxWidth);
37
+ }
38
+ const metrics = measureText(boundTextUpdates.text, getFontString(textElement), textElement.lineHeight);
39
+ boundTextUpdates.width = metrics.width;
40
+ boundTextUpdates.height = metrics.height;
41
+ boundTextUpdates.baseline = metrics.baseline;
42
+ if (container) {
43
+ const maxContainerHeight = getBoundTextMaxHeight(container, textElement);
44
+ const maxContainerWidth = getBoundTextMaxWidth(container);
45
+ if (!isArrowElement(container) && metrics.height > maxContainerHeight) {
46
+ const nextHeight = computeContainerDimensionForBoundText(metrics.height, container.type);
47
+ mutateElement(container, { height: nextHeight });
48
+ updateOriginalContainerCache(container.id, nextHeight);
49
+ }
50
+ if (metrics.width > maxContainerWidth) {
51
+ const nextWidth = computeContainerDimensionForBoundText(metrics.width, container.type);
52
+ mutateElement(container, { width: nextWidth });
53
+ }
54
+ const updatedTextElement = {
55
+ ...textElement,
56
+ ...boundTextUpdates,
57
+ };
58
+ const { x, y } = computeBoundTextPosition(container, updatedTextElement);
59
+ boundTextUpdates.x = x;
60
+ boundTextUpdates.y = y;
61
+ }
62
+ mutateElement(textElement, boundTextUpdates);
63
+ };
64
+ export const bindTextToShapeAfterDuplication = (sceneElements, oldElements, oldIdToDuplicatedId) => {
65
+ const sceneElementMap = arrayToMap(sceneElements);
66
+ oldElements.forEach((element) => {
67
+ const newElementId = oldIdToDuplicatedId.get(element.id);
68
+ const boundTextElementId = getBoundTextElementId(element);
69
+ if (boundTextElementId) {
70
+ const newTextElementId = oldIdToDuplicatedId.get(boundTextElementId);
71
+ if (newTextElementId) {
72
+ const newContainer = sceneElementMap.get(newElementId);
73
+ if (newContainer) {
74
+ mutateElement(newContainer, {
75
+ boundElements: (element.boundElements || [])
76
+ .filter((boundElement) => boundElement.id !== newTextElementId &&
77
+ boundElement.id !== boundTextElementId)
78
+ .concat({
79
+ type: "text",
80
+ id: newTextElementId,
81
+ }),
82
+ });
83
+ }
84
+ const newTextElement = sceneElementMap.get(newTextElementId);
85
+ if (newTextElement && isTextElement(newTextElement)) {
86
+ mutateElement(newTextElement, {
87
+ containerId: newContainer ? newElementId : null,
88
+ });
89
+ }
90
+ }
91
+ }
92
+ });
93
+ };
94
+ export const handleBindTextResize = (container, transformHandleType, shouldMaintainAspectRatio = false) => {
95
+ const boundTextElementId = getBoundTextElementId(container);
96
+ if (!boundTextElementId) {
97
+ return;
98
+ }
99
+ resetOriginalContainerCache(container.id);
100
+ let textElement = Scene.getScene(container).getElement(boundTextElementId);
101
+ if (textElement && textElement.text) {
102
+ if (!container) {
103
+ return;
104
+ }
105
+ textElement = Scene.getScene(container).getElement(boundTextElementId);
106
+ let text = textElement.text;
107
+ let nextHeight = textElement.height;
108
+ let nextWidth = textElement.width;
109
+ const maxWidth = getBoundTextMaxWidth(container);
110
+ const maxHeight = getBoundTextMaxHeight(container, textElement);
111
+ let containerHeight = container.height;
112
+ let nextBaseLine = textElement.baseline;
113
+ if (shouldMaintainAspectRatio ||
114
+ (transformHandleType !== "n" && transformHandleType !== "s")) {
115
+ if (text) {
116
+ text = wrapText(textElement.originalText, getFontString(textElement), maxWidth);
117
+ }
118
+ const metrics = measureText(text, getFontString(textElement), textElement.lineHeight);
119
+ nextHeight = metrics.height;
120
+ nextWidth = metrics.width;
121
+ nextBaseLine = metrics.baseline;
122
+ }
123
+ // increase height in case text element height exceeds
124
+ if (nextHeight > maxHeight) {
125
+ containerHeight = computeContainerDimensionForBoundText(nextHeight, container.type);
126
+ const diff = containerHeight - container.height;
127
+ // fix the y coord when resizing from ne/nw/n
128
+ const updatedY = !isArrowElement(container) &&
129
+ (transformHandleType === "ne" ||
130
+ transformHandleType === "nw" ||
131
+ transformHandleType === "n")
132
+ ? container.y - diff
133
+ : container.y;
134
+ mutateElement(container, {
135
+ height: containerHeight,
136
+ y: updatedY,
137
+ });
138
+ }
139
+ mutateElement(textElement, {
140
+ text,
141
+ width: nextWidth,
142
+ height: nextHeight,
143
+ baseline: nextBaseLine,
144
+ });
145
+ if (!isArrowElement(container)) {
146
+ mutateElement(textElement, computeBoundTextPosition(container, textElement));
147
+ }
148
+ }
149
+ };
150
+ export const computeBoundTextPosition = (container, boundTextElement) => {
151
+ if (isArrowElement(container)) {
152
+ return LinearElementEditor.getBoundTextElementPosition(container, boundTextElement);
153
+ }
154
+ const containerCoords = getContainerCoords(container);
155
+ const maxContainerHeight = getBoundTextMaxHeight(container, boundTextElement);
156
+ const maxContainerWidth = getBoundTextMaxWidth(container);
157
+ let x;
158
+ let y;
159
+ if (boundTextElement.verticalAlign === VERTICAL_ALIGN.TOP) {
160
+ y = containerCoords.y;
161
+ }
162
+ else if (boundTextElement.verticalAlign === VERTICAL_ALIGN.BOTTOM) {
163
+ y = containerCoords.y + (maxContainerHeight - boundTextElement.height);
164
+ }
165
+ else {
166
+ y =
167
+ containerCoords.y +
168
+ (maxContainerHeight / 2 - boundTextElement.height / 2);
169
+ }
170
+ if (boundTextElement.textAlign === TEXT_ALIGN.LEFT) {
171
+ x = containerCoords.x;
172
+ }
173
+ else if (boundTextElement.textAlign === TEXT_ALIGN.RIGHT) {
174
+ x = containerCoords.x + (maxContainerWidth - boundTextElement.width);
175
+ }
176
+ else {
177
+ x =
178
+ containerCoords.x + (maxContainerWidth / 2 - boundTextElement.width / 2);
179
+ }
180
+ return { x, y };
181
+ };
182
+ // https://github.com/grassator/canvas-text-editor/blob/master/lib/FontMetrics.js
183
+ export const measureText = (text, font, lineHeight) => {
184
+ text = text
185
+ .split("\n")
186
+ // replace empty lines with single space because leading/trailing empty
187
+ // lines would be stripped from computation
188
+ .map((x) => x || " ")
189
+ .join("\n");
190
+ const fontSize = parseFloat(font);
191
+ const height = getTextHeight(text, fontSize, lineHeight);
192
+ const width = getTextWidth(text, font);
193
+ const baseline = measureBaseline(text, font, lineHeight);
194
+ return { width, height, baseline };
195
+ };
196
+ export const measureBaseline = (text, font, lineHeight, wrapInContainer) => {
197
+ const container = document.createElement("div");
198
+ container.style.position = "absolute";
199
+ container.style.whiteSpace = "pre";
200
+ container.style.font = font;
201
+ container.style.minHeight = "1em";
202
+ if (wrapInContainer) {
203
+ container.style.overflow = "hidden";
204
+ container.style.wordBreak = "break-word";
205
+ container.style.whiteSpace = "pre-wrap";
206
+ }
207
+ container.style.lineHeight = String(lineHeight);
208
+ container.innerText = text;
209
+ // Baseline is important for positioning text on canvas
210
+ document.body.appendChild(container);
211
+ const span = document.createElement("span");
212
+ span.style.display = "inline-block";
213
+ span.style.overflow = "hidden";
214
+ span.style.width = "1px";
215
+ span.style.height = "1px";
216
+ container.appendChild(span);
217
+ let baseline = span.offsetTop + span.offsetHeight;
218
+ const height = container.offsetHeight;
219
+ if (isSafari) {
220
+ const canvasHeight = getTextHeight(text, parseFloat(font), lineHeight);
221
+ const fontSize = parseFloat(font);
222
+ // In Safari the font size gets rounded off when rendering hence calculating the safari height and shifting the baseline if it differs
223
+ // from the actual canvas height
224
+ const domHeight = getTextHeight(text, Math.round(fontSize), lineHeight);
225
+ if (canvasHeight > height) {
226
+ baseline += canvasHeight - domHeight;
227
+ }
228
+ if (height > canvasHeight) {
229
+ baseline -= domHeight - canvasHeight;
230
+ }
231
+ }
232
+ document.body.removeChild(container);
233
+ return baseline;
234
+ };
235
+ /**
236
+ * To get unitless line-height (if unknown) we can calculate it by dividing
237
+ * height-per-line by fontSize.
238
+ */
239
+ export const detectLineHeight = (textElement) => {
240
+ const lineCount = splitIntoLines(textElement.text).length;
241
+ return (textElement.height /
242
+ lineCount /
243
+ textElement.fontSize);
244
+ };
245
+ /**
246
+ * We calculate the line height from the font size and the unitless line height,
247
+ * aligning with the W3C spec.
248
+ */
249
+ export const getLineHeightInPx = (fontSize, lineHeight) => {
250
+ return fontSize * lineHeight;
251
+ };
252
+ // FIXME rename to getApproxMinContainerHeight
253
+ export const getApproxMinLineHeight = (fontSize, lineHeight) => {
254
+ return getLineHeightInPx(fontSize, lineHeight) + BOUND_TEXT_PADDING * 2;
255
+ };
256
+ let canvas;
257
+ const getLineWidth = (text, font) => {
258
+ if (!canvas) {
259
+ canvas = document.createElement("canvas");
260
+ }
261
+ const canvas2dContext = canvas.getContext("2d");
262
+ canvas2dContext.font = font;
263
+ const width = canvas2dContext.measureText(text).width;
264
+ // since in test env the canvas measureText algo
265
+ // doesn't measure text and instead just returns number of
266
+ // characters hence we assume that each letteris 10px
267
+ if (isTestEnv()) {
268
+ return width * 10;
269
+ }
270
+ return width;
271
+ };
272
+ export const getTextWidth = (text, font) => {
273
+ const lines = splitIntoLines(text);
274
+ let width = 0;
275
+ lines.forEach((line) => {
276
+ width = Math.max(width, getLineWidth(line, font));
277
+ });
278
+ return width;
279
+ };
280
+ export const getTextHeight = (text, fontSize, lineHeight) => {
281
+ const lineCount = splitIntoLines(text).length;
282
+ return getLineHeightInPx(fontSize, lineHeight) * lineCount;
283
+ };
284
+ export const parseTokens = (text) => {
285
+ // Splitting words containing "-" as those are treated as separate words
286
+ // by css wrapping algorithm eg non-profit => non-, profit
287
+ const words = text.split("-");
288
+ if (words.length > 1) {
289
+ // non-proft org => ['non-', 'profit org']
290
+ words.forEach((word, index) => {
291
+ if (index !== words.length - 1) {
292
+ words[index] = word += "-";
293
+ }
294
+ });
295
+ }
296
+ // Joining the words with space and splitting them again with space to get the
297
+ // final list of tokens
298
+ // ['non-', 'profit org'] =>,'non- proft org' => ['non-','profit','org']
299
+ return words.join(" ").split(" ");
300
+ };
301
+ export const wrapText = (text, font, maxWidth) => {
302
+ // if maxWidth is not finite or NaN which can happen in case of bugs in
303
+ // computation, we need to make sure we don't continue as we'll end up
304
+ // in an infinite loop
305
+ if (!Number.isFinite(maxWidth) || maxWidth < 0) {
306
+ return text;
307
+ }
308
+ const lines = [];
309
+ const originalLines = text.split("\n");
310
+ const spaceWidth = getLineWidth(" ", font);
311
+ let currentLine = "";
312
+ let currentLineWidthTillNow = 0;
313
+ const push = (str) => {
314
+ if (str.trim()) {
315
+ lines.push(str);
316
+ }
317
+ };
318
+ const resetParams = () => {
319
+ currentLine = "";
320
+ currentLineWidthTillNow = 0;
321
+ };
322
+ originalLines.forEach((originalLine) => {
323
+ const currentLineWidth = getTextWidth(originalLine, font);
324
+ // Push the line if its <= maxWidth
325
+ if (currentLineWidth <= maxWidth) {
326
+ lines.push(originalLine);
327
+ return; // continue
328
+ }
329
+ const words = parseTokens(originalLine);
330
+ resetParams();
331
+ let index = 0;
332
+ while (index < words.length) {
333
+ const currentWordWidth = getLineWidth(words[index], font);
334
+ // This will only happen when single word takes entire width
335
+ if (currentWordWidth === maxWidth) {
336
+ push(words[index]);
337
+ index++;
338
+ }
339
+ // Start breaking longer words exceeding max width
340
+ else if (currentWordWidth > maxWidth) {
341
+ // push current line since the current word exceeds the max width
342
+ // so will be appended in next line
343
+ push(currentLine);
344
+ resetParams();
345
+ while (words[index].length > 0) {
346
+ const currentChar = String.fromCodePoint(words[index].codePointAt(0));
347
+ const width = charWidth.calculate(currentChar, font);
348
+ currentLineWidthTillNow += width;
349
+ words[index] = words[index].slice(currentChar.length);
350
+ if (currentLineWidthTillNow >= maxWidth) {
351
+ push(currentLine);
352
+ currentLine = currentChar;
353
+ currentLineWidthTillNow = width;
354
+ }
355
+ else {
356
+ currentLine += currentChar;
357
+ }
358
+ }
359
+ // push current line if appending space exceeds max width
360
+ if (currentLineWidthTillNow + spaceWidth >= maxWidth) {
361
+ push(currentLine);
362
+ resetParams();
363
+ // space needs to be appended before next word
364
+ // as currentLine contains chars which couldn't be appended
365
+ // to previous line unless the line ends with hyphen to sync
366
+ // with css word-wrap
367
+ }
368
+ else if (!currentLine.endsWith("-")) {
369
+ currentLine += " ";
370
+ currentLineWidthTillNow += spaceWidth;
371
+ }
372
+ index++;
373
+ }
374
+ else {
375
+ // Start appending words in a line till max width reached
376
+ while (currentLineWidthTillNow < maxWidth && index < words.length) {
377
+ const word = words[index];
378
+ currentLineWidthTillNow = getLineWidth(currentLine + word, font);
379
+ if (currentLineWidthTillNow > maxWidth) {
380
+ push(currentLine);
381
+ resetParams();
382
+ break;
383
+ }
384
+ index++;
385
+ // if word ends with "-" then we don't need to add space
386
+ // to sync with css word-wrap
387
+ const shouldAppendSpace = !word.endsWith("-");
388
+ currentLine += word;
389
+ if (shouldAppendSpace) {
390
+ currentLine += " ";
391
+ }
392
+ // Push the word if appending space exceeds max width
393
+ if (currentLineWidthTillNow + spaceWidth >= maxWidth) {
394
+ if (shouldAppendSpace) {
395
+ lines.push(currentLine.slice(0, -1));
396
+ }
397
+ else {
398
+ lines.push(currentLine);
399
+ }
400
+ resetParams();
401
+ break;
402
+ }
403
+ }
404
+ }
405
+ }
406
+ if (currentLine.slice(-1) === " ") {
407
+ // only remove last trailing space which we have added when joining words
408
+ currentLine = currentLine.slice(0, -1);
409
+ push(currentLine);
410
+ }
411
+ });
412
+ return lines.join("\n");
413
+ };
414
+ export const charWidth = (() => {
415
+ const cachedCharWidth = {};
416
+ const calculate = (char, font) => {
417
+ const ascii = char.charCodeAt(0);
418
+ if (!cachedCharWidth[font]) {
419
+ cachedCharWidth[font] = [];
420
+ }
421
+ if (!cachedCharWidth[font][ascii]) {
422
+ const width = getLineWidth(char, font);
423
+ cachedCharWidth[font][ascii] = width;
424
+ }
425
+ return cachedCharWidth[font][ascii];
426
+ };
427
+ const getCache = (font) => {
428
+ return cachedCharWidth[font];
429
+ };
430
+ return {
431
+ calculate,
432
+ getCache,
433
+ };
434
+ })();
435
+ const DUMMY_TEXT = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();
436
+ // FIXME rename to getApproxMinContainerWidth
437
+ export const getApproxMinLineWidth = (font, lineHeight) => {
438
+ const maxCharWidth = getMaxCharWidth(font);
439
+ if (maxCharWidth === 0) {
440
+ return (measureText(DUMMY_TEXT.split("").join("\n"), font, lineHeight).width +
441
+ BOUND_TEXT_PADDING * 2);
442
+ }
443
+ return maxCharWidth + BOUND_TEXT_PADDING * 2;
444
+ };
445
+ export const getMinCharWidth = (font) => {
446
+ const cache = charWidth.getCache(font);
447
+ if (!cache) {
448
+ return 0;
449
+ }
450
+ const cacheWithOutEmpty = cache.filter((val) => val !== undefined);
451
+ return Math.min(...cacheWithOutEmpty);
452
+ };
453
+ export const getMaxCharWidth = (font) => {
454
+ const cache = charWidth.getCache(font);
455
+ if (!cache) {
456
+ return 0;
457
+ }
458
+ const cacheWithOutEmpty = cache.filter((val) => val !== undefined);
459
+ return Math.max(...cacheWithOutEmpty);
460
+ };
461
+ export const getApproxCharsToFitInWidth = (font, width) => {
462
+ // Generally lower case is used so converting to lower case
463
+ const dummyText = DUMMY_TEXT.toLocaleLowerCase();
464
+ const batchLength = 6;
465
+ let index = 0;
466
+ let widthTillNow = 0;
467
+ let str = "";
468
+ while (widthTillNow <= width) {
469
+ const batch = dummyText.substr(index, index + batchLength);
470
+ str += batch;
471
+ widthTillNow += getLineWidth(str, font);
472
+ if (index === dummyText.length - 1) {
473
+ index = 0;
474
+ }
475
+ index = index + batchLength;
476
+ }
477
+ while (widthTillNow > width) {
478
+ str = str.substr(0, str.length - 1);
479
+ widthTillNow = getLineWidth(str, font);
480
+ }
481
+ return str.length;
482
+ };
483
+ export const getBoundTextElementId = (container) => {
484
+ return container?.boundElements?.length
485
+ ? container?.boundElements?.filter((ele) => ele.type === "text")[0]?.id ||
486
+ null
487
+ : null;
488
+ };
489
+ export const getBoundTextElement = (element) => {
490
+ if (!element) {
491
+ return null;
492
+ }
493
+ const boundTextElementId = getBoundTextElementId(element);
494
+ if (boundTextElementId) {
495
+ return (Scene.getScene(element)?.getElement(boundTextElementId) || null);
496
+ }
497
+ return null;
498
+ };
499
+ export const getContainerElement = (element) => {
500
+ if (!element) {
501
+ return null;
502
+ }
503
+ if (element.containerId) {
504
+ return Scene.getScene(element)?.getElement(element.containerId) || null;
505
+ }
506
+ return null;
507
+ };
508
+ export const getContainerCenter = (container, appState) => {
509
+ if (!isArrowElement(container)) {
510
+ return {
511
+ x: container.x + container.width / 2,
512
+ y: container.y + container.height / 2,
513
+ };
514
+ }
515
+ const points = LinearElementEditor.getPointsGlobalCoordinates(container);
516
+ if (points.length % 2 === 1) {
517
+ const index = Math.floor(container.points.length / 2);
518
+ const midPoint = LinearElementEditor.getPointGlobalCoordinates(container, container.points[index]);
519
+ return { x: midPoint[0], y: midPoint[1] };
520
+ }
521
+ const index = container.points.length / 2 - 1;
522
+ let midSegmentMidpoint = LinearElementEditor.getEditorMidPoints(container, appState)[index];
523
+ if (!midSegmentMidpoint) {
524
+ midSegmentMidpoint = LinearElementEditor.getSegmentMidPoint(container, points[index], points[index + 1], index + 1);
525
+ }
526
+ return { x: midSegmentMidpoint[0], y: midSegmentMidpoint[1] };
527
+ };
528
+ export const getContainerCoords = (container) => {
529
+ let offsetX = BOUND_TEXT_PADDING;
530
+ let offsetY = BOUND_TEXT_PADDING;
531
+ if (container.type === "ellipse") {
532
+ // The derivation of coordinates is explained in https://github.com/excalidraw/excalidraw/pull/6172
533
+ offsetX += (container.width / 2) * (1 - Math.sqrt(2) / 2);
534
+ offsetY += (container.height / 2) * (1 - Math.sqrt(2) / 2);
535
+ }
536
+ // The derivation of coordinates is explained in https://github.com/excalidraw/excalidraw/pull/6265
537
+ if (container.type === "diamond") {
538
+ offsetX += container.width / 4;
539
+ offsetY += container.height / 4;
540
+ }
541
+ return {
542
+ x: container.x + offsetX,
543
+ y: container.y + offsetY,
544
+ };
545
+ };
546
+ export const getTextElementAngle = (textElement) => {
547
+ const container = getContainerElement(textElement);
548
+ if (!container || isArrowElement(container)) {
549
+ return textElement.angle;
550
+ }
551
+ return container.angle;
552
+ };
553
+ export const getBoundTextElementOffset = (boundTextElement) => {
554
+ const container = getContainerElement(boundTextElement);
555
+ if (!container || !boundTextElement) {
556
+ return 0;
557
+ }
558
+ if (isArrowElement(container)) {
559
+ return BOUND_TEXT_PADDING * 8;
560
+ }
561
+ return BOUND_TEXT_PADDING;
562
+ };
563
+ export const getBoundTextElementPosition = (container, boundTextElement) => {
564
+ if (isArrowElement(container)) {
565
+ return LinearElementEditor.getBoundTextElementPosition(container, boundTextElement);
566
+ }
567
+ };
568
+ export const shouldAllowVerticalAlign = (selectedElements) => {
569
+ return selectedElements.some((element) => {
570
+ const hasBoundContainer = isBoundToContainer(element);
571
+ if (hasBoundContainer) {
572
+ const container = getContainerElement(element);
573
+ if (isTextElement(element) && isArrowElement(container)) {
574
+ return false;
575
+ }
576
+ return true;
577
+ }
578
+ return false;
579
+ });
580
+ };
581
+ export const suppportsHorizontalAlign = (selectedElements) => {
582
+ return selectedElements.some((element) => {
583
+ const hasBoundContainer = isBoundToContainer(element);
584
+ if (hasBoundContainer) {
585
+ const container = getContainerElement(element);
586
+ if (isTextElement(element) && isArrowElement(container)) {
587
+ return false;
588
+ }
589
+ return true;
590
+ }
591
+ return isTextElement(element);
592
+ });
593
+ };
594
+ export const getTextBindableContainerAtPosition = (elements, appState, x, y) => {
595
+ const selectedElements = getSelectedElements(elements, appState);
596
+ if (selectedElements.length === 1) {
597
+ return isTextBindableContainer(selectedElements[0], false)
598
+ ? selectedElements[0]
599
+ : null;
600
+ }
601
+ let hitElement = null;
602
+ // We need to to hit testing from front (end of the array) to back (beginning of the array)
603
+ for (let index = elements.length - 1; index >= 0; --index) {
604
+ if (elements[index].isDeleted) {
605
+ continue;
606
+ }
607
+ const [x1, y1, x2, y2] = getElementAbsoluteCoords(elements[index]);
608
+ if (isArrowElement(elements[index]) &&
609
+ isHittingElementNotConsideringBoundingBox(elements[index], appState, null, [x, y])) {
610
+ hitElement = elements[index];
611
+ break;
612
+ }
613
+ else if (x1 < x && x < x2 && y1 < y && y < y2) {
614
+ hitElement = elements[index];
615
+ break;
616
+ }
617
+ }
618
+ return isTextBindableContainer(hitElement, false) ? hitElement : null;
619
+ };
620
+ const VALID_CONTAINER_TYPES = new Set([
621
+ "rectangle",
622
+ "ellipse",
623
+ "diamond",
624
+ "arrow",
625
+ ]);
626
+ export const isValidTextContainer = (element) => VALID_CONTAINER_TYPES.has(element.type);
627
+ export const computeContainerDimensionForBoundText = (dimension, containerType) => {
628
+ dimension = Math.ceil(dimension);
629
+ const padding = BOUND_TEXT_PADDING * 2;
630
+ if (containerType === "ellipse") {
631
+ return Math.round(((dimension + padding) / Math.sqrt(2)) * 2);
632
+ }
633
+ if (containerType === "arrow") {
634
+ return dimension + padding * 8;
635
+ }
636
+ if (containerType === "diamond") {
637
+ return 2 * (dimension + padding);
638
+ }
639
+ return dimension + padding;
640
+ };
641
+ export const getBoundTextMaxWidth = (container, boundTextElement = getBoundTextElement(container)) => {
642
+ const { width } = container;
643
+ if (isArrowElement(container)) {
644
+ const minWidth = (boundTextElement?.fontSize ?? DEFAULT_FONT_SIZE) *
645
+ ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO;
646
+ return Math.max(ARROW_LABEL_WIDTH_FRACTION * width, minWidth);
647
+ }
648
+ if (container.type === "ellipse") {
649
+ // The width of the largest rectangle inscribed inside an ellipse is
650
+ // Math.round((ellipse.width / 2) * Math.sqrt(2)) which is derived from
651
+ // equation of an ellipse -https://github.com/excalidraw/excalidraw/pull/6172
652
+ return Math.round((width / 2) * Math.sqrt(2)) - BOUND_TEXT_PADDING * 2;
653
+ }
654
+ if (container.type === "diamond") {
655
+ // The width of the largest rectangle inscribed inside a rhombus is
656
+ // Math.round(width / 2) - https://github.com/excalidraw/excalidraw/pull/6265
657
+ return Math.round(width / 2) - BOUND_TEXT_PADDING * 2;
658
+ }
659
+ return width - BOUND_TEXT_PADDING * 2;
660
+ };
661
+ export const getBoundTextMaxHeight = (container, boundTextElement) => {
662
+ const { height } = container;
663
+ if (isArrowElement(container)) {
664
+ const containerHeight = height - BOUND_TEXT_PADDING * 8 * 2;
665
+ if (containerHeight <= 0) {
666
+ return boundTextElement.height;
667
+ }
668
+ return height;
669
+ }
670
+ if (container.type === "ellipse") {
671
+ // The height of the largest rectangle inscribed inside an ellipse is
672
+ // Math.round((ellipse.height / 2) * Math.sqrt(2)) which is derived from
673
+ // equation of an ellipse - https://github.com/excalidraw/excalidraw/pull/6172
674
+ return Math.round((height / 2) * Math.sqrt(2)) - BOUND_TEXT_PADDING * 2;
675
+ }
676
+ if (container.type === "diamond") {
677
+ // The height of the largest rectangle inscribed inside a rhombus is
678
+ // Math.round(height / 2) - https://github.com/excalidraw/excalidraw/pull/6265
679
+ return Math.round(height / 2) - BOUND_TEXT_PADDING * 2;
680
+ }
681
+ return height - BOUND_TEXT_PADDING * 2;
682
+ };
683
+ export const isMeasureTextSupported = () => {
684
+ const width = getTextWidth(DUMMY_TEXT, getFontString({
685
+ fontSize: DEFAULT_FONT_SIZE,
686
+ fontFamily: DEFAULT_FONT_FAMILY,
687
+ }));
688
+ return width > 0;
689
+ };
690
+ /**
691
+ * Unitless line height
692
+ *
693
+ * In previous versions we used `normal` line height, which browsers interpret
694
+ * differently, and based on font-family and font-size.
695
+ *
696
+ * To make line heights consistent across browsers we hardcode the values for
697
+ * each of our fonts based on most common average line-heights.
698
+ * See https://github.com/excalidraw/excalidraw/pull/6360#issuecomment-1477635971
699
+ * where the values come from.
700
+ */
701
+ const DEFAULT_LINE_HEIGHT = {
702
+ // ~1.25 is the average for Virgil in WebKit and Blink.
703
+ // Gecko (FF) uses ~1.28.
704
+ [FONT_FAMILY.Virgil]: 1.25,
705
+ // ~1.15 is the average for Virgil in WebKit and Blink.
706
+ // Gecko if all over the place.
707
+ [FONT_FAMILY.Helvetica]: 1.15,
708
+ // ~1.2 is the average for Virgil in WebKit and Blink, and kinda Gecko too
709
+ [FONT_FAMILY.Cascadia]: 1.2,
710
+ };
711
+ export const getDefaultLineHeight = (fontFamily) => {
712
+ if (fontFamily in DEFAULT_LINE_HEIGHT) {
713
+ return DEFAULT_LINE_HEIGHT[fontFamily];
714
+ }
715
+ return DEFAULT_LINE_HEIGHT[DEFAULT_FONT_FAMILY];
716
+ };