@excalidraw/excalidraw 0.17.1-d2f67e6 → 0.17.1-e63dd02

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 (252) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/browser/dev/excalidraw-assets-dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  3. package/dist/browser/dev/excalidraw-assets-dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  4. package/dist/browser/dev/excalidraw-assets-dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  5. package/dist/browser/dev/excalidraw-assets-dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  6. package/dist/browser/dev/excalidraw-assets-dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  7. package/dist/browser/dev/excalidraw-assets-dev/{chunk-EM6LVGFW.js → chunk-IT7T3AIK.js} +23 -5
  8. package/dist/browser/dev/excalidraw-assets-dev/chunk-IT7T3AIK.js.map +7 -0
  9. package/dist/browser/dev/excalidraw-assets-dev/{chunk-B4UMSLQQ.js → chunk-RNHSD5AR.js} +7451 -2098
  10. package/dist/browser/dev/excalidraw-assets-dev/chunk-RNHSD5AR.js.map +7 -0
  11. package/dist/browser/dev/excalidraw-assets-dev/{dist-6QVAH5JA.js → dist-DNSPZDOZ.js} +31 -19
  12. package/dist/browser/dev/excalidraw-assets-dev/dist-DNSPZDOZ.js.map +7 -0
  13. package/dist/browser/dev/excalidraw-assets-dev/{en-AZFA5HJJ.js → en-XV7OZCPP.js} +6 -2
  14. package/dist/browser/dev/excalidraw-assets-dev/{image-V7E6IT6R.js → image-77HZYGLG.js} +2 -2
  15. package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css → image-WDHYGKKP.css} +1 -1
  16. package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css.map → image-WDHYGKKP.css.map} +2 -2
  17. package/dist/browser/dev/index.css +449 -114
  18. package/dist/browser/dev/index.css.map +3 -3
  19. package/dist/browser/dev/index.js +4143 -5956
  20. package/dist/browser/dev/index.js.map +4 -4
  21. package/dist/browser/prod/excalidraw-assets/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  22. package/dist/browser/prod/excalidraw-assets/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  23. package/dist/browser/prod/excalidraw-assets/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  24. package/dist/browser/prod/excalidraw-assets/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  25. package/dist/browser/prod/excalidraw-assets/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  26. package/dist/browser/prod/excalidraw-assets/chunk-OYEADJSR.js +63 -0
  27. package/dist/browser/prod/excalidraw-assets/{chunk-7DXALCB2.js → chunk-PDYFZJMS.js} +3 -3
  28. package/dist/browser/prod/excalidraw-assets/dist-NLUQPPQQ.js +7 -0
  29. package/dist/browser/prod/excalidraw-assets/en-YVAVVILW.js +1 -0
  30. package/dist/browser/prod/excalidraw-assets/image-X3GFZHNN.js +1 -0
  31. package/dist/browser/prod/index.css +1 -1
  32. package/dist/browser/prod/index.js +40 -50
  33. package/dist/dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  34. package/dist/dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  35. package/dist/dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  36. package/dist/dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  37. package/dist/dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  38. package/dist/dev/{en-EB2MBPAV.json → en-YNVBSAIL.json} +18 -4
  39. package/dist/dev/index.css +449 -114
  40. package/dist/dev/index.css.map +3 -3
  41. package/dist/dev/index.js +21626 -18122
  42. package/dist/dev/index.js.map +4 -4
  43. package/dist/excalidraw/actions/actionAddToLibrary.d.ts +9 -3
  44. package/dist/excalidraw/actions/actionBoundText.d.ts +6 -2
  45. package/dist/excalidraw/actions/actionCanvas.d.ts +36 -12
  46. package/dist/excalidraw/actions/actionClipboard.d.ts +22 -7
  47. package/dist/excalidraw/actions/actionDeleteSelected.d.ts +12 -5
  48. package/dist/excalidraw/actions/actionDeleteSelected.js +24 -5
  49. package/dist/excalidraw/actions/actionDuplicateSelection.js +1 -2
  50. package/dist/excalidraw/actions/actionElementLock.d.ts +6 -2
  51. package/dist/excalidraw/actions/actionExport.d.ts +27 -9
  52. package/dist/excalidraw/actions/actionFinalize.d.ts +6 -2
  53. package/dist/excalidraw/actions/actionFinalize.js +2 -2
  54. package/dist/excalidraw/actions/actionFlip.js +2 -2
  55. package/dist/excalidraw/actions/actionFrame.d.ts +12 -4
  56. package/dist/excalidraw/actions/actionGroup.d.ts +6 -2
  57. package/dist/excalidraw/actions/actionHistory.js +4 -4
  58. package/dist/excalidraw/actions/actionLinearEditor.d.ts +3 -1
  59. package/dist/excalidraw/actions/actionLinearEditor.js +3 -2
  60. package/dist/excalidraw/actions/actionLink.d.ts +3 -1
  61. package/dist/excalidraw/actions/actionMenu.d.ts +9 -3
  62. package/dist/excalidraw/actions/actionNavigate.d.ts +6 -2
  63. package/dist/excalidraw/actions/actionProperties.d.ts +411 -56
  64. package/dist/excalidraw/actions/actionProperties.js +383 -58
  65. package/dist/excalidraw/actions/actionSelectAll.d.ts +3 -1
  66. package/dist/excalidraw/actions/actionStyles.d.ts +3 -1
  67. package/dist/excalidraw/actions/actionStyles.js +3 -2
  68. package/dist/excalidraw/actions/actionToggleGridMode.d.ts +3 -1
  69. package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +3 -1
  70. package/dist/excalidraw/actions/actionToggleStats.d.ts +3 -1
  71. package/dist/excalidraw/actions/actionToggleViewMode.d.ts +3 -1
  72. package/dist/excalidraw/actions/actionToggleZenMode.d.ts +3 -1
  73. package/dist/excalidraw/actions/types.d.ts +1 -1
  74. package/dist/excalidraw/analytics.js +9 -7
  75. package/dist/excalidraw/appState.d.ts +1 -0
  76. package/dist/excalidraw/appState.js +9 -1
  77. package/dist/excalidraw/binaryheap.d.ts +12 -0
  78. package/dist/excalidraw/binaryheap.js +93 -0
  79. package/dist/excalidraw/change.d.ts +2 -1
  80. package/dist/excalidraw/change.js +6 -4
  81. package/dist/excalidraw/charts.js +0 -10
  82. package/dist/excalidraw/components/Actions.js +7 -5
  83. package/dist/excalidraw/components/App.d.ts +5 -9
  84. package/dist/excalidraw/components/App.js +218 -161
  85. package/dist/excalidraw/components/ButtonIcon.d.ts +15 -0
  86. package/dist/excalidraw/components/ButtonIcon.js +8 -0
  87. package/dist/excalidraw/components/ButtonIconSelect.js +2 -3
  88. package/dist/excalidraw/components/ButtonSeparator.d.ts +2 -0
  89. package/dist/excalidraw/components/ButtonSeparator.js +7 -0
  90. package/dist/excalidraw/components/ColorPicker/ColorPicker.js +47 -79
  91. package/dist/excalidraw/components/ColorPicker/Picker.js +1 -1
  92. package/dist/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
  93. package/dist/excalidraw/components/FontPicker/FontPicker.js +49 -0
  94. package/dist/excalidraw/components/FontPicker/FontPickerList.d.ts +25 -0
  95. package/dist/excalidraw/components/FontPicker/FontPickerList.js +119 -0
  96. package/dist/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +7 -0
  97. package/dist/excalidraw/components/FontPicker/FontPickerTrigger.js +13 -0
  98. package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
  99. package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.js +38 -0
  100. package/dist/excalidraw/components/HelpDialog.js +1 -1
  101. package/dist/excalidraw/components/HintViewer.js +6 -3
  102. package/dist/excalidraw/components/PropertiesPopover.d.ts +15 -0
  103. package/dist/excalidraw/components/PropertiesPopover.js +31 -0
  104. package/dist/excalidraw/components/QuickSearch.d.ts +9 -0
  105. package/dist/excalidraw/components/QuickSearch.js +8 -0
  106. package/dist/excalidraw/components/ScrollableList.d.ts +9 -0
  107. package/dist/excalidraw/components/ScrollableList.js +8 -0
  108. package/dist/excalidraw/components/Stats/Angle.d.ts +7 -3
  109. package/dist/excalidraw/components/Stats/Angle.js +39 -31
  110. package/dist/excalidraw/components/Stats/Dimension.d.ts +6 -3
  111. package/dist/excalidraw/components/Stats/Dimension.js +51 -49
  112. package/dist/excalidraw/components/Stats/DragInput.d.ts +15 -6
  113. package/dist/excalidraw/components/Stats/DragInput.js +59 -26
  114. package/dist/excalidraw/components/Stats/FontSize.d.ts +8 -4
  115. package/dist/excalidraw/components/Stats/FontSize.js +39 -36
  116. package/dist/excalidraw/components/Stats/MultiAngle.d.ts +5 -3
  117. package/dist/excalidraw/components/Stats/MultiAngle.js +43 -34
  118. package/dist/excalidraw/components/Stats/MultiDimension.d.ts +5 -3
  119. package/dist/excalidraw/components/Stats/MultiDimension.js +101 -99
  120. package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +6 -3
  121. package/dist/excalidraw/components/Stats/MultiFontSize.js +47 -32
  122. package/dist/excalidraw/components/Stats/MultiPosition.d.ts +3 -1
  123. package/dist/excalidraw/components/Stats/MultiPosition.js +52 -48
  124. package/dist/excalidraw/components/Stats/Position.d.ts +5 -1
  125. package/dist/excalidraw/components/Stats/Position.js +31 -29
  126. package/dist/excalidraw/components/Stats/index.js +5 -17
  127. package/dist/excalidraw/components/Stats/utils.d.ts +14 -3
  128. package/dist/excalidraw/components/Stats/utils.js +48 -9
  129. package/dist/excalidraw/components/TTDDialog/common.d.ts +2 -2
  130. package/dist/excalidraw/components/TTDDialog/common.js +3 -7
  131. package/dist/excalidraw/components/UserList.js +22 -22
  132. package/dist/excalidraw/components/canvases/StaticCanvas.js +1 -0
  133. package/dist/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +12 -3
  134. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +24 -4
  135. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +55 -14
  136. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
  137. package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +2 -2
  138. package/dist/excalidraw/components/dropdownMenu/common.d.ts +1 -1
  139. package/dist/excalidraw/components/dropdownMenu/common.js +3 -2
  140. package/dist/excalidraw/components/icons.d.ts +4 -0
  141. package/dist/excalidraw/components/icons.js +7 -0
  142. package/dist/excalidraw/components/main-menu/MainMenu.d.ts +12 -3
  143. package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +2 -2
  144. package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +3 -3
  145. package/dist/excalidraw/constants.d.ts +17 -2
  146. package/dist/excalidraw/constants.js +21 -4
  147. package/dist/excalidraw/data/reconcile.js +18 -1
  148. package/dist/excalidraw/data/restore.js +55 -9
  149. package/dist/excalidraw/data/transform.js +8 -5
  150. package/dist/excalidraw/element/binding.d.ts +28 -9
  151. package/dist/excalidraw/element/binding.js +303 -71
  152. package/dist/excalidraw/element/collision.d.ts +1 -1
  153. package/dist/excalidraw/element/collision.js +4 -1
  154. package/dist/excalidraw/element/dragElements.d.ts +2 -2
  155. package/dist/excalidraw/element/dragElements.js +13 -3
  156. package/dist/excalidraw/element/embeddable.d.ts +3 -1
  157. package/dist/excalidraw/element/heading.d.ts +11 -0
  158. package/dist/excalidraw/element/heading.js +81 -0
  159. package/dist/excalidraw/element/index.d.ts +1 -1
  160. package/dist/excalidraw/element/index.js +1 -1
  161. package/dist/excalidraw/element/linearElementEditor.d.ts +21 -13
  162. package/dist/excalidraw/element/linearElementEditor.js +133 -56
  163. package/dist/excalidraw/element/newElement.d.ts +8 -3
  164. package/dist/excalidraw/element/newElement.js +15 -2
  165. package/dist/excalidraw/element/resizeElements.d.ts +4 -3
  166. package/dist/excalidraw/element/resizeElements.js +47 -23
  167. package/dist/excalidraw/element/routing.d.ts +13 -0
  168. package/dist/excalidraw/element/routing.js +641 -0
  169. package/dist/excalidraw/element/textElement.d.ts +3 -26
  170. package/dist/excalidraw/element/textElement.js +54 -110
  171. package/dist/excalidraw/element/textWysiwyg.js +39 -47
  172. package/dist/excalidraw/element/transformHandles.js +7 -2
  173. package/dist/excalidraw/element/typeChecks.d.ts +5 -2
  174. package/dist/excalidraw/element/typeChecks.js +17 -0
  175. package/dist/excalidraw/element/types.d.ts +12 -1
  176. package/dist/excalidraw/fonts/ExcalidrawFont.d.ts +21 -0
  177. package/dist/excalidraw/fonts/ExcalidrawFont.js +112 -0
  178. package/dist/excalidraw/fonts/index.d.ts +58 -0
  179. package/dist/excalidraw/fonts/index.js +240 -0
  180. package/dist/excalidraw/fonts/metadata.d.ts +36 -0
  181. package/dist/excalidraw/fonts/metadata.js +91 -0
  182. package/dist/excalidraw/fractionalIndex.d.ts +11 -4
  183. package/dist/excalidraw/fractionalIndex.js +38 -6
  184. package/dist/excalidraw/frame.d.ts +1 -1
  185. package/dist/excalidraw/frame.js +3 -3
  186. package/dist/excalidraw/history.d.ts +4 -3
  187. package/dist/excalidraw/history.js +8 -8
  188. package/dist/excalidraw/index.d.ts +1 -1
  189. package/dist/excalidraw/index.js +3 -3
  190. package/dist/excalidraw/locales/en.json +18 -4
  191. package/dist/excalidraw/math.d.ts +43 -0
  192. package/dist/excalidraw/math.js +110 -0
  193. package/dist/excalidraw/mermaid.js +4 -3
  194. package/dist/excalidraw/renderer/interactiveScene.js +33 -17
  195. package/dist/excalidraw/renderer/renderElement.d.ts +2 -0
  196. package/dist/excalidraw/renderer/renderElement.js +74 -54
  197. package/dist/excalidraw/renderer/staticSvgScene.js +2 -1
  198. package/dist/excalidraw/scene/Scene.js +9 -3
  199. package/dist/excalidraw/scene/Shape.js +56 -5
  200. package/dist/excalidraw/scene/comparisons.d.ts +1 -0
  201. package/dist/excalidraw/scene/comparisons.js +1 -1
  202. package/dist/excalidraw/scene/export.d.ts +2 -1
  203. package/dist/excalidraw/scene/export.js +33 -35
  204. package/dist/excalidraw/scene/types.d.ts +1 -4
  205. package/dist/excalidraw/shapes.d.ts +8 -0
  206. package/dist/excalidraw/shapes.js +57 -0
  207. package/dist/excalidraw/types.d.ts +8 -3
  208. package/dist/excalidraw/utils.d.ts +11 -1
  209. package/dist/excalidraw/utils.js +22 -0
  210. package/dist/prod/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
  211. package/dist/prod/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
  212. package/dist/prod/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
  213. package/dist/prod/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
  214. package/dist/prod/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
  215. package/dist/prod/{en-EB2MBPAV.json → en-YNVBSAIL.json} +18 -4
  216. package/dist/prod/index.css +1 -1
  217. package/dist/prod/index.js +49 -53
  218. package/dist/utils/export.d.ts +2 -1
  219. package/dist/utils/export.js +2 -1
  220. package/dist/utils/geometry/geometry.d.ts +2 -1
  221. package/dist/utils/geometry/geometry.js +5 -1
  222. package/dist/utils/index.d.ts +1 -0
  223. package/dist/utils/index.js +1 -0
  224. package/history.ts +9 -2
  225. package/package.json +2 -2
  226. package/dist/browser/dev/Cascadia-CYPE3OJC.woff2 +0 -0
  227. package/dist/browser/dev/Virgil-UZN6MUT6.woff2 +0 -0
  228. package/dist/browser/dev/excalidraw-assets-dev/chunk-B4UMSLQQ.js.map +0 -7
  229. package/dist/browser/dev/excalidraw-assets-dev/chunk-EM6LVGFW.js.map +0 -7
  230. package/dist/browser/dev/excalidraw-assets-dev/dist-6QVAH5JA.js.map +0 -7
  231. package/dist/browser/prod/Cascadia-CYPE3OJC.woff2 +0 -0
  232. package/dist/browser/prod/Virgil-UZN6MUT6.woff2 +0 -0
  233. package/dist/browser/prod/excalidraw-assets/chunk-EGOLGOLD.js +0 -55
  234. package/dist/browser/prod/excalidraw-assets/dist-567JAXHK.js +0 -7
  235. package/dist/browser/prod/excalidraw-assets/en-6E7MYLWO.js +0 -1
  236. package/dist/browser/prod/excalidraw-assets/image-SI7BKULC.js +0 -1
  237. package/dist/dev/Cascadia-CYPE3OJC.woff2 +0 -0
  238. package/dist/dev/Virgil-UZN6MUT6.woff2 +0 -0
  239. package/dist/excalidraw/scene/Fonts.d.ts +0 -19
  240. package/dist/excalidraw/scene/Fonts.js +0 -66
  241. package/dist/prod/Cascadia-CYPE3OJC.woff2 +0 -0
  242. package/dist/prod/Virgil-UZN6MUT6.woff2 +0 -0
  243. /package/dist/browser/dev/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets-dev/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
  244. /package/dist/browser/dev/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets-dev/Assistant-Medium-DZ25RZU3.woff2} +0 -0
  245. /package/dist/browser/dev/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets-dev/Assistant-Regular-PLF2XOGW.woff2} +0 -0
  246. /package/dist/browser/dev/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets-dev/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
  247. /package/dist/browser/dev/excalidraw-assets-dev/{en-AZFA5HJJ.js.map → en-XV7OZCPP.js.map} +0 -0
  248. /package/dist/browser/dev/excalidraw-assets-dev/{image-V7E6IT6R.js.map → image-77HZYGLG.js.map} +0 -0
  249. /package/dist/browser/prod/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
  250. /package/dist/browser/prod/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets/Assistant-Medium-DZ25RZU3.woff2} +0 -0
  251. /package/dist/browser/prod/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets/Assistant-Regular-PLF2XOGW.woff2} +0 -0
  252. /package/dist/browser/prod/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
@@ -1,22 +1,63 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
2
3
  import { getDropdownMenuItemClassName, useHandleDropdownMenuItemClick, } from "./common";
3
4
  import MenuItemContent from "./DropdownMenuItemContent";
4
- const DropdownMenuItem = ({ icon, onSelect, children, shortcut, className, selected, ...rest }) => {
5
- const handleClick = useHandleDropdownMenuItemClick(rest.onClick, onSelect);
6
- return (_jsx("button", { ...rest, onClick: handleClick, type: "button", className: getDropdownMenuItemClassName(className, selected), title: rest.title ?? rest["aria-label"], children: _jsx(MenuItemContent, { icon: icon, shortcut: shortcut, children: children }) }));
5
+ import { useExcalidrawAppState } from "../App";
6
+ import { THEME } from "../../constants";
7
+ const DropdownMenuItem = ({ icon, value, order, children, shortcut, className, hovered, selected, textStyle, onSelect, onClick, ...rest }) => {
8
+ const handleClick = useHandleDropdownMenuItemClick(onClick, onSelect);
9
+ const ref = useRef(null);
10
+ useEffect(() => {
11
+ if (hovered) {
12
+ if (order === 0) {
13
+ // scroll into the first item differently, so it's visible what is above (i.e. group title)
14
+ ref.current?.scrollIntoView({ block: "end" });
15
+ }
16
+ else {
17
+ ref.current?.scrollIntoView({ block: "nearest" });
18
+ }
19
+ }
20
+ }, [hovered, order]);
21
+ return (_jsx("button", { ...rest, ref: ref, value: value, onClick: handleClick, className: getDropdownMenuItemClassName(className, selected, hovered), title: rest.title ?? rest["aria-label"], children: _jsx(MenuItemContent, { textStyle: textStyle, icon: icon, shortcut: shortcut, children: children }) }));
7
22
  };
8
23
  DropdownMenuItem.displayName = "DropdownMenuItem";
9
- export const DropDownMenuItemBadge = ({ children, }) => {
10
- return (_jsx("div", { style: {
11
- display: "inline-flex",
12
- marginLeft: "auto",
13
- padding: "2px 4px",
14
- background: "var(--color-promo)",
15
- color: "var(--color-surface-lowest)",
16
- borderRadius: 6,
17
- fontSize: 9,
18
- fontFamily: "Cascadia, monospace",
19
- }, children: children }));
24
+ export const DropDownMenuItemBadgeType = {
25
+ GREEN: "green",
26
+ RED: "red",
27
+ BLUE: "blue",
28
+ };
29
+ export const DropDownMenuItemBadge = ({ type = DropDownMenuItemBadgeType.BLUE, children, }) => {
30
+ const { theme } = useExcalidrawAppState();
31
+ const style = {
32
+ display: "inline-flex",
33
+ marginLeft: "auto",
34
+ padding: "2px 4px",
35
+ borderRadius: 6,
36
+ fontSize: 9,
37
+ fontFamily: "Cascadia, monospace",
38
+ border: theme === THEME.LIGHT ? "1.5px solid white" : "none",
39
+ };
40
+ switch (type) {
41
+ case DropDownMenuItemBadgeType.GREEN:
42
+ Object.assign(style, {
43
+ backgroundColor: "var(--background-color-badge)",
44
+ color: "var(--color-badge)",
45
+ });
46
+ break;
47
+ case DropDownMenuItemBadgeType.RED:
48
+ Object.assign(style, {
49
+ backgroundColor: "pink",
50
+ color: "darkred",
51
+ });
52
+ break;
53
+ case DropDownMenuItemBadgeType.BLUE:
54
+ default:
55
+ Object.assign(style, {
56
+ background: "var(--color-promo)",
57
+ color: "var(--color-surface-lowest)",
58
+ });
59
+ }
60
+ return (_jsx("div", { className: "DropDownMenuItemBadge", style: style, children: children }));
20
61
  };
21
62
  DropDownMenuItemBadge.displayName = "DropdownMenuItemBadge";
22
63
  DropdownMenuItem.Badge = DropDownMenuItemBadge;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
- declare const MenuItemContent: ({ icon, shortcut, children, }: {
2
+ declare const MenuItemContent: ({ textStyle, icon, shortcut, children, }: {
3
3
  icon?: JSX.Element | undefined;
4
4
  shortcut?: string | undefined;
5
+ textStyle?: import("react").CSSProperties | undefined;
5
6
  children: React.ReactNode;
6
7
  }) => JSX.Element;
7
8
  export default MenuItemContent;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useDevice } from "../App";
3
- const MenuItemContent = ({ icon, shortcut, children, }) => {
3
+ const MenuItemContent = ({ textStyle, icon, shortcut, children, }) => {
4
4
  const device = useDevice();
5
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "dropdown-menu-item__icon", children: icon }), _jsx("div", { className: "dropdown-menu-item__text", children: children }), shortcut && !device.editor.isMobile && (_jsx("div", { className: "dropdown-menu-item__shortcut", children: shortcut }))] }));
5
+ return (_jsxs(_Fragment, { children: [icon && _jsx("div", { className: "dropdown-menu-item__icon", children: icon }), _jsx("div", { style: textStyle, className: "dropdown-menu-item__text", children: children }), shortcut && !device.editor.isMobile && (_jsx("div", { className: "dropdown-menu-item__shortcut", children: shortcut }))] }));
6
6
  };
7
7
  export default MenuItemContent;
@@ -2,5 +2,5 @@ import React from "react";
2
2
  export declare const DropdownMenuContentPropsContext: React.Context<{
3
3
  onSelect?: ((event: Event) => void) | undefined;
4
4
  }>;
5
- export declare const getDropdownMenuItemClassName: (className?: string, selected?: boolean) => string;
5
+ export declare const getDropdownMenuItemClassName: (className?: string, selected?: boolean, hovered?: boolean) => string;
6
6
  export declare const useHandleDropdownMenuItemClick: (origOnClick: React.MouseEventHandler<HTMLAnchorElement | HTMLButtonElement> | undefined, onSelect: ((event: Event) => void) | undefined) => (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement, MouseEvent>) => void;
@@ -2,8 +2,9 @@ import React, { useContext } from "react";
2
2
  import { EVENT } from "../../constants";
3
3
  import { composeEventHandlers } from "../../utils";
4
4
  export const DropdownMenuContentPropsContext = React.createContext({});
5
- export const getDropdownMenuItemClassName = (className = "", selected = false) => {
6
- return `dropdown-menu-item dropdown-menu-item-base ${className} ${selected ? "dropdown-menu-item--selected" : ""}`.trim();
5
+ export const getDropdownMenuItemClassName = (className = "", selected = false, hovered = false) => {
6
+ return `dropdown-menu-item dropdown-menu-item-base ${className}
7
+ ${selected ? "dropdown-menu-item--selected" : ""} ${hovered ? "dropdown-menu-item--hovered" : ""}`.trim();
7
8
  };
8
9
  export const useHandleDropdownMenuItemClick = (origOnClick, onSelect) => {
9
10
  const DropdownMenuContentProps = useContext(DropdownMenuContentPropsContext);
@@ -140,6 +140,7 @@ export declare const FontSizeMediumIcon: JSX.Element;
140
140
  export declare const FontSizeLargeIcon: JSX.Element;
141
141
  export declare const FontSizeExtraLargeIcon: JSX.Element;
142
142
  export declare const fontSizeIcon: JSX.Element;
143
+ export declare const FontFamilyHeadingIcon: JSX.Element;
143
144
  export declare const FontFamilyNormalIcon: JSX.Element;
144
145
  export declare const FontFamilyCodeIcon: JSX.Element;
145
146
  export declare const TextAlignLeftIcon: JSX.Element;
@@ -200,6 +201,9 @@ export declare const loginIcon: JSX.Element;
200
201
  export declare const youtubeIcon: JSX.Element;
201
202
  export declare const gridIcon: JSX.Element;
202
203
  export declare const lineEditorIcon: JSX.Element;
204
+ export declare const sharpArrowIcon: JSX.Element;
205
+ export declare const elbowArrowIcon: JSX.Element;
206
+ export declare const roundArrowIcon: JSX.Element;
203
207
  export declare const collapseDownIcon: JSX.Element;
204
208
  export declare const collapseUpIcon: JSX.Element;
205
209
  export {};
@@ -201,6 +201,7 @@ export const FontSizeMediumIcon = createIcon(_jsxs(_Fragment, { children: [_jsx(
201
201
  export const FontSizeLargeIcon = createIcon(_jsxs(_Fragment, { children: [_jsx("g", { clipPath: "url(#a)", children: _jsx("path", { d: "M5.833 3.333v13.334h8.334", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("defs", { children: _jsx("clipPath", { id: "a", children: _jsx("path", { fill: "#fff", d: "M0 0h20v20H0z" }) }) })] }), modifiedTablerIconProps);
202
202
  export const FontSizeExtraLargeIcon = createIcon(_jsx(_Fragment, { children: _jsx("path", { d: "m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) }), modifiedTablerIconProps);
203
203
  export const fontSizeIcon = createIcon(_jsxs("g", { strokeWidth: 1.25, children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M3 7v-2h13v2" }), _jsx("path", { d: "M10 5v14" }), _jsx("path", { d: "M12 19h-4" }), _jsx("path", { d: "M15 13v-1h6v1" }), _jsx("path", { d: "M18 12v7" }), _jsx("path", { d: "M17 19h2" })] }), tablerIconProps);
204
+ export const FontFamilyHeadingIcon = createIcon(_jsx(_Fragment, { children: _jsxs("g", { stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M7 12h10" }), _jsx("path", { d: "M7 5v14" }), _jsx("path", { d: "M17 5v14" }), _jsx("path", { d: "M15 19h4" }), _jsx("path", { d: "M15 5h4" }), _jsx("path", { d: "M5 19h4" }), _jsx("path", { d: "M5 5h4" })] }) }), tablerIconProps);
204
205
  export const FontFamilyNormalIcon = createIcon(_jsx(_Fragment, { children: _jsx("g", { stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334" }) }) }), modifiedTablerIconProps);
205
206
  export const FontFamilyCodeIcon = createIcon(_jsxs(_Fragment, { children: [_jsx("g", { clipPath: "url(#a)", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667" }) }), _jsx("defs", { children: _jsx("clipPath", { id: "a", children: _jsx("path", { fill: "#fff", d: "M0 0h20v20H0z" }) }) })] }), modifiedTablerIconProps);
206
207
  export const TextAlignLeftIcon = createIcon(_jsxs("g", { stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("line", { x1: "4", y1: "8", x2: "20", y2: "8" }), _jsx("line", { x1: "4", y1: "12", x2: "12", y2: "12" }), _jsx("line", { x1: "4", y1: "16", x2: "16", y2: "16" })] }), tablerIconProps);
@@ -259,5 +260,11 @@ export const loginIcon = createIcon(_jsxs("g", { strokeWidth: 1.5, children: [_j
259
260
  export const youtubeIcon = createIcon(_jsxs("g", { children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z" }), _jsx("path", { d: "M10 9l5 3l-5 3z" })] }), tablerIconProps);
260
261
  export const gridIcon = createIcon(_jsxs("g", { strokeWidth: 1.5, children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M3 6h18" }), _jsx("path", { d: "M3 12h18" }), _jsx("path", { d: "M3 18h18" }), _jsx("path", { d: "M6 3v18" }), _jsx("path", { d: "M12 3v18" }), _jsx("path", { d: "M18 3v18" })] }), tablerIconProps);
261
262
  export const lineEditorIcon = createIcon(_jsxs("g", { strokeWidth: 1.5, children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z" }), _jsx("path", { d: "M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z" }), _jsx("path", { d: "M17 5c-6.627 0 -12 5.373 -12 12" })] }), tablerIconProps);
263
+ // arrow-up-right (modified)
264
+ export const sharpArrowIcon = createIcon(_jsxs("g", { children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M6 18l12 -12" }), _jsx("path", { d: "M18 10v-4h-4" })] }), tablerIconProps);
265
+ // arrow-guide (modified)
266
+ export const elbowArrowIcon = createIcon(_jsxs("g", { children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7" }), _jsx("path", { d: "M18 4l3 3l-3 3" })] }), tablerIconProps);
267
+ // arrow-ramp-right-2 (heavily modified)
268
+ export const roundArrowIcon = createIcon(_jsxs("g", { children: [_jsx("path", { d: "M16,12L20,9L16,6" }), _jsx("path", { d: "M6 20c0 -6.075 4.925 -11 11 -11h3" })] }), tablerIconProps);
262
269
  export const collapseDownIcon = createIcon(_jsxs("g", { children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M6 9l6 6l6 -6" })] }), tablerIconProps);
263
270
  export const collapseUpIcon = createIcon(_jsxs("g", { children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M6 15l6 -6l6 6" })] }), tablerIconProps);
@@ -19,17 +19,26 @@ declare const MainMenu: React.FC<{
19
19
  displayName: string;
20
20
  };
21
21
  Item: {
22
- ({ icon, onSelect, children, shortcut, className, selected, ...rest }: {
22
+ ({ icon, value, order, children, shortcut, className, hovered, selected, textStyle, onSelect, onClick, ...rest }: {
23
23
  icon?: JSX.Element | undefined;
24
- onSelect: (event: Event) => void;
24
+ value?: string | number | undefined;
25
+ order?: number | undefined;
26
+ onSelect?: ((event: Event) => void) | undefined;
25
27
  children: React.ReactNode;
26
28
  shortcut?: string | undefined;
29
+ hovered?: boolean | undefined;
27
30
  selected?: boolean | undefined;
31
+ textStyle?: React.CSSProperties | undefined;
28
32
  className?: string | undefined;
29
33
  } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">): JSX.Element;
30
34
  displayName: string;
31
35
  Badge: {
32
- ({ children, }: {
36
+ ({ type, children, }: {
37
+ type?: import("../../utility-types").ValueOf<{
38
+ readonly GREEN: "green";
39
+ readonly RED: "red";
40
+ readonly BLUE: "blue";
41
+ }> | undefined;
33
42
  children: React.ReactNode;
34
43
  }): JSX.Element;
35
44
  displayName: string;
@@ -26,11 +26,11 @@ const Center = ({ children }) => {
26
26
  };
27
27
  Center.displayName = "Center";
28
28
  const Logo = ({ children }) => {
29
- return (_jsx("div", { className: "welcome-screen-center__logo virgil welcome-screen-decor", children: children || _jsx(ExcalidrawLogo, { withText: true }) }));
29
+ return (_jsx("div", { className: "welcome-screen-center__logo excalifont welcome-screen-decor", children: children || _jsx(ExcalidrawLogo, { withText: true }) }));
30
30
  };
31
31
  Logo.displayName = "Logo";
32
32
  const Heading = ({ children }) => {
33
- return (_jsx("div", { className: "welcome-screen-center__heading welcome-screen-decor virgil", children: children }));
33
+ return (_jsx("div", { className: "welcome-screen-center__heading welcome-screen-decor excalifont", children: children }));
34
34
  };
35
35
  Heading.displayName = "Heading";
36
36
  const Menu = ({ children }) => {
@@ -4,17 +4,17 @@ import { useTunnels } from "../../context/tunnels";
4
4
  import { WelcomeScreenHelpArrow, WelcomeScreenMenuArrow, WelcomeScreenTopToolbarArrow, } from "../icons";
5
5
  const MenuHint = ({ children }) => {
6
6
  const { WelcomeScreenMenuHintTunnel } = useTunnels();
7
- return (_jsx(WelcomeScreenMenuHintTunnel.In, { children: _jsxs("div", { className: "virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu", children: [WelcomeScreenMenuArrow, _jsx("div", { className: "welcome-screen-decor-hint__label", children: children || t("welcomeScreen.defaults.menuHint") })] }) }));
7
+ return (_jsx(WelcomeScreenMenuHintTunnel.In, { children: _jsxs("div", { className: "excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu", children: [WelcomeScreenMenuArrow, _jsx("div", { className: "welcome-screen-decor-hint__label", children: children || t("welcomeScreen.defaults.menuHint") })] }) }));
8
8
  };
9
9
  MenuHint.displayName = "MenuHint";
10
10
  const ToolbarHint = ({ children }) => {
11
11
  const { WelcomeScreenToolbarHintTunnel } = useTunnels();
12
- return (_jsx(WelcomeScreenToolbarHintTunnel.In, { children: _jsxs("div", { className: "virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar", children: [_jsx("div", { className: "welcome-screen-decor-hint__label", children: children || t("welcomeScreen.defaults.toolbarHint") }), WelcomeScreenTopToolbarArrow] }) }));
12
+ return (_jsx(WelcomeScreenToolbarHintTunnel.In, { children: _jsxs("div", { className: "excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar", children: [_jsx("div", { className: "welcome-screen-decor-hint__label", children: children || t("welcomeScreen.defaults.toolbarHint") }), WelcomeScreenTopToolbarArrow] }) }));
13
13
  };
14
14
  ToolbarHint.displayName = "ToolbarHint";
15
15
  const HelpHint = ({ children }) => {
16
16
  const { WelcomeScreenHelpHintTunnel } = useTunnels();
17
- return (_jsx(WelcomeScreenHelpHintTunnel.In, { children: _jsxs("div", { className: "virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help", children: [_jsx("div", { children: children || t("welcomeScreen.defaults.helpHint") }), WelcomeScreenHelpArrow] }) }));
17
+ return (_jsx(WelcomeScreenHelpHintTunnel.In, { children: _jsxs("div", { className: "excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help", children: [_jsx("div", { children: children || t("welcomeScreen.defaults.helpHint") }), WelcomeScreenHelpArrow] }) }));
18
18
  };
19
19
  HelpHint.displayName = "HelpHint";
20
20
  export { HelpHint, MenuHint, ToolbarHint };
@@ -1,4 +1,4 @@
1
- import type { AppProps } from "./types";
1
+ import type { AppProps, AppState } from "./types";
2
2
  import type { ExcalidrawElement, FontFamilyValues } from "./element/types";
3
3
  export declare const isDarwin: boolean;
4
4
  export declare const isWindows: boolean;
@@ -86,11 +86,23 @@ export declare const ENV: {
86
86
  export declare const CLASSES: {
87
87
  SHAPE_ACTIONS_MENU: string;
88
88
  };
89
+ /**
90
+ * // TODO: shouldn't be really `const`, likely neither have integers as values, due to value for the custom fonts, which should likely be some hash.
91
+ *
92
+ * Let's think this through and consider:
93
+ * - https://developer.mozilla.org/en-US/docs/Web/CSS/generic-family
94
+ * - https://drafts.csswg.org/css-fonts-4/#font-family-prop
95
+ * - https://learn.microsoft.com/en-us/typography/opentype/spec/ibmfc
96
+ */
89
97
  export declare const FONT_FAMILY: {
90
98
  Virgil: number;
91
99
  Helvetica: number;
92
100
  Cascadia: number;
93
- Assistant: number;
101
+ Excalifont: number;
102
+ Nunito: number;
103
+ "Lilita One": number;
104
+ "Comic Shanns": number;
105
+ "Liberation Sans": number;
94
106
  };
95
107
  export declare const THEME: {
96
108
  readonly LIGHT: "light";
@@ -285,3 +297,6 @@ export declare const STATS_PANELS: {
285
297
  readonly elementProperties: 2;
286
298
  };
287
299
  export declare const MIN_WIDTH_OR_HEIGHT = 1;
300
+ export declare const ARROW_TYPE: {
301
+ [T in AppState["currentItemArrowType"]]: T;
302
+ };
@@ -99,12 +99,24 @@ export const ENV = {
99
99
  export const CLASSES = {
100
100
  SHAPE_ACTIONS_MENU: "App-menu__left",
101
101
  };
102
- // 1-based in case we ever do `if(element.fontFamily)`
102
+ /**
103
+ * // TODO: shouldn't be really `const`, likely neither have integers as values, due to value for the custom fonts, which should likely be some hash.
104
+ *
105
+ * Let's think this through and consider:
106
+ * - https://developer.mozilla.org/en-US/docs/Web/CSS/generic-family
107
+ * - https://drafts.csswg.org/css-fonts-4/#font-family-prop
108
+ * - https://learn.microsoft.com/en-us/typography/opentype/spec/ibmfc
109
+ */
103
110
  export const FONT_FAMILY = {
104
111
  Virgil: 1,
105
112
  Helvetica: 2,
106
113
  Cascadia: 3,
107
- Assistant: 4,
114
+ // leave 4 unused as it was historically used for Assistant (which we don't use anymore) or custom font (Obsidian)
115
+ Excalifont: 5,
116
+ Nunito: 6,
117
+ "Lilita One": 7,
118
+ "Comic Shanns": 8,
119
+ "Liberation Sans": 9,
108
120
  };
109
121
  export const THEME = {
110
122
  LIGHT: "light",
@@ -128,7 +140,7 @@ export const FRAME_STYLE = {
128
140
  export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
129
141
  export const MIN_FONT_SIZE = 1;
130
142
  export const DEFAULT_FONT_SIZE = 20;
131
- export const DEFAULT_FONT_FAMILY = FONT_FAMILY.Virgil;
143
+ export const DEFAULT_FONT_FAMILY = FONT_FAMILY.Excalifont;
132
144
  export const DEFAULT_TEXT_ALIGN = "left";
133
145
  export const DEFAULT_VERTICAL_ALIGN = "top";
134
146
  export const DEFAULT_VERSION = "{version}";
@@ -231,7 +243,7 @@ export const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
231
243
  export const EXPORT_SCALES = [1, 2, 3];
232
244
  export const DEFAULT_EXPORT_PADDING = 10; // px
233
245
  export const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
234
- export const MAX_ALLOWED_FILE_BYTES = 2 * 1024 * 1024;
246
+ export const MAX_ALLOWED_FILE_BYTES = 4 * 1024 * 1024;
235
247
  export const SVG_NS = "http://www.w3.org/2000/svg";
236
248
  export const ENCRYPTION_KEY_BITS = 128;
237
249
  export const VERSIONS = {
@@ -336,3 +348,8 @@ export const EDITOR_LS_KEYS = {
336
348
  export const DEFAULT_FILENAME = "Untitled";
337
349
  export const STATS_PANELS = { generalStats: 1, elementProperties: 2 };
338
350
  export const MIN_WIDTH_OR_HEIGHT = 1;
351
+ export const ARROW_TYPE = {
352
+ sharp: "sharp",
353
+ round: "round",
354
+ elbow: "elbow",
355
+ };
@@ -1,4 +1,5 @@
1
- import { orderByFractionalIndex, syncInvalidIndices } from "../fractionalIndex";
1
+ import { ENV } from "../constants";
2
+ import { orderByFractionalIndex, syncInvalidIndices, validateFractionalIndices, } from "../fractionalIndex";
2
3
  import { arrayToMap } from "../utils";
3
4
  const shouldDiscardRemoteElement = (localAppState, local, remote) => {
4
5
  if (local &&
@@ -43,6 +44,22 @@ export const reconcileElements = (localElements, remoteElements, localAppState)
43
44
  }
44
45
  }
45
46
  const orderedElements = orderByFractionalIndex(reconciledElements);
47
+ if (import.meta.env.DEV ||
48
+ import.meta.env.MODE === ENV.TEST ||
49
+ window?.DEBUG_FRACTIONAL_INDICES) {
50
+ const elements = syncInvalidIndices(
51
+ // create new instances due to the mutation
52
+ orderedElements.map((x) => ({ ...x })));
53
+ validateFractionalIndices(elements, {
54
+ // throw in dev & test only, to remain functional on `DEBUG_FRACTIONAL_INDICES`
55
+ shouldThrow: import.meta.env.DEV || import.meta.env.MODE === ENV.TEST,
56
+ includeBoundTextValidation: true,
57
+ reconciliationContext: {
58
+ localElements,
59
+ remoteElements,
60
+ },
61
+ });
62
+ }
46
63
  // de-duplicate indices
47
64
  syncInvalidIndices(orderedElements);
48
65
  return orderedElements;
@@ -1,5 +1,5 @@
1
1
  import { getNonDeletedElements, getNormalizedDimensions, isInvisiblySmallElement, refreshTextDimensions, } from "../element";
2
- import { isTextElement, isUsingAdaptiveRadius } from "../element/typeChecks";
2
+ import { isArrowElement, isElbowArrow, 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";
@@ -7,10 +7,11 @@ import { LinearElementEditor } from "../element/linearElementEditor";
7
7
  import { bumpVersion } from "../element/mutateElement";
8
8
  import { getUpdatedTimestamp, updateActiveTool } from "../utils";
9
9
  import { arrayToMap } from "../utils";
10
- import { detectLineHeight, getContainerElement, getDefaultLineHeight, } from "../element/textElement";
10
+ import { detectLineHeight, getContainerElement } from "../element/textElement";
11
11
  import { normalizeLink } from "./url";
12
12
  import { syncInvalidIndices } from "../fractionalIndex";
13
13
  import { getSizeFromPoints } from "../points";
14
+ import { getLineHeight } from "../fonts";
14
15
  export const AllowedExcalidrawActiveTools = {
15
16
  selection: true,
16
17
  text: true,
@@ -35,11 +36,17 @@ const getFontFamilyByName = (fontFamilyName) => {
35
36
  }
36
37
  return DEFAULT_FONT_FAMILY;
37
38
  };
38
- const repairBinding = (binding) => {
39
+ const repairBinding = (element, binding) => {
39
40
  if (!binding) {
40
41
  return null;
41
42
  }
42
- return { ...binding, focus: binding.focus || 0 };
43
+ return {
44
+ ...binding,
45
+ focus: binding.focus || 0,
46
+ fixedPoint: isElbowArrow(element)
47
+ ? binding.fixedPoint ?? [0, 0]
48
+ : null,
49
+ };
43
50
  };
44
51
  const restoreElementWithProperties = (element, extra) => {
45
52
  const base = {
@@ -116,7 +123,7 @@ const restoreElement = (element) => {
116
123
  detectLineHeight(element)
117
124
  : // no element height likely means programmatic use, so default
118
125
  // to a fixed line height
119
- getDefaultLineHeight(element.fontFamily));
126
+ getLineHeight(element.fontFamily));
120
127
  element = restoreElementWithProperties(element, {
121
128
  fontSize,
122
129
  fontFamily,
@@ -153,8 +160,7 @@ const restoreElement = (element) => {
153
160
  // @ts-ignore LEGACY type
154
161
  // eslint-disable-next-line no-fallthrough
155
162
  case "draw":
156
- case "arrow": {
157
- const { startArrowhead = null, endArrowhead = element.type === "arrow" ? "arrow" : null, } = element;
163
+ const { startArrowhead = null, endArrowhead = null } = element;
158
164
  let x = element.x;
159
165
  let y = element.y;
160
166
  let points = // migrate old arrow model to new one
@@ -171,14 +177,42 @@ const restoreElement = (element) => {
171
177
  type: element.type === "draw"
172
178
  ? "line"
173
179
  : element.type,
174
- startBinding: repairBinding(element.startBinding),
175
- endBinding: repairBinding(element.endBinding),
180
+ startBinding: repairBinding(element, element.startBinding),
181
+ endBinding: repairBinding(element, element.endBinding),
182
+ lastCommittedPoint: null,
183
+ startArrowhead,
184
+ endArrowhead,
185
+ points,
186
+ x,
187
+ y,
188
+ ...getSizeFromPoints(points),
189
+ });
190
+ case "arrow": {
191
+ const { startArrowhead = null, endArrowhead = "arrow" } = element;
192
+ let x = element.x;
193
+ let y = element.y;
194
+ let points = // migrate old arrow model to new one
195
+ !Array.isArray(element.points) || element.points.length < 2
196
+ ? [
197
+ [0, 0],
198
+ [element.width, element.height],
199
+ ]
200
+ : element.points;
201
+ if (points[0][0] !== 0 || points[0][1] !== 0) {
202
+ ({ points, x, y } = LinearElementEditor.getNormalizedPoints(element));
203
+ }
204
+ // TODO: Separate arrow from linear element
205
+ return restoreElementWithProperties(element, {
206
+ type: element.type,
207
+ startBinding: repairBinding(element, element.startBinding),
208
+ endBinding: repairBinding(element, element.endBinding),
176
209
  lastCommittedPoint: null,
177
210
  startArrowhead,
178
211
  endArrowhead,
179
212
  points,
180
213
  x,
181
214
  y,
215
+ elbowed: element.elbowed,
182
216
  ...getSizeFromPoints(points),
183
217
  });
184
218
  }
@@ -314,6 +348,18 @@ localElements, opts) => {
314
348
  if (opts.refreshDimensions && isTextElement(element)) {
315
349
  Object.assign(element, refreshTextDimensions(element, getContainerElement(element, restoredElementsMap), restoredElementsMap));
316
350
  }
351
+ if (isLinearElement(element)) {
352
+ if (element.startBinding &&
353
+ (!restoredElementsMap.has(element.startBinding.elementId) ||
354
+ !isArrowElement(element))) {
355
+ element.startBinding = null;
356
+ }
357
+ if (element.endBinding &&
358
+ (!restoredElementsMap.has(element.endBinding.elementId) ||
359
+ !isArrowElement(element))) {
360
+ element.endBinding = null;
361
+ }
362
+ }
317
363
  }
318
364
  return restoredElements;
319
365
  };
@@ -1,12 +1,14 @@
1
1
  import { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, TEXT_ALIGN, VERTICAL_ALIGN, } from "../constants";
2
2
  import { getCommonBounds, newElement, newLinearElement, redrawTextBoundingBox, } from "../element";
3
3
  import { bindLinearElement } from "../element/binding";
4
- import { newFrameElement, newImageElement, newMagicFrameElement, newTextElement, } from "../element/newElement";
5
- import { getDefaultLineHeight, measureText, normalizeText, } from "../element/textElement";
4
+ import { newArrowElement, newFrameElement, newImageElement, newMagicFrameElement, newTextElement, } from "../element/newElement";
5
+ import { measureText, normalizeText } from "../element/textElement";
6
6
  import { arrayToMap, assertNever, cloneJSON, getFontString, toBrandedType, } from "../utils";
7
7
  import { getSizeFromPoints } from "../points";
8
8
  import { randomId } from "../random";
9
9
  import { syncInvalidIndices } from "../fractionalIndex";
10
+ import { getLineHeight } from "../fonts";
11
+ import { isArrowElement } from "../element/typeChecks";
10
12
  const DEFAULT_LINEAR_ELEMENT_PROPS = {
11
13
  width: 100,
12
14
  height: 0,
@@ -273,7 +275,7 @@ export const convertToExcalidrawElements = (elementsSkeleton, opts) => {
273
275
  case "arrow": {
274
276
  const width = element.width || DEFAULT_LINEAR_ELEMENT_PROPS.width;
275
277
  const height = element.height || DEFAULT_LINEAR_ELEMENT_PROPS.height;
276
- excalidrawElement = newLinearElement({
278
+ excalidrawElement = newArrowElement({
277
279
  width,
278
280
  height,
279
281
  endArrowhead: "arrow",
@@ -282,6 +284,7 @@ export const convertToExcalidrawElements = (elementsSkeleton, opts) => {
282
284
  [width, height],
283
285
  ],
284
286
  ...element,
287
+ type: "arrow",
285
288
  });
286
289
  Object.assign(excalidrawElement, getSizeFromPoints(excalidrawElement.points));
287
290
  break;
@@ -289,7 +292,7 @@ export const convertToExcalidrawElements = (elementsSkeleton, opts) => {
289
292
  case "text": {
290
293
  const fontFamily = element?.fontFamily || DEFAULT_FONT_FAMILY;
291
294
  const fontSize = element?.fontSize || DEFAULT_FONT_SIZE;
292
- const lineHeight = element?.lineHeight || getDefaultLineHeight(fontFamily);
295
+ const lineHeight = element?.lineHeight || getLineHeight(fontFamily);
293
296
  const text = element.text ?? "";
294
297
  const normalizedText = normalizeText(text);
295
298
  const metrics = measureText(normalizedText, getFontString({ fontFamily, fontSize }), lineHeight);
@@ -362,7 +365,7 @@ export const convertToExcalidrawElements = (elementsSkeleton, opts) => {
362
365
  let [container, text] = bindTextToContainer(excalidrawElement, element?.label, elementsMap);
363
366
  elementStore.add(container);
364
367
  elementStore.add(text);
365
- if (container.type === "arrow") {
368
+ if (isArrowElement(container)) {
366
369
  const originalStart = element.type === "arrow" ? element?.start : undefined;
367
370
  const originalEnd = element.type === "arrow" ? element?.end : undefined;
368
371
  if (originalStart && originalStart.id) {
@@ -1,6 +1,9 @@
1
- import type { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap } from "./types";
2
- import type { AppClassProperties, AppState } from "../types";
1
+ import type { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap, OrderedExcalidrawElement, ExcalidrawElbowArrowElement, FixedPoint } from "./types";
2
+ import type { Bounds } from "./bounds";
3
+ import type { AppState } from "../types";
3
4
  import type { ElementUpdate } from "./mutateElement";
5
+ import type Scene from "../scene/Scene";
6
+ import { type Heading } from "./heading";
4
7
  export type SuggestedBinding = NonDeleted<ExcalidrawBindableElement> | SuggestedPointBinding;
5
8
  export type SuggestedPointBinding = [
6
9
  NonDeleted<ExcalidrawLinearElement>,
@@ -9,29 +12,43 @@ export type SuggestedPointBinding = [
9
12
  ];
10
13
  export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
11
14
  export declare const isBindingEnabled: (appState: AppState) => boolean;
12
- export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", elementsMap: NonDeletedSceneElementsMap) => void;
13
- export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], app: AppClassProperties, isBindingEnabled: boolean, draggingPoints: readonly number[] | null) => void;
14
- export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], app: AppClassProperties) => SuggestedBinding[];
15
+ export declare const FIXED_BINDING_DISTANCE = 5;
16
+ export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", elementsMap: NonDeletedSceneElementsMap, scene: Scene) => void;
17
+ export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], elementsMap: NonDeletedSceneElementsMap, elements: readonly NonDeletedExcalidrawElement[], scene: Scene, isBindingEnabled: boolean, draggingPoints: readonly number[] | null) => void;
18
+ export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap) => SuggestedBinding[];
15
19
  export declare const maybeBindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, appState: AppState, pointerCoords: {
16
20
  x: number;
17
21
  y: number;
18
- }, app: AppClassProperties) => void;
22
+ }, elementsMap: NonDeletedSceneElementsMap, elements: readonly NonDeletedExcalidrawElement[]) => void;
19
23
  export declare const bindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: NonDeletedSceneElementsMap) => void;
20
24
  export declare const isLinearElementSimpleAndAlreadyBound: (linearElement: NonDeleted<ExcalidrawLinearElement>, alreadyBoundToId: ExcalidrawBindableElement["id"] | undefined, bindableElement: ExcalidrawBindableElement) => boolean;
21
25
  export declare const getHoveredElementForBinding: (pointerCoords: {
22
26
  x: number;
23
27
  y: number;
24
- }, app: AppClassProperties) => NonDeleted<ExcalidrawBindableElement> | null;
25
- export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, elementsMap: ElementsMap, options?: {
28
+ }, elements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap, fullShape?: boolean) => NonDeleted<ExcalidrawBindableElement> | null;
29
+ export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, elementsMap: ElementsMap, scene: Scene, options?: {
26
30
  simultaneouslyUpdated?: readonly ExcalidrawElement[];
27
- newSize?: {
31
+ oldSize?: {
28
32
  width: number;
29
33
  height: number;
30
34
  };
35
+ changedElements?: Map<string, OrderedExcalidrawElement>;
31
36
  }) => void;
37
+ export declare const getHeadingForElbowArrowSnap: (point: readonly [number, number], otherPoint: readonly [number, number], bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, elementsMap: ElementsMap, origPoint: readonly [number, number]) => Heading;
38
+ export declare const bindPointToSnapToElementOutline: (point: readonly [number, number], otherPoint: readonly [number, number], bindableElement: ExcalidrawBindableElement | undefined, elementsMap: ElementsMap) => readonly [number, number];
39
+ export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: readonly [number, number]) => readonly [number, number];
40
+ export declare const snapToMid: (element: ExcalidrawBindableElement, p: readonly [number, number], tolerance?: number) => readonly [number, number];
41
+ export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
42
+ fixedPoint: FixedPoint;
43
+ };
32
44
  export declare const fixBindingsAfterDuplication: (sceneElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicatesServeAsOld?: "duplicatesServeAsOld" | undefined) => void;
33
45
  export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
46
+ export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
47
+ x: number;
48
+ y: number;
49
+ }, elementsMap: NonDeletedSceneElementsMap, fullShape?: boolean) => boolean;
34
50
  export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number) => number;
51
+ export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, point: readonly [number, number], elementsMap: ElementsMap) => number;
35
52
  export declare const bindingProperties: Set<BindableProp | BindingProp>;
36
53
  export type BindableProp = "boundElements";
37
54
  export type BindingProp = "frameId" | "containerId" | "startBinding" | "endBinding";
@@ -73,3 +90,5 @@ export declare class BindableElement {
73
90
  */
74
91
  static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
75
92
  }
93
+ export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement) => [number, number];
94
+ export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => (readonly [number, number])[];