@tldraw/editor 4.6.0-next.5a871ec02ff3 → 4.6.0-next.6594d48ace27

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 (448) hide show
  1. package/dist-cjs/index.d.ts +1316 -285
  2. package/dist-cjs/index.js +31 -26
  3. package/dist-cjs/index.js.map +3 -3
  4. package/dist-cjs/lib/TldrawEditor.js +62 -14
  5. package/dist-cjs/lib/TldrawEditor.js.map +3 -3
  6. package/dist-cjs/lib/components/MenuClickCapture.js +99 -38
  7. package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
  8. package/dist-cjs/lib/components/default-components/CanvasOverlays.js +180 -0
  9. package/dist-cjs/lib/components/default-components/CanvasOverlays.js.map +7 -0
  10. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +33 -236
  11. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
  12. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
  13. package/dist-cjs/lib/config/{createTLUser.js → createTLCurrentUser.js} +9 -9
  14. package/dist-cjs/lib/config/createTLCurrentUser.js.map +7 -0
  15. package/dist-cjs/lib/config/createTLStore.js +31 -1
  16. package/dist-cjs/lib/config/createTLStore.js.map +2 -2
  17. package/dist-cjs/lib/{components/default-components/DefaultShapeIndicatorErrorFallback.js → config/defaultAssets.js} +17 -9
  18. package/dist-cjs/lib/config/defaultAssets.js.map +7 -0
  19. package/dist-cjs/lib/config/defaultShapes.js.map +2 -2
  20. package/dist-cjs/lib/editor/Editor.js +921 -386
  21. package/dist-cjs/lib/editor/Editor.js.map +3 -3
  22. package/dist-cjs/lib/editor/assets/AssetUtil.js +67 -0
  23. package/dist-cjs/lib/editor/assets/AssetUtil.js.map +7 -0
  24. package/dist-cjs/lib/editor/bindings/BindingUtil.js +1 -0
  25. package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +1 -1
  26. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +26 -64
  27. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
  28. package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +98 -0
  29. package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +7 -0
  30. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +2 -1
  31. package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
  32. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +15 -53
  33. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +1 -1
  34. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js +2 -0
  35. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
  36. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +2 -0
  37. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +1 -1
  38. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +83 -112
  39. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
  40. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js +80 -0
  41. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js.map +7 -0
  42. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +466 -0
  43. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +7 -0
  44. package/dist-cjs/lib/{components/default-components/DefaultHandles.js → editor/managers/PerformanceManager/perf-types.js} +3 -14
  45. package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js.map +7 -0
  46. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js +1 -0
  47. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +1 -1
  48. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +22 -56
  49. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
  50. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +12 -52
  51. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
  52. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +21 -57
  53. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
  54. package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +5 -4
  55. package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
  56. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +103 -30
  57. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
  58. package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +107 -0
  59. package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
  60. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +600 -0
  61. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
  62. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +17 -55
  63. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
  64. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +65 -72
  65. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  66. package/dist-cjs/lib/editor/overlays/OverlayManager.js +154 -0
  67. package/dist-cjs/lib/editor/overlays/OverlayManager.js.map +7 -0
  68. package/dist-cjs/lib/editor/overlays/OverlayUtil.js +92 -0
  69. package/dist-cjs/lib/editor/overlays/OverlayUtil.js.map +7 -0
  70. package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +161 -0
  71. package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +7 -0
  72. package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js +76 -0
  73. package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js.map +7 -0
  74. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +35 -20
  75. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  76. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +33 -3
  77. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  78. package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js +6 -0
  79. package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
  80. package/dist-cjs/lib/editor/tools/StateNode.js +15 -17
  81. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  82. package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
  83. package/dist-cjs/lib/editor/types/clipboard-types.js.map +1 -1
  84. package/dist-cjs/lib/editor/types/event-types.js.map +2 -2
  85. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  86. package/dist-cjs/lib/exports/ExportDelay.js +13 -53
  87. package/dist-cjs/lib/exports/ExportDelay.js.map +1 -1
  88. package/dist-cjs/lib/exports/FontEmbedder.js +14 -57
  89. package/dist-cjs/lib/exports/FontEmbedder.js.map +1 -1
  90. package/dist-cjs/lib/exports/StyleEmbedder.js +2 -1
  91. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  92. package/dist-cjs/lib/exports/fetchCache.js +1 -1
  93. package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
  94. package/dist-cjs/lib/exports/getSvgJsx.js +14 -8
  95. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  96. package/dist-cjs/lib/globals/environment.js +18 -1
  97. package/dist-cjs/lib/globals/environment.js.map +2 -2
  98. package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
  99. package/dist-cjs/lib/hooks/useCanvasEvents.js +25 -4
  100. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  101. package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
  102. package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
  103. package/dist-cjs/lib/hooks/useCursor.js +3 -7
  104. package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
  105. package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
  106. package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
  107. package/dist-cjs/lib/hooks/useEditorComponents.js +0 -28
  108. package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
  109. package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
  110. package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
  111. package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
  112. package/dist-cjs/lib/hooks/usePeerIds.js +1 -36
  113. package/dist-cjs/lib/hooks/usePeerIds.js.map +2 -2
  114. package/dist-cjs/lib/hooks/useShapeCulling.js +2 -1
  115. package/dist-cjs/lib/hooks/useShapeCulling.js.map +2 -2
  116. package/dist-cjs/lib/options.js +4 -0
  117. package/dist-cjs/lib/options.js.map +2 -2
  118. package/dist-cjs/lib/primitives/Box.js +26 -26
  119. package/dist-cjs/lib/primitives/Box.js.map +2 -2
  120. package/dist-cjs/lib/primitives/Vec.js +4 -1
  121. package/dist-cjs/lib/primitives/Vec.js.map +2 -2
  122. package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
  123. package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
  124. package/dist-cjs/lib/primitives/geometry/Circle2d.js +3 -2
  125. package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
  126. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +1 -1
  127. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +1 -1
  128. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +4 -3
  129. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
  130. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +12 -9
  131. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  132. package/dist-cjs/lib/primitives/geometry/Polyline2d.js +2 -2
  133. package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
  134. package/dist-cjs/lib/primitives/geometry/Stadium2d.js +2 -1
  135. package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
  136. package/dist-cjs/lib/utils/EditorAtom.js +2 -0
  137. package/dist-cjs/lib/utils/EditorAtom.js.map +1 -1
  138. package/dist-cjs/lib/utils/SharedStylesMap.js +1 -1
  139. package/dist-cjs/lib/utils/SharedStylesMap.js.map +1 -1
  140. package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +2 -2
  141. package/dist-cjs/lib/utils/reparenting.js +2 -1
  142. package/dist-cjs/lib/utils/reparenting.js.map +2 -2
  143. package/dist-cjs/lib/utils/richText.js.map +2 -2
  144. package/dist-cjs/lib/utils/runtime.js +2 -1
  145. package/dist-cjs/lib/utils/runtime.js.map +2 -2
  146. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +8 -2
  147. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
  148. package/dist-cjs/lib/utils/sync/hardReset.js +0 -8
  149. package/dist-cjs/lib/utils/sync/hardReset.js.map +2 -2
  150. package/dist-cjs/version.js +3 -3
  151. package/dist-cjs/version.js.map +1 -1
  152. package/dist-esm/index.d.mts +1316 -285
  153. package/dist-esm/index.mjs +44 -48
  154. package/dist-esm/index.mjs.map +2 -2
  155. package/dist-esm/lib/TldrawEditor.mjs +65 -14
  156. package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
  157. package/dist-esm/lib/components/MenuClickCapture.mjs +100 -39
  158. package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
  159. package/dist-esm/lib/components/default-components/CanvasOverlays.mjs +160 -0
  160. package/dist-esm/lib/components/default-components/CanvasOverlays.mjs.map +7 -0
  161. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +34 -237
  162. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +3 -3
  163. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
  164. package/dist-esm/lib/config/{createTLUser.mjs → createTLCurrentUser.mjs} +6 -6
  165. package/dist-esm/lib/config/createTLCurrentUser.mjs.map +7 -0
  166. package/dist-esm/lib/config/createTLStore.mjs +37 -2
  167. package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
  168. package/dist-esm/lib/config/defaultAssets.mjs +16 -0
  169. package/dist-esm/lib/config/defaultAssets.mjs.map +7 -0
  170. package/dist-esm/lib/config/defaultShapes.mjs.map +2 -2
  171. package/dist-esm/lib/editor/Editor.mjs +924 -389
  172. package/dist-esm/lib/editor/Editor.mjs.map +3 -3
  173. package/dist-esm/lib/editor/assets/AssetUtil.mjs +47 -0
  174. package/dist-esm/lib/editor/assets/AssetUtil.mjs.map +7 -0
  175. package/dist-esm/lib/editor/bindings/BindingUtil.mjs +1 -0
  176. package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +1 -1
  177. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +26 -64
  178. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
  179. package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +83 -0
  180. package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +7 -0
  181. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +2 -1
  182. package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
  183. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +15 -53
  184. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +1 -1
  185. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs +2 -0
  186. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
  187. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +2 -0
  188. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +1 -1
  189. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +83 -112
  190. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
  191. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs +60 -0
  192. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs.map +7 -0
  193. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +438 -0
  194. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +7 -0
  195. package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs +1 -0
  196. package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs.map +7 -0
  197. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs +1 -0
  198. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +1 -1
  199. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +22 -56
  200. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
  201. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +12 -52
  202. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
  203. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +21 -57
  204. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
  205. package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +5 -4
  206. package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
  207. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +103 -30
  208. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
  209. package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +89 -0
  210. package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
  211. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +582 -0
  212. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
  213. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +17 -55
  214. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
  215. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +65 -72
  216. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  217. package/dist-esm/lib/editor/overlays/OverlayManager.mjs +136 -0
  218. package/dist-esm/lib/editor/overlays/OverlayManager.mjs.map +7 -0
  219. package/dist-esm/lib/editor/overlays/OverlayUtil.mjs +72 -0
  220. package/dist-esm/lib/editor/overlays/OverlayUtil.mjs.map +7 -0
  221. package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +141 -0
  222. package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +7 -0
  223. package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs +56 -0
  224. package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs.map +7 -0
  225. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +35 -20
  226. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  227. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +33 -3
  228. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  229. package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs +6 -0
  230. package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
  231. package/dist-esm/lib/editor/tools/StateNode.mjs +15 -17
  232. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  233. package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
  234. package/dist-esm/lib/editor/types/event-types.mjs.map +2 -2
  235. package/dist-esm/lib/exports/ExportDelay.mjs +13 -53
  236. package/dist-esm/lib/exports/ExportDelay.mjs.map +1 -1
  237. package/dist-esm/lib/exports/FontEmbedder.mjs +14 -57
  238. package/dist-esm/lib/exports/FontEmbedder.mjs.map +1 -1
  239. package/dist-esm/lib/exports/StyleEmbedder.mjs +2 -1
  240. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  241. package/dist-esm/lib/exports/fetchCache.mjs +2 -2
  242. package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
  243. package/dist-esm/lib/exports/getSvgJsx.mjs +14 -11
  244. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  245. package/dist-esm/lib/globals/environment.mjs +18 -1
  246. package/dist-esm/lib/globals/environment.mjs.map +2 -2
  247. package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
  248. package/dist-esm/lib/hooks/useCanvasEvents.mjs +25 -4
  249. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  250. package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
  251. package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
  252. package/dist-esm/lib/hooks/useCursor.mjs +3 -7
  253. package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
  254. package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
  255. package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
  256. package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -28
  257. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  258. package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
  259. package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
  260. package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
  261. package/dist-esm/lib/hooks/usePeerIds.mjs +2 -40
  262. package/dist-esm/lib/hooks/usePeerIds.mjs.map +2 -2
  263. package/dist-esm/lib/hooks/useShapeCulling.mjs +2 -1
  264. package/dist-esm/lib/hooks/useShapeCulling.mjs.map +2 -2
  265. package/dist-esm/lib/options.mjs +4 -0
  266. package/dist-esm/lib/options.mjs.map +2 -2
  267. package/dist-esm/lib/primitives/Box.mjs +26 -26
  268. package/dist-esm/lib/primitives/Box.mjs.map +2 -2
  269. package/dist-esm/lib/primitives/Vec.mjs +4 -1
  270. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  271. package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
  272. package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
  273. package/dist-esm/lib/primitives/geometry/Circle2d.mjs +3 -2
  274. package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
  275. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +1 -1
  276. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +1 -1
  277. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +4 -3
  278. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
  279. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +12 -9
  280. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  281. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +2 -2
  282. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
  283. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +2 -1
  284. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
  285. package/dist-esm/lib/utils/EditorAtom.mjs +2 -0
  286. package/dist-esm/lib/utils/EditorAtom.mjs.map +1 -1
  287. package/dist-esm/lib/utils/SharedStylesMap.mjs +1 -1
  288. package/dist-esm/lib/utils/SharedStylesMap.mjs.map +1 -1
  289. package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +2 -2
  290. package/dist-esm/lib/utils/reparenting.mjs +2 -1
  291. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  292. package/dist-esm/lib/utils/richText.mjs.map +2 -2
  293. package/dist-esm/lib/utils/runtime.mjs +2 -1
  294. package/dist-esm/lib/utils/runtime.mjs.map +2 -2
  295. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +8 -2
  296. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
  297. package/dist-esm/lib/utils/sync/hardReset.mjs +0 -8
  298. package/dist-esm/lib/utils/sync/hardReset.mjs.map +2 -2
  299. package/dist-esm/version.mjs +3 -3
  300. package/dist-esm/version.mjs.map +1 -1
  301. package/editor.css +16 -256
  302. package/package.json +7 -8
  303. package/src/index.ts +58 -52
  304. package/src/lib/TldrawEditor.tsx +108 -20
  305. package/src/lib/components/MenuClickCapture.tsx +129 -49
  306. package/src/lib/components/default-components/CanvasOverlays.tsx +208 -0
  307. package/src/lib/components/default-components/DefaultCanvas.tsx +38 -310
  308. package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -0
  309. package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
  310. package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +9 -9
  311. package/src/lib/config/createTLStore.ts +58 -3
  312. package/src/lib/config/defaultAssets.ts +19 -0
  313. package/src/lib/config/defaultShapes.ts +1 -1
  314. package/src/lib/editor/Editor.test.ts +3 -1
  315. package/src/lib/editor/Editor.ts +610 -69
  316. package/src/lib/editor/assets/AssetUtil.ts +85 -0
  317. package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
  318. package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +98 -0
  319. package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
  320. package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
  321. package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
  322. package/src/lib/editor/managers/InputsManager/InputsManager.ts +42 -30
  323. package/src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts +82 -0
  324. package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +522 -0
  325. package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +583 -0
  326. package/src/lib/editor/managers/PerformanceManager/perf-types.ts +196 -0
  327. package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +1 -1
  328. package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
  329. package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +13 -2
  330. package/src/lib/editor/managers/SnapManager/SnapManager.ts +1 -1
  331. package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
  332. package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
  333. package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
  334. package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
  335. package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +619 -0
  336. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +25 -31
  337. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +7 -5
  338. package/src/lib/editor/overlays/OverlayManager.ts +183 -0
  339. package/src/lib/editor/overlays/OverlayUtil.ts +143 -0
  340. package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +216 -0
  341. package/src/lib/editor/shapes/BaseFrameLikeShapeUtil.tsx +123 -0
  342. package/src/lib/editor/shapes/ShapeUtil.ts +67 -30
  343. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +41 -4
  344. package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +7 -0
  345. package/src/lib/editor/tools/StateNode.ts +16 -18
  346. package/src/lib/editor/types/SvgExportContext.tsx +5 -0
  347. package/src/lib/editor/types/clipboard-types.ts +2 -1
  348. package/src/lib/editor/types/event-types.ts +2 -0
  349. package/src/lib/editor/types/external-content.ts +1 -0
  350. package/src/lib/exports/StyleEmbedder.ts +1 -1
  351. package/src/lib/exports/fetchCache.ts +2 -4
  352. package/src/lib/exports/getSvgJsx.test.ts +3 -1
  353. package/src/lib/exports/getSvgJsx.tsx +24 -17
  354. package/src/lib/globals/environment.ts +18 -0
  355. package/src/lib/hooks/EditorComponentsContext.tsx +0 -27
  356. package/src/lib/hooks/useCanvasEvents.ts +40 -3
  357. package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
  358. package/src/lib/hooks/useCursor.ts +3 -7
  359. package/src/lib/hooks/useDarkMode.ts +4 -4
  360. package/src/lib/hooks/useEditorComponents.tsx +1 -29
  361. package/src/lib/hooks/useGestureEvents.ts +240 -168
  362. package/src/lib/hooks/useLocalStore.ts +1 -1
  363. package/src/lib/hooks/usePeerIds.ts +6 -55
  364. package/src/lib/hooks/useShapeCulling.tsx +3 -1
  365. package/src/lib/options.ts +115 -0
  366. package/src/lib/primitives/Box.test.ts +30 -0
  367. package/src/lib/primitives/Box.ts +26 -26
  368. package/src/lib/primitives/Vec.ts +1 -1
  369. package/src/lib/primitives/geometry/Arc2d.ts +2 -2
  370. package/src/lib/primitives/geometry/Circle2d.ts +2 -2
  371. package/src/lib/primitives/geometry/CubicSpline2d.ts +1 -1
  372. package/src/lib/primitives/geometry/Ellipse2d.ts +3 -3
  373. package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
  374. package/src/lib/primitives/geometry/Geometry2d.ts +10 -9
  375. package/src/lib/primitives/geometry/Polyline2d.ts +2 -2
  376. package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
  377. package/src/lib/utils/SharedStylesMap.ts +1 -1
  378. package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
  379. package/src/lib/utils/reparenting.ts +6 -2
  380. package/src/lib/utils/richText.ts +1 -1
  381. package/src/lib/utils/runtime.ts +3 -1
  382. package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
  383. package/src/lib/utils/sync/TLLocalSyncClient.ts +5 -1
  384. package/src/lib/utils/sync/hardReset.ts +0 -8
  385. package/src/version.ts +3 -3
  386. package/dist-cjs/lib/components/LiveCollaborators.js +0 -151
  387. package/dist-cjs/lib/components/LiveCollaborators.js.map +0 -7
  388. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +0 -227
  389. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +0 -7
  390. package/dist-cjs/lib/components/default-components/DefaultBrush.js +0 -38
  391. package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +0 -7
  392. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +0 -71
  393. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +0 -7
  394. package/dist-cjs/lib/components/default-components/DefaultHandle.js +0 -56
  395. package/dist-cjs/lib/components/default-components/DefaultHandle.js.map +0 -7
  396. package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +0 -7
  397. package/dist-cjs/lib/components/default-components/DefaultScribble.js +0 -51
  398. package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +0 -7
  399. package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js +0 -69
  400. package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js.map +0 -7
  401. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +0 -107
  402. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +0 -7
  403. package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js.map +0 -7
  404. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +0 -101
  405. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +0 -7
  406. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +0 -170
  407. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +0 -7
  408. package/dist-cjs/lib/config/createTLUser.js.map +0 -7
  409. package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
  410. package/dist-esm/lib/components/LiveCollaborators.mjs +0 -134
  411. package/dist-esm/lib/components/LiveCollaborators.mjs.map +0 -7
  412. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +0 -207
  413. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +0 -7
  414. package/dist-esm/lib/components/default-components/DefaultBrush.mjs +0 -18
  415. package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +0 -7
  416. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +0 -41
  417. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +0 -7
  418. package/dist-esm/lib/components/default-components/DefaultHandle.mjs +0 -26
  419. package/dist-esm/lib/components/default-components/DefaultHandle.mjs.map +0 -7
  420. package/dist-esm/lib/components/default-components/DefaultHandles.mjs +0 -8
  421. package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +0 -7
  422. package/dist-esm/lib/components/default-components/DefaultScribble.mjs +0 -21
  423. package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +0 -7
  424. package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs +0 -39
  425. package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs.map +0 -7
  426. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +0 -77
  427. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +0 -7
  428. package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs +0 -8
  429. package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs.map +0 -7
  430. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +0 -81
  431. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +0 -7
  432. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +0 -142
  433. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +0 -7
  434. package/dist-esm/lib/config/createTLUser.mjs.map +0 -7
  435. package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
  436. package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
  437. package/src/lib/components/LiveCollaborators.tsx +0 -174
  438. package/src/lib/components/default-components/CanvasShapeIndicators.tsx +0 -289
  439. package/src/lib/components/default-components/DefaultBrush.tsx +0 -35
  440. package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +0 -52
  441. package/src/lib/components/default-components/DefaultHandle.tsx +0 -42
  442. package/src/lib/components/default-components/DefaultHandles.tsx +0 -15
  443. package/src/lib/components/default-components/DefaultScribble.tsx +0 -31
  444. package/src/lib/components/default-components/DefaultSelectionForeground.tsx +0 -50
  445. package/src/lib/components/default-components/DefaultShapeIndicator.tsx +0 -104
  446. package/src/lib/components/default-components/DefaultShapeIndicatorErrorFallback.tsx +0 -9
  447. package/src/lib/components/default-components/DefaultShapeIndicators.tsx +0 -116
  448. package/src/lib/components/default-components/DefaultSnapIndictor.tsx +0 -174
@@ -1,52 +1,13 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
5
- var __typeError = (msg) => {
6
- throw TypeError(msg);
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
7
10
  };
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
11
- var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
12
- var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
13
- var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
14
- var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
15
- var __runInitializers = (array, flags, self, value) => {
16
- for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
17
- return value;
18
- };
19
- var __decorateElement = (array, flags, name, decorators, target, extra) => {
20
- var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
21
- var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
22
- var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
23
- var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
24
- return __privateGet(this, extra);
25
- }, set [name](x) {
26
- return __privateSet(this, extra, x);
27
- } }, name));
28
- k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
29
- for (var i = decorators.length - 1; i >= 0; i--) {
30
- ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
31
- if (k) {
32
- ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
33
- if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
34
- if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
35
- }
36
- it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
37
- if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
38
- else if (typeof it !== "object" || it === null) __typeError("Object expected");
39
- else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
40
- }
41
- return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
42
- };
43
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
44
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
45
- var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
46
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
48
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
49
- var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getEfficientZoomLevel_dec, __getAboveDebouncedZoomThreshold_dec, _getDebouncedZoomLevel_dec, _getResizeScaleFactor_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _canRedo_dec, _canUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
50
11
  import {
51
12
  EMPTY_ARRAY,
52
13
  atom,
@@ -64,8 +25,10 @@ import {
64
25
  PageRecordType,
65
26
  TLDOCUMENT_ID,
66
27
  TLINSTANCE_ID,
28
+ UserRecordType,
67
29
  createBindingId,
68
30
  createShapeId,
31
+ createUserId,
69
32
  getShapePropKeysByStyle,
70
33
  isPageId,
71
34
  isShapeId
@@ -93,7 +56,6 @@ import {
93
56
  hasOwnProperty,
94
57
  last,
95
58
  lerp,
96
- maxBy,
97
59
  minBy,
98
60
  sortById,
99
61
  sortByIndex,
@@ -101,13 +63,14 @@ import {
101
63
  uniqueId
102
64
  } from "@tldraw/utils";
103
65
  import EventEmitter from "eventemitter3";
66
+ import { createTLCurrentUser } from "../config/createTLCurrentUser.mjs";
67
+ import { checkAssets } from "../config/defaultAssets.mjs";
68
+ import { checkBindings } from "../config/defaultBindings.mjs";
69
+ import { checkShapesAndAddCore } from "../config/defaultShapes.mjs";
104
70
  import {
105
71
  getSnapshot,
106
72
  loadSnapshot
107
73
  } from "../config/TLEditorSnapshot.mjs";
108
- import { createTLUser } from "../config/createTLUser.mjs";
109
- import { checkBindings } from "../config/defaultBindings.mjs";
110
- import { checkShapesAndAddCore } from "../config/defaultShapes.mjs";
111
74
  import {
112
75
  DEFAULT_ANIMATION_OPTIONS,
113
76
  DEFAULT_CAMERA_OPTIONS,
@@ -124,13 +87,12 @@ import { tlmenus } from "../globals/menus.mjs";
124
87
  import { tltime } from "../globals/time.mjs";
125
88
  import { defaultTldrawOptions } from "../options.mjs";
126
89
  import { Box } from "../primitives/Box.mjs";
127
- import { Mat } from "../primitives/Mat.mjs";
128
- import { Vec } from "../primitives/Vec.mjs";
129
90
  import { EASINGS } from "../primitives/easings.mjs";
130
91
  import { Group2d } from "../primitives/geometry/Group2d.mjs";
131
92
  import { intersectPolygonPolygon } from "../primitives/intersect.mjs";
93
+ import { Mat } from "../primitives/Mat.mjs";
132
94
  import { PI, approximately, areAnglesCompatible, clamp, pointInPolygon } from "../primitives/utils.mjs";
133
- import { SharedStyleMap } from "../utils/SharedStylesMap.mjs";
95
+ import { Vec } from "../primitives/Vec.mjs";
134
96
  import { areShapesContentEqual } from "../utils/areShapesContentEqual.mjs";
135
97
  import { dataUrlToFile } from "../utils/assets.mjs";
136
98
  import { debugFlags } from "../utils/debug-flags.mjs";
@@ -142,29 +104,37 @@ import { getIncrementedName } from "../utils/getIncrementedName.mjs";
142
104
  import { getReorderingShapesChanges } from "../utils/reorderShapes.mjs";
143
105
  import { getDroppedShapesToNewParents, kickoutOccludedShapes } from "../utils/reparenting.mjs";
144
106
  import { applyRotationToSnapshotShapes, getRotationSnapshot } from "../utils/rotation.mjs";
107
+ import { SharedStyleMap } from "../utils/SharedStylesMap.mjs";
145
108
  import { bindingsIndex } from "./derivations/bindingsIndex.mjs";
146
109
  import { notVisibleShapes } from "./derivations/notVisibleShapes.mjs";
147
110
  import { parentsToChildren } from "./derivations/parentsToChildren.mjs";
148
111
  import { deriveShapeIdsInCurrentPage } from "./derivations/shapeIdsInCurrentPage.mjs";
149
112
  import { ClickManager } from "./managers/ClickManager/ClickManager.mjs";
113
+ import { CollaboratorsManager } from "./managers/CollaboratorsManager/CollaboratorsManager.mjs";
150
114
  import { EdgeScrollManager } from "./managers/EdgeScrollManager/EdgeScrollManager.mjs";
151
115
  import { FocusManager } from "./managers/FocusManager/FocusManager.mjs";
152
116
  import { FontManager } from "./managers/FontManager/FontManager.mjs";
153
117
  import { HistoryManager } from "./managers/HistoryManager/HistoryManager.mjs";
154
118
  import { InputsManager } from "./managers/InputsManager/InputsManager.mjs";
119
+ import { PerformanceManager } from "./managers/PerformanceManager/PerformanceManager.mjs";
155
120
  import { ScribbleManager } from "./managers/ScribbleManager/ScribbleManager.mjs";
156
121
  import { SnapManager } from "./managers/SnapManager/SnapManager.mjs";
157
122
  import { SpatialIndexManager } from "./managers/SpatialIndexManager/SpatialIndexManager.mjs";
158
123
  import { TextManager } from "./managers/TextManager/TextManager.mjs";
124
+ import { ThemeManager, resolveThemes } from "./managers/ThemeManager/ThemeManager.mjs";
159
125
  import { TickManager } from "./managers/TickManager/TickManager.mjs";
160
126
  import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
127
+ import { OverlayManager } from "./overlays/OverlayManager.mjs";
161
128
  import { RootState } from "./tools/RootState.mjs";
162
- class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _canUndo_dec = [computed], _canRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getResizeScaleFactor_dec = [computed], _getDebouncedZoomLevel_dec = [computed], __getAboveDebouncedZoomThreshold_dec = [computed], _getEfficientZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], _getNotVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
129
+ class Editor extends EventEmitter {
130
+ id = uniqueId();
163
131
  constructor({
164
132
  store,
165
133
  user,
166
134
  shapeUtils,
167
135
  bindingUtils,
136
+ assetUtils: assetUtilConstructors,
137
+ overlayUtils: overlayUtilConstructors,
168
138
  tools,
169
139
  getContainer,
170
140
  // needs to be here for backwards compatibility with TldrawEditor
@@ -172,242 +142,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
172
142
  cameraOptions,
173
143
  initialState,
174
144
  autoFocus,
175
- inferDarkMode,
176
145
  options: _options,
177
146
  // needs to be here for backwards compatibility with TldrawEditor
178
147
  // eslint-disable-next-line @typescript-eslint/no-deprecated
179
148
  textOptions: _textOptions,
180
149
  getShapeVisibility,
181
- fontAssetUrls
150
+ colorScheme,
151
+ fontAssetUrls,
152
+ themes,
153
+ initialTheme
182
154
  }) {
183
155
  super();
184
- __runInitializers(_init, 5, this);
185
- __publicField(this, "id", uniqueId());
186
- __publicField(this, "_getShapeVisibility");
187
- __publicField(this, "options");
188
- __publicField(this, "contextId", uniqueId());
189
- /**
190
- * The editor's store
191
- *
192
- * @public
193
- */
194
- __publicField(this, "store");
195
- /**
196
- * The root state of the statechart.
197
- *
198
- * @public
199
- */
200
- __publicField(this, "root");
201
- /**
202
- * A set of functions to call when the editor is disposed.
203
- *
204
- * @public
205
- */
206
- __publicField(this, "disposables", /* @__PURE__ */ new Set());
207
- /**
208
- * Whether the editor is disposed.
209
- *
210
- * @public
211
- */
212
- __publicField(this, "isDisposed", false);
213
- /**
214
- * A manager for the editor's tick events.
215
- *
216
- * @internal */
217
- __publicField(this, "_tickManager");
218
- /**
219
- * A manager for the editor's input state.
220
- *
221
- * @public
222
- */
223
- __publicField(this, "inputs");
224
- /**
225
- * A manager for the editor's snapping feature.
226
- *
227
- * @public
228
- */
229
- __publicField(this, "snaps");
230
- __publicField(this, "_spatialIndex");
231
- /**
232
- * A manager for the any asynchronous events and making sure they're
233
- * cleaned up upon disposal.
234
- *
235
- * @public
236
- */
237
- __publicField(this, "timers", tltime.forContext(this.contextId));
238
- /**
239
- * A manager for the user and their preferences.
240
- *
241
- * @public
242
- */
243
- __publicField(this, "user");
244
- /**
245
- * A helper for measuring text.
246
- *
247
- * @public
248
- */
249
- __publicField(this, "textMeasure");
250
- /**
251
- * A utility for managing the set of fonts that should be rendered in the document.
252
- *
253
- * @public
254
- */
255
- __publicField(this, "fonts");
256
- /**
257
- * A manager for the editor's scribbles.
258
- *
259
- * @public
260
- */
261
- __publicField(this, "scribbles");
262
- /**
263
- * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
264
- *
265
- * @public
266
- */
267
- __publicField(this, "sideEffects");
268
- /**
269
- * A manager for moving the camera when the mouse is at the edge of the screen.
270
- *
271
- * @public
272
- */
273
- __publicField(this, "edgeScrollManager");
274
- /**
275
- * A manager for ensuring correct focus. See FocusManager for details.
276
- *
277
- * @internal
278
- */
279
- __publicField(this, "focusManager");
280
- /**
281
- * The current HTML element containing the editor.
282
- *
283
- * @example
284
- * ```ts
285
- * const container = editor.getContainer()
286
- * ```
287
- *
288
- * @public
289
- */
290
- __publicField(this, "getContainer");
291
- /* ------------------- Shape Utils ------------------ */
292
- /**
293
- * A map of shape utility classes (TLShapeUtils) by shape type.
294
- *
295
- * @public
296
- */
297
- __publicField(this, "shapeUtils");
298
- __publicField(this, "styleProps");
299
- /* ------------------- Binding Utils ------------------ */
300
- /**
301
- * A map of shape utility classes (TLShapeUtils) by shape type.
302
- *
303
- * @public
304
- */
305
- __publicField(this, "bindingUtils");
306
- /* --------------------- History -------------------- */
307
- /**
308
- * A manager for the editor's history.
309
- *
310
- * @readonly
311
- */
312
- __publicField(this, "history");
313
- __publicField(this, "_shouldIgnoreShapeLock", false);
314
- /** @internal */
315
- __publicField(this, "_crashingError", null);
316
- /** @internal */
317
- __publicField(this, "_isChangingStyleTimeout", -1);
318
- // Menus
319
- __publicField(this, "menus", tlmenus.forContext(this.contextId));
320
- // Rich text editor
321
- __publicField(this, "_currentRichTextEditor", atom("rich text editor", null));
322
- __publicField(this, "_textOptions");
323
- __publicField(this, "_debouncedZoomLevel", atom("debounced zoom level", 1));
324
- __publicField(this, "_cameraOptions", atom("camera options", DEFAULT_CAMERA_OPTIONS));
325
- /** @internal */
326
- __publicField(this, "_viewportAnimation", null);
327
- // Viewport
328
- /** @internal */
329
- __publicField(this, "_willSetInitialBounds", true);
330
- // Following
331
- // When we are 'locked on' to a user, our camera is derived from their camera.
332
- __publicField(this, "_isLockedOnFollowingUser", atom("isLockedOnFollowingUser", false));
333
- // Camera state
334
- // Camera state does two things: first, it allows us to subscribe to whether
335
- // the camera is moving or not; and second, it allows us to update the rendering
336
- // shapes on the canvas. Changing the rendering shapes may cause shapes to
337
- // unmount / remount in the DOM, which is expensive; and computing visibility is
338
- // also expensive in large projects. For this reason, we use a second bounding
339
- // box just for rendering, and we only update after the camera stops moving.
340
- __publicField(this, "_cameraStateTimeoutRemaining", 0);
341
- /* @internal */
342
- __publicField(this, "_currentPageShapeIds");
343
- /* --------------------- Shapes --------------------- */
344
- __publicField(this, "_shapeGeometryCaches", {});
345
- __publicField(this, "_notVisibleShapes", notVisibleShapes(this));
346
- __publicField(this, "_culledShapesCache", null);
347
- // Parents and children
348
- /**
349
- * A cache of parents to children.
350
- *
351
- * @internal
352
- */
353
- __publicField(this, "_parentIdsToChildIds");
354
- __publicField(this, "animatingShapes", /* @__PURE__ */ new Map());
355
- /* --------------------- Content -------------------- */
356
- /** @internal */
357
- __publicField(this, "externalAssetContentHandlers", {
358
- file: null,
359
- url: null
360
- });
361
- /** @internal */
362
- __publicField(this, "temporaryAssetPreview", /* @__PURE__ */ new Map());
363
- /** @internal */
364
- __publicField(this, "externalContentHandlers", {
365
- text: null,
366
- files: null,
367
- "file-replace": null,
368
- embed: null,
369
- "svg-text": null,
370
- url: null,
371
- tldraw: null,
372
- excalidraw: null
373
- });
374
- /**
375
- * A manager for recording multiple click events.
376
- *
377
- * @internal
378
- */
379
- __publicField(this, "_clickManager", new ClickManager(this));
380
- /**
381
- * The previous cursor. Used for restoring the cursor after pan events.
382
- *
383
- * @internal
384
- */
385
- __publicField(this, "_prevCursor", "default");
386
- /** @internal */
387
- __publicField(this, "_shiftKeyTimeout", -1);
388
- /** @internal */
389
- __publicField(this, "_altKeyTimeout", -1);
390
- /** @internal */
391
- __publicField(this, "_ctrlKeyTimeout", -1);
392
- /** @internal */
393
- __publicField(this, "_metaKeyTimeout", -1);
394
- /** @internal */
395
- __publicField(this, "_restoreToolId", "select");
396
- /** @internal */
397
- __publicField(this, "_didPinch", false);
398
- /** @internal */
399
- __publicField(this, "_selectedShapeIdsAtPointerDown", []);
400
- /** @internal */
401
- __publicField(this, "_longPressTimeout", -1);
402
- /** @internal */
403
- __publicField(this, "capturedPointerId", null);
404
- /** @internal */
405
- __publicField(this, "performanceTracker");
406
- /** @internal */
407
- __publicField(this, "performanceTrackerTimeout", -1);
408
- /** @internal */
409
- __publicField(this, "handledEvents", /* @__PURE__ */ new WeakSet());
410
- __publicField(this, "_pendingEventsForNextTick", []);
411
156
  this._getShapeVisibility = getShapeVisibility;
412
157
  const options = _textOptions ? { ..._options, text: _options?.text ?? _textOptions } : _options;
413
158
  this.options = { ...defaultTldrawOptions, ...options };
@@ -428,15 +173,28 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
428
173
  ...cameraOptions,
429
174
  ...options?.camera
430
175
  });
176
+ this.getContainer = getContainer;
431
177
  this._textOptions = atom("text options", options?.text ?? null);
432
- this.user = new UserPreferencesManager(user ?? createTLUser(), inferDarkMode ?? false);
178
+ this.user = new UserPreferencesManager(user ?? createTLCurrentUser(), colorScheme ?? "light");
433
179
  this.disposables.add(() => this.user.dispose());
434
- this.getContainer = getContainer;
435
180
  this.textMeasure = new TextManager(this);
436
181
  this.disposables.add(() => this.textMeasure.dispose());
437
- this.fonts = new FontManager(this, fontAssetUrls);
182
+ this._themeManager = new ThemeManager(this, {
183
+ themes: resolveThemes(themes),
184
+ initial: initialTheme ?? "default"
185
+ });
186
+ this.disposables.add(() => this._themeManager.dispose());
438
187
  this._tickManager = new TickManager(this);
188
+ this.disposables.add(() => this._tickManager.dispose());
189
+ this.disposables.add(() => {
190
+ this.off("tick", this._decayCameraStateTimeout);
191
+ this._setCameraState("idle");
192
+ });
193
+ this.fonts = new FontManager(this, fontAssetUrls);
439
194
  this.inputs = new InputsManager(this);
195
+ this.performance = new PerformanceManager(this);
196
+ this.disposables.add(() => this.performance.dispose());
197
+ this.collaborators = new CollaboratorsManager(this);
440
198
  class NewRoot extends RootState {
441
199
  static initial = initialState ?? "";
442
200
  }
@@ -464,6 +222,16 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
464
222
  }
465
223
  this.shapeUtils = _shapeUtils;
466
224
  this.styleProps = _styleProps;
225
+ const _shapeUtilsByAssetType = {};
226
+ for (const Util of allShapeUtils) {
227
+ const assetTypes = Util.handledAssetTypes;
228
+ if (assetTypes) {
229
+ for (const assetType of assetTypes) {
230
+ _shapeUtilsByAssetType[assetType] = _shapeUtils[Util.type];
231
+ }
232
+ }
233
+ }
234
+ this._shapeUtilsByAssetType = _shapeUtilsByAssetType;
467
235
  const allBindingUtils = checkBindings(bindingUtils);
468
236
  const _bindingUtils = {};
469
237
  for (const Util of allBindingUtils) {
@@ -471,6 +239,15 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
471
239
  _bindingUtils[Util.type] = util;
472
240
  }
473
241
  this.bindingUtils = _bindingUtils;
242
+ if (assetUtilConstructors) {
243
+ const allAssetUtils = checkAssets(assetUtilConstructors);
244
+ const _assetUtils = {};
245
+ for (const Util of allAssetUtils) {
246
+ const util = new Util(this);
247
+ _assetUtils[Util.type] = util;
248
+ }
249
+ this.assetUtils = _assetUtils;
250
+ }
474
251
  for (const Tool of [...tools]) {
475
252
  if (hasOwnProperty(this.root.children, Tool.id)) {
476
253
  throw Error(`Can't override tool with id "${Tool.id}"`);
@@ -478,6 +255,13 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
478
255
  this.root.children[Tool.id] = new Tool(this, this.root);
479
256
  }
480
257
  this.scribbles = new ScribbleManager(this);
258
+ this.overlays = new OverlayManager(this);
259
+ if (overlayUtilConstructors) {
260
+ for (const Util of overlayUtilConstructors) {
261
+ const util = new Util(this);
262
+ this.overlays.registerUtil(util);
263
+ }
264
+ }
481
265
  const cleanupInstancePageState = (prevPageState, shapesNoLongerInPage) => {
482
266
  let nextPageState = null;
483
267
  const selectedShapeIds = prevPageState.selectedShapeIds.filter(
@@ -812,7 +596,16 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
812
596
  })
813
597
  );
814
598
  }
599
+ this.disposables.add(
600
+ react("sync current user record", () => {
601
+ const user2 = this.store.props.users.currentUser.get();
602
+ if (user2) {
603
+ this._ensureUserRecord(user2);
604
+ }
605
+ })
606
+ );
815
607
  }
608
+ _getShapeVisibility;
816
609
  getIsShapeHiddenCache() {
817
610
  if (!this._getShapeVisibility) return null;
818
611
  return this.store.createComputedCache("isShapeHidden", (shape) => {
@@ -828,6 +621,20 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
828
621
  typeof shapeOrId === "string" ? shapeOrId : shapeOrId.id
829
622
  );
830
623
  }
624
+ options;
625
+ contextId = uniqueId();
626
+ /**
627
+ * The editor's store
628
+ *
629
+ * @public
630
+ */
631
+ store;
632
+ /**
633
+ * The root state of the statechart.
634
+ *
635
+ * @public
636
+ */
637
+ root;
831
638
  /**
832
639
  * Set a tool. Useful if you need to add a tool to the state chart on demand,
833
640
  * after the editor has already been initialized.
@@ -859,6 +666,125 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
859
666
  delete parent.children[Tool.id];
860
667
  }
861
668
  }
669
+ /**
670
+ * A set of functions to call when the editor is disposed.
671
+ *
672
+ * @public
673
+ */
674
+ disposables = /* @__PURE__ */ new Set();
675
+ /**
676
+ * Whether the editor is disposed.
677
+ *
678
+ * @public
679
+ */
680
+ isDisposed = false;
681
+ /**
682
+ * A manager for the editor's tick events.
683
+ *
684
+ * @internal */
685
+ _tickManager;
686
+ /**
687
+ * A manager for the editor's input state.
688
+ *
689
+ * @public
690
+ */
691
+ inputs;
692
+ /**
693
+ * A manager for the editor's snapping feature.
694
+ *
695
+ * @public
696
+ */
697
+ snaps;
698
+ /**
699
+ * A manager for performance measurement hooks.
700
+ *
701
+ * @public
702
+ */
703
+ performance;
704
+ /**
705
+ * A manager for the spatial index, tracking where shapes exist on the canvas.
706
+ *
707
+ * @internal
708
+ */
709
+ _spatialIndex;
710
+ /**
711
+ * A manager for the any asynchronous events and making sure they're
712
+ * cleaned up upon disposal.
713
+ *
714
+ * @public
715
+ */
716
+ timers = tltime.forContext(this.contextId);
717
+ /**
718
+ * A manager for remote peer collaborators connected to this editor.
719
+ *
720
+ * @public
721
+ */
722
+ collaborators;
723
+ /**
724
+ * A manager for the user and their preferences.
725
+ *
726
+ * @public
727
+ */
728
+ user;
729
+ /**
730
+ * A manager for the editor's themes.
731
+ *
732
+ * @internal
733
+ */
734
+ _themeManager;
735
+ /**
736
+ * A helper for measuring text.
737
+ *
738
+ * @public
739
+ */
740
+ textMeasure;
741
+ /**
742
+ * A utility for managing the set of fonts that should be rendered in the document.
743
+ *
744
+ * @public
745
+ */
746
+ fonts;
747
+ /**
748
+ * A manager for the editor's scribbles.
749
+ *
750
+ * @public
751
+ */
752
+ scribbles;
753
+ /**
754
+ * A manager for canvas overlay UI elements (selection handles, shape handles, etc.).
755
+ *
756
+ * @public
757
+ */
758
+ overlays;
759
+ /**
760
+ * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
761
+ *
762
+ * @public
763
+ */
764
+ sideEffects;
765
+ /**
766
+ * A manager for moving the camera when the mouse is at the edge of the screen.
767
+ *
768
+ * @public
769
+ */
770
+ edgeScrollManager;
771
+ /**
772
+ * A manager for ensuring correct focus. See FocusManager for details.
773
+ *
774
+ * @internal
775
+ */
776
+ focusManager;
777
+ /**
778
+ * The current HTML element containing the editor.
779
+ *
780
+ * @example
781
+ * ```ts
782
+ * const container = editor.getContainer()
783
+ * ```
784
+ *
785
+ * @public
786
+ */
787
+ getContainer;
862
788
  /**
863
789
  * The document that the editor's container element belongs to.
864
790
  * Use this instead of the global `document` to support cross-window embedding.
@@ -883,12 +809,127 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
883
809
  * @public
884
810
  */
885
811
  dispose() {
812
+ this.stopCameraAnimation();
813
+ if (this.getInstanceState().followingUserId) {
814
+ this.stopFollowingUser();
815
+ }
886
816
  this.disposables.forEach((dispose) => dispose());
887
817
  this.disposables.clear();
818
+ this.menus.clearOpenMenus();
888
819
  this.store.dispose();
889
820
  this.isDisposed = true;
890
821
  this.emit("dispose");
891
822
  }
823
+ /* ------------------ Themes (shadowing the theme manager) ------------------ */
824
+ /**
825
+ * Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
826
+ *
827
+ * @public
828
+ */
829
+ getColorMode() {
830
+ return this._themeManager.getColorMode();
831
+ }
832
+ /**
833
+ * Set the color mode. Note that this is a convenience method that passes the mode to
834
+ * `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
835
+ *
836
+ * @public
837
+ */
838
+ setColorMode(mode) {
839
+ this.user.updateUserPreferences({ colorScheme: mode });
840
+ return this;
841
+ }
842
+ /**
843
+ * Get the id of the current theme.
844
+ *
845
+ * @public
846
+ */
847
+ getCurrentThemeId() {
848
+ return this._themeManager.getCurrentThemeId();
849
+ }
850
+ /**
851
+ * Get the current theme definition.
852
+ *
853
+ * @public
854
+ */
855
+ getCurrentTheme() {
856
+ return this._themeManager.getCurrentTheme();
857
+ }
858
+ /**
859
+ * Set the current theme by id.
860
+ *
861
+ * @public
862
+ */
863
+ setCurrentTheme(id) {
864
+ this._themeManager.setCurrentTheme(id);
865
+ return this;
866
+ }
867
+ /**
868
+ * Get all registered theme definitions.
869
+ *
870
+ * @public
871
+ */
872
+ getThemes() {
873
+ return this._themeManager.getThemes();
874
+ }
875
+ /**
876
+ * Get a single theme definition by id.
877
+ *
878
+ * @public
879
+ */
880
+ getTheme(id) {
881
+ return this._themeManager.getTheme(id);
882
+ }
883
+ /**
884
+ * Replace all theme definitions, or update them via a callback that receives a deep copy.
885
+ * The `'default'` theme must always be present in the result.
886
+ *
887
+ * @example
888
+ * ```ts
889
+ * // Replace all themes
890
+ * editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
891
+ *
892
+ * // Update via callback
893
+ * editor.updateThemes((themes) => {
894
+ * delete themes.ocean
895
+ * return themes
896
+ * })
897
+ * ```
898
+ *
899
+ * @public
900
+ */
901
+ updateThemes(themes) {
902
+ this._themeManager.updateThemes(themes);
903
+ return this;
904
+ }
905
+ /**
906
+ * Register or update a single theme definition. The theme is keyed by its `id` property.
907
+ *
908
+ * @example
909
+ * ```ts
910
+ * // Override a property on the default theme
911
+ * editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
912
+ *
913
+ * // Register a new theme
914
+ * editor.updateTheme({ id: 'ocean', ...myOceanTheme })
915
+ * ```
916
+ *
917
+ * @public
918
+ */
919
+ updateTheme(theme) {
920
+ this._themeManager.updateTheme(theme);
921
+ return this;
922
+ }
923
+ /* ------------------- Shape Utils ------------------ */
924
+ /**
925
+ * A map of shape utility classes (TLShapeUtils) by shape type.
926
+ *
927
+ * @public
928
+ */
929
+ shapeUtils;
930
+ /** @internal */
931
+ _shapeUtilsByAssetType = {};
932
+ styleProps;
892
933
  getShapeUtil(arg) {
893
934
  const type = typeof arg === "string" ? arg : arg.type;
894
935
  const shapeUtil = getOwnProperty(this.shapeUtils, type);
@@ -899,12 +940,73 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
899
940
  const type = typeof arg === "string" ? arg : arg.type;
900
941
  return hasOwnProperty(this.shapeUtils, type);
901
942
  }
943
+ /**
944
+ * Get the shape util that handles the given asset type.
945
+ * Returns the shape util whose {@link ShapeUtil.handledAssetTypes} includes
946
+ * the given asset type, or undefined if none matches.
947
+ *
948
+ * @param assetType - The asset type string.
949
+ * @public
950
+ */
951
+ getShapeUtilForAssetType(assetType) {
952
+ return getOwnProperty(this._shapeUtilsByAssetType, assetType);
953
+ }
954
+ /* ------------------- Binding Utils ------------------ */
955
+ /**
956
+ * A map of shape utility classes (TLShapeUtils) by shape type.
957
+ *
958
+ * @public
959
+ */
960
+ bindingUtils;
902
961
  getBindingUtil(arg) {
903
962
  const type = typeof arg === "string" ? arg : arg.type;
904
963
  const bindingUtil = getOwnProperty(this.bindingUtils, type);
905
964
  assert(bindingUtil, `No binding util found for type "${type}"`);
906
965
  return bindingUtil;
907
966
  }
967
+ /* ------------------- Asset Utils ------------------ */
968
+ /**
969
+ * A map of asset utility classes by asset type.
970
+ *
971
+ * @public
972
+ */
973
+ assetUtils = {};
974
+ getAssetUtil(arg) {
975
+ const type = typeof arg === "string" ? arg : arg.type;
976
+ const assetUtil = getOwnProperty(this.assetUtils, type);
977
+ assert(assetUtil, `No asset util found for type "${type}"`);
978
+ return assetUtil;
979
+ }
980
+ /**
981
+ * Returns true if the editor has an asset util for the given asset type.
982
+ *
983
+ * @public
984
+ */
985
+ hasAssetUtil(arg) {
986
+ const type = typeof arg === "string" ? arg : arg.type;
987
+ return hasOwnProperty(this.assetUtils, type);
988
+ }
989
+ /**
990
+ * Get the asset util that accepts the given MIME type.
991
+ * Returns null if no registered asset util accepts the MIME type.
992
+ *
993
+ * @public
994
+ */
995
+ getAssetUtilForMimeType(mimeType) {
996
+ for (const util of Object.values(this.assetUtils)) {
997
+ if (util && util.acceptsMimeType(mimeType)) {
998
+ return util;
999
+ }
1000
+ }
1001
+ return null;
1002
+ }
1003
+ /* --------------------- History -------------------- */
1004
+ /**
1005
+ * A manager for the editor's history.
1006
+ *
1007
+ * @readonly
1008
+ */
1009
+ history;
908
1010
  /**
909
1011
  * Undo to the last mark.
910
1012
  *
@@ -919,6 +1021,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
919
1021
  this._flushEventsForTick(0);
920
1022
  this.complete();
921
1023
  this.history.undo();
1024
+ this.performance._notifyUndoRedo("undo", this.history.getNumUndos(), this.history.getNumRedos());
922
1025
  return this;
923
1026
  }
924
1027
  canUndo() {
@@ -941,6 +1044,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
941
1044
  this._flushEventsForTick(0);
942
1045
  this.complete();
943
1046
  this.history.redo();
1047
+ this.performance._notifyUndoRedo("redo", this.history.getNumUndos(), this.history.getNumRedos());
944
1048
  return this;
945
1049
  }
946
1050
  canRedo() {
@@ -1032,6 +1136,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1032
1136
  this.history.bailToMark(id);
1033
1137
  return this;
1034
1138
  }
1139
+ _shouldIgnoreShapeLock = false;
1035
1140
  /**
1036
1141
  * Run a function in a transaction with optional options for context.
1037
1142
  * You can use the options to change the way that history is treated
@@ -1123,6 +1228,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1123
1228
  };
1124
1229
  }
1125
1230
  }
1231
+ /** @internal */
1232
+ _crashingError = null;
1126
1233
  /**
1127
1234
  * We can't use an `atom` here because there's a chance that when `crashAndReportError` is called,
1128
1235
  * we're in a transaction that's about to be rolled back due to the same error we're currently
@@ -1289,15 +1396,28 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1289
1396
  ]);
1290
1397
  }, opts);
1291
1398
  }
1399
+ /** @internal */
1400
+ _isChangingStyleTimeout = -1;
1401
+ // Menus
1402
+ menus = tlmenus.forContext(this.contextId);
1292
1403
  /* --------------------- Cursor --------------------- */
1293
1404
  /**
1294
1405
  * Set the cursor.
1295
1406
  *
1407
+ * No-op when the partial wouldn't change the current cursor — `setCursor`
1408
+ * is called from pointer-move hot paths (see `updateHoveredOverlayId`,
1409
+ * various tool states) and skipping redundant writes avoids needlessly
1410
+ * dirtying instance state.
1411
+ *
1296
1412
  * @param cursor - The cursor to set.
1297
1413
  * @public
1298
1414
  */
1299
1415
  setCursor(cursor) {
1300
- this.updateInstanceState({ cursor: { ...this.getInstanceState().cursor, ...cursor } });
1416
+ const current = this.getInstanceState().cursor;
1417
+ if ((cursor.type === void 0 || cursor.type === current.type) && (cursor.rotation === void 0 || cursor.rotation === current.rotation)) {
1418
+ return this;
1419
+ }
1420
+ this.updateInstanceState({ cursor: { ...current, ...cursor } });
1301
1421
  return this;
1302
1422
  }
1303
1423
  getPageStates() {
@@ -1854,6 +1974,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1854
1974
  );
1855
1975
  return this;
1856
1976
  }
1977
+ // Rich text editor
1978
+ _currentRichTextEditor = atom("rich text editor", null);
1857
1979
  getRichTextEditor() {
1858
1980
  return this._currentRichTextEditor.get();
1859
1981
  }
@@ -2033,6 +2155,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2033
2155
  }
2034
2156
  return this;
2035
2157
  }
2158
+ _textOptions;
2036
2159
  /**
2037
2160
  * Get the current text options.
2038
2161
  *
@@ -2103,6 +2226,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2103
2226
  getResizeScaleFactor() {
2104
2227
  return this.user.getIsDynamicResizeMode() ? 1 / this.getZoomLevel() : 1;
2105
2228
  }
2229
+ _debouncedZoomLevel = atom("debounced zoom level", 1);
2106
2230
  getDebouncedZoomLevel() {
2107
2231
  if (this.options.debouncedZoom) {
2108
2232
  if (this.getCameraState() === "idle") {
@@ -2207,6 +2331,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2207
2331
  }
2208
2332
  }
2209
2333
  }
2334
+ _cameraOptions = atom("camera options", DEFAULT_CAMERA_OPTIONS);
2210
2335
  /**
2211
2336
  * Get the current camera options.
2212
2337
  *
@@ -2681,6 +2806,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2681
2806
  return this;
2682
2807
  }
2683
2808
  /** @internal */
2809
+ _viewportAnimation = null;
2810
+ /** @internal */
2684
2811
  _animateViewport(ms) {
2685
2812
  if (!this._viewportAnimation) return;
2686
2813
  this._viewportAnimation.elapsed += ms;
@@ -2819,6 +2946,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2819
2946
  });
2820
2947
  return this;
2821
2948
  }
2949
+ // Viewport
2950
+ /** @internal */
2951
+ _willSetInitialBounds = true;
2822
2952
  /**
2823
2953
  * Update the viewport. The viewport will measure the size and screen position of its container
2824
2954
  * element. This should be done whenever the container's position on the screen changes.
@@ -2953,27 +3083,127 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2953
3083
  const { x: cx, y: cy, z: cz = 1 } = this.getCamera();
2954
3084
  return new Vec((point.x + cx) * cz, (point.y + cy) * cz, point.z ?? 0.5);
2955
3085
  }
2956
- _getCollaboratorsQuery() {
2957
- return this.store.query.records("instance_presence", () => ({
2958
- userId: { neq: this.user.getId() }
2959
- }));
2960
- }
3086
+ // Collaborators
3087
+ /**
3088
+ * Returns a list of presence records for all peer collaborators.
3089
+ * This will return the latest presence record for each connected user.
3090
+ *
3091
+ * Convenience wrapper for {@link CollaboratorsManager.getCollaborators}.
3092
+ *
3093
+ * @public
3094
+ */
2961
3095
  getCollaborators() {
2962
- const allPresenceRecords = this._getCollaboratorsQuery().get();
2963
- if (!allPresenceRecords.length) return EMPTY_ARRAY;
2964
- const userIds = [...new Set(allPresenceRecords.map((c) => c.userId))].sort();
2965
- return userIds.map((id) => {
2966
- const latestPresence = maxBy(
2967
- allPresenceRecords.filter((c) => c.userId === id),
2968
- (p) => p.lastActivityTimestamp ?? 0
2969
- );
2970
- return latestPresence;
2971
- });
3096
+ return this.collaborators.getCollaborators();
2972
3097
  }
3098
+ /**
3099
+ * Returns a list of presence records for all peer collaborators on the current page.
3100
+ * This will return the latest presence record for each connected user.
3101
+ *
3102
+ * Convenience wrapper for {@link CollaboratorsManager.getCollaboratorsOnCurrentPage}.
3103
+ *
3104
+ * @public
3105
+ */
2973
3106
  getCollaboratorsOnCurrentPage() {
2974
- const currentPageId = this.getCurrentPageId();
2975
- return this.getCollaborators().filter((c) => c.currentPageId === currentPageId);
3107
+ return this.collaborators.getCollaboratorsOnCurrentPage();
3108
+ }
3109
+ /**
3110
+ * Returns a list of presence records for peer collaborators who should currently be
3111
+ * shown in the UI. Filters {@link Editor.getCollaborators} by activity state
3112
+ * (active / idle / inactive) and visibility rules such as following and highlighted
3113
+ * users. Re-evaluates on the collaborator visibility clock, so callers don't need to
3114
+ * drive their own activity timer.
3115
+ *
3116
+ * Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaborators}.
3117
+ *
3118
+ * @public
3119
+ */
3120
+ getVisibleCollaborators() {
3121
+ return this.collaborators.getVisibleCollaborators();
3122
+ }
3123
+ /**
3124
+ * Returns a list of presence records for peer collaborators who should currently be
3125
+ * shown in the UI, filtered to those on the current page.
3126
+ *
3127
+ * Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaboratorsOnCurrentPage}.
3128
+ *
3129
+ * @public
3130
+ */
3131
+ getVisibleCollaboratorsOnCurrentPage() {
3132
+ return this.collaborators.getVisibleCollaboratorsOnCurrentPage();
3133
+ }
3134
+ // Attribution
3135
+ /**
3136
+ * Get the current user's ID for attribution purposes.
3137
+ * Also ensures a `user:` record exists in the store for the current user.
3138
+ * Returns `null` when the user store has no current user.
3139
+ *
3140
+ * @public
3141
+ */
3142
+ getAttributionUserId() {
3143
+ const user = this.store.props.users.currentUser.get();
3144
+ if (!user) return null;
3145
+ this._ensureUserRecord(user);
3146
+ return UserRecordType.parseId(user.id);
3147
+ }
3148
+ /**
3149
+ * Ensure a user record exists in the store for the given user,
3150
+ * updating it if the data has changed.
3151
+ *
3152
+ * @internal
3153
+ */
3154
+ _ensureUserRecord(user) {
3155
+ const existing = this.store.get(user.id);
3156
+ if (existing && existing.name === user.name && existing.color === user.color && existing.imageUrl === user.imageUrl && existing.meta === user.meta) {
3157
+ return;
3158
+ }
3159
+ this.run(
3160
+ () => {
3161
+ this.store.put([user]);
3162
+ },
3163
+ { history: "ignore" }
3164
+ );
3165
+ }
3166
+ /**
3167
+ * Resolve a display name for a user ID. Asks the
3168
+ * {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
3169
+ * falling back to the `user:` record in the store.
3170
+ *
3171
+ * @public
3172
+ */
3173
+ getAttributionDisplayName(userId) {
3174
+ if (!userId) return null;
3175
+ return this.store.props.users.resolve(userId).get()?.name ?? this.store.get(createUserId(userId))?.name ?? null;
3176
+ }
3177
+ /**
3178
+ * Resolve a user record by ID. Asks the
3179
+ * {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
3180
+ * falling back to the `user:` record in the store.
3181
+ *
3182
+ * @public
3183
+ */
3184
+ getAttributionUser(userId) {
3185
+ if (!userId) return null;
3186
+ return this.store.props.users.resolve(userId).get() ?? this.store.get(createUserId(userId)) ?? null;
3187
+ }
3188
+ /**
3189
+ * Collect user IDs referenced by a set of shapes via shape-specific props
3190
+ * (e.g. `textFirstEditedBy` on notes).
3191
+ *
3192
+ * @internal
3193
+ */
3194
+ _getReferencedUserIds(shapes) {
3195
+ const userIds = /* @__PURE__ */ new Set();
3196
+ for (const shape of shapes) {
3197
+ const util = this.getShapeUtil(shape);
3198
+ for (const id of util.getReferencedUserIds(shape)) {
3199
+ userIds.add(id);
3200
+ }
3201
+ }
3202
+ return userIds;
2976
3203
  }
3204
+ // Following
3205
+ // When we are 'locked on' to a user, our camera is derived from their camera.
3206
+ _isLockedOnFollowingUser = atom("isLockedOnFollowingUser", false);
2977
3207
  /**
2978
3208
  * Start viewport-following a user.
2979
3209
  *
@@ -3149,6 +3379,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3149
3379
  }
3150
3380
  return renderingShapes;
3151
3381
  }
3382
+ // Camera state
3383
+ // Camera state does two things: first, it allows us to subscribe to whether
3384
+ // the camera is moving or not; and second, it allows us to update the rendering
3385
+ // shapes on the canvas. Changing the rendering shapes may cause shapes to
3386
+ // unmount / remount in the DOM, which is expensive; and computing visibility is
3387
+ // also expensive in large projects. For this reason, we use a second bounding
3388
+ // box just for rendering, and we only update after the camera stops moving.
3389
+ _cameraStateTimeoutRemaining = 0;
3152
3390
  _decayCameraStateTimeout(elapsed) {
3153
3391
  this._cameraStateTimeoutRemaining -= elapsed;
3154
3392
  if (this._cameraStateTimeoutRemaining > 0) return;
@@ -3220,6 +3458,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3220
3458
  getPage(page) {
3221
3459
  return this.store.get(typeof page === "string" ? page : page.id);
3222
3460
  }
3461
+ /* @internal */
3462
+ _currentPageShapeIds;
3223
3463
  /**
3224
3464
  * An array of all of the shapes on the current page.
3225
3465
  *
@@ -3525,7 +3765,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3525
3765
  } = context;
3526
3766
  const zoomStepFunction = (zoom) => Math.pow(2, Math.ceil(Math.log2(zoom)));
3527
3767
  const steppedScreenScale = zoomStepFunction(screenScale);
3528
- const networkEffectiveType = "connection" in navigator ? navigator.connection.effectiveType : null;
3768
+ const networkEffectiveType = "connection" in navigator ? navigator.connection?.effectiveType ?? null : null;
3529
3769
  return await this.store.props.assets.resolve(asset, {
3530
3770
  screenScale: screenScale || 1,
3531
3771
  steppedScreenScale,
@@ -3541,6 +3781,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3541
3781
  async uploadAsset(asset, file, abortSignal) {
3542
3782
  return await this.store.props.assets.upload(asset, file, abortSignal);
3543
3783
  }
3784
+ /* --------------------- Shapes --------------------- */
3785
+ _shapeGeometryCaches = {};
3544
3786
  /**
3545
3787
  * Get the geometry of a shape in shape-space.
3546
3788
  *
@@ -3911,6 +4153,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3911
4153
  getNotVisibleShapes() {
3912
4154
  return this._notVisibleShapes.get();
3913
4155
  }
4156
+ _notVisibleShapes = notVisibleShapes(this);
4157
+ _culledShapesCache = null;
3914
4158
  getCulledShapes() {
3915
4159
  const notVisibleShapes2 = this.getNotVisibleShapes();
3916
4160
  const selectedShapeIds = this.getSelectedShapeIds();
@@ -3991,7 +4235,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3991
4235
  const searchMargin = Math.max(innerMargin, outerMargin, this.options.hitTestMargin / zoomLevel);
3992
4236
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, searchMargin);
3993
4237
  const shapesToCheck = (opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted()).filter((shape) => {
3994
- if (!candidateIds.has(shape.id) && !this.isShapeOfType(shape, "frame")) return false;
4238
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
3995
4239
  if (shape.isLocked && !hitLocked || this.isShapeHidden(shape) || this.isShapeOfType(shape, "group"))
3996
4240
  return false;
3997
4241
  const pageMask = this.getShapeMask(shape);
@@ -4004,14 +4248,16 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4004
4248
  const geometry = this.getShapeGeometry(shape);
4005
4249
  const isGroup = geometry instanceof Group2d;
4006
4250
  const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
4007
- if (this.isShapeOfType(shape, "frame") || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && this.getShapeUtil(shape).getText(shape)?.trim()) {
4251
+ const shapeUtil = this.getShapeUtil(shape);
4252
+ const isShapeFrameLike = this.isShapeFrameLike(shape);
4253
+ if (isShapeFrameLike || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && shapeUtil.getText(shape)?.trim()) {
4008
4254
  for (const childGeometry of geometry.children) {
4009
4255
  if (childGeometry.isLabel && childGeometry.isPointInBounds(pointInShapeSpace)) {
4010
4256
  return shape;
4011
4257
  }
4012
4258
  }
4013
4259
  }
4014
- if (this.isShapeOfType(shape, "frame")) {
4260
+ if (isShapeFrameLike) {
4015
4261
  const distance2 = geometry.distanceToPoint(pointInShapeSpace, hitFrameInside);
4016
4262
  if (hitFrameInside ? distance2 > 0 && distance2 <= outerMargin || distance2 <= 0 && distance2 > -innerMargin : distance2 > 0 && distance2 <= outerMargin) {
4017
4263
  return inMarginClosestToEdgeHit || shape;
@@ -4105,7 +4351,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4105
4351
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, margin);
4106
4352
  return this.getCurrentPageShapesSorted().filter((shape) => {
4107
4353
  if (this.isShapeHidden(shape)) return false;
4108
- if (!candidateIds.has(shape.id) && !this.isShapeOfType(shape, "frame")) return false;
4354
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
4109
4355
  return this.isPointInShape(shape, point, opts);
4110
4356
  }).reverse();
4111
4357
  }
@@ -4218,6 +4464,24 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4218
4464
  if (!shape) return false;
4219
4465
  return shape.type === type;
4220
4466
  }
4467
+ /**
4468
+ * Get whether a shape behaves like a frame — a container that has child
4469
+ * shapes, requires full-brush selection, blocks erasure from inside, etc.
4470
+ *
4471
+ * @example
4472
+ * ```ts
4473
+ * const isFrameLike = editor.isShapeFrameLike(someShape)
4474
+ * ```
4475
+ *
4476
+ * @param shape - The shape (or shape id) to test.
4477
+ *
4478
+ * @public
4479
+ */
4480
+ isShapeFrameLike(shape) {
4481
+ const _shape = typeof shape === "string" ? this.getShape(shape) : shape;
4482
+ if (!_shape) return false;
4483
+ return this.getShapeUtil(_shape).isFrameLike(_shape);
4484
+ }
4221
4485
  /**
4222
4486
  * Get a shape by its id.
4223
4487
  *
@@ -4325,6 +4589,13 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4325
4589
  return this.getAncestorPageId(this.getShape(_shape.parentId));
4326
4590
  }
4327
4591
  }
4592
+ // Parents and children
4593
+ /**
4594
+ * A cache of parents to children.
4595
+ *
4596
+ * @internal
4597
+ */
4598
+ _parentIdsToChildIds;
4328
4599
  /**
4329
4600
  * Reparent shapes to a new parent. This operation preserves the shape's current page positions /
4330
4601
  * rotations.
@@ -5969,6 +6240,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
5969
6240
  });
5970
6241
  return this;
5971
6242
  }
6243
+ animatingShapes = /* @__PURE__ */ new Map();
5972
6244
  /**
5973
6245
  * Animate a shape.
5974
6246
  *
@@ -6462,6 +6734,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6462
6734
  }
6463
6735
  return this;
6464
6736
  }
6737
+ /* --------------------- Content -------------------- */
6738
+ /** @internal */
6739
+ externalAssetContentHandlers = {
6740
+ file: null,
6741
+ url: null
6742
+ };
6743
+ /** @internal */
6744
+ temporaryAssetPreview = /* @__PURE__ */ new Map();
6465
6745
  /**
6466
6746
  * Register an external asset handler. This handler will be called when the editor needs to
6467
6747
  * create an asset for some external content, like an image/video file or a bookmark URL. For
@@ -6547,6 +6827,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6547
6827
  hasExternalAssetHandler(type) {
6548
6828
  return !!this.externalAssetContentHandlers[type];
6549
6829
  }
6830
+ /** @internal */
6831
+ externalContentHandlers = {
6832
+ text: null,
6833
+ files: null,
6834
+ "file-replace": null,
6835
+ embed: null,
6836
+ "svg-text": null,
6837
+ url: null,
6838
+ tldraw: null,
6839
+ excalidraw: null
6840
+ };
6550
6841
  /**
6551
6842
  * Register an external content handler. This handler will be called when the editor receives
6552
6843
  * external content of the provided type. For example, the 'image' type handler will be called
@@ -6643,12 +6934,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6643
6934
  if (!asset) continue;
6644
6935
  assets.push(asset);
6645
6936
  }
6937
+ const users = [];
6938
+ const seenUserIds = /* @__PURE__ */ new Set();
6939
+ for (const userId of this._getReferencedUserIds(shapes2)) {
6940
+ const recordId = createUserId(userId);
6941
+ if (seenUserIds.has(recordId)) continue;
6942
+ seenUserIds.add(recordId);
6943
+ const user = this.store.get(recordId);
6944
+ if (user) users.push(user);
6945
+ }
6646
6946
  return {
6647
6947
  schema: this.store.schema.serialize(),
6648
6948
  shapes: shapes2,
6649
6949
  rootShapeIds,
6650
6950
  bindings,
6651
- assets
6951
+ assets,
6952
+ users
6652
6953
  };
6653
6954
  });
6654
6955
  }
@@ -6698,13 +6999,15 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6698
6999
  const assets = [];
6699
7000
  const shapes = [];
6700
7001
  const bindings = [];
7002
+ const users = [];
6701
7003
  const store = {
6702
7004
  store: {
6703
7005
  ...Object.fromEntries(content.assets.map((asset) => [asset.id, asset])),
6704
7006
  ...Object.fromEntries(content.shapes.map((shape) => [shape.id, shape])),
6705
7007
  ...Object.fromEntries(
6706
7008
  content.bindings?.map((bindings2) => [bindings2.id, bindings2]) ?? []
6707
- )
7009
+ ),
7010
+ ...Object.fromEntries(content.users?.map((user) => [user.id, user]) ?? [])
6708
7011
  },
6709
7012
  schema: content.schema
6710
7013
  };
@@ -6726,6 +7029,19 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6726
7029
  bindings.push(record);
6727
7030
  break;
6728
7031
  }
7032
+ case "user": {
7033
+ users.push(record);
7034
+ break;
7035
+ }
7036
+ }
7037
+ }
7038
+ if (users.length > 0) {
7039
+ const existingUserIds = new Set(
7040
+ this.store.allRecords().filter((r) => r.typeName === "user").map((r) => r.id)
7041
+ );
7042
+ const usersToCreate = users.filter((u) => !existingUserIds.has(u.id));
7043
+ if (usersToCreate.length > 0) {
7044
+ this.store.put(usersToCreate);
6729
7045
  }
6730
7046
  }
6731
7047
  const shapeIdMap = new Map(
@@ -7436,6 +7752,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7436
7752
  scheduleEffect.cancel();
7437
7753
  };
7438
7754
  }
7755
+ /**
7756
+ * A manager for recording multiple click events.
7757
+ *
7758
+ * @internal
7759
+ */
7760
+ _clickManager = new ClickManager(this);
7439
7761
  /**
7440
7762
  * Prevent a double click event from firing the next time the user clicks
7441
7763
  *
@@ -7444,6 +7766,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7444
7766
  cancelDoubleClick() {
7445
7767
  this._clickManager.cancelDoubleClickTimeout();
7446
7768
  }
7769
+ /**
7770
+ * The previous cursor. Used for restoring the cursor after pan events.
7771
+ *
7772
+ * @internal
7773
+ */
7774
+ _prevCursor = "default";
7775
+ /** @internal */
7776
+ _shiftKeyTimeout = -1;
7447
7777
  _setShiftKeyTimeout() {
7448
7778
  this.inputs.setShiftKey(false);
7449
7779
  this.dispatch({
@@ -7458,6 +7788,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7458
7788
  code: "ShiftLeft"
7459
7789
  });
7460
7790
  }
7791
+ /** @internal */
7792
+ _altKeyTimeout = -1;
7461
7793
  _setAltKeyTimeout() {
7462
7794
  this.inputs.setAltKey(false);
7463
7795
  this.dispatch({
@@ -7472,6 +7804,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7472
7804
  code: "AltLeft"
7473
7805
  });
7474
7806
  }
7807
+ /** @internal */
7808
+ _ctrlKeyTimeout = -1;
7475
7809
  _setCtrlKeyTimeout() {
7476
7810
  this.inputs.setCtrlKey(false);
7477
7811
  this.dispatch({
@@ -7486,6 +7820,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7486
7820
  code: "ControlLeft"
7487
7821
  });
7488
7822
  }
7823
+ /** @internal */
7824
+ _metaKeyTimeout = -1;
7489
7825
  _setMetaKeyTimeout() {
7490
7826
  this.inputs.setMetaKey(false);
7491
7827
  this.dispatch({
@@ -7500,6 +7836,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7500
7836
  code: "MetaLeft"
7501
7837
  });
7502
7838
  }
7839
+ /** @internal */
7840
+ _restoreToolId = "select";
7841
+ /** @internal */
7842
+ _didPinch = false;
7843
+ /** @internal */
7844
+ _selectedShapeIdsAtPointerDown = [];
7845
+ /** @internal */
7846
+ _longPressTimeout = -1;
7847
+ /** @internal */
7848
+ capturedPointerId = null;
7849
+ /** @internal */
7850
+ performanceTracker;
7851
+ /** @internal */
7852
+ performanceTrackerTimeout = -1;
7853
+ /** @internal */
7854
+ handledEvents = /* @__PURE__ */ new WeakSet();
7503
7855
  /**
7504
7856
  * In tldraw, events are sometimes handled by multiple components. For example, the shapes might
7505
7857
  * have events, but the canvas handles events too. The way that the canvas handles events can
@@ -7545,6 +7897,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7545
7897
  }
7546
7898
  return this;
7547
7899
  }
7900
+ _pendingEventsForNextTick = [];
7548
7901
  _flushEventsForTick(elapsed) {
7549
7902
  this.run(() => {
7550
7903
  if (this._pendingEventsForNextTick.length > 0) {
@@ -7654,6 +8007,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7654
8007
  ),
7655
8008
  { immediate: true }
7656
8009
  );
8010
+ this.performance._notifyCameraOperation("zooming");
7657
8011
  this.emit("event", info);
7658
8012
  return;
7659
8013
  }
@@ -7715,6 +8069,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7715
8069
  immediate: true
7716
8070
  });
7717
8071
  this.maybeTrackPerformance("Zooming");
8072
+ this.performance._notifyCameraOperation("zooming");
7718
8073
  this.root.handleEvent(info);
7719
8074
  this.emit("event", info);
7720
8075
  return;
@@ -7724,6 +8079,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7724
8079
  immediate: true
7725
8080
  });
7726
8081
  this.maybeTrackPerformance("Panning");
8082
+ this.performance._notifyCameraOperation("panning");
7727
8083
  this.root.handleEvent(info);
7728
8084
  this.emit("event", info);
7729
8085
  return;
@@ -7770,6 +8126,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7770
8126
  }
7771
8127
  this.inputs.setIsPanning(true);
7772
8128
  clearTimeout(this._longPressTimeout);
8129
+ } else if (info.button === RIGHT_MOUSE_BUTTON && this.options.rightClickPanning) {
8130
+ this.inputs.setIsRightPointing(true);
8131
+ clearTimeout(this._longPressTimeout);
8132
+ return this;
7773
8133
  }
7774
8134
  if (this.inputs.getIsPanning()) {
7775
8135
  this.stopCameraAnimation();
@@ -7781,6 +8141,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7781
8141
  case "pointer_move": {
7782
8142
  if (!isPen && isPenMode) return;
7783
8143
  const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera());
8144
+ if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
8145
+ const currentScreenPoint = this.inputs.getCurrentScreenPoint();
8146
+ const originScreenPoint = this.inputs.getOriginScreenPoint();
8147
+ if (Vec.Dist2(originScreenPoint, currentScreenPoint) > this.options.dragDistanceSquared) {
8148
+ this._prevCursor = this.getInstanceState().cursor.type;
8149
+ this.inputs.setIsPanning(true);
8150
+ this.setCursor({ type: "grabbing", rotation: 0 });
8151
+ this.stopCameraAnimation();
8152
+ const offset = Vec.Sub(currentScreenPoint, originScreenPoint);
8153
+ this.setCamera(new Vec(cx + offset.x / cz, cy + offset.y / cz, cz), {
8154
+ immediate: true
8155
+ });
8156
+ this.maybeTrackPerformance("Panning");
8157
+ }
8158
+ return;
8159
+ }
7784
8160
  if (this.inputs.getIsPanning() && this.inputs.getIsPointing()) {
7785
8161
  const currentScreenPoint = this.inputs.getCurrentScreenPoint();
7786
8162
  const previousScreenPoint = this.inputs.getPreviousScreenPoint();
@@ -7789,6 +8165,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7789
8165
  immediate: true
7790
8166
  });
7791
8167
  this.maybeTrackPerformance("Panning");
8168
+ this.performance._notifyCameraOperation("panning");
7792
8169
  return;
7793
8170
  }
7794
8171
  if (inputs.getIsPointing() && !inputs.getIsDragging() && Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
@@ -7803,6 +8180,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7803
8180
  clearTimeout(this._longPressTimeout);
7804
8181
  inputs.buttons.delete(info.button);
7805
8182
  if (instanceState.isPenMode && !isPen) return;
8183
+ if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
8184
+ this.inputs.setIsRightPointing(false);
8185
+ this._selectedShapeIdsAtPointerDown = [];
8186
+ break;
8187
+ }
8188
+ this.inputs.setIsRightPointing(false);
7806
8189
  if (this.capturedPointerId === info.pointerId) {
7807
8190
  this.capturedPointerId = null;
7808
8191
  info.button = 0;
@@ -7820,11 +8203,24 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7820
8203
  break;
7821
8204
  }
7822
8205
  case MIDDLE_MOUSE_BUTTON: {
7823
- if (this.inputs.keys.has(" ")) {
8206
+ if (this.inputs.keys.has("Space")) {
7824
8207
  this.setCursor({ type: "grab", rotation: 0 });
7825
8208
  } else {
7826
8209
  this.setCursor({ type: this._prevCursor, rotation: 0 });
7827
8210
  }
8211
+ break;
8212
+ }
8213
+ case RIGHT_MOUSE_BUTTON: {
8214
+ if (this.inputs.keys.has("Space")) {
8215
+ this.setCursor({ type: "grab", rotation: 0 });
8216
+ } else {
8217
+ this.setCursor({ type: this._prevCursor, rotation: 0 });
8218
+ }
8219
+ if (slideSpeed > 0) {
8220
+ this.slideCamera({ speed: slideSpeed, direction: slideDirection });
8221
+ }
8222
+ this._selectedShapeIdsAtPointerDown = [];
8223
+ return this;
7828
8224
  }
7829
8225
  }
7830
8226
  if (slideSpeed > 0) {
@@ -7952,83 +8348,222 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7952
8348
  }
7953
8349
  }
7954
8350
  }
7955
- _init = __decoratorStart(_a);
7956
- __decorateElement(_init, 1, "getIsShapeHiddenCache", _getIsShapeHiddenCache_dec, Editor);
7957
- __decorateElement(_init, 1, "canUndo", _canUndo_dec, Editor);
7958
- __decorateElement(_init, 1, "canRedo", _canRedo_dec, Editor);
7959
- __decorateElement(_init, 1, "getPath", _getPath_dec, Editor);
7960
- __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
7961
- __decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
7962
- __decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
7963
- __decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
7964
- __decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
7965
- __decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
7966
- __decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);
7967
- __decorateElement(_init, 1, "_getCurrentPageStateId", __getCurrentPageStateId_dec, Editor);
7968
- __decorateElement(_init, 1, "getSelectedShapeIds", _getSelectedShapeIds_dec, Editor);
7969
- __decorateElement(_init, 1, "getSelectedShapes", _getSelectedShapes_dec, Editor);
7970
- __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPageShapesInReadingOrder_dec, Editor);
7971
- __decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
7972
- __decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
7973
- __decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
7974
- __decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
7975
- __decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
7976
- __decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);
7977
- __decorateElement(_init, 1, "getFocusedGroupId", _getFocusedGroupId_dec, Editor);
7978
- __decorateElement(_init, 1, "getFocusedGroup", _getFocusedGroup_dec, Editor);
7979
- __decorateElement(_init, 1, "getEditingShapeId", _getEditingShapeId_dec, Editor);
7980
- __decorateElement(_init, 1, "getEditingShape", _getEditingShape_dec, Editor);
7981
- __decorateElement(_init, 1, "getRichTextEditor", _getRichTextEditor_dec, Editor);
7982
- __decorateElement(_init, 1, "getHoveredShapeId", _getHoveredShapeId_dec, Editor);
7983
- __decorateElement(_init, 1, "getHoveredShape", _getHoveredShape_dec, Editor);
7984
- __decorateElement(_init, 1, "getHintingShapeIds", _getHintingShapeIds_dec, Editor);
7985
- __decorateElement(_init, 1, "getHintingShape", _getHintingShape_dec, Editor);
7986
- __decorateElement(_init, 1, "getErasingShapeIds", _getErasingShapeIds_dec, Editor);
7987
- __decorateElement(_init, 1, "getErasingShapes", _getErasingShapes_dec, Editor);
7988
- __decorateElement(_init, 1, "_unsafe_getCameraId", __unsafe_getCameraId_dec, Editor);
7989
- __decorateElement(_init, 1, "getCamera", _getCamera_dec, Editor);
7990
- __decorateElement(_init, 1, "getViewportPageBoundsForFollowing", _getViewportPageBoundsForFollowing_dec, Editor);
7991
- __decorateElement(_init, 1, "getCameraForFollowing", _getCameraForFollowing_dec, Editor);
7992
- __decorateElement(_init, 1, "getZoomLevel", _getZoomLevel_dec, Editor);
7993
- __decorateElement(_init, 1, "getResizeScaleFactor", _getResizeScaleFactor_dec, Editor);
7994
- __decorateElement(_init, 1, "getDebouncedZoomLevel", _getDebouncedZoomLevel_dec, Editor);
7995
- __decorateElement(_init, 1, "_getAboveDebouncedZoomThreshold", __getAboveDebouncedZoomThreshold_dec, Editor);
7996
- __decorateElement(_init, 1, "getEfficientZoomLevel", _getEfficientZoomLevel_dec, Editor);
7997
- __decorateElement(_init, 1, "getViewportScreenBounds", _getViewportScreenBounds_dec, Editor);
7998
- __decorateElement(_init, 1, "getViewportScreenCenter", _getViewportScreenCenter_dec, Editor);
7999
- __decorateElement(_init, 1, "getViewportPageBounds", _getViewportPageBounds_dec, Editor);
8000
- __decorateElement(_init, 1, "_getCollaboratorsQuery", __getCollaboratorsQuery_dec, Editor);
8001
- __decorateElement(_init, 1, "getCollaborators", _getCollaborators_dec, Editor);
8002
- __decorateElement(_init, 1, "getCollaboratorsOnCurrentPage", _getCollaboratorsOnCurrentPage_dec, Editor);
8003
- __decorateElement(_init, 1, "getRenderingShapes", _getRenderingShapes_dec, Editor);
8004
- __decorateElement(_init, 1, "_getAllPagesQuery", __getAllPagesQuery_dec, Editor);
8005
- __decorateElement(_init, 1, "getPages", _getPages_dec, Editor);
8006
- __decorateElement(_init, 1, "getCurrentPageId", _getCurrentPageId_dec, Editor);
8007
- __decorateElement(_init, 1, "getCurrentPageShapeIdsSorted", _getCurrentPageShapeIdsSorted_dec, Editor);
8008
- __decorateElement(_init, 1, "_getAllAssetsQuery", __getAllAssetsQuery_dec, Editor);
8009
- __decorateElement(_init, 1, "_getShapeHandlesCache", __getShapeHandlesCache_dec, Editor);
8010
- __decorateElement(_init, 1, "_getShapePageTransformCache", __getShapePageTransformCache_dec, Editor);
8011
- __decorateElement(_init, 1, "_getShapePageBoundsCache", __getShapePageBoundsCache_dec, Editor);
8012
- __decorateElement(_init, 1, "_getShapeClipPathCache", __getShapeClipPathCache_dec, Editor);
8013
- __decorateElement(_init, 1, "_getShapeMaskCache", __getShapeMaskCache_dec, Editor);
8014
- __decorateElement(_init, 1, "_getShapeMaskedPageBoundsCache", __getShapeMaskedPageBoundsCache_dec, Editor);
8015
- __decorateElement(_init, 1, "getNotVisibleShapes", _getNotVisibleShapes_dec, Editor);
8016
- __decorateElement(_init, 1, "getCulledShapes", _getCulledShapes_dec, Editor);
8017
- __decorateElement(_init, 1, "getCurrentPageBounds", _getCurrentPageBounds_dec, Editor);
8018
- __decorateElement(_init, 1, "getCurrentPageShapes", _getCurrentPageShapes_dec, Editor);
8019
- __decorateElement(_init, 1, "getCurrentPageShapesSorted", _getCurrentPageShapesSorted_dec, Editor);
8020
- __decorateElement(_init, 1, "getCurrentPageRenderingShapesSorted", _getCurrentPageRenderingShapesSorted_dec, Editor);
8021
- __decorateElement(_init, 1, "_getBindingsIndexCache", __getBindingsIndexCache_dec, Editor);
8022
- __decorateElement(_init, 1, "_getSelectionSharedStyles", __getSelectionSharedStyles_dec, Editor);
8023
- __decorateElement(_init, 1, "getSharedStyles", _getSharedStyles_dec, Editor);
8024
- __decorateElement(_init, 1, "getSharedOpacity", _getSharedOpacity_dec, Editor);
8025
- __decorateElement(_init, 1, "getIsFocused", _getIsFocused_dec, Editor);
8026
- __decorateElement(_init, 1, "getIsReadonly", _getIsReadonly_dec, Editor);
8027
- __decorateElement(_init, 1, "_setShiftKeyTimeout", __setShiftKeyTimeout_dec, Editor);
8028
- __decorateElement(_init, 1, "_setAltKeyTimeout", __setAltKeyTimeout_dec, Editor);
8029
- __decorateElement(_init, 1, "_setCtrlKeyTimeout", __setCtrlKeyTimeout_dec, Editor);
8030
- __decorateElement(_init, 1, "_setMetaKeyTimeout", __setMetaKeyTimeout_dec, Editor);
8031
- __decoratorMetadata(_init, Editor);
8351
+ __decorateClass([
8352
+ computed
8353
+ ], Editor.prototype, "getIsShapeHiddenCache", 1);
8354
+ __decorateClass([
8355
+ computed
8356
+ ], Editor.prototype, "canUndo", 1);
8357
+ __decorateClass([
8358
+ computed
8359
+ ], Editor.prototype, "canRedo", 1);
8360
+ __decorateClass([
8361
+ computed
8362
+ ], Editor.prototype, "getPath", 1);
8363
+ __decorateClass([
8364
+ computed
8365
+ ], Editor.prototype, "getCurrentTool", 1);
8366
+ __decorateClass([
8367
+ computed
8368
+ ], Editor.prototype, "getCurrentToolId", 1);
8369
+ __decorateClass([
8370
+ computed
8371
+ ], Editor.prototype, "getDocumentSettings", 1);
8372
+ __decorateClass([
8373
+ computed
8374
+ ], Editor.prototype, "getInstanceState", 1);
8375
+ __decorateClass([
8376
+ computed
8377
+ ], Editor.prototype, "getPageStates", 1);
8378
+ __decorateClass([
8379
+ computed
8380
+ ], Editor.prototype, "_getPageStatesQuery", 1);
8381
+ __decorateClass([
8382
+ computed
8383
+ ], Editor.prototype, "getCurrentPageState", 1);
8384
+ __decorateClass([
8385
+ computed
8386
+ ], Editor.prototype, "_getCurrentPageStateId", 1);
8387
+ __decorateClass([
8388
+ computed
8389
+ ], Editor.prototype, "getSelectedShapeIds", 1);
8390
+ __decorateClass([
8391
+ computed
8392
+ ], Editor.prototype, "getSelectedShapes", 1);
8393
+ __decorateClass([
8394
+ computed
8395
+ ], Editor.prototype, "getCurrentPageShapesInReadingOrder", 1);
8396
+ __decorateClass([
8397
+ computed
8398
+ ], Editor.prototype, "getOnlySelectedShapeId", 1);
8399
+ __decorateClass([
8400
+ computed
8401
+ ], Editor.prototype, "getOnlySelectedShape", 1);
8402
+ __decorateClass([
8403
+ computed
8404
+ ], Editor.prototype, "getSelectionPageBounds", 1);
8405
+ __decorateClass([
8406
+ computed
8407
+ ], Editor.prototype, "getSelectionRotation", 1);
8408
+ __decorateClass([
8409
+ computed
8410
+ ], Editor.prototype, "getSelectionRotatedPageBounds", 1);
8411
+ __decorateClass([
8412
+ computed
8413
+ ], Editor.prototype, "getSelectionRotatedScreenBounds", 1);
8414
+ __decorateClass([
8415
+ computed
8416
+ ], Editor.prototype, "getFocusedGroupId", 1);
8417
+ __decorateClass([
8418
+ computed
8419
+ ], Editor.prototype, "getFocusedGroup", 1);
8420
+ __decorateClass([
8421
+ computed
8422
+ ], Editor.prototype, "getEditingShapeId", 1);
8423
+ __decorateClass([
8424
+ computed
8425
+ ], Editor.prototype, "getEditingShape", 1);
8426
+ __decorateClass([
8427
+ computed
8428
+ ], Editor.prototype, "getRichTextEditor", 1);
8429
+ __decorateClass([
8430
+ computed
8431
+ ], Editor.prototype, "getHoveredShapeId", 1);
8432
+ __decorateClass([
8433
+ computed
8434
+ ], Editor.prototype, "getHoveredShape", 1);
8435
+ __decorateClass([
8436
+ computed
8437
+ ], Editor.prototype, "getHintingShapeIds", 1);
8438
+ __decorateClass([
8439
+ computed
8440
+ ], Editor.prototype, "getHintingShape", 1);
8441
+ __decorateClass([
8442
+ computed
8443
+ ], Editor.prototype, "getErasingShapeIds", 1);
8444
+ __decorateClass([
8445
+ computed
8446
+ ], Editor.prototype, "getErasingShapes", 1);
8447
+ __decorateClass([
8448
+ computed
8449
+ ], Editor.prototype, "_unsafe_getCameraId", 1);
8450
+ __decorateClass([
8451
+ computed
8452
+ ], Editor.prototype, "getCamera", 1);
8453
+ __decorateClass([
8454
+ computed
8455
+ ], Editor.prototype, "getViewportPageBoundsForFollowing", 1);
8456
+ __decorateClass([
8457
+ computed
8458
+ ], Editor.prototype, "getCameraForFollowing", 1);
8459
+ __decorateClass([
8460
+ computed
8461
+ ], Editor.prototype, "getZoomLevel", 1);
8462
+ __decorateClass([
8463
+ computed
8464
+ ], Editor.prototype, "getResizeScaleFactor", 1);
8465
+ __decorateClass([
8466
+ computed
8467
+ ], Editor.prototype, "getDebouncedZoomLevel", 1);
8468
+ __decorateClass([
8469
+ computed
8470
+ ], Editor.prototype, "_getAboveDebouncedZoomThreshold", 1);
8471
+ __decorateClass([
8472
+ computed
8473
+ ], Editor.prototype, "getEfficientZoomLevel", 1);
8474
+ __decorateClass([
8475
+ computed
8476
+ ], Editor.prototype, "getViewportScreenBounds", 1);
8477
+ __decorateClass([
8478
+ computed
8479
+ ], Editor.prototype, "getViewportScreenCenter", 1);
8480
+ __decorateClass([
8481
+ computed
8482
+ ], Editor.prototype, "getViewportPageBounds", 1);
8483
+ __decorateClass([
8484
+ computed
8485
+ ], Editor.prototype, "getRenderingShapes", 1);
8486
+ __decorateClass([
8487
+ computed
8488
+ ], Editor.prototype, "_getAllPagesQuery", 1);
8489
+ __decorateClass([
8490
+ computed
8491
+ ], Editor.prototype, "getPages", 1);
8492
+ __decorateClass([
8493
+ computed
8494
+ ], Editor.prototype, "getCurrentPageId", 1);
8495
+ __decorateClass([
8496
+ computed
8497
+ ], Editor.prototype, "getCurrentPageShapeIdsSorted", 1);
8498
+ __decorateClass([
8499
+ computed
8500
+ ], Editor.prototype, "_getAllAssetsQuery", 1);
8501
+ __decorateClass([
8502
+ computed
8503
+ ], Editor.prototype, "_getShapeHandlesCache", 1);
8504
+ __decorateClass([
8505
+ computed
8506
+ ], Editor.prototype, "_getShapePageTransformCache", 1);
8507
+ __decorateClass([
8508
+ computed
8509
+ ], Editor.prototype, "_getShapePageBoundsCache", 1);
8510
+ __decorateClass([
8511
+ computed
8512
+ ], Editor.prototype, "_getShapeClipPathCache", 1);
8513
+ __decorateClass([
8514
+ computed
8515
+ ], Editor.prototype, "_getShapeMaskCache", 1);
8516
+ __decorateClass([
8517
+ computed
8518
+ ], Editor.prototype, "_getShapeMaskedPageBoundsCache", 1);
8519
+ __decorateClass([
8520
+ computed
8521
+ ], Editor.prototype, "getNotVisibleShapes", 1);
8522
+ __decorateClass([
8523
+ computed
8524
+ ], Editor.prototype, "getCulledShapes", 1);
8525
+ __decorateClass([
8526
+ computed
8527
+ ], Editor.prototype, "getCurrentPageBounds", 1);
8528
+ __decorateClass([
8529
+ computed
8530
+ ], Editor.prototype, "getCurrentPageShapes", 1);
8531
+ __decorateClass([
8532
+ computed
8533
+ ], Editor.prototype, "getCurrentPageShapesSorted", 1);
8534
+ __decorateClass([
8535
+ computed
8536
+ ], Editor.prototype, "getCurrentPageRenderingShapesSorted", 1);
8537
+ __decorateClass([
8538
+ computed
8539
+ ], Editor.prototype, "_getBindingsIndexCache", 1);
8540
+ __decorateClass([
8541
+ computed
8542
+ ], Editor.prototype, "_getSelectionSharedStyles", 1);
8543
+ __decorateClass([
8544
+ computed({ isEqual: (a, b) => a.equals(b) })
8545
+ ], Editor.prototype, "getSharedStyles", 1);
8546
+ __decorateClass([
8547
+ computed
8548
+ ], Editor.prototype, "getSharedOpacity", 1);
8549
+ __decorateClass([
8550
+ computed
8551
+ ], Editor.prototype, "getIsFocused", 1);
8552
+ __decorateClass([
8553
+ computed
8554
+ ], Editor.prototype, "getIsReadonly", 1);
8555
+ __decorateClass([
8556
+ bind
8557
+ ], Editor.prototype, "_setShiftKeyTimeout", 1);
8558
+ __decorateClass([
8559
+ bind
8560
+ ], Editor.prototype, "_setAltKeyTimeout", 1);
8561
+ __decorateClass([
8562
+ bind
8563
+ ], Editor.prototype, "_setCtrlKeyTimeout", 1);
8564
+ __decorateClass([
8565
+ bind
8566
+ ], Editor.prototype, "_setMetaKeyTimeout", 1);
8032
8567
  function alertMaxShapes(editor, pageId = editor.getCurrentPageId()) {
8033
8568
  const name = editor.getPage(pageId).name;
8034
8569
  editor.emit("max-shapes", { name, pageId, count: editor.options.maxShapesPerPage });