@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
@@ -5,12 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
9
- var __typeError = (msg) => {
10
- throw TypeError(msg);
11
- };
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
8
  var __export = (target, all) => {
15
9
  for (var name in all)
16
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -32,45 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
26
  mod
33
27
  ));
34
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
36
- var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
37
- var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
38
- var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
39
- var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
40
- var __runInitializers = (array, flags, self, value) => {
41
- 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);
42
- return value;
43
- };
44
- var __decorateElement = (array, flags, name, decorators, target, extra) => {
45
- var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
46
- var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
47
- var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
48
- var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
49
- return __privateGet(this, extra);
50
- }, set [name](x) {
51
- return __privateSet(this, extra, x);
52
- } }, name));
53
- k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
54
- for (var i = decorators.length - 1; i >= 0; i--) {
55
- ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
56
- if (k) {
57
- ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
58
- if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
59
- if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
60
- }
61
- 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;
62
- if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
63
- else if (typeof it !== "object" || it === null) __typeError("Object expected");
64
- else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
65
- }
66
- return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
29
+ var __decorateClass = (decorators, target, key, kind) => {
30
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
31
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
32
+ if (decorator = decorators[i])
33
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
+ if (kind && result) __defProp(target, key, result);
35
+ return result;
67
36
  };
68
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
69
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
70
- var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
71
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
72
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
73
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
74
37
  var Editor_exports = {};
75
38
  __export(Editor_exports, {
76
39
  Editor: () => Editor
@@ -81,10 +44,11 @@ var import_store = require("@tldraw/store");
81
44
  var import_tlschema = require("@tldraw/tlschema");
82
45
  var import_utils = require("@tldraw/utils");
83
46
  var import_eventemitter3 = __toESM(require("eventemitter3"), 1);
84
- var import_TLEditorSnapshot = require("../config/TLEditorSnapshot");
85
- var import_createTLUser = require("../config/createTLUser");
47
+ var import_createTLCurrentUser = require("../config/createTLCurrentUser");
48
+ var import_defaultAssets = require("../config/defaultAssets");
86
49
  var import_defaultBindings = require("../config/defaultBindings");
87
50
  var import_defaultShapes = require("../config/defaultShapes");
51
+ var import_TLEditorSnapshot = require("../config/TLEditorSnapshot");
88
52
  var import_constants = require("../constants");
89
53
  var import_domUtils = require("../exports/domUtils");
90
54
  var import_exportToSvg = require("../exports/exportToSvg");
@@ -93,13 +57,12 @@ var import_menus = require("../globals/menus");
93
57
  var import_time = require("../globals/time");
94
58
  var import_options = require("../options");
95
59
  var import_Box = require("../primitives/Box");
96
- var import_Mat = require("../primitives/Mat");
97
- var import_Vec = require("../primitives/Vec");
98
60
  var import_easings = require("../primitives/easings");
99
61
  var import_Group2d = require("../primitives/geometry/Group2d");
100
62
  var import_intersect = require("../primitives/intersect");
63
+ var import_Mat = require("../primitives/Mat");
101
64
  var import_utils2 = require("../primitives/utils");
102
- var import_SharedStylesMap = require("../utils/SharedStylesMap");
65
+ var import_Vec = require("../primitives/Vec");
103
66
  var import_areShapesContentEqual = require("../utils/areShapesContentEqual");
104
67
  var import_assets = require("../utils/assets");
105
68
  var import_debug_flags = require("../utils/debug-flags");
@@ -108,30 +71,37 @@ var import_getIncrementedName = require("../utils/getIncrementedName");
108
71
  var import_reorderShapes = require("../utils/reorderShapes");
109
72
  var import_reparenting = require("../utils/reparenting");
110
73
  var import_rotation = require("../utils/rotation");
74
+ var import_SharedStylesMap = require("../utils/SharedStylesMap");
111
75
  var import_bindingsIndex = require("./derivations/bindingsIndex");
112
76
  var import_notVisibleShapes = require("./derivations/notVisibleShapes");
113
77
  var import_parentsToChildren = require("./derivations/parentsToChildren");
114
78
  var import_shapeIdsInCurrentPage = require("./derivations/shapeIdsInCurrentPage");
115
79
  var import_ClickManager = require("./managers/ClickManager/ClickManager");
80
+ var import_CollaboratorsManager = require("./managers/CollaboratorsManager/CollaboratorsManager");
116
81
  var import_EdgeScrollManager = require("./managers/EdgeScrollManager/EdgeScrollManager");
117
82
  var import_FocusManager = require("./managers/FocusManager/FocusManager");
118
83
  var import_FontManager = require("./managers/FontManager/FontManager");
119
84
  var import_HistoryManager = require("./managers/HistoryManager/HistoryManager");
120
85
  var import_InputsManager = require("./managers/InputsManager/InputsManager");
86
+ var import_PerformanceManager = require("./managers/PerformanceManager/PerformanceManager");
121
87
  var import_ScribbleManager = require("./managers/ScribbleManager/ScribbleManager");
122
88
  var import_SnapManager = require("./managers/SnapManager/SnapManager");
123
89
  var import_SpatialIndexManager = require("./managers/SpatialIndexManager/SpatialIndexManager");
124
90
  var import_TextManager = require("./managers/TextManager/TextManager");
91
+ var import_ThemeManager = require("./managers/ThemeManager/ThemeManager");
125
92
  var import_TickManager = require("./managers/TickManager/TickManager");
126
93
  var import_UserPreferencesManager = require("./managers/UserPreferencesManager/UserPreferencesManager");
94
+ var import_OverlayManager = require("./overlays/OverlayManager");
127
95
  var import_RootState = require("./tools/RootState");
128
- 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;
129
- class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_dec = [import_state.computed], _canUndo_dec = [import_state.computed], _canRedo_dec = [import_state.computed], _getPath_dec = [import_state.computed], _getCurrentTool_dec = [import_state.computed], _getCurrentToolId_dec = [import_state.computed], _getDocumentSettings_dec = [import_state.computed], _getInstanceState_dec = [import_state.computed], _getPageStates_dec = [import_state.computed], __getPageStatesQuery_dec = [import_state.computed], _getCurrentPageState_dec = [import_state.computed], __getCurrentPageStateId_dec = [import_state.computed], _getSelectedShapeIds_dec = [import_state.computed], _getSelectedShapes_dec = [import_state.computed], _getCurrentPageShapesInReadingOrder_dec = [import_state.computed], _getOnlySelectedShapeId_dec = [import_state.computed], _getOnlySelectedShape_dec = [import_state.computed], _getSelectionPageBounds_dec = [import_state.computed], _getSelectionRotation_dec = [import_state.computed], _getSelectionRotatedPageBounds_dec = [import_state.computed], _getSelectionRotatedScreenBounds_dec = [import_state.computed], _getFocusedGroupId_dec = [import_state.computed], _getFocusedGroup_dec = [import_state.computed], _getEditingShapeId_dec = [import_state.computed], _getEditingShape_dec = [import_state.computed], _getRichTextEditor_dec = [import_state.computed], _getHoveredShapeId_dec = [import_state.computed], _getHoveredShape_dec = [import_state.computed], _getHintingShapeIds_dec = [import_state.computed], _getHintingShape_dec = [import_state.computed], _getErasingShapeIds_dec = [import_state.computed], _getErasingShapes_dec = [import_state.computed], __unsafe_getCameraId_dec = [import_state.computed], _getCamera_dec = [import_state.computed], _getViewportPageBoundsForFollowing_dec = [import_state.computed], _getCameraForFollowing_dec = [import_state.computed], _getZoomLevel_dec = [import_state.computed], _getResizeScaleFactor_dec = [import_state.computed], _getDebouncedZoomLevel_dec = [import_state.computed], __getAboveDebouncedZoomThreshold_dec = [import_state.computed], _getEfficientZoomLevel_dec = [import_state.computed], _getViewportScreenBounds_dec = [import_state.computed], _getViewportScreenCenter_dec = [import_state.computed], _getViewportPageBounds_dec = [import_state.computed], __getCollaboratorsQuery_dec = [import_state.computed], _getCollaborators_dec = [import_state.computed], _getCollaboratorsOnCurrentPage_dec = [import_state.computed], _getRenderingShapes_dec = [import_state.computed], __getAllPagesQuery_dec = [import_state.computed], _getPages_dec = [import_state.computed], _getCurrentPageId_dec = [import_state.computed], _getCurrentPageShapeIdsSorted_dec = [import_state.computed], __getAllAssetsQuery_dec = [import_state.computed], __getShapeHandlesCache_dec = [import_state.computed], __getShapePageTransformCache_dec = [import_state.computed], __getShapePageBoundsCache_dec = [import_state.computed], __getShapeClipPathCache_dec = [import_state.computed], __getShapeMaskCache_dec = [import_state.computed], __getShapeMaskedPageBoundsCache_dec = [import_state.computed], _getNotVisibleShapes_dec = [import_state.computed], _getCulledShapes_dec = [import_state.computed], _getCurrentPageBounds_dec = [import_state.computed], _getCurrentPageShapes_dec = [import_state.computed], _getCurrentPageShapesSorted_dec = [import_state.computed], _getCurrentPageRenderingShapesSorted_dec = [import_state.computed], __getBindingsIndexCache_dec = [import_state.computed], __getSelectionSharedStyles_dec = [import_state.computed], _getSharedStyles_dec = [(0, import_state.computed)({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [import_state.computed], _getIsFocused_dec = [import_state.computed], _getIsReadonly_dec = [import_state.computed], __setShiftKeyTimeout_dec = [import_utils.bind], __setAltKeyTimeout_dec = [import_utils.bind], __setCtrlKeyTimeout_dec = [import_utils.bind], __setMetaKeyTimeout_dec = [import_utils.bind], _a) {
96
+ class Editor extends import_eventemitter3.default {
97
+ id = (0, import_utils.uniqueId)();
130
98
  constructor({
131
99
  store,
132
100
  user,
133
101
  shapeUtils,
134
102
  bindingUtils,
103
+ assetUtils: assetUtilConstructors,
104
+ overlayUtils: overlayUtilConstructors,
135
105
  tools,
136
106
  getContainer,
137
107
  // needs to be here for backwards compatibility with TldrawEditor
@@ -139,242 +109,17 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
139
109
  cameraOptions,
140
110
  initialState,
141
111
  autoFocus,
142
- inferDarkMode,
143
112
  options: _options,
144
113
  // needs to be here for backwards compatibility with TldrawEditor
145
114
  // eslint-disable-next-line @typescript-eslint/no-deprecated
146
115
  textOptions: _textOptions,
147
116
  getShapeVisibility,
148
- fontAssetUrls
117
+ colorScheme,
118
+ fontAssetUrls,
119
+ themes,
120
+ initialTheme
149
121
  }) {
150
122
  super();
151
- __runInitializers(_init, 5, this);
152
- __publicField(this, "id", (0, import_utils.uniqueId)());
153
- __publicField(this, "_getShapeVisibility");
154
- __publicField(this, "options");
155
- __publicField(this, "contextId", (0, import_utils.uniqueId)());
156
- /**
157
- * The editor's store
158
- *
159
- * @public
160
- */
161
- __publicField(this, "store");
162
- /**
163
- * The root state of the statechart.
164
- *
165
- * @public
166
- */
167
- __publicField(this, "root");
168
- /**
169
- * A set of functions to call when the editor is disposed.
170
- *
171
- * @public
172
- */
173
- __publicField(this, "disposables", /* @__PURE__ */ new Set());
174
- /**
175
- * Whether the editor is disposed.
176
- *
177
- * @public
178
- */
179
- __publicField(this, "isDisposed", false);
180
- /**
181
- * A manager for the editor's tick events.
182
- *
183
- * @internal */
184
- __publicField(this, "_tickManager");
185
- /**
186
- * A manager for the editor's input state.
187
- *
188
- * @public
189
- */
190
- __publicField(this, "inputs");
191
- /**
192
- * A manager for the editor's snapping feature.
193
- *
194
- * @public
195
- */
196
- __publicField(this, "snaps");
197
- __publicField(this, "_spatialIndex");
198
- /**
199
- * A manager for the any asynchronous events and making sure they're
200
- * cleaned up upon disposal.
201
- *
202
- * @public
203
- */
204
- __publicField(this, "timers", import_time.tltime.forContext(this.contextId));
205
- /**
206
- * A manager for the user and their preferences.
207
- *
208
- * @public
209
- */
210
- __publicField(this, "user");
211
- /**
212
- * A helper for measuring text.
213
- *
214
- * @public
215
- */
216
- __publicField(this, "textMeasure");
217
- /**
218
- * A utility for managing the set of fonts that should be rendered in the document.
219
- *
220
- * @public
221
- */
222
- __publicField(this, "fonts");
223
- /**
224
- * A manager for the editor's scribbles.
225
- *
226
- * @public
227
- */
228
- __publicField(this, "scribbles");
229
- /**
230
- * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
231
- *
232
- * @public
233
- */
234
- __publicField(this, "sideEffects");
235
- /**
236
- * A manager for moving the camera when the mouse is at the edge of the screen.
237
- *
238
- * @public
239
- */
240
- __publicField(this, "edgeScrollManager");
241
- /**
242
- * A manager for ensuring correct focus. See FocusManager for details.
243
- *
244
- * @internal
245
- */
246
- __publicField(this, "focusManager");
247
- /**
248
- * The current HTML element containing the editor.
249
- *
250
- * @example
251
- * ```ts
252
- * const container = editor.getContainer()
253
- * ```
254
- *
255
- * @public
256
- */
257
- __publicField(this, "getContainer");
258
- /* ------------------- Shape Utils ------------------ */
259
- /**
260
- * A map of shape utility classes (TLShapeUtils) by shape type.
261
- *
262
- * @public
263
- */
264
- __publicField(this, "shapeUtils");
265
- __publicField(this, "styleProps");
266
- /* ------------------- Binding Utils ------------------ */
267
- /**
268
- * A map of shape utility classes (TLShapeUtils) by shape type.
269
- *
270
- * @public
271
- */
272
- __publicField(this, "bindingUtils");
273
- /* --------------------- History -------------------- */
274
- /**
275
- * A manager for the editor's history.
276
- *
277
- * @readonly
278
- */
279
- __publicField(this, "history");
280
- __publicField(this, "_shouldIgnoreShapeLock", false);
281
- /** @internal */
282
- __publicField(this, "_crashingError", null);
283
- /** @internal */
284
- __publicField(this, "_isChangingStyleTimeout", -1);
285
- // Menus
286
- __publicField(this, "menus", import_menus.tlmenus.forContext(this.contextId));
287
- // Rich text editor
288
- __publicField(this, "_currentRichTextEditor", (0, import_state.atom)("rich text editor", null));
289
- __publicField(this, "_textOptions");
290
- __publicField(this, "_debouncedZoomLevel", (0, import_state.atom)("debounced zoom level", 1));
291
- __publicField(this, "_cameraOptions", (0, import_state.atom)("camera options", import_constants.DEFAULT_CAMERA_OPTIONS));
292
- /** @internal */
293
- __publicField(this, "_viewportAnimation", null);
294
- // Viewport
295
- /** @internal */
296
- __publicField(this, "_willSetInitialBounds", true);
297
- // Following
298
- // When we are 'locked on' to a user, our camera is derived from their camera.
299
- __publicField(this, "_isLockedOnFollowingUser", (0, import_state.atom)("isLockedOnFollowingUser", false));
300
- // Camera state
301
- // Camera state does two things: first, it allows us to subscribe to whether
302
- // the camera is moving or not; and second, it allows us to update the rendering
303
- // shapes on the canvas. Changing the rendering shapes may cause shapes to
304
- // unmount / remount in the DOM, which is expensive; and computing visibility is
305
- // also expensive in large projects. For this reason, we use a second bounding
306
- // box just for rendering, and we only update after the camera stops moving.
307
- __publicField(this, "_cameraStateTimeoutRemaining", 0);
308
- /* @internal */
309
- __publicField(this, "_currentPageShapeIds");
310
- /* --------------------- Shapes --------------------- */
311
- __publicField(this, "_shapeGeometryCaches", {});
312
- __publicField(this, "_notVisibleShapes", (0, import_notVisibleShapes.notVisibleShapes)(this));
313
- __publicField(this, "_culledShapesCache", null);
314
- // Parents and children
315
- /**
316
- * A cache of parents to children.
317
- *
318
- * @internal
319
- */
320
- __publicField(this, "_parentIdsToChildIds");
321
- __publicField(this, "animatingShapes", /* @__PURE__ */ new Map());
322
- /* --------------------- Content -------------------- */
323
- /** @internal */
324
- __publicField(this, "externalAssetContentHandlers", {
325
- file: null,
326
- url: null
327
- });
328
- /** @internal */
329
- __publicField(this, "temporaryAssetPreview", /* @__PURE__ */ new Map());
330
- /** @internal */
331
- __publicField(this, "externalContentHandlers", {
332
- text: null,
333
- files: null,
334
- "file-replace": null,
335
- embed: null,
336
- "svg-text": null,
337
- url: null,
338
- tldraw: null,
339
- excalidraw: null
340
- });
341
- /**
342
- * A manager for recording multiple click events.
343
- *
344
- * @internal
345
- */
346
- __publicField(this, "_clickManager", new import_ClickManager.ClickManager(this));
347
- /**
348
- * The previous cursor. Used for restoring the cursor after pan events.
349
- *
350
- * @internal
351
- */
352
- __publicField(this, "_prevCursor", "default");
353
- /** @internal */
354
- __publicField(this, "_shiftKeyTimeout", -1);
355
- /** @internal */
356
- __publicField(this, "_altKeyTimeout", -1);
357
- /** @internal */
358
- __publicField(this, "_ctrlKeyTimeout", -1);
359
- /** @internal */
360
- __publicField(this, "_metaKeyTimeout", -1);
361
- /** @internal */
362
- __publicField(this, "_restoreToolId", "select");
363
- /** @internal */
364
- __publicField(this, "_didPinch", false);
365
- /** @internal */
366
- __publicField(this, "_selectedShapeIdsAtPointerDown", []);
367
- /** @internal */
368
- __publicField(this, "_longPressTimeout", -1);
369
- /** @internal */
370
- __publicField(this, "capturedPointerId", null);
371
- /** @internal */
372
- __publicField(this, "performanceTracker");
373
- /** @internal */
374
- __publicField(this, "performanceTrackerTimeout", -1);
375
- /** @internal */
376
- __publicField(this, "handledEvents", /* @__PURE__ */ new WeakSet());
377
- __publicField(this, "_pendingEventsForNextTick", []);
378
123
  this._getShapeVisibility = getShapeVisibility;
379
124
  const options = _textOptions ? { ..._options, text: _options?.text ?? _textOptions } : _options;
380
125
  this.options = { ...import_options.defaultTldrawOptions, ...options };
@@ -395,15 +140,28 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
395
140
  ...cameraOptions,
396
141
  ...options?.camera
397
142
  });
143
+ this.getContainer = getContainer;
398
144
  this._textOptions = (0, import_state.atom)("text options", options?.text ?? null);
399
- this.user = new import_UserPreferencesManager.UserPreferencesManager(user ?? (0, import_createTLUser.createTLUser)(), inferDarkMode ?? false);
145
+ this.user = new import_UserPreferencesManager.UserPreferencesManager(user ?? (0, import_createTLCurrentUser.createTLCurrentUser)(), colorScheme ?? "light");
400
146
  this.disposables.add(() => this.user.dispose());
401
- this.getContainer = getContainer;
402
147
  this.textMeasure = new import_TextManager.TextManager(this);
403
148
  this.disposables.add(() => this.textMeasure.dispose());
404
- this.fonts = new import_FontManager.FontManager(this, fontAssetUrls);
149
+ this._themeManager = new import_ThemeManager.ThemeManager(this, {
150
+ themes: (0, import_ThemeManager.resolveThemes)(themes),
151
+ initial: initialTheme ?? "default"
152
+ });
153
+ this.disposables.add(() => this._themeManager.dispose());
405
154
  this._tickManager = new import_TickManager.TickManager(this);
155
+ this.disposables.add(() => this._tickManager.dispose());
156
+ this.disposables.add(() => {
157
+ this.off("tick", this._decayCameraStateTimeout);
158
+ this._setCameraState("idle");
159
+ });
160
+ this.fonts = new import_FontManager.FontManager(this, fontAssetUrls);
406
161
  this.inputs = new import_InputsManager.InputsManager(this);
162
+ this.performance = new import_PerformanceManager.PerformanceManager(this);
163
+ this.disposables.add(() => this.performance.dispose());
164
+ this.collaborators = new import_CollaboratorsManager.CollaboratorsManager(this);
407
165
  class NewRoot extends import_RootState.RootState {
408
166
  static initial = initialState ?? "";
409
167
  }
@@ -431,6 +189,16 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
431
189
  }
432
190
  this.shapeUtils = _shapeUtils;
433
191
  this.styleProps = _styleProps;
192
+ const _shapeUtilsByAssetType = {};
193
+ for (const Util of allShapeUtils) {
194
+ const assetTypes = Util.handledAssetTypes;
195
+ if (assetTypes) {
196
+ for (const assetType of assetTypes) {
197
+ _shapeUtilsByAssetType[assetType] = _shapeUtils[Util.type];
198
+ }
199
+ }
200
+ }
201
+ this._shapeUtilsByAssetType = _shapeUtilsByAssetType;
434
202
  const allBindingUtils = (0, import_defaultBindings.checkBindings)(bindingUtils);
435
203
  const _bindingUtils = {};
436
204
  for (const Util of allBindingUtils) {
@@ -438,6 +206,15 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
438
206
  _bindingUtils[Util.type] = util;
439
207
  }
440
208
  this.bindingUtils = _bindingUtils;
209
+ if (assetUtilConstructors) {
210
+ const allAssetUtils = (0, import_defaultAssets.checkAssets)(assetUtilConstructors);
211
+ const _assetUtils = {};
212
+ for (const Util of allAssetUtils) {
213
+ const util = new Util(this);
214
+ _assetUtils[Util.type] = util;
215
+ }
216
+ this.assetUtils = _assetUtils;
217
+ }
441
218
  for (const Tool of [...tools]) {
442
219
  if ((0, import_utils.hasOwnProperty)(this.root.children, Tool.id)) {
443
220
  throw Error(`Can't override tool with id "${Tool.id}"`);
@@ -445,6 +222,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
445
222
  this.root.children[Tool.id] = new Tool(this, this.root);
446
223
  }
447
224
  this.scribbles = new import_ScribbleManager.ScribbleManager(this);
225
+ this.overlays = new import_OverlayManager.OverlayManager(this);
226
+ if (overlayUtilConstructors) {
227
+ for (const Util of overlayUtilConstructors) {
228
+ const util = new Util(this);
229
+ this.overlays.registerUtil(util);
230
+ }
231
+ }
448
232
  const cleanupInstancePageState = (prevPageState, shapesNoLongerInPage) => {
449
233
  let nextPageState = null;
450
234
  const selectedShapeIds = prevPageState.selectedShapeIds.filter(
@@ -779,7 +563,16 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
779
563
  })
780
564
  );
781
565
  }
566
+ this.disposables.add(
567
+ (0, import_state.react)("sync current user record", () => {
568
+ const user2 = this.store.props.users.currentUser.get();
569
+ if (user2) {
570
+ this._ensureUserRecord(user2);
571
+ }
572
+ })
573
+ );
782
574
  }
575
+ _getShapeVisibility;
783
576
  getIsShapeHiddenCache() {
784
577
  if (!this._getShapeVisibility) return null;
785
578
  return this.store.createComputedCache("isShapeHidden", (shape) => {
@@ -795,6 +588,20 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
795
588
  typeof shapeOrId === "string" ? shapeOrId : shapeOrId.id
796
589
  );
797
590
  }
591
+ options;
592
+ contextId = (0, import_utils.uniqueId)();
593
+ /**
594
+ * The editor's store
595
+ *
596
+ * @public
597
+ */
598
+ store;
599
+ /**
600
+ * The root state of the statechart.
601
+ *
602
+ * @public
603
+ */
604
+ root;
798
605
  /**
799
606
  * Set a tool. Useful if you need to add a tool to the state chart on demand,
800
607
  * after the editor has already been initialized.
@@ -826,6 +633,125 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
826
633
  delete parent.children[Tool.id];
827
634
  }
828
635
  }
636
+ /**
637
+ * A set of functions to call when the editor is disposed.
638
+ *
639
+ * @public
640
+ */
641
+ disposables = /* @__PURE__ */ new Set();
642
+ /**
643
+ * Whether the editor is disposed.
644
+ *
645
+ * @public
646
+ */
647
+ isDisposed = false;
648
+ /**
649
+ * A manager for the editor's tick events.
650
+ *
651
+ * @internal */
652
+ _tickManager;
653
+ /**
654
+ * A manager for the editor's input state.
655
+ *
656
+ * @public
657
+ */
658
+ inputs;
659
+ /**
660
+ * A manager for the editor's snapping feature.
661
+ *
662
+ * @public
663
+ */
664
+ snaps;
665
+ /**
666
+ * A manager for performance measurement hooks.
667
+ *
668
+ * @public
669
+ */
670
+ performance;
671
+ /**
672
+ * A manager for the spatial index, tracking where shapes exist on the canvas.
673
+ *
674
+ * @internal
675
+ */
676
+ _spatialIndex;
677
+ /**
678
+ * A manager for the any asynchronous events and making sure they're
679
+ * cleaned up upon disposal.
680
+ *
681
+ * @public
682
+ */
683
+ timers = import_time.tltime.forContext(this.contextId);
684
+ /**
685
+ * A manager for remote peer collaborators connected to this editor.
686
+ *
687
+ * @public
688
+ */
689
+ collaborators;
690
+ /**
691
+ * A manager for the user and their preferences.
692
+ *
693
+ * @public
694
+ */
695
+ user;
696
+ /**
697
+ * A manager for the editor's themes.
698
+ *
699
+ * @internal
700
+ */
701
+ _themeManager;
702
+ /**
703
+ * A helper for measuring text.
704
+ *
705
+ * @public
706
+ */
707
+ textMeasure;
708
+ /**
709
+ * A utility for managing the set of fonts that should be rendered in the document.
710
+ *
711
+ * @public
712
+ */
713
+ fonts;
714
+ /**
715
+ * A manager for the editor's scribbles.
716
+ *
717
+ * @public
718
+ */
719
+ scribbles;
720
+ /**
721
+ * A manager for canvas overlay UI elements (selection handles, shape handles, etc.).
722
+ *
723
+ * @public
724
+ */
725
+ overlays;
726
+ /**
727
+ * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
728
+ *
729
+ * @public
730
+ */
731
+ sideEffects;
732
+ /**
733
+ * A manager for moving the camera when the mouse is at the edge of the screen.
734
+ *
735
+ * @public
736
+ */
737
+ edgeScrollManager;
738
+ /**
739
+ * A manager for ensuring correct focus. See FocusManager for details.
740
+ *
741
+ * @internal
742
+ */
743
+ focusManager;
744
+ /**
745
+ * The current HTML element containing the editor.
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * const container = editor.getContainer()
750
+ * ```
751
+ *
752
+ * @public
753
+ */
754
+ getContainer;
829
755
  /**
830
756
  * The document that the editor's container element belongs to.
831
757
  * Use this instead of the global `document` to support cross-window embedding.
@@ -850,12 +776,127 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
850
776
  * @public
851
777
  */
852
778
  dispose() {
779
+ this.stopCameraAnimation();
780
+ if (this.getInstanceState().followingUserId) {
781
+ this.stopFollowingUser();
782
+ }
853
783
  this.disposables.forEach((dispose) => dispose());
854
784
  this.disposables.clear();
785
+ this.menus.clearOpenMenus();
855
786
  this.store.dispose();
856
787
  this.isDisposed = true;
857
788
  this.emit("dispose");
858
789
  }
790
+ /* ------------------ Themes (shadowing the theme manager) ------------------ */
791
+ /**
792
+ * Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
793
+ *
794
+ * @public
795
+ */
796
+ getColorMode() {
797
+ return this._themeManager.getColorMode();
798
+ }
799
+ /**
800
+ * Set the color mode. Note that this is a convenience method that passes the mode to
801
+ * `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
802
+ *
803
+ * @public
804
+ */
805
+ setColorMode(mode) {
806
+ this.user.updateUserPreferences({ colorScheme: mode });
807
+ return this;
808
+ }
809
+ /**
810
+ * Get the id of the current theme.
811
+ *
812
+ * @public
813
+ */
814
+ getCurrentThemeId() {
815
+ return this._themeManager.getCurrentThemeId();
816
+ }
817
+ /**
818
+ * Get the current theme definition.
819
+ *
820
+ * @public
821
+ */
822
+ getCurrentTheme() {
823
+ return this._themeManager.getCurrentTheme();
824
+ }
825
+ /**
826
+ * Set the current theme by id.
827
+ *
828
+ * @public
829
+ */
830
+ setCurrentTheme(id) {
831
+ this._themeManager.setCurrentTheme(id);
832
+ return this;
833
+ }
834
+ /**
835
+ * Get all registered theme definitions.
836
+ *
837
+ * @public
838
+ */
839
+ getThemes() {
840
+ return this._themeManager.getThemes();
841
+ }
842
+ /**
843
+ * Get a single theme definition by id.
844
+ *
845
+ * @public
846
+ */
847
+ getTheme(id) {
848
+ return this._themeManager.getTheme(id);
849
+ }
850
+ /**
851
+ * Replace all theme definitions, or update them via a callback that receives a deep copy.
852
+ * The `'default'` theme must always be present in the result.
853
+ *
854
+ * @example
855
+ * ```ts
856
+ * // Replace all themes
857
+ * editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
858
+ *
859
+ * // Update via callback
860
+ * editor.updateThemes((themes) => {
861
+ * delete themes.ocean
862
+ * return themes
863
+ * })
864
+ * ```
865
+ *
866
+ * @public
867
+ */
868
+ updateThemes(themes) {
869
+ this._themeManager.updateThemes(themes);
870
+ return this;
871
+ }
872
+ /**
873
+ * Register or update a single theme definition. The theme is keyed by its `id` property.
874
+ *
875
+ * @example
876
+ * ```ts
877
+ * // Override a property on the default theme
878
+ * editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
879
+ *
880
+ * // Register a new theme
881
+ * editor.updateTheme({ id: 'ocean', ...myOceanTheme })
882
+ * ```
883
+ *
884
+ * @public
885
+ */
886
+ updateTheme(theme) {
887
+ this._themeManager.updateTheme(theme);
888
+ return this;
889
+ }
890
+ /* ------------------- Shape Utils ------------------ */
891
+ /**
892
+ * A map of shape utility classes (TLShapeUtils) by shape type.
893
+ *
894
+ * @public
895
+ */
896
+ shapeUtils;
897
+ /** @internal */
898
+ _shapeUtilsByAssetType = {};
899
+ styleProps;
859
900
  getShapeUtil(arg) {
860
901
  const type = typeof arg === "string" ? arg : arg.type;
861
902
  const shapeUtil = (0, import_utils.getOwnProperty)(this.shapeUtils, type);
@@ -866,12 +907,73 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
866
907
  const type = typeof arg === "string" ? arg : arg.type;
867
908
  return (0, import_utils.hasOwnProperty)(this.shapeUtils, type);
868
909
  }
910
+ /**
911
+ * Get the shape util that handles the given asset type.
912
+ * Returns the shape util whose {@link ShapeUtil.handledAssetTypes} includes
913
+ * the given asset type, or undefined if none matches.
914
+ *
915
+ * @param assetType - The asset type string.
916
+ * @public
917
+ */
918
+ getShapeUtilForAssetType(assetType) {
919
+ return (0, import_utils.getOwnProperty)(this._shapeUtilsByAssetType, assetType);
920
+ }
921
+ /* ------------------- Binding Utils ------------------ */
922
+ /**
923
+ * A map of shape utility classes (TLShapeUtils) by shape type.
924
+ *
925
+ * @public
926
+ */
927
+ bindingUtils;
869
928
  getBindingUtil(arg) {
870
929
  const type = typeof arg === "string" ? arg : arg.type;
871
930
  const bindingUtil = (0, import_utils.getOwnProperty)(this.bindingUtils, type);
872
931
  (0, import_utils.assert)(bindingUtil, `No binding util found for type "${type}"`);
873
932
  return bindingUtil;
874
933
  }
934
+ /* ------------------- Asset Utils ------------------ */
935
+ /**
936
+ * A map of asset utility classes by asset type.
937
+ *
938
+ * @public
939
+ */
940
+ assetUtils = {};
941
+ getAssetUtil(arg) {
942
+ const type = typeof arg === "string" ? arg : arg.type;
943
+ const assetUtil = (0, import_utils.getOwnProperty)(this.assetUtils, type);
944
+ (0, import_utils.assert)(assetUtil, `No asset util found for type "${type}"`);
945
+ return assetUtil;
946
+ }
947
+ /**
948
+ * Returns true if the editor has an asset util for the given asset type.
949
+ *
950
+ * @public
951
+ */
952
+ hasAssetUtil(arg) {
953
+ const type = typeof arg === "string" ? arg : arg.type;
954
+ return (0, import_utils.hasOwnProperty)(this.assetUtils, type);
955
+ }
956
+ /**
957
+ * Get the asset util that accepts the given MIME type.
958
+ * Returns null if no registered asset util accepts the MIME type.
959
+ *
960
+ * @public
961
+ */
962
+ getAssetUtilForMimeType(mimeType) {
963
+ for (const util of Object.values(this.assetUtils)) {
964
+ if (util && util.acceptsMimeType(mimeType)) {
965
+ return util;
966
+ }
967
+ }
968
+ return null;
969
+ }
970
+ /* --------------------- History -------------------- */
971
+ /**
972
+ * A manager for the editor's history.
973
+ *
974
+ * @readonly
975
+ */
976
+ history;
875
977
  /**
876
978
  * Undo to the last mark.
877
979
  *
@@ -886,6 +988,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
886
988
  this._flushEventsForTick(0);
887
989
  this.complete();
888
990
  this.history.undo();
991
+ this.performance._notifyUndoRedo("undo", this.history.getNumUndos(), this.history.getNumRedos());
889
992
  return this;
890
993
  }
891
994
  canUndo() {
@@ -908,6 +1011,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
908
1011
  this._flushEventsForTick(0);
909
1012
  this.complete();
910
1013
  this.history.redo();
1014
+ this.performance._notifyUndoRedo("redo", this.history.getNumUndos(), this.history.getNumRedos());
911
1015
  return this;
912
1016
  }
913
1017
  canRedo() {
@@ -999,6 +1103,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
999
1103
  this.history.bailToMark(id);
1000
1104
  return this;
1001
1105
  }
1106
+ _shouldIgnoreShapeLock = false;
1002
1107
  /**
1003
1108
  * Run a function in a transaction with optional options for context.
1004
1109
  * You can use the options to change the way that history is treated
@@ -1090,6 +1195,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1090
1195
  };
1091
1196
  }
1092
1197
  }
1198
+ /** @internal */
1199
+ _crashingError = null;
1093
1200
  /**
1094
1201
  * We can't use an `atom` here because there's a chance that when `crashAndReportError` is called,
1095
1202
  * we're in a transaction that's about to be rolled back due to the same error we're currently
@@ -1256,15 +1363,28 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1256
1363
  ]);
1257
1364
  }, opts);
1258
1365
  }
1366
+ /** @internal */
1367
+ _isChangingStyleTimeout = -1;
1368
+ // Menus
1369
+ menus = import_menus.tlmenus.forContext(this.contextId);
1259
1370
  /* --------------------- Cursor --------------------- */
1260
1371
  /**
1261
1372
  * Set the cursor.
1262
1373
  *
1374
+ * No-op when the partial wouldn't change the current cursor — `setCursor`
1375
+ * is called from pointer-move hot paths (see `updateHoveredOverlayId`,
1376
+ * various tool states) and skipping redundant writes avoids needlessly
1377
+ * dirtying instance state.
1378
+ *
1263
1379
  * @param cursor - The cursor to set.
1264
1380
  * @public
1265
1381
  */
1266
1382
  setCursor(cursor) {
1267
- this.updateInstanceState({ cursor: { ...this.getInstanceState().cursor, ...cursor } });
1383
+ const current = this.getInstanceState().cursor;
1384
+ if ((cursor.type === void 0 || cursor.type === current.type) && (cursor.rotation === void 0 || cursor.rotation === current.rotation)) {
1385
+ return this;
1386
+ }
1387
+ this.updateInstanceState({ cursor: { ...current, ...cursor } });
1268
1388
  return this;
1269
1389
  }
1270
1390
  getPageStates() {
@@ -1821,6 +1941,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1821
1941
  );
1822
1942
  return this;
1823
1943
  }
1944
+ // Rich text editor
1945
+ _currentRichTextEditor = (0, import_state.atom)("rich text editor", null);
1824
1946
  getRichTextEditor() {
1825
1947
  return this._currentRichTextEditor.get();
1826
1948
  }
@@ -2000,6 +2122,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2000
2122
  }
2001
2123
  return this;
2002
2124
  }
2125
+ _textOptions;
2003
2126
  /**
2004
2127
  * Get the current text options.
2005
2128
  *
@@ -2070,6 +2193,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2070
2193
  getResizeScaleFactor() {
2071
2194
  return this.user.getIsDynamicResizeMode() ? 1 / this.getZoomLevel() : 1;
2072
2195
  }
2196
+ _debouncedZoomLevel = (0, import_state.atom)("debounced zoom level", 1);
2073
2197
  getDebouncedZoomLevel() {
2074
2198
  if (this.options.debouncedZoom) {
2075
2199
  if (this.getCameraState() === "idle") {
@@ -2174,6 +2298,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2174
2298
  }
2175
2299
  }
2176
2300
  }
2301
+ _cameraOptions = (0, import_state.atom)("camera options", import_constants.DEFAULT_CAMERA_OPTIONS);
2177
2302
  /**
2178
2303
  * Get the current camera options.
2179
2304
  *
@@ -2648,6 +2773,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2648
2773
  return this;
2649
2774
  }
2650
2775
  /** @internal */
2776
+ _viewportAnimation = null;
2777
+ /** @internal */
2651
2778
  _animateViewport(ms) {
2652
2779
  if (!this._viewportAnimation) return;
2653
2780
  this._viewportAnimation.elapsed += ms;
@@ -2786,6 +2913,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2786
2913
  });
2787
2914
  return this;
2788
2915
  }
2916
+ // Viewport
2917
+ /** @internal */
2918
+ _willSetInitialBounds = true;
2789
2919
  /**
2790
2920
  * Update the viewport. The viewport will measure the size and screen position of its container
2791
2921
  * element. This should be done whenever the container's position on the screen changes.
@@ -2920,27 +3050,127 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2920
3050
  const { x: cx, y: cy, z: cz = 1 } = this.getCamera();
2921
3051
  return new import_Vec.Vec((point.x + cx) * cz, (point.y + cy) * cz, point.z ?? 0.5);
2922
3052
  }
2923
- _getCollaboratorsQuery() {
2924
- return this.store.query.records("instance_presence", () => ({
2925
- userId: { neq: this.user.getId() }
2926
- }));
2927
- }
3053
+ // Collaborators
3054
+ /**
3055
+ * Returns a list of presence records for all peer collaborators.
3056
+ * This will return the latest presence record for each connected user.
3057
+ *
3058
+ * Convenience wrapper for {@link CollaboratorsManager.getCollaborators}.
3059
+ *
3060
+ * @public
3061
+ */
2928
3062
  getCollaborators() {
2929
- const allPresenceRecords = this._getCollaboratorsQuery().get();
2930
- if (!allPresenceRecords.length) return import_state.EMPTY_ARRAY;
2931
- const userIds = [...new Set(allPresenceRecords.map((c) => c.userId))].sort();
2932
- return userIds.map((id) => {
2933
- const latestPresence = (0, import_utils.maxBy)(
2934
- allPresenceRecords.filter((c) => c.userId === id),
2935
- (p) => p.lastActivityTimestamp ?? 0
2936
- );
2937
- return latestPresence;
2938
- });
3063
+ return this.collaborators.getCollaborators();
2939
3064
  }
3065
+ /**
3066
+ * Returns a list of presence records for all peer collaborators on the current page.
3067
+ * This will return the latest presence record for each connected user.
3068
+ *
3069
+ * Convenience wrapper for {@link CollaboratorsManager.getCollaboratorsOnCurrentPage}.
3070
+ *
3071
+ * @public
3072
+ */
2940
3073
  getCollaboratorsOnCurrentPage() {
2941
- const currentPageId = this.getCurrentPageId();
2942
- return this.getCollaborators().filter((c) => c.currentPageId === currentPageId);
3074
+ return this.collaborators.getCollaboratorsOnCurrentPage();
3075
+ }
3076
+ /**
3077
+ * Returns a list of presence records for peer collaborators who should currently be
3078
+ * shown in the UI. Filters {@link Editor.getCollaborators} by activity state
3079
+ * (active / idle / inactive) and visibility rules such as following and highlighted
3080
+ * users. Re-evaluates on the collaborator visibility clock, so callers don't need to
3081
+ * drive their own activity timer.
3082
+ *
3083
+ * Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaborators}.
3084
+ *
3085
+ * @public
3086
+ */
3087
+ getVisibleCollaborators() {
3088
+ return this.collaborators.getVisibleCollaborators();
3089
+ }
3090
+ /**
3091
+ * Returns a list of presence records for peer collaborators who should currently be
3092
+ * shown in the UI, filtered to those on the current page.
3093
+ *
3094
+ * Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaboratorsOnCurrentPage}.
3095
+ *
3096
+ * @public
3097
+ */
3098
+ getVisibleCollaboratorsOnCurrentPage() {
3099
+ return this.collaborators.getVisibleCollaboratorsOnCurrentPage();
3100
+ }
3101
+ // Attribution
3102
+ /**
3103
+ * Get the current user's ID for attribution purposes.
3104
+ * Also ensures a `user:` record exists in the store for the current user.
3105
+ * Returns `null` when the user store has no current user.
3106
+ *
3107
+ * @public
3108
+ */
3109
+ getAttributionUserId() {
3110
+ const user = this.store.props.users.currentUser.get();
3111
+ if (!user) return null;
3112
+ this._ensureUserRecord(user);
3113
+ return import_tlschema.UserRecordType.parseId(user.id);
2943
3114
  }
3115
+ /**
3116
+ * Ensure a user record exists in the store for the given user,
3117
+ * updating it if the data has changed.
3118
+ *
3119
+ * @internal
3120
+ */
3121
+ _ensureUserRecord(user) {
3122
+ const existing = this.store.get(user.id);
3123
+ if (existing && existing.name === user.name && existing.color === user.color && existing.imageUrl === user.imageUrl && existing.meta === user.meta) {
3124
+ return;
3125
+ }
3126
+ this.run(
3127
+ () => {
3128
+ this.store.put([user]);
3129
+ },
3130
+ { history: "ignore" }
3131
+ );
3132
+ }
3133
+ /**
3134
+ * Resolve a display name for a user ID. Asks the
3135
+ * {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
3136
+ * falling back to the `user:` record in the store.
3137
+ *
3138
+ * @public
3139
+ */
3140
+ getAttributionDisplayName(userId) {
3141
+ if (!userId) return null;
3142
+ return this.store.props.users.resolve(userId).get()?.name ?? this.store.get((0, import_tlschema.createUserId)(userId))?.name ?? null;
3143
+ }
3144
+ /**
3145
+ * Resolve a user record by ID. Asks the
3146
+ * {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
3147
+ * falling back to the `user:` record in the store.
3148
+ *
3149
+ * @public
3150
+ */
3151
+ getAttributionUser(userId) {
3152
+ if (!userId) return null;
3153
+ return this.store.props.users.resolve(userId).get() ?? this.store.get((0, import_tlschema.createUserId)(userId)) ?? null;
3154
+ }
3155
+ /**
3156
+ * Collect user IDs referenced by a set of shapes via shape-specific props
3157
+ * (e.g. `textFirstEditedBy` on notes).
3158
+ *
3159
+ * @internal
3160
+ */
3161
+ _getReferencedUserIds(shapes) {
3162
+ const userIds = /* @__PURE__ */ new Set();
3163
+ for (const shape of shapes) {
3164
+ const util = this.getShapeUtil(shape);
3165
+ for (const id of util.getReferencedUserIds(shape)) {
3166
+ userIds.add(id);
3167
+ }
3168
+ }
3169
+ return userIds;
3170
+ }
3171
+ // Following
3172
+ // When we are 'locked on' to a user, our camera is derived from their camera.
3173
+ _isLockedOnFollowingUser = (0, import_state.atom)("isLockedOnFollowingUser", false);
2944
3174
  /**
2945
3175
  * Start viewport-following a user.
2946
3176
  *
@@ -3116,6 +3346,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3116
3346
  }
3117
3347
  return renderingShapes;
3118
3348
  }
3349
+ // Camera state
3350
+ // Camera state does two things: first, it allows us to subscribe to whether
3351
+ // the camera is moving or not; and second, it allows us to update the rendering
3352
+ // shapes on the canvas. Changing the rendering shapes may cause shapes to
3353
+ // unmount / remount in the DOM, which is expensive; and computing visibility is
3354
+ // also expensive in large projects. For this reason, we use a second bounding
3355
+ // box just for rendering, and we only update after the camera stops moving.
3356
+ _cameraStateTimeoutRemaining = 0;
3119
3357
  _decayCameraStateTimeout(elapsed) {
3120
3358
  this._cameraStateTimeoutRemaining -= elapsed;
3121
3359
  if (this._cameraStateTimeoutRemaining > 0) return;
@@ -3187,6 +3425,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3187
3425
  getPage(page) {
3188
3426
  return this.store.get(typeof page === "string" ? page : page.id);
3189
3427
  }
3428
+ /* @internal */
3429
+ _currentPageShapeIds;
3190
3430
  /**
3191
3431
  * An array of all of the shapes on the current page.
3192
3432
  *
@@ -3492,7 +3732,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3492
3732
  } = context;
3493
3733
  const zoomStepFunction = (zoom) => Math.pow(2, Math.ceil(Math.log2(zoom)));
3494
3734
  const steppedScreenScale = zoomStepFunction(screenScale);
3495
- const networkEffectiveType = "connection" in navigator ? navigator.connection.effectiveType : null;
3735
+ const networkEffectiveType = "connection" in navigator ? navigator.connection?.effectiveType ?? null : null;
3496
3736
  return await this.store.props.assets.resolve(asset, {
3497
3737
  screenScale: screenScale || 1,
3498
3738
  steppedScreenScale,
@@ -3508,6 +3748,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3508
3748
  async uploadAsset(asset, file, abortSignal) {
3509
3749
  return await this.store.props.assets.upload(asset, file, abortSignal);
3510
3750
  }
3751
+ /* --------------------- Shapes --------------------- */
3752
+ _shapeGeometryCaches = {};
3511
3753
  /**
3512
3754
  * Get the geometry of a shape in shape-space.
3513
3755
  *
@@ -3878,6 +4120,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3878
4120
  getNotVisibleShapes() {
3879
4121
  return this._notVisibleShapes.get();
3880
4122
  }
4123
+ _notVisibleShapes = (0, import_notVisibleShapes.notVisibleShapes)(this);
4124
+ _culledShapesCache = null;
3881
4125
  getCulledShapes() {
3882
4126
  const notVisibleShapes2 = this.getNotVisibleShapes();
3883
4127
  const selectedShapeIds = this.getSelectedShapeIds();
@@ -3958,7 +4202,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3958
4202
  const searchMargin = Math.max(innerMargin, outerMargin, this.options.hitTestMargin / zoomLevel);
3959
4203
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, searchMargin);
3960
4204
  const shapesToCheck = (opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted()).filter((shape) => {
3961
- if (!candidateIds.has(shape.id) && !this.isShapeOfType(shape, "frame")) return false;
4205
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
3962
4206
  if (shape.isLocked && !hitLocked || this.isShapeHidden(shape) || this.isShapeOfType(shape, "group"))
3963
4207
  return false;
3964
4208
  const pageMask = this.getShapeMask(shape);
@@ -3971,14 +4215,16 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3971
4215
  const geometry = this.getShapeGeometry(shape);
3972
4216
  const isGroup = geometry instanceof import_Group2d.Group2d;
3973
4217
  const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
3974
- 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()) {
4218
+ const shapeUtil = this.getShapeUtil(shape);
4219
+ const isShapeFrameLike = this.isShapeFrameLike(shape);
4220
+ if (isShapeFrameLike || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && shapeUtil.getText(shape)?.trim()) {
3975
4221
  for (const childGeometry of geometry.children) {
3976
4222
  if (childGeometry.isLabel && childGeometry.isPointInBounds(pointInShapeSpace)) {
3977
4223
  return shape;
3978
4224
  }
3979
4225
  }
3980
4226
  }
3981
- if (this.isShapeOfType(shape, "frame")) {
4227
+ if (isShapeFrameLike) {
3982
4228
  const distance2 = geometry.distanceToPoint(pointInShapeSpace, hitFrameInside);
3983
4229
  if (hitFrameInside ? distance2 > 0 && distance2 <= outerMargin || distance2 <= 0 && distance2 > -innerMargin : distance2 > 0 && distance2 <= outerMargin) {
3984
4230
  return inMarginClosestToEdgeHit || shape;
@@ -4072,7 +4318,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
4072
4318
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, margin);
4073
4319
  return this.getCurrentPageShapesSorted().filter((shape) => {
4074
4320
  if (this.isShapeHidden(shape)) return false;
4075
- if (!candidateIds.has(shape.id) && !this.isShapeOfType(shape, "frame")) return false;
4321
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
4076
4322
  return this.isPointInShape(shape, point, opts);
4077
4323
  }).reverse();
4078
4324
  }
@@ -4185,6 +4431,24 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
4185
4431
  if (!shape) return false;
4186
4432
  return shape.type === type;
4187
4433
  }
4434
+ /**
4435
+ * Get whether a shape behaves like a frame — a container that has child
4436
+ * shapes, requires full-brush selection, blocks erasure from inside, etc.
4437
+ *
4438
+ * @example
4439
+ * ```ts
4440
+ * const isFrameLike = editor.isShapeFrameLike(someShape)
4441
+ * ```
4442
+ *
4443
+ * @param shape - The shape (or shape id) to test.
4444
+ *
4445
+ * @public
4446
+ */
4447
+ isShapeFrameLike(shape) {
4448
+ const _shape = typeof shape === "string" ? this.getShape(shape) : shape;
4449
+ if (!_shape) return false;
4450
+ return this.getShapeUtil(_shape).isFrameLike(_shape);
4451
+ }
4188
4452
  /**
4189
4453
  * Get a shape by its id.
4190
4454
  *
@@ -4292,6 +4556,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
4292
4556
  return this.getAncestorPageId(this.getShape(_shape.parentId));
4293
4557
  }
4294
4558
  }
4559
+ // Parents and children
4560
+ /**
4561
+ * A cache of parents to children.
4562
+ *
4563
+ * @internal
4564
+ */
4565
+ _parentIdsToChildIds;
4295
4566
  /**
4296
4567
  * Reparent shapes to a new parent. This operation preserves the shape's current page positions /
4297
4568
  * rotations.
@@ -5936,6 +6207,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
5936
6207
  });
5937
6208
  return this;
5938
6209
  }
6210
+ animatingShapes = /* @__PURE__ */ new Map();
5939
6211
  /**
5940
6212
  * Animate a shape.
5941
6213
  *
@@ -6429,6 +6701,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6429
6701
  }
6430
6702
  return this;
6431
6703
  }
6704
+ /* --------------------- Content -------------------- */
6705
+ /** @internal */
6706
+ externalAssetContentHandlers = {
6707
+ file: null,
6708
+ url: null
6709
+ };
6710
+ /** @internal */
6711
+ temporaryAssetPreview = /* @__PURE__ */ new Map();
6432
6712
  /**
6433
6713
  * Register an external asset handler. This handler will be called when the editor needs to
6434
6714
  * create an asset for some external content, like an image/video file or a bookmark URL. For
@@ -6514,6 +6794,17 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6514
6794
  hasExternalAssetHandler(type) {
6515
6795
  return !!this.externalAssetContentHandlers[type];
6516
6796
  }
6797
+ /** @internal */
6798
+ externalContentHandlers = {
6799
+ text: null,
6800
+ files: null,
6801
+ "file-replace": null,
6802
+ embed: null,
6803
+ "svg-text": null,
6804
+ url: null,
6805
+ tldraw: null,
6806
+ excalidraw: null
6807
+ };
6517
6808
  /**
6518
6809
  * Register an external content handler. This handler will be called when the editor receives
6519
6810
  * external content of the provided type. For example, the 'image' type handler will be called
@@ -6610,12 +6901,22 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6610
6901
  if (!asset) continue;
6611
6902
  assets.push(asset);
6612
6903
  }
6904
+ const users = [];
6905
+ const seenUserIds = /* @__PURE__ */ new Set();
6906
+ for (const userId of this._getReferencedUserIds(shapes2)) {
6907
+ const recordId = (0, import_tlschema.createUserId)(userId);
6908
+ if (seenUserIds.has(recordId)) continue;
6909
+ seenUserIds.add(recordId);
6910
+ const user = this.store.get(recordId);
6911
+ if (user) users.push(user);
6912
+ }
6613
6913
  return {
6614
6914
  schema: this.store.schema.serialize(),
6615
6915
  shapes: shapes2,
6616
6916
  rootShapeIds,
6617
6917
  bindings,
6618
- assets
6918
+ assets,
6919
+ users
6619
6920
  };
6620
6921
  });
6621
6922
  }
@@ -6665,13 +6966,15 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6665
6966
  const assets = [];
6666
6967
  const shapes = [];
6667
6968
  const bindings = [];
6969
+ const users = [];
6668
6970
  const store = {
6669
6971
  store: {
6670
6972
  ...Object.fromEntries(content.assets.map((asset) => [asset.id, asset])),
6671
6973
  ...Object.fromEntries(content.shapes.map((shape) => [shape.id, shape])),
6672
6974
  ...Object.fromEntries(
6673
6975
  content.bindings?.map((bindings2) => [bindings2.id, bindings2]) ?? []
6674
- )
6976
+ ),
6977
+ ...Object.fromEntries(content.users?.map((user) => [user.id, user]) ?? [])
6675
6978
  },
6676
6979
  schema: content.schema
6677
6980
  };
@@ -6693,6 +6996,19 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6693
6996
  bindings.push(record);
6694
6997
  break;
6695
6998
  }
6999
+ case "user": {
7000
+ users.push(record);
7001
+ break;
7002
+ }
7003
+ }
7004
+ }
7005
+ if (users.length > 0) {
7006
+ const existingUserIds = new Set(
7007
+ this.store.allRecords().filter((r) => r.typeName === "user").map((r) => r.id)
7008
+ );
7009
+ const usersToCreate = users.filter((u) => !existingUserIds.has(u.id));
7010
+ if (usersToCreate.length > 0) {
7011
+ this.store.put(usersToCreate);
6696
7012
  }
6697
7013
  }
6698
7014
  const shapeIdMap = new Map(
@@ -7403,6 +7719,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7403
7719
  scheduleEffect.cancel();
7404
7720
  };
7405
7721
  }
7722
+ /**
7723
+ * A manager for recording multiple click events.
7724
+ *
7725
+ * @internal
7726
+ */
7727
+ _clickManager = new import_ClickManager.ClickManager(this);
7406
7728
  /**
7407
7729
  * Prevent a double click event from firing the next time the user clicks
7408
7730
  *
@@ -7411,6 +7733,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7411
7733
  cancelDoubleClick() {
7412
7734
  this._clickManager.cancelDoubleClickTimeout();
7413
7735
  }
7736
+ /**
7737
+ * The previous cursor. Used for restoring the cursor after pan events.
7738
+ *
7739
+ * @internal
7740
+ */
7741
+ _prevCursor = "default";
7742
+ /** @internal */
7743
+ _shiftKeyTimeout = -1;
7414
7744
  _setShiftKeyTimeout() {
7415
7745
  this.inputs.setShiftKey(false);
7416
7746
  this.dispatch({
@@ -7425,6 +7755,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7425
7755
  code: "ShiftLeft"
7426
7756
  });
7427
7757
  }
7758
+ /** @internal */
7759
+ _altKeyTimeout = -1;
7428
7760
  _setAltKeyTimeout() {
7429
7761
  this.inputs.setAltKey(false);
7430
7762
  this.dispatch({
@@ -7439,6 +7771,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7439
7771
  code: "AltLeft"
7440
7772
  });
7441
7773
  }
7774
+ /** @internal */
7775
+ _ctrlKeyTimeout = -1;
7442
7776
  _setCtrlKeyTimeout() {
7443
7777
  this.inputs.setCtrlKey(false);
7444
7778
  this.dispatch({
@@ -7453,6 +7787,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7453
7787
  code: "ControlLeft"
7454
7788
  });
7455
7789
  }
7790
+ /** @internal */
7791
+ _metaKeyTimeout = -1;
7456
7792
  _setMetaKeyTimeout() {
7457
7793
  this.inputs.setMetaKey(false);
7458
7794
  this.dispatch({
@@ -7467,6 +7803,22 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7467
7803
  code: "MetaLeft"
7468
7804
  });
7469
7805
  }
7806
+ /** @internal */
7807
+ _restoreToolId = "select";
7808
+ /** @internal */
7809
+ _didPinch = false;
7810
+ /** @internal */
7811
+ _selectedShapeIdsAtPointerDown = [];
7812
+ /** @internal */
7813
+ _longPressTimeout = -1;
7814
+ /** @internal */
7815
+ capturedPointerId = null;
7816
+ /** @internal */
7817
+ performanceTracker;
7818
+ /** @internal */
7819
+ performanceTrackerTimeout = -1;
7820
+ /** @internal */
7821
+ handledEvents = /* @__PURE__ */ new WeakSet();
7470
7822
  /**
7471
7823
  * In tldraw, events are sometimes handled by multiple components. For example, the shapes might
7472
7824
  * have events, but the canvas handles events too. The way that the canvas handles events can
@@ -7512,6 +7864,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7512
7864
  }
7513
7865
  return this;
7514
7866
  }
7867
+ _pendingEventsForNextTick = [];
7515
7868
  _flushEventsForTick(elapsed) {
7516
7869
  this.run(() => {
7517
7870
  if (this._pendingEventsForNextTick.length > 0) {
@@ -7621,6 +7974,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7621
7974
  ),
7622
7975
  { immediate: true }
7623
7976
  );
7977
+ this.performance._notifyCameraOperation("zooming");
7624
7978
  this.emit("event", info);
7625
7979
  return;
7626
7980
  }
@@ -7682,6 +8036,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7682
8036
  immediate: true
7683
8037
  });
7684
8038
  this.maybeTrackPerformance("Zooming");
8039
+ this.performance._notifyCameraOperation("zooming");
7685
8040
  this.root.handleEvent(info);
7686
8041
  this.emit("event", info);
7687
8042
  return;
@@ -7691,6 +8046,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7691
8046
  immediate: true
7692
8047
  });
7693
8048
  this.maybeTrackPerformance("Panning");
8049
+ this.performance._notifyCameraOperation("panning");
7694
8050
  this.root.handleEvent(info);
7695
8051
  this.emit("event", info);
7696
8052
  return;
@@ -7737,6 +8093,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7737
8093
  }
7738
8094
  this.inputs.setIsPanning(true);
7739
8095
  clearTimeout(this._longPressTimeout);
8096
+ } else if (info.button === import_constants.RIGHT_MOUSE_BUTTON && this.options.rightClickPanning) {
8097
+ this.inputs.setIsRightPointing(true);
8098
+ clearTimeout(this._longPressTimeout);
8099
+ return this;
7740
8100
  }
7741
8101
  if (this.inputs.getIsPanning()) {
7742
8102
  this.stopCameraAnimation();
@@ -7748,6 +8108,22 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7748
8108
  case "pointer_move": {
7749
8109
  if (!isPen && isPenMode) return;
7750
8110
  const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
8111
+ if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
8112
+ const currentScreenPoint = this.inputs.getCurrentScreenPoint();
8113
+ const originScreenPoint = this.inputs.getOriginScreenPoint();
8114
+ if (import_Vec.Vec.Dist2(originScreenPoint, currentScreenPoint) > this.options.dragDistanceSquared) {
8115
+ this._prevCursor = this.getInstanceState().cursor.type;
8116
+ this.inputs.setIsPanning(true);
8117
+ this.setCursor({ type: "grabbing", rotation: 0 });
8118
+ this.stopCameraAnimation();
8119
+ const offset = import_Vec.Vec.Sub(currentScreenPoint, originScreenPoint);
8120
+ this.setCamera(new import_Vec.Vec(cx + offset.x / cz, cy + offset.y / cz, cz), {
8121
+ immediate: true
8122
+ });
8123
+ this.maybeTrackPerformance("Panning");
8124
+ }
8125
+ return;
8126
+ }
7751
8127
  if (this.inputs.getIsPanning() && this.inputs.getIsPointing()) {
7752
8128
  const currentScreenPoint = this.inputs.getCurrentScreenPoint();
7753
8129
  const previousScreenPoint = this.inputs.getPreviousScreenPoint();
@@ -7756,6 +8132,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7756
8132
  immediate: true
7757
8133
  });
7758
8134
  this.maybeTrackPerformance("Panning");
8135
+ this.performance._notifyCameraOperation("panning");
7759
8136
  return;
7760
8137
  }
7761
8138
  if (inputs.getIsPointing() && !inputs.getIsDragging() && import_Vec.Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
@@ -7770,6 +8147,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7770
8147
  clearTimeout(this._longPressTimeout);
7771
8148
  inputs.buttons.delete(info.button);
7772
8149
  if (instanceState.isPenMode && !isPen) return;
8150
+ if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
8151
+ this.inputs.setIsRightPointing(false);
8152
+ this._selectedShapeIdsAtPointerDown = [];
8153
+ break;
8154
+ }
8155
+ this.inputs.setIsRightPointing(false);
7773
8156
  if (this.capturedPointerId === info.pointerId) {
7774
8157
  this.capturedPointerId = null;
7775
8158
  info.button = 0;
@@ -7787,11 +8170,24 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7787
8170
  break;
7788
8171
  }
7789
8172
  case import_constants.MIDDLE_MOUSE_BUTTON: {
7790
- if (this.inputs.keys.has(" ")) {
8173
+ if (this.inputs.keys.has("Space")) {
8174
+ this.setCursor({ type: "grab", rotation: 0 });
8175
+ } else {
8176
+ this.setCursor({ type: this._prevCursor, rotation: 0 });
8177
+ }
8178
+ break;
8179
+ }
8180
+ case import_constants.RIGHT_MOUSE_BUTTON: {
8181
+ if (this.inputs.keys.has("Space")) {
7791
8182
  this.setCursor({ type: "grab", rotation: 0 });
7792
8183
  } else {
7793
8184
  this.setCursor({ type: this._prevCursor, rotation: 0 });
7794
8185
  }
8186
+ if (slideSpeed > 0) {
8187
+ this.slideCamera({ speed: slideSpeed, direction: slideDirection });
8188
+ }
8189
+ this._selectedShapeIdsAtPointerDown = [];
8190
+ return this;
7795
8191
  }
7796
8192
  }
7797
8193
  if (slideSpeed > 0) {
@@ -7919,83 +8315,222 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7919
8315
  }
7920
8316
  }
7921
8317
  }
7922
- _init = __decoratorStart(_a);
7923
- __decorateElement(_init, 1, "getIsShapeHiddenCache", _getIsShapeHiddenCache_dec, Editor);
7924
- __decorateElement(_init, 1, "canUndo", _canUndo_dec, Editor);
7925
- __decorateElement(_init, 1, "canRedo", _canRedo_dec, Editor);
7926
- __decorateElement(_init, 1, "getPath", _getPath_dec, Editor);
7927
- __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
7928
- __decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
7929
- __decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
7930
- __decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
7931
- __decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
7932
- __decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
7933
- __decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);
7934
- __decorateElement(_init, 1, "_getCurrentPageStateId", __getCurrentPageStateId_dec, Editor);
7935
- __decorateElement(_init, 1, "getSelectedShapeIds", _getSelectedShapeIds_dec, Editor);
7936
- __decorateElement(_init, 1, "getSelectedShapes", _getSelectedShapes_dec, Editor);
7937
- __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPageShapesInReadingOrder_dec, Editor);
7938
- __decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
7939
- __decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
7940
- __decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
7941
- __decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
7942
- __decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
7943
- __decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);
7944
- __decorateElement(_init, 1, "getFocusedGroupId", _getFocusedGroupId_dec, Editor);
7945
- __decorateElement(_init, 1, "getFocusedGroup", _getFocusedGroup_dec, Editor);
7946
- __decorateElement(_init, 1, "getEditingShapeId", _getEditingShapeId_dec, Editor);
7947
- __decorateElement(_init, 1, "getEditingShape", _getEditingShape_dec, Editor);
7948
- __decorateElement(_init, 1, "getRichTextEditor", _getRichTextEditor_dec, Editor);
7949
- __decorateElement(_init, 1, "getHoveredShapeId", _getHoveredShapeId_dec, Editor);
7950
- __decorateElement(_init, 1, "getHoveredShape", _getHoveredShape_dec, Editor);
7951
- __decorateElement(_init, 1, "getHintingShapeIds", _getHintingShapeIds_dec, Editor);
7952
- __decorateElement(_init, 1, "getHintingShape", _getHintingShape_dec, Editor);
7953
- __decorateElement(_init, 1, "getErasingShapeIds", _getErasingShapeIds_dec, Editor);
7954
- __decorateElement(_init, 1, "getErasingShapes", _getErasingShapes_dec, Editor);
7955
- __decorateElement(_init, 1, "_unsafe_getCameraId", __unsafe_getCameraId_dec, Editor);
7956
- __decorateElement(_init, 1, "getCamera", _getCamera_dec, Editor);
7957
- __decorateElement(_init, 1, "getViewportPageBoundsForFollowing", _getViewportPageBoundsForFollowing_dec, Editor);
7958
- __decorateElement(_init, 1, "getCameraForFollowing", _getCameraForFollowing_dec, Editor);
7959
- __decorateElement(_init, 1, "getZoomLevel", _getZoomLevel_dec, Editor);
7960
- __decorateElement(_init, 1, "getResizeScaleFactor", _getResizeScaleFactor_dec, Editor);
7961
- __decorateElement(_init, 1, "getDebouncedZoomLevel", _getDebouncedZoomLevel_dec, Editor);
7962
- __decorateElement(_init, 1, "_getAboveDebouncedZoomThreshold", __getAboveDebouncedZoomThreshold_dec, Editor);
7963
- __decorateElement(_init, 1, "getEfficientZoomLevel", _getEfficientZoomLevel_dec, Editor);
7964
- __decorateElement(_init, 1, "getViewportScreenBounds", _getViewportScreenBounds_dec, Editor);
7965
- __decorateElement(_init, 1, "getViewportScreenCenter", _getViewportScreenCenter_dec, Editor);
7966
- __decorateElement(_init, 1, "getViewportPageBounds", _getViewportPageBounds_dec, Editor);
7967
- __decorateElement(_init, 1, "_getCollaboratorsQuery", __getCollaboratorsQuery_dec, Editor);
7968
- __decorateElement(_init, 1, "getCollaborators", _getCollaborators_dec, Editor);
7969
- __decorateElement(_init, 1, "getCollaboratorsOnCurrentPage", _getCollaboratorsOnCurrentPage_dec, Editor);
7970
- __decorateElement(_init, 1, "getRenderingShapes", _getRenderingShapes_dec, Editor);
7971
- __decorateElement(_init, 1, "_getAllPagesQuery", __getAllPagesQuery_dec, Editor);
7972
- __decorateElement(_init, 1, "getPages", _getPages_dec, Editor);
7973
- __decorateElement(_init, 1, "getCurrentPageId", _getCurrentPageId_dec, Editor);
7974
- __decorateElement(_init, 1, "getCurrentPageShapeIdsSorted", _getCurrentPageShapeIdsSorted_dec, Editor);
7975
- __decorateElement(_init, 1, "_getAllAssetsQuery", __getAllAssetsQuery_dec, Editor);
7976
- __decorateElement(_init, 1, "_getShapeHandlesCache", __getShapeHandlesCache_dec, Editor);
7977
- __decorateElement(_init, 1, "_getShapePageTransformCache", __getShapePageTransformCache_dec, Editor);
7978
- __decorateElement(_init, 1, "_getShapePageBoundsCache", __getShapePageBoundsCache_dec, Editor);
7979
- __decorateElement(_init, 1, "_getShapeClipPathCache", __getShapeClipPathCache_dec, Editor);
7980
- __decorateElement(_init, 1, "_getShapeMaskCache", __getShapeMaskCache_dec, Editor);
7981
- __decorateElement(_init, 1, "_getShapeMaskedPageBoundsCache", __getShapeMaskedPageBoundsCache_dec, Editor);
7982
- __decorateElement(_init, 1, "getNotVisibleShapes", _getNotVisibleShapes_dec, Editor);
7983
- __decorateElement(_init, 1, "getCulledShapes", _getCulledShapes_dec, Editor);
7984
- __decorateElement(_init, 1, "getCurrentPageBounds", _getCurrentPageBounds_dec, Editor);
7985
- __decorateElement(_init, 1, "getCurrentPageShapes", _getCurrentPageShapes_dec, Editor);
7986
- __decorateElement(_init, 1, "getCurrentPageShapesSorted", _getCurrentPageShapesSorted_dec, Editor);
7987
- __decorateElement(_init, 1, "getCurrentPageRenderingShapesSorted", _getCurrentPageRenderingShapesSorted_dec, Editor);
7988
- __decorateElement(_init, 1, "_getBindingsIndexCache", __getBindingsIndexCache_dec, Editor);
7989
- __decorateElement(_init, 1, "_getSelectionSharedStyles", __getSelectionSharedStyles_dec, Editor);
7990
- __decorateElement(_init, 1, "getSharedStyles", _getSharedStyles_dec, Editor);
7991
- __decorateElement(_init, 1, "getSharedOpacity", _getSharedOpacity_dec, Editor);
7992
- __decorateElement(_init, 1, "getIsFocused", _getIsFocused_dec, Editor);
7993
- __decorateElement(_init, 1, "getIsReadonly", _getIsReadonly_dec, Editor);
7994
- __decorateElement(_init, 1, "_setShiftKeyTimeout", __setShiftKeyTimeout_dec, Editor);
7995
- __decorateElement(_init, 1, "_setAltKeyTimeout", __setAltKeyTimeout_dec, Editor);
7996
- __decorateElement(_init, 1, "_setCtrlKeyTimeout", __setCtrlKeyTimeout_dec, Editor);
7997
- __decorateElement(_init, 1, "_setMetaKeyTimeout", __setMetaKeyTimeout_dec, Editor);
7998
- __decoratorMetadata(_init, Editor);
8318
+ __decorateClass([
8319
+ import_state.computed
8320
+ ], Editor.prototype, "getIsShapeHiddenCache", 1);
8321
+ __decorateClass([
8322
+ import_state.computed
8323
+ ], Editor.prototype, "canUndo", 1);
8324
+ __decorateClass([
8325
+ import_state.computed
8326
+ ], Editor.prototype, "canRedo", 1);
8327
+ __decorateClass([
8328
+ import_state.computed
8329
+ ], Editor.prototype, "getPath", 1);
8330
+ __decorateClass([
8331
+ import_state.computed
8332
+ ], Editor.prototype, "getCurrentTool", 1);
8333
+ __decorateClass([
8334
+ import_state.computed
8335
+ ], Editor.prototype, "getCurrentToolId", 1);
8336
+ __decorateClass([
8337
+ import_state.computed
8338
+ ], Editor.prototype, "getDocumentSettings", 1);
8339
+ __decorateClass([
8340
+ import_state.computed
8341
+ ], Editor.prototype, "getInstanceState", 1);
8342
+ __decorateClass([
8343
+ import_state.computed
8344
+ ], Editor.prototype, "getPageStates", 1);
8345
+ __decorateClass([
8346
+ import_state.computed
8347
+ ], Editor.prototype, "_getPageStatesQuery", 1);
8348
+ __decorateClass([
8349
+ import_state.computed
8350
+ ], Editor.prototype, "getCurrentPageState", 1);
8351
+ __decorateClass([
8352
+ import_state.computed
8353
+ ], Editor.prototype, "_getCurrentPageStateId", 1);
8354
+ __decorateClass([
8355
+ import_state.computed
8356
+ ], Editor.prototype, "getSelectedShapeIds", 1);
8357
+ __decorateClass([
8358
+ import_state.computed
8359
+ ], Editor.prototype, "getSelectedShapes", 1);
8360
+ __decorateClass([
8361
+ import_state.computed
8362
+ ], Editor.prototype, "getCurrentPageShapesInReadingOrder", 1);
8363
+ __decorateClass([
8364
+ import_state.computed
8365
+ ], Editor.prototype, "getOnlySelectedShapeId", 1);
8366
+ __decorateClass([
8367
+ import_state.computed
8368
+ ], Editor.prototype, "getOnlySelectedShape", 1);
8369
+ __decorateClass([
8370
+ import_state.computed
8371
+ ], Editor.prototype, "getSelectionPageBounds", 1);
8372
+ __decorateClass([
8373
+ import_state.computed
8374
+ ], Editor.prototype, "getSelectionRotation", 1);
8375
+ __decorateClass([
8376
+ import_state.computed
8377
+ ], Editor.prototype, "getSelectionRotatedPageBounds", 1);
8378
+ __decorateClass([
8379
+ import_state.computed
8380
+ ], Editor.prototype, "getSelectionRotatedScreenBounds", 1);
8381
+ __decorateClass([
8382
+ import_state.computed
8383
+ ], Editor.prototype, "getFocusedGroupId", 1);
8384
+ __decorateClass([
8385
+ import_state.computed
8386
+ ], Editor.prototype, "getFocusedGroup", 1);
8387
+ __decorateClass([
8388
+ import_state.computed
8389
+ ], Editor.prototype, "getEditingShapeId", 1);
8390
+ __decorateClass([
8391
+ import_state.computed
8392
+ ], Editor.prototype, "getEditingShape", 1);
8393
+ __decorateClass([
8394
+ import_state.computed
8395
+ ], Editor.prototype, "getRichTextEditor", 1);
8396
+ __decorateClass([
8397
+ import_state.computed
8398
+ ], Editor.prototype, "getHoveredShapeId", 1);
8399
+ __decorateClass([
8400
+ import_state.computed
8401
+ ], Editor.prototype, "getHoveredShape", 1);
8402
+ __decorateClass([
8403
+ import_state.computed
8404
+ ], Editor.prototype, "getHintingShapeIds", 1);
8405
+ __decorateClass([
8406
+ import_state.computed
8407
+ ], Editor.prototype, "getHintingShape", 1);
8408
+ __decorateClass([
8409
+ import_state.computed
8410
+ ], Editor.prototype, "getErasingShapeIds", 1);
8411
+ __decorateClass([
8412
+ import_state.computed
8413
+ ], Editor.prototype, "getErasingShapes", 1);
8414
+ __decorateClass([
8415
+ import_state.computed
8416
+ ], Editor.prototype, "_unsafe_getCameraId", 1);
8417
+ __decorateClass([
8418
+ import_state.computed
8419
+ ], Editor.prototype, "getCamera", 1);
8420
+ __decorateClass([
8421
+ import_state.computed
8422
+ ], Editor.prototype, "getViewportPageBoundsForFollowing", 1);
8423
+ __decorateClass([
8424
+ import_state.computed
8425
+ ], Editor.prototype, "getCameraForFollowing", 1);
8426
+ __decorateClass([
8427
+ import_state.computed
8428
+ ], Editor.prototype, "getZoomLevel", 1);
8429
+ __decorateClass([
8430
+ import_state.computed
8431
+ ], Editor.prototype, "getResizeScaleFactor", 1);
8432
+ __decorateClass([
8433
+ import_state.computed
8434
+ ], Editor.prototype, "getDebouncedZoomLevel", 1);
8435
+ __decorateClass([
8436
+ import_state.computed
8437
+ ], Editor.prototype, "_getAboveDebouncedZoomThreshold", 1);
8438
+ __decorateClass([
8439
+ import_state.computed
8440
+ ], Editor.prototype, "getEfficientZoomLevel", 1);
8441
+ __decorateClass([
8442
+ import_state.computed
8443
+ ], Editor.prototype, "getViewportScreenBounds", 1);
8444
+ __decorateClass([
8445
+ import_state.computed
8446
+ ], Editor.prototype, "getViewportScreenCenter", 1);
8447
+ __decorateClass([
8448
+ import_state.computed
8449
+ ], Editor.prototype, "getViewportPageBounds", 1);
8450
+ __decorateClass([
8451
+ import_state.computed
8452
+ ], Editor.prototype, "getRenderingShapes", 1);
8453
+ __decorateClass([
8454
+ import_state.computed
8455
+ ], Editor.prototype, "_getAllPagesQuery", 1);
8456
+ __decorateClass([
8457
+ import_state.computed
8458
+ ], Editor.prototype, "getPages", 1);
8459
+ __decorateClass([
8460
+ import_state.computed
8461
+ ], Editor.prototype, "getCurrentPageId", 1);
8462
+ __decorateClass([
8463
+ import_state.computed
8464
+ ], Editor.prototype, "getCurrentPageShapeIdsSorted", 1);
8465
+ __decorateClass([
8466
+ import_state.computed
8467
+ ], Editor.prototype, "_getAllAssetsQuery", 1);
8468
+ __decorateClass([
8469
+ import_state.computed
8470
+ ], Editor.prototype, "_getShapeHandlesCache", 1);
8471
+ __decorateClass([
8472
+ import_state.computed
8473
+ ], Editor.prototype, "_getShapePageTransformCache", 1);
8474
+ __decorateClass([
8475
+ import_state.computed
8476
+ ], Editor.prototype, "_getShapePageBoundsCache", 1);
8477
+ __decorateClass([
8478
+ import_state.computed
8479
+ ], Editor.prototype, "_getShapeClipPathCache", 1);
8480
+ __decorateClass([
8481
+ import_state.computed
8482
+ ], Editor.prototype, "_getShapeMaskCache", 1);
8483
+ __decorateClass([
8484
+ import_state.computed
8485
+ ], Editor.prototype, "_getShapeMaskedPageBoundsCache", 1);
8486
+ __decorateClass([
8487
+ import_state.computed
8488
+ ], Editor.prototype, "getNotVisibleShapes", 1);
8489
+ __decorateClass([
8490
+ import_state.computed
8491
+ ], Editor.prototype, "getCulledShapes", 1);
8492
+ __decorateClass([
8493
+ import_state.computed
8494
+ ], Editor.prototype, "getCurrentPageBounds", 1);
8495
+ __decorateClass([
8496
+ import_state.computed
8497
+ ], Editor.prototype, "getCurrentPageShapes", 1);
8498
+ __decorateClass([
8499
+ import_state.computed
8500
+ ], Editor.prototype, "getCurrentPageShapesSorted", 1);
8501
+ __decorateClass([
8502
+ import_state.computed
8503
+ ], Editor.prototype, "getCurrentPageRenderingShapesSorted", 1);
8504
+ __decorateClass([
8505
+ import_state.computed
8506
+ ], Editor.prototype, "_getBindingsIndexCache", 1);
8507
+ __decorateClass([
8508
+ import_state.computed
8509
+ ], Editor.prototype, "_getSelectionSharedStyles", 1);
8510
+ __decorateClass([
8511
+ (0, import_state.computed)({ isEqual: (a, b) => a.equals(b) })
8512
+ ], Editor.prototype, "getSharedStyles", 1);
8513
+ __decorateClass([
8514
+ import_state.computed
8515
+ ], Editor.prototype, "getSharedOpacity", 1);
8516
+ __decorateClass([
8517
+ import_state.computed
8518
+ ], Editor.prototype, "getIsFocused", 1);
8519
+ __decorateClass([
8520
+ import_state.computed
8521
+ ], Editor.prototype, "getIsReadonly", 1);
8522
+ __decorateClass([
8523
+ import_utils.bind
8524
+ ], Editor.prototype, "_setShiftKeyTimeout", 1);
8525
+ __decorateClass([
8526
+ import_utils.bind
8527
+ ], Editor.prototype, "_setAltKeyTimeout", 1);
8528
+ __decorateClass([
8529
+ import_utils.bind
8530
+ ], Editor.prototype, "_setCtrlKeyTimeout", 1);
8531
+ __decorateClass([
8532
+ import_utils.bind
8533
+ ], Editor.prototype, "_setMetaKeyTimeout", 1);
7999
8534
  function alertMaxShapes(editor, pageId = editor.getCurrentPageId()) {
8000
8535
  const name = editor.getPage(pageId).name;
8001
8536
  editor.emit("max-shapes", { name, pageId, count: editor.options.maxShapesPerPage });