@tldraw/editor 4.5.2 → 4.6.0-canary.00a8c03b5687

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 (279) hide show
  1. package/dist-cjs/index.d.ts +37 -6
  2. package/dist-cjs/index.js +6 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +7 -5
  5. package/dist-cjs/lib/TldrawEditor.js.map +3 -3
  6. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +3 -2
  7. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +2 -2
  8. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
  9. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  10. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +8 -5
  11. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
  12. package/dist-cjs/lib/config/TLSessionStateSnapshot.js +8 -5
  13. package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +2 -2
  14. package/dist-cjs/lib/config/TLUserPreferences.js +3 -2
  15. package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
  16. package/dist-cjs/lib/config/createTLStore.js +1 -0
  17. package/dist-cjs/lib/config/createTLStore.js.map +2 -2
  18. package/dist-cjs/lib/config/createTLUser.js.map +1 -1
  19. package/dist-cjs/lib/editor/Editor.js +511 -366
  20. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  21. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +25 -64
  22. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
  23. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +22 -5
  24. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +2 -2
  25. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js +4 -3
  26. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
  27. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +5 -0
  28. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
  29. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +71 -112
  30. package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
  31. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +20 -55
  32. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +1 -1
  33. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +11 -52
  34. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +1 -1
  35. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +19 -56
  36. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +1 -1
  37. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +2 -2
  38. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
  39. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +16 -55
  40. package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
  41. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +60 -70
  42. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  43. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  44. package/dist-cjs/lib/exports/ExportDelay.js +12 -53
  45. package/dist-cjs/lib/exports/ExportDelay.js.map +1 -1
  46. package/dist-cjs/lib/exports/FontEmbedder.js +23 -65
  47. package/dist-cjs/lib/exports/FontEmbedder.js.map +2 -2
  48. package/dist-cjs/lib/exports/StyleEmbedder.js +27 -15
  49. package/dist-cjs/lib/exports/StyleEmbedder.js.map +3 -3
  50. package/dist-cjs/lib/exports/domUtils.js +15 -0
  51. package/dist-cjs/lib/exports/domUtils.js.map +2 -2
  52. package/dist-cjs/lib/exports/embedMedia.js +15 -12
  53. package/dist-cjs/lib/exports/embedMedia.js.map +2 -2
  54. package/dist-cjs/lib/exports/exportToSvg.js +8 -7
  55. package/dist-cjs/lib/exports/exportToSvg.js.map +2 -2
  56. package/dist-cjs/lib/exports/getSvgAsImage.js +181 -29
  57. package/dist-cjs/lib/exports/getSvgAsImage.js.map +3 -3
  58. package/dist-cjs/lib/exports/getSvgJsx.js +21 -9
  59. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  60. package/dist-cjs/lib/globals/environment.js +4 -3
  61. package/dist-cjs/lib/globals/environment.js.map +2 -2
  62. package/dist-cjs/lib/hooks/useCanvasEvents.js +2 -2
  63. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  64. package/dist-cjs/lib/hooks/useDocumentEvents.js +13 -11
  65. package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
  66. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js +3 -2
  67. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
  68. package/dist-cjs/lib/hooks/useScreenBounds.js +10 -6
  69. package/dist-cjs/lib/hooks/useScreenBounds.js.map +2 -2
  70. package/dist-cjs/lib/hooks/useViewportHeight.js +13 -11
  71. package/dist-cjs/lib/hooks/useViewportHeight.js.map +3 -3
  72. package/dist-cjs/lib/license/Watermark.js +10 -0
  73. package/dist-cjs/lib/license/Watermark.js.map +2 -2
  74. package/dist-cjs/lib/primitives/Box.js +25 -25
  75. package/dist-cjs/lib/primitives/Box.js.map +1 -1
  76. package/dist-cjs/lib/primitives/Vec.js +36 -23
  77. package/dist-cjs/lib/primitives/Vec.js.map +2 -2
  78. package/dist-cjs/lib/primitives/geometry/Arc2d.js +6 -13
  79. package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
  80. package/dist-cjs/lib/primitives/geometry/Circle2d.js +31 -2
  81. package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
  82. package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +9 -0
  83. package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
  84. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +10 -1
  85. package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +2 -2
  86. package/dist-cjs/lib/primitives/geometry/Edge2d.js +32 -18
  87. package/dist-cjs/lib/primitives/geometry/Edge2d.js.map +2 -2
  88. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +13 -1
  89. package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
  90. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +6 -6
  91. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +1 -1
  92. package/dist-cjs/lib/primitives/geometry/Polyline2d.js +52 -13
  93. package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
  94. package/dist-cjs/lib/primitives/geometry/Stadium2d.js +12 -0
  95. package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
  96. package/dist-cjs/lib/primitives/geometry/geometry.bench.js +133 -0
  97. package/dist-cjs/lib/primitives/geometry/geometry.bench.js.map +7 -0
  98. package/dist-cjs/lib/primitives/intersect.js +16 -15
  99. package/dist-cjs/lib/primitives/intersect.js.map +2 -2
  100. package/dist-cjs/lib/primitives/utils.js +0 -1
  101. package/dist-cjs/lib/primitives/utils.js.map +2 -2
  102. package/dist-cjs/lib/utils/SharedStylesMap.js +1 -1
  103. package/dist-cjs/lib/utils/SharedStylesMap.js.map +1 -1
  104. package/dist-cjs/lib/utils/browserCanvasMaxSize.js +3 -2
  105. package/dist-cjs/lib/utils/browserCanvasMaxSize.js.map +2 -2
  106. package/dist-cjs/lib/utils/dom.js +15 -2
  107. package/dist-cjs/lib/utils/dom.js.map +2 -2
  108. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +2 -1
  109. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
  110. package/dist-cjs/version.js +3 -3
  111. package/dist-cjs/version.js.map +1 -1
  112. package/dist-esm/index.d.mts +37 -6
  113. package/dist-esm/index.mjs +8 -1
  114. package/dist-esm/index.mjs.map +2 -2
  115. package/dist-esm/lib/TldrawEditor.mjs +7 -5
  116. package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
  117. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +2 -1
  118. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +2 -2
  119. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
  120. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  121. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +8 -5
  122. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
  123. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs +8 -5
  124. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
  125. package/dist-esm/lib/config/TLUserPreferences.mjs +3 -2
  126. package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
  127. package/dist-esm/lib/config/createTLStore.mjs +1 -0
  128. package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
  129. package/dist-esm/lib/config/createTLUser.mjs.map +1 -1
  130. package/dist-esm/lib/editor/Editor.mjs +512 -368
  131. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  132. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +25 -64
  133. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
  134. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +24 -5
  135. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +2 -2
  136. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs +4 -3
  137. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
  138. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +5 -0
  139. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
  140. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +71 -112
  141. package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
  142. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +20 -55
  143. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +1 -1
  144. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +11 -52
  145. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +1 -1
  146. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +19 -56
  147. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +1 -1
  148. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +2 -2
  149. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
  150. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +16 -55
  151. package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
  152. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +60 -70
  153. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  154. package/dist-esm/lib/exports/ExportDelay.mjs +12 -53
  155. package/dist-esm/lib/exports/ExportDelay.mjs.map +1 -1
  156. package/dist-esm/lib/exports/FontEmbedder.mjs +23 -65
  157. package/dist-esm/lib/exports/FontEmbedder.mjs.map +2 -2
  158. package/dist-esm/lib/exports/StyleEmbedder.mjs +29 -16
  159. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +3 -3
  160. package/dist-esm/lib/exports/domUtils.mjs +15 -0
  161. package/dist-esm/lib/exports/domUtils.mjs.map +2 -2
  162. package/dist-esm/lib/exports/embedMedia.mjs +16 -13
  163. package/dist-esm/lib/exports/embedMedia.mjs.map +2 -2
  164. package/dist-esm/lib/exports/exportToSvg.mjs +8 -7
  165. package/dist-esm/lib/exports/exportToSvg.mjs.map +2 -2
  166. package/dist-esm/lib/exports/getSvgAsImage.mjs +181 -29
  167. package/dist-esm/lib/exports/getSvgAsImage.mjs.map +3 -3
  168. package/dist-esm/lib/exports/getSvgJsx.mjs +21 -9
  169. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  170. package/dist-esm/lib/globals/environment.mjs +4 -3
  171. package/dist-esm/lib/globals/environment.mjs.map +2 -2
  172. package/dist-esm/lib/hooks/useCanvasEvents.mjs +2 -2
  173. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  174. package/dist-esm/lib/hooks/useDocumentEvents.mjs +13 -11
  175. package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
  176. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs +3 -2
  177. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
  178. package/dist-esm/lib/hooks/useScreenBounds.mjs +10 -6
  179. package/dist-esm/lib/hooks/useScreenBounds.mjs.map +2 -2
  180. package/dist-esm/lib/hooks/useViewportHeight.mjs +13 -11
  181. package/dist-esm/lib/hooks/useViewportHeight.mjs.map +3 -3
  182. package/dist-esm/lib/license/Watermark.mjs +10 -0
  183. package/dist-esm/lib/license/Watermark.mjs.map +2 -2
  184. package/dist-esm/lib/primitives/Box.mjs +25 -25
  185. package/dist-esm/lib/primitives/Box.mjs.map +1 -1
  186. package/dist-esm/lib/primitives/Vec.mjs +36 -23
  187. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  188. package/dist-esm/lib/primitives/geometry/Arc2d.mjs +6 -13
  189. package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
  190. package/dist-esm/lib/primitives/geometry/Circle2d.mjs +31 -2
  191. package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
  192. package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +9 -0
  193. package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
  194. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +10 -1
  195. package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +2 -2
  196. package/dist-esm/lib/primitives/geometry/Edge2d.mjs +32 -18
  197. package/dist-esm/lib/primitives/geometry/Edge2d.mjs.map +2 -2
  198. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +14 -2
  199. package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
  200. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +6 -6
  201. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +1 -1
  202. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +52 -13
  203. package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
  204. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +13 -1
  205. package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
  206. package/dist-esm/lib/primitives/geometry/geometry.bench.mjs +132 -0
  207. package/dist-esm/lib/primitives/geometry/geometry.bench.mjs.map +7 -0
  208. package/dist-esm/lib/primitives/intersect.mjs +17 -16
  209. package/dist-esm/lib/primitives/intersect.mjs.map +2 -2
  210. package/dist-esm/lib/primitives/utils.mjs +0 -1
  211. package/dist-esm/lib/primitives/utils.mjs.map +2 -2
  212. package/dist-esm/lib/utils/SharedStylesMap.mjs +1 -1
  213. package/dist-esm/lib/utils/SharedStylesMap.mjs.map +1 -1
  214. package/dist-esm/lib/utils/browserCanvasMaxSize.mjs +3 -2
  215. package/dist-esm/lib/utils/browserCanvasMaxSize.mjs.map +2 -2
  216. package/dist-esm/lib/utils/dom.mjs +15 -2
  217. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  218. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +2 -1
  219. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
  220. package/dist-esm/version.mjs +3 -3
  221. package/dist-esm/version.mjs.map +1 -1
  222. package/package.json +8 -8
  223. package/src/index.ts +10 -6
  224. package/src/lib/TldrawEditor.tsx +7 -5
  225. package/src/lib/components/default-components/CanvasShapeIndicators.tsx +2 -1
  226. package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
  227. package/src/lib/components/default-components/DefaultErrorFallback.tsx +9 -5
  228. package/src/lib/config/TLSessionStateSnapshot.ts +8 -5
  229. package/src/lib/config/TLUserPreferences.ts +3 -2
  230. package/src/lib/config/createTLStore.ts +3 -0
  231. package/src/lib/config/createTLUser.ts +3 -3
  232. package/src/lib/editor/Editor.ts +53 -15
  233. package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
  234. package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +7 -6
  235. package/src/lib/editor/managers/FocusManager/FocusManager.ts +10 -7
  236. package/src/lib/editor/managers/FontManager/FontManager.test.ts +1 -0
  237. package/src/lib/editor/managers/FontManager/FontManager.ts +4 -3
  238. package/src/lib/editor/managers/HistoryManager/HistoryManager.test.ts +16 -0
  239. package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +7 -2
  240. package/src/lib/editor/managers/InputsManager/InputsManager.ts +30 -30
  241. package/src/lib/editor/managers/TextManager/TextManager.test.ts +4 -5
  242. package/src/lib/editor/managers/TextManager/TextManager.ts +2 -2
  243. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +3 -2
  244. package/src/lib/editor/types/misc-types.ts +8 -2
  245. package/src/lib/exports/FontEmbedder.ts +10 -9
  246. package/src/lib/exports/StyleEmbedder.ts +33 -15
  247. package/src/lib/exports/domUtils.ts +20 -0
  248. package/src/lib/exports/embedMedia.ts +23 -17
  249. package/src/lib/exports/exportToSvg.tsx +8 -7
  250. package/src/lib/exports/getSvgAsImage.ts +292 -32
  251. package/src/lib/exports/getSvgJsx.test.ts +103 -101
  252. package/src/lib/exports/getSvgJsx.tsx +33 -10
  253. package/src/lib/globals/environment.ts +4 -3
  254. package/src/lib/hooks/useCanvasEvents.ts +2 -3
  255. package/src/lib/hooks/useDocumentEvents.ts +16 -11
  256. package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +3 -3
  257. package/src/lib/hooks/useScreenBounds.ts +10 -6
  258. package/src/lib/hooks/useViewportHeight.ts +13 -11
  259. package/src/lib/license/Watermark.tsx +10 -0
  260. package/src/lib/primitives/Box.ts +25 -25
  261. package/src/lib/primitives/Vec.ts +52 -25
  262. package/src/lib/primitives/geometry/Arc2d.ts +10 -15
  263. package/src/lib/primitives/geometry/Circle2d.ts +40 -2
  264. package/src/lib/primitives/geometry/CubicBezier2d.ts +10 -0
  265. package/src/lib/primitives/geometry/CubicSpline2d.ts +11 -1
  266. package/src/lib/primitives/geometry/Edge2d.ts +41 -18
  267. package/src/lib/primitives/geometry/Ellipse2d.ts +15 -2
  268. package/src/lib/primitives/geometry/Geometry2d.ts +6 -6
  269. package/src/lib/primitives/geometry/Polyline2d.ts +61 -13
  270. package/src/lib/primitives/geometry/Stadium2d.ts +14 -1
  271. package/src/lib/primitives/geometry/geometry.bench.ts +179 -0
  272. package/src/lib/primitives/intersect.ts +27 -27
  273. package/src/lib/primitives/utils.ts +4 -4
  274. package/src/lib/test/TestEditor.ts +1 -0
  275. package/src/lib/utils/SharedStylesMap.ts +1 -1
  276. package/src/lib/utils/browserCanvasMaxSize.ts +4 -2
  277. package/src/lib/utils/dom.ts +34 -2
  278. package/src/lib/utils/sync/TLLocalSyncClient.ts +1 -0
  279. package/src/version.ts +3 -3
@@ -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
@@ -86,6 +49,7 @@ var import_createTLUser = require("../config/createTLUser");
86
49
  var import_defaultBindings = require("../config/defaultBindings");
87
50
  var import_defaultShapes = require("../config/defaultShapes");
88
51
  var import_constants = require("../constants");
52
+ var import_domUtils = require("../exports/domUtils");
89
53
  var import_exportToSvg = require("../exports/exportToSvg");
90
54
  var import_getSvgAsImage = require("../exports/getSvgAsImage");
91
55
  var import_menus = require("../globals/menus");
@@ -124,8 +88,8 @@ var import_TextManager = require("./managers/TextManager/TextManager");
124
88
  var import_TickManager = require("./managers/TickManager/TickManager");
125
89
  var import_UserPreferencesManager = require("./managers/UserPreferencesManager/UserPreferencesManager");
126
90
  var import_RootState = require("./tools/RootState");
127
- 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;
128
- 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) {
91
+ class Editor extends import_eventemitter3.default {
92
+ id = (0, import_utils.uniqueId)();
129
93
  constructor({
130
94
  store,
131
95
  user,
@@ -147,233 +111,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
147
111
  fontAssetUrls
148
112
  }) {
149
113
  super();
150
- __runInitializers(_init, 5, this);
151
- __publicField(this, "id", (0, import_utils.uniqueId)());
152
- __publicField(this, "_getShapeVisibility");
153
- __publicField(this, "options");
154
- __publicField(this, "contextId", (0, import_utils.uniqueId)());
155
- /**
156
- * The editor's store
157
- *
158
- * @public
159
- */
160
- __publicField(this, "store");
161
- /**
162
- * The root state of the statechart.
163
- *
164
- * @public
165
- */
166
- __publicField(this, "root");
167
- /**
168
- * A set of functions to call when the editor is disposed.
169
- *
170
- * @public
171
- */
172
- __publicField(this, "disposables", /* @__PURE__ */ new Set());
173
- /**
174
- * Whether the editor is disposed.
175
- *
176
- * @public
177
- */
178
- __publicField(this, "isDisposed", false);
179
- /**
180
- * A manager for the editor's tick events.
181
- *
182
- * @internal */
183
- __publicField(this, "_tickManager");
184
- /**
185
- * A manager for the editor's input state.
186
- *
187
- * @public
188
- */
189
- __publicField(this, "inputs");
190
- /**
191
- * A manager for the editor's snapping feature.
192
- *
193
- * @public
194
- */
195
- __publicField(this, "snaps");
196
- __publicField(this, "_spatialIndex");
197
- /**
198
- * A manager for the any asynchronous events and making sure they're
199
- * cleaned up upon disposal.
200
- *
201
- * @public
202
- */
203
- __publicField(this, "timers", import_time.tltime.forContext(this.contextId));
204
- /**
205
- * A manager for the user and their preferences.
206
- *
207
- * @public
208
- */
209
- __publicField(this, "user");
210
- /**
211
- * A helper for measuring text.
212
- *
213
- * @public
214
- */
215
- __publicField(this, "textMeasure");
216
- /**
217
- * A utility for managing the set of fonts that should be rendered in the document.
218
- *
219
- * @public
220
- */
221
- __publicField(this, "fonts");
222
- /**
223
- * A manager for the editor's scribbles.
224
- *
225
- * @public
226
- */
227
- __publicField(this, "scribbles");
228
- /**
229
- * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
230
- *
231
- * @public
232
- */
233
- __publicField(this, "sideEffects");
234
- /**
235
- * A manager for moving the camera when the mouse is at the edge of the screen.
236
- *
237
- * @public
238
- */
239
- __publicField(this, "edgeScrollManager");
240
- /**
241
- * A manager for ensuring correct focus. See FocusManager for details.
242
- *
243
- * @internal
244
- */
245
- __publicField(this, "focusManager");
246
- /**
247
- * The current HTML element containing the editor.
248
- *
249
- * @example
250
- * ```ts
251
- * const container = editor.getContainer()
252
- * ```
253
- *
254
- * @public
255
- */
256
- __publicField(this, "getContainer");
257
- /* ------------------- Shape Utils ------------------ */
258
- /**
259
- * A map of shape utility classes (TLShapeUtils) by shape type.
260
- *
261
- * @public
262
- */
263
- __publicField(this, "shapeUtils");
264
- __publicField(this, "styleProps");
265
- /* ------------------- Binding Utils ------------------ */
266
- /**
267
- * A map of shape utility classes (TLShapeUtils) by shape type.
268
- *
269
- * @public
270
- */
271
- __publicField(this, "bindingUtils");
272
- /* --------------------- History -------------------- */
273
- /**
274
- * A manager for the editor's history.
275
- *
276
- * @readonly
277
- */
278
- __publicField(this, "history");
279
- __publicField(this, "_shouldIgnoreShapeLock", false);
280
- /** @internal */
281
- __publicField(this, "_crashingError", null);
282
- /** @internal */
283
- __publicField(this, "_isChangingStyleTimeout", -1);
284
- // Menus
285
- __publicField(this, "menus", import_menus.tlmenus.forContext(this.contextId));
286
- // Rich text editor
287
- __publicField(this, "_currentRichTextEditor", (0, import_state.atom)("rich text editor", null));
288
- __publicField(this, "_textOptions");
289
- __publicField(this, "_debouncedZoomLevel", (0, import_state.atom)("debounced zoom level", 1));
290
- __publicField(this, "_cameraOptions", (0, import_state.atom)("camera options", import_constants.DEFAULT_CAMERA_OPTIONS));
291
- /** @internal */
292
- __publicField(this, "_viewportAnimation", null);
293
- // Viewport
294
- /** @internal */
295
- __publicField(this, "_willSetInitialBounds", true);
296
- // Following
297
- // When we are 'locked on' to a user, our camera is derived from their camera.
298
- __publicField(this, "_isLockedOnFollowingUser", (0, import_state.atom)("isLockedOnFollowingUser", false));
299
- // Camera state
300
- // Camera state does two things: first, it allows us to subscribe to whether
301
- // the camera is moving or not; and second, it allows us to update the rendering
302
- // shapes on the canvas. Changing the rendering shapes may cause shapes to
303
- // unmount / remount in the DOM, which is expensive; and computing visibility is
304
- // also expensive in large projects. For this reason, we use a second bounding
305
- // box just for rendering, and we only update after the camera stops moving.
306
- __publicField(this, "_cameraStateTimeoutRemaining", 0);
307
- /* @internal */
308
- __publicField(this, "_currentPageShapeIds");
309
- /* --------------------- Shapes --------------------- */
310
- __publicField(this, "_shapeGeometryCaches", {});
311
- __publicField(this, "_notVisibleShapes", (0, import_notVisibleShapes.notVisibleShapes)(this));
312
- __publicField(this, "_culledShapesCache", null);
313
- // Parents and children
314
- /**
315
- * A cache of parents to children.
316
- *
317
- * @internal
318
- */
319
- __publicField(this, "_parentIdsToChildIds");
320
- __publicField(this, "animatingShapes", /* @__PURE__ */ new Map());
321
- /* --------------------- Content -------------------- */
322
- /** @internal */
323
- __publicField(this, "externalAssetContentHandlers", {
324
- file: null,
325
- url: null
326
- });
327
- /** @internal */
328
- __publicField(this, "temporaryAssetPreview", /* @__PURE__ */ new Map());
329
- /** @internal */
330
- __publicField(this, "externalContentHandlers", {
331
- text: null,
332
- files: null,
333
- "file-replace": null,
334
- embed: null,
335
- "svg-text": null,
336
- url: null,
337
- tldraw: null,
338
- excalidraw: null
339
- });
340
- /**
341
- * A manager for recording multiple click events.
342
- *
343
- * @internal
344
- */
345
- __publicField(this, "_clickManager", new import_ClickManager.ClickManager(this));
346
- /**
347
- * The previous cursor. Used for restoring the cursor after pan events.
348
- *
349
- * @internal
350
- */
351
- __publicField(this, "_prevCursor", "default");
352
- /** @internal */
353
- __publicField(this, "_shiftKeyTimeout", -1);
354
- /** @internal */
355
- __publicField(this, "_altKeyTimeout", -1);
356
- /** @internal */
357
- __publicField(this, "_ctrlKeyTimeout", -1);
358
- /** @internal */
359
- __publicField(this, "_metaKeyTimeout", -1);
360
- /** @internal */
361
- __publicField(this, "_restoreToolId", "select");
362
- /** @internal */
363
- __publicField(this, "_didPinch", false);
364
- /** @internal */
365
- __publicField(this, "_selectedShapeIdsAtPointerDown", []);
366
- /** @internal */
367
- __publicField(this, "_longPressTimeout", -1);
368
- /** @internal */
369
- __publicField(this, "capturedPointerId", null);
370
- /** @internal */
371
- __publicField(this, "performanceTracker");
372
- /** @internal */
373
- __publicField(this, "performanceTrackerTimeout", -1);
374
- /** @internal */
375
- __publicField(this, "handledEvents", /* @__PURE__ */ new WeakSet());
376
- __publicField(this, "_pendingEventsForNextTick", []);
377
114
  this._getShapeVisibility = getShapeVisibility;
378
115
  const options = _textOptions ? { ..._options, text: _options?.text ?? _textOptions } : _options;
379
116
  this.options = { ...import_options.defaultTldrawOptions, ...options };
@@ -779,6 +516,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
779
516
  );
780
517
  }
781
518
  }
519
+ _getShapeVisibility;
782
520
  getIsShapeHiddenCache() {
783
521
  if (!this._getShapeVisibility) return null;
784
522
  return this.store.createComputedCache("isShapeHidden", (shape) => {
@@ -794,6 +532,20 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
794
532
  typeof shapeOrId === "string" ? shapeOrId : shapeOrId.id
795
533
  );
796
534
  }
535
+ options;
536
+ contextId = (0, import_utils.uniqueId)();
537
+ /**
538
+ * The editor's store
539
+ *
540
+ * @public
541
+ */
542
+ store;
543
+ /**
544
+ * The root state of the statechart.
545
+ *
546
+ * @public
547
+ */
548
+ root;
797
549
  /**
798
550
  * Set a tool. Useful if you need to add a tool to the state chart on demand,
799
551
  * after the editor has already been initialized.
@@ -825,6 +577,114 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
825
577
  delete parent.children[Tool.id];
826
578
  }
827
579
  }
580
+ /**
581
+ * A set of functions to call when the editor is disposed.
582
+ *
583
+ * @public
584
+ */
585
+ disposables = /* @__PURE__ */ new Set();
586
+ /**
587
+ * Whether the editor is disposed.
588
+ *
589
+ * @public
590
+ */
591
+ isDisposed = false;
592
+ /**
593
+ * A manager for the editor's tick events.
594
+ *
595
+ * @internal */
596
+ _tickManager;
597
+ /**
598
+ * A manager for the editor's input state.
599
+ *
600
+ * @public
601
+ */
602
+ inputs;
603
+ /**
604
+ * A manager for the editor's snapping feature.
605
+ *
606
+ * @public
607
+ */
608
+ snaps;
609
+ _spatialIndex;
610
+ /**
611
+ * A manager for the any asynchronous events and making sure they're
612
+ * cleaned up upon disposal.
613
+ *
614
+ * @public
615
+ */
616
+ timers = import_time.tltime.forContext(this.contextId);
617
+ /**
618
+ * A manager for the user and their preferences.
619
+ *
620
+ * @public
621
+ */
622
+ user;
623
+ /**
624
+ * A helper for measuring text.
625
+ *
626
+ * @public
627
+ */
628
+ textMeasure;
629
+ /**
630
+ * A utility for managing the set of fonts that should be rendered in the document.
631
+ *
632
+ * @public
633
+ */
634
+ fonts;
635
+ /**
636
+ * A manager for the editor's scribbles.
637
+ *
638
+ * @public
639
+ */
640
+ scribbles;
641
+ /**
642
+ * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
643
+ *
644
+ * @public
645
+ */
646
+ sideEffects;
647
+ /**
648
+ * A manager for moving the camera when the mouse is at the edge of the screen.
649
+ *
650
+ * @public
651
+ */
652
+ edgeScrollManager;
653
+ /**
654
+ * A manager for ensuring correct focus. See FocusManager for details.
655
+ *
656
+ * @internal
657
+ */
658
+ focusManager;
659
+ /**
660
+ * The current HTML element containing the editor.
661
+ *
662
+ * @example
663
+ * ```ts
664
+ * const container = editor.getContainer()
665
+ * ```
666
+ *
667
+ * @public
668
+ */
669
+ getContainer;
670
+ /**
671
+ * The document that the editor's container element belongs to.
672
+ * Use this instead of the global `document` to support cross-window embedding.
673
+ *
674
+ * @internal
675
+ */
676
+ getContainerDocument() {
677
+ return this.getContainer().ownerDocument;
678
+ }
679
+ /**
680
+ * The window that the editor's container element belongs to.
681
+ * Use this instead of the global `window` to support cross-window embedding.
682
+ *
683
+ * @internal
684
+ */
685
+ getContainerWindow() {
686
+ return (0, import_domUtils.getOwnerWindow)(this.getContainer());
687
+ }
828
688
  /**
829
689
  * Dispose the editor.
830
690
  *
@@ -837,6 +697,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
837
697
  this.isDisposed = true;
838
698
  this.emit("dispose");
839
699
  }
700
+ /* ------------------- Shape Utils ------------------ */
701
+ /**
702
+ * A map of shape utility classes (TLShapeUtils) by shape type.
703
+ *
704
+ * @public
705
+ */
706
+ shapeUtils;
707
+ styleProps;
840
708
  getShapeUtil(arg) {
841
709
  const type = typeof arg === "string" ? arg : arg.type;
842
710
  const shapeUtil = (0, import_utils.getOwnProperty)(this.shapeUtils, type);
@@ -847,12 +715,26 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
847
715
  const type = typeof arg === "string" ? arg : arg.type;
848
716
  return (0, import_utils.hasOwnProperty)(this.shapeUtils, type);
849
717
  }
718
+ /* ------------------- Binding Utils ------------------ */
719
+ /**
720
+ * A map of shape utility classes (TLShapeUtils) by shape type.
721
+ *
722
+ * @public
723
+ */
724
+ bindingUtils;
850
725
  getBindingUtil(arg) {
851
726
  const type = typeof arg === "string" ? arg : arg.type;
852
727
  const bindingUtil = (0, import_utils.getOwnProperty)(this.bindingUtils, type);
853
728
  (0, import_utils.assert)(bindingUtil, `No binding util found for type "${type}"`);
854
729
  return bindingUtil;
855
730
  }
731
+ /* --------------------- History -------------------- */
732
+ /**
733
+ * A manager for the editor's history.
734
+ *
735
+ * @readonly
736
+ */
737
+ history;
856
738
  /**
857
739
  * Undo to the last mark.
858
740
  *
@@ -980,6 +862,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
980
862
  this.history.bailToMark(id);
981
863
  return this;
982
864
  }
865
+ _shouldIgnoreShapeLock = false;
983
866
  /**
984
867
  * Run a function in a transaction with optional options for context.
985
868
  * You can use the options to change the way that history is treated
@@ -1071,6 +954,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1071
954
  };
1072
955
  }
1073
956
  }
957
+ /** @internal */
958
+ _crashingError = null;
1074
959
  /**
1075
960
  * We can't use an `atom` here because there's a chance that when `crashAndReportError` is called,
1076
961
  * we're in a transaction that's about to be rolled back due to the same error we're currently
@@ -1237,6 +1122,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1237
1122
  ]);
1238
1123
  }, opts);
1239
1124
  }
1125
+ /** @internal */
1126
+ _isChangingStyleTimeout = -1;
1127
+ // Menus
1128
+ menus = import_menus.tlmenus.forContext(this.contextId);
1240
1129
  /* --------------------- Cursor --------------------- */
1241
1130
  /**
1242
1131
  * Set the cursor.
@@ -1802,6 +1691,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1802
1691
  );
1803
1692
  return this;
1804
1693
  }
1694
+ // Rich text editor
1695
+ _currentRichTextEditor = (0, import_state.atom)("rich text editor", null);
1805
1696
  getRichTextEditor() {
1806
1697
  return this._currentRichTextEditor.get();
1807
1698
  }
@@ -1981,6 +1872,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1981
1872
  }
1982
1873
  return this;
1983
1874
  }
1875
+ _textOptions;
1984
1876
  /**
1985
1877
  * Get the current text options.
1986
1878
  *
@@ -2051,6 +1943,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2051
1943
  getResizeScaleFactor() {
2052
1944
  return this.user.getIsDynamicResizeMode() ? 1 / this.getZoomLevel() : 1;
2053
1945
  }
1946
+ _debouncedZoomLevel = (0, import_state.atom)("debounced zoom level", 1);
2054
1947
  getDebouncedZoomLevel() {
2055
1948
  if (this.options.debouncedZoom) {
2056
1949
  if (this.getCameraState() === "idle") {
@@ -2155,6 +2048,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2155
2048
  }
2156
2049
  }
2157
2050
  }
2051
+ _cameraOptions = (0, import_state.atom)("camera options", import_constants.DEFAULT_CAMERA_OPTIONS);
2158
2052
  /**
2159
2053
  * Get the current camera options.
2160
2054
  *
@@ -2629,6 +2523,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2629
2523
  return this;
2630
2524
  }
2631
2525
  /** @internal */
2526
+ _viewportAnimation = null;
2527
+ /** @internal */
2632
2528
  _animateViewport(ms) {
2633
2529
  if (!this._viewportAnimation) return;
2634
2530
  this._viewportAnimation.elapsed += ms;
@@ -2767,6 +2663,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2767
2663
  });
2768
2664
  return this;
2769
2665
  }
2666
+ // Viewport
2667
+ /** @internal */
2668
+ _willSetInitialBounds = true;
2770
2669
  /**
2771
2670
  * Update the viewport. The viewport will measure the size and screen position of its container
2772
2671
  * element. This should be done whenever the container's position on the screen changes.
@@ -2795,13 +2694,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2795
2694
  screenBounds.width = Math.max(screenBounds.width, 1);
2796
2695
  screenBounds.height = Math.max(screenBounds.height, 1);
2797
2696
  }
2697
+ const doc = this.getContainerDocument();
2798
2698
  const insets = [
2799
2699
  // top
2800
2700
  screenBounds.minY !== 0,
2801
2701
  // right
2802
- !(0, import_utils2.approximately)(document.body.scrollWidth, screenBounds.maxX, 1),
2702
+ !(0, import_utils2.approximately)(doc.body.scrollWidth, screenBounds.maxX, 1),
2803
2703
  // bottom
2804
- !(0, import_utils2.approximately)(document.body.scrollHeight, screenBounds.maxY, 1),
2704
+ !(0, import_utils2.approximately)(doc.body.scrollHeight, screenBounds.maxY, 1),
2805
2705
  // left
2806
2706
  screenBounds.minX !== 0
2807
2707
  ];
@@ -2921,6 +2821,9 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2921
2821
  const currentPageId = this.getCurrentPageId();
2922
2822
  return this.getCollaborators().filter((c) => c.currentPageId === currentPageId);
2923
2823
  }
2824
+ // Following
2825
+ // When we are 'locked on' to a user, our camera is derived from their camera.
2826
+ _isLockedOnFollowingUser = (0, import_state.atom)("isLockedOnFollowingUser", false);
2924
2827
  /**
2925
2828
  * Start viewport-following a user.
2926
2829
  *
@@ -3096,6 +2999,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3096
2999
  }
3097
3000
  return renderingShapes;
3098
3001
  }
3002
+ // Camera state
3003
+ // Camera state does two things: first, it allows us to subscribe to whether
3004
+ // the camera is moving or not; and second, it allows us to update the rendering
3005
+ // shapes on the canvas. Changing the rendering shapes may cause shapes to
3006
+ // unmount / remount in the DOM, which is expensive; and computing visibility is
3007
+ // also expensive in large projects. For this reason, we use a second bounding
3008
+ // box just for rendering, and we only update after the camera stops moving.
3009
+ _cameraStateTimeoutRemaining = 0;
3099
3010
  _decayCameraStateTimeout(elapsed) {
3100
3011
  this._cameraStateTimeoutRemaining -= elapsed;
3101
3012
  if (this._cameraStateTimeoutRemaining > 0) return;
@@ -3167,6 +3078,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3167
3078
  getPage(page) {
3168
3079
  return this.store.get(typeof page === "string" ? page : page.id);
3169
3080
  }
3081
+ /* @internal */
3082
+ _currentPageShapeIds;
3170
3083
  /**
3171
3084
  * An array of all of the shapes on the current page.
3172
3085
  *
@@ -3488,6 +3401,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3488
3401
  async uploadAsset(asset, file, abortSignal) {
3489
3402
  return await this.store.props.assets.upload(asset, file, abortSignal);
3490
3403
  }
3404
+ /* --------------------- Shapes --------------------- */
3405
+ _shapeGeometryCaches = {};
3491
3406
  /**
3492
3407
  * Get the geometry of a shape in shape-space.
3493
3408
  *
@@ -3858,6 +3773,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
3858
3773
  getNotVisibleShapes() {
3859
3774
  return this._notVisibleShapes.get();
3860
3775
  }
3776
+ _notVisibleShapes = (0, import_notVisibleShapes.notVisibleShapes)(this);
3777
+ _culledShapesCache = null;
3861
3778
  getCulledShapes() {
3862
3779
  const notVisibleShapes2 = this.getNotVisibleShapes();
3863
3780
  const selectedShapeIds = this.getSelectedShapeIds();
@@ -4272,6 +4189,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
4272
4189
  return this.getAncestorPageId(this.getShape(_shape.parentId));
4273
4190
  }
4274
4191
  }
4192
+ // Parents and children
4193
+ /**
4194
+ * A cache of parents to children.
4195
+ *
4196
+ * @internal
4197
+ */
4198
+ _parentIdsToChildIds;
4275
4199
  /**
4276
4200
  * Reparent shapes to a new parent. This operation preserves the shape's current page positions /
4277
4201
  * rotations.
@@ -5916,6 +5840,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
5916
5840
  });
5917
5841
  return this;
5918
5842
  }
5843
+ animatingShapes = /* @__PURE__ */ new Map();
5919
5844
  /**
5920
5845
  * Animate a shape.
5921
5846
  *
@@ -6409,6 +6334,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6409
6334
  }
6410
6335
  return this;
6411
6336
  }
6337
+ /* --------------------- Content -------------------- */
6338
+ /** @internal */
6339
+ externalAssetContentHandlers = {
6340
+ file: null,
6341
+ url: null
6342
+ };
6343
+ /** @internal */
6344
+ temporaryAssetPreview = /* @__PURE__ */ new Map();
6412
6345
  /**
6413
6346
  * Register an external asset handler. This handler will be called when the editor needs to
6414
6347
  * create an asset for some external content, like an image/video file or a bookmark URL. For
@@ -6494,6 +6427,17 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6494
6427
  hasExternalAssetHandler(type) {
6495
6428
  return !!this.externalAssetContentHandlers[type];
6496
6429
  }
6430
+ /** @internal */
6431
+ externalContentHandlers = {
6432
+ text: null,
6433
+ files: null,
6434
+ "file-replace": null,
6435
+ embed: null,
6436
+ "svg-text": null,
6437
+ url: null,
6438
+ tldraw: null,
6439
+ excalidraw: null
6440
+ };
6497
6441
  /**
6498
6442
  * Register an external content handler. This handler will be called when the editor receives
6499
6443
  * external content of the provided type. For example, the 'image' type handler will be called
@@ -6914,7 +6858,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6914
6858
  return {
6915
6859
  svg: serializer.serializeToString(result.svg),
6916
6860
  width: result.width,
6917
- height: result.height
6861
+ height: result.height,
6862
+ trimPadding: result.trimPadding
6918
6863
  };
6919
6864
  }
6920
6865
  /**
@@ -6936,30 +6881,45 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
6936
6881
  const result = await this.getSvgString(shapes, withDefaults);
6937
6882
  if (!result) throw new Error("Could not create SVG");
6938
6883
  switch (withDefaults.format) {
6939
- case "svg":
6884
+ case "svg": {
6885
+ let svg = result.svg;
6886
+ let w = result.width;
6887
+ let h = result.height;
6888
+ if (result.trimPadding > 0) {
6889
+ const trimmed = await (0, import_getSvgAsImage.trimSvgToContent)(svg, {
6890
+ width: w,
6891
+ height: h,
6892
+ trimPadding: result.trimPadding,
6893
+ scale: withDefaults.scale
6894
+ });
6895
+ if (trimmed) {
6896
+ svg = trimmed.svg;
6897
+ w = trimmed.width;
6898
+ h = trimmed.height;
6899
+ }
6900
+ }
6940
6901
  return {
6941
- blob: new Blob([result.svg], { type: "image/svg+xml" }),
6942
- width: result.width,
6943
- height: result.height
6902
+ blob: new Blob([svg], { type: "image/svg+xml" }),
6903
+ width: w,
6904
+ height: h
6944
6905
  };
6906
+ }
6945
6907
  case "jpeg":
6946
6908
  case "png":
6947
6909
  case "webp": {
6948
- const blob = await (0, import_getSvgAsImage.getSvgAsImage)(result.svg, {
6910
+ const imageResult = await (0, import_getSvgAsImage.getSvgAsImageWithOptions)(result.svg, {
6949
6911
  type: withDefaults.format,
6950
6912
  quality: withDefaults.quality,
6951
6913
  pixelRatio: withDefaults.pixelRatio,
6952
6914
  width: result.width,
6953
- height: result.height
6915
+ height: result.height,
6916
+ trimPadding: result.trimPadding,
6917
+ scale: withDefaults.scale
6954
6918
  });
6955
- if (!blob) {
6919
+ if (!imageResult) {
6956
6920
  throw new Error("Could not construct image.");
6957
6921
  }
6958
- return {
6959
- blob,
6960
- width: result.width,
6961
- height: result.height
6962
- };
6922
+ return imageResult;
6963
6923
  }
6964
6924
  default: {
6965
6925
  (0, import_utils.exhaustiveSwitchError)(withDefaults.format);
@@ -7354,7 +7314,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7354
7314
  param: opts?.param,
7355
7315
  to: opts?.getTarget?.(this)
7356
7316
  });
7357
- window.history.replaceState({}, document.title, url.toString());
7317
+ window.history.replaceState({}, this.getContainerDocument().title, url.toString());
7358
7318
  });
7359
7319
  const scheduleEffect = (0, import_utils.debounce)((execute) => execute(), opts?.debounceMs ?? 500);
7360
7320
  const unlisten = (0, import_state.react)(
@@ -7367,6 +7327,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7367
7327
  scheduleEffect.cancel();
7368
7328
  };
7369
7329
  }
7330
+ /**
7331
+ * A manager for recording multiple click events.
7332
+ *
7333
+ * @internal
7334
+ */
7335
+ _clickManager = new import_ClickManager.ClickManager(this);
7370
7336
  /**
7371
7337
  * Prevent a double click event from firing the next time the user clicks
7372
7338
  *
@@ -7375,6 +7341,14 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7375
7341
  cancelDoubleClick() {
7376
7342
  this._clickManager.cancelDoubleClickTimeout();
7377
7343
  }
7344
+ /**
7345
+ * The previous cursor. Used for restoring the cursor after pan events.
7346
+ *
7347
+ * @internal
7348
+ */
7349
+ _prevCursor = "default";
7350
+ /** @internal */
7351
+ _shiftKeyTimeout = -1;
7378
7352
  _setShiftKeyTimeout() {
7379
7353
  this.inputs.setShiftKey(false);
7380
7354
  this.dispatch({
@@ -7389,6 +7363,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7389
7363
  code: "ShiftLeft"
7390
7364
  });
7391
7365
  }
7366
+ /** @internal */
7367
+ _altKeyTimeout = -1;
7392
7368
  _setAltKeyTimeout() {
7393
7369
  this.inputs.setAltKey(false);
7394
7370
  this.dispatch({
@@ -7403,6 +7379,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7403
7379
  code: "AltLeft"
7404
7380
  });
7405
7381
  }
7382
+ /** @internal */
7383
+ _ctrlKeyTimeout = -1;
7406
7384
  _setCtrlKeyTimeout() {
7407
7385
  this.inputs.setCtrlKey(false);
7408
7386
  this.dispatch({
@@ -7417,6 +7395,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7417
7395
  code: "ControlLeft"
7418
7396
  });
7419
7397
  }
7398
+ /** @internal */
7399
+ _metaKeyTimeout = -1;
7420
7400
  _setMetaKeyTimeout() {
7421
7401
  this.inputs.setMetaKey(false);
7422
7402
  this.dispatch({
@@ -7431,6 +7411,22 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7431
7411
  code: "MetaLeft"
7432
7412
  });
7433
7413
  }
7414
+ /** @internal */
7415
+ _restoreToolId = "select";
7416
+ /** @internal */
7417
+ _didPinch = false;
7418
+ /** @internal */
7419
+ _selectedShapeIdsAtPointerDown = [];
7420
+ /** @internal */
7421
+ _longPressTimeout = -1;
7422
+ /** @internal */
7423
+ capturedPointerId = null;
7424
+ /** @internal */
7425
+ performanceTracker;
7426
+ /** @internal */
7427
+ performanceTrackerTimeout = -1;
7428
+ /** @internal */
7429
+ handledEvents = /* @__PURE__ */ new WeakSet();
7434
7430
  /**
7435
7431
  * In tldraw, events are sometimes handled by multiple components. For example, the shapes might
7436
7432
  * have events, but the canvas handles events too. The way that the canvas handles events can
@@ -7476,6 +7472,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7476
7472
  }
7477
7473
  return this;
7478
7474
  }
7475
+ _pendingEventsForNextTick = [];
7479
7476
  _flushEventsForTick(elapsed) {
7480
7477
  this.run(() => {
7481
7478
  if (this._pendingEventsForNextTick.length > 0) {
@@ -7883,83 +7880,231 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7883
7880
  }
7884
7881
  }
7885
7882
  }
7886
- _init = __decoratorStart(_a);
7887
- __decorateElement(_init, 1, "getIsShapeHiddenCache", _getIsShapeHiddenCache_dec, Editor);
7888
- __decorateElement(_init, 1, "canUndo", _canUndo_dec, Editor);
7889
- __decorateElement(_init, 1, "canRedo", _canRedo_dec, Editor);
7890
- __decorateElement(_init, 1, "getPath", _getPath_dec, Editor);
7891
- __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
7892
- __decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
7893
- __decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
7894
- __decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
7895
- __decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
7896
- __decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
7897
- __decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);
7898
- __decorateElement(_init, 1, "_getCurrentPageStateId", __getCurrentPageStateId_dec, Editor);
7899
- __decorateElement(_init, 1, "getSelectedShapeIds", _getSelectedShapeIds_dec, Editor);
7900
- __decorateElement(_init, 1, "getSelectedShapes", _getSelectedShapes_dec, Editor);
7901
- __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPageShapesInReadingOrder_dec, Editor);
7902
- __decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
7903
- __decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
7904
- __decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
7905
- __decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
7906
- __decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
7907
- __decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);
7908
- __decorateElement(_init, 1, "getFocusedGroupId", _getFocusedGroupId_dec, Editor);
7909
- __decorateElement(_init, 1, "getFocusedGroup", _getFocusedGroup_dec, Editor);
7910
- __decorateElement(_init, 1, "getEditingShapeId", _getEditingShapeId_dec, Editor);
7911
- __decorateElement(_init, 1, "getEditingShape", _getEditingShape_dec, Editor);
7912
- __decorateElement(_init, 1, "getRichTextEditor", _getRichTextEditor_dec, Editor);
7913
- __decorateElement(_init, 1, "getHoveredShapeId", _getHoveredShapeId_dec, Editor);
7914
- __decorateElement(_init, 1, "getHoveredShape", _getHoveredShape_dec, Editor);
7915
- __decorateElement(_init, 1, "getHintingShapeIds", _getHintingShapeIds_dec, Editor);
7916
- __decorateElement(_init, 1, "getHintingShape", _getHintingShape_dec, Editor);
7917
- __decorateElement(_init, 1, "getErasingShapeIds", _getErasingShapeIds_dec, Editor);
7918
- __decorateElement(_init, 1, "getErasingShapes", _getErasingShapes_dec, Editor);
7919
- __decorateElement(_init, 1, "_unsafe_getCameraId", __unsafe_getCameraId_dec, Editor);
7920
- __decorateElement(_init, 1, "getCamera", _getCamera_dec, Editor);
7921
- __decorateElement(_init, 1, "getViewportPageBoundsForFollowing", _getViewportPageBoundsForFollowing_dec, Editor);
7922
- __decorateElement(_init, 1, "getCameraForFollowing", _getCameraForFollowing_dec, Editor);
7923
- __decorateElement(_init, 1, "getZoomLevel", _getZoomLevel_dec, Editor);
7924
- __decorateElement(_init, 1, "getResizeScaleFactor", _getResizeScaleFactor_dec, Editor);
7925
- __decorateElement(_init, 1, "getDebouncedZoomLevel", _getDebouncedZoomLevel_dec, Editor);
7926
- __decorateElement(_init, 1, "_getAboveDebouncedZoomThreshold", __getAboveDebouncedZoomThreshold_dec, Editor);
7927
- __decorateElement(_init, 1, "getEfficientZoomLevel", _getEfficientZoomLevel_dec, Editor);
7928
- __decorateElement(_init, 1, "getViewportScreenBounds", _getViewportScreenBounds_dec, Editor);
7929
- __decorateElement(_init, 1, "getViewportScreenCenter", _getViewportScreenCenter_dec, Editor);
7930
- __decorateElement(_init, 1, "getViewportPageBounds", _getViewportPageBounds_dec, Editor);
7931
- __decorateElement(_init, 1, "_getCollaboratorsQuery", __getCollaboratorsQuery_dec, Editor);
7932
- __decorateElement(_init, 1, "getCollaborators", _getCollaborators_dec, Editor);
7933
- __decorateElement(_init, 1, "getCollaboratorsOnCurrentPage", _getCollaboratorsOnCurrentPage_dec, Editor);
7934
- __decorateElement(_init, 1, "getRenderingShapes", _getRenderingShapes_dec, Editor);
7935
- __decorateElement(_init, 1, "_getAllPagesQuery", __getAllPagesQuery_dec, Editor);
7936
- __decorateElement(_init, 1, "getPages", _getPages_dec, Editor);
7937
- __decorateElement(_init, 1, "getCurrentPageId", _getCurrentPageId_dec, Editor);
7938
- __decorateElement(_init, 1, "getCurrentPageShapeIdsSorted", _getCurrentPageShapeIdsSorted_dec, Editor);
7939
- __decorateElement(_init, 1, "_getAllAssetsQuery", __getAllAssetsQuery_dec, Editor);
7940
- __decorateElement(_init, 1, "_getShapeHandlesCache", __getShapeHandlesCache_dec, Editor);
7941
- __decorateElement(_init, 1, "_getShapePageTransformCache", __getShapePageTransformCache_dec, Editor);
7942
- __decorateElement(_init, 1, "_getShapePageBoundsCache", __getShapePageBoundsCache_dec, Editor);
7943
- __decorateElement(_init, 1, "_getShapeClipPathCache", __getShapeClipPathCache_dec, Editor);
7944
- __decorateElement(_init, 1, "_getShapeMaskCache", __getShapeMaskCache_dec, Editor);
7945
- __decorateElement(_init, 1, "_getShapeMaskedPageBoundsCache", __getShapeMaskedPageBoundsCache_dec, Editor);
7946
- __decorateElement(_init, 1, "getNotVisibleShapes", _getNotVisibleShapes_dec, Editor);
7947
- __decorateElement(_init, 1, "getCulledShapes", _getCulledShapes_dec, Editor);
7948
- __decorateElement(_init, 1, "getCurrentPageBounds", _getCurrentPageBounds_dec, Editor);
7949
- __decorateElement(_init, 1, "getCurrentPageShapes", _getCurrentPageShapes_dec, Editor);
7950
- __decorateElement(_init, 1, "getCurrentPageShapesSorted", _getCurrentPageShapesSorted_dec, Editor);
7951
- __decorateElement(_init, 1, "getCurrentPageRenderingShapesSorted", _getCurrentPageRenderingShapesSorted_dec, Editor);
7952
- __decorateElement(_init, 1, "_getBindingsIndexCache", __getBindingsIndexCache_dec, Editor);
7953
- __decorateElement(_init, 1, "_getSelectionSharedStyles", __getSelectionSharedStyles_dec, Editor);
7954
- __decorateElement(_init, 1, "getSharedStyles", _getSharedStyles_dec, Editor);
7955
- __decorateElement(_init, 1, "getSharedOpacity", _getSharedOpacity_dec, Editor);
7956
- __decorateElement(_init, 1, "getIsFocused", _getIsFocused_dec, Editor);
7957
- __decorateElement(_init, 1, "getIsReadonly", _getIsReadonly_dec, Editor);
7958
- __decorateElement(_init, 1, "_setShiftKeyTimeout", __setShiftKeyTimeout_dec, Editor);
7959
- __decorateElement(_init, 1, "_setAltKeyTimeout", __setAltKeyTimeout_dec, Editor);
7960
- __decorateElement(_init, 1, "_setCtrlKeyTimeout", __setCtrlKeyTimeout_dec, Editor);
7961
- __decorateElement(_init, 1, "_setMetaKeyTimeout", __setMetaKeyTimeout_dec, Editor);
7962
- __decoratorMetadata(_init, Editor);
7883
+ __decorateClass([
7884
+ import_state.computed
7885
+ ], Editor.prototype, "getIsShapeHiddenCache", 1);
7886
+ __decorateClass([
7887
+ import_state.computed
7888
+ ], Editor.prototype, "canUndo", 1);
7889
+ __decorateClass([
7890
+ import_state.computed
7891
+ ], Editor.prototype, "canRedo", 1);
7892
+ __decorateClass([
7893
+ import_state.computed
7894
+ ], Editor.prototype, "getPath", 1);
7895
+ __decorateClass([
7896
+ import_state.computed
7897
+ ], Editor.prototype, "getCurrentTool", 1);
7898
+ __decorateClass([
7899
+ import_state.computed
7900
+ ], Editor.prototype, "getCurrentToolId", 1);
7901
+ __decorateClass([
7902
+ import_state.computed
7903
+ ], Editor.prototype, "getDocumentSettings", 1);
7904
+ __decorateClass([
7905
+ import_state.computed
7906
+ ], Editor.prototype, "getInstanceState", 1);
7907
+ __decorateClass([
7908
+ import_state.computed
7909
+ ], Editor.prototype, "getPageStates", 1);
7910
+ __decorateClass([
7911
+ import_state.computed
7912
+ ], Editor.prototype, "_getPageStatesQuery", 1);
7913
+ __decorateClass([
7914
+ import_state.computed
7915
+ ], Editor.prototype, "getCurrentPageState", 1);
7916
+ __decorateClass([
7917
+ import_state.computed
7918
+ ], Editor.prototype, "_getCurrentPageStateId", 1);
7919
+ __decorateClass([
7920
+ import_state.computed
7921
+ ], Editor.prototype, "getSelectedShapeIds", 1);
7922
+ __decorateClass([
7923
+ import_state.computed
7924
+ ], Editor.prototype, "getSelectedShapes", 1);
7925
+ __decorateClass([
7926
+ import_state.computed
7927
+ ], Editor.prototype, "getCurrentPageShapesInReadingOrder", 1);
7928
+ __decorateClass([
7929
+ import_state.computed
7930
+ ], Editor.prototype, "getOnlySelectedShapeId", 1);
7931
+ __decorateClass([
7932
+ import_state.computed
7933
+ ], Editor.prototype, "getOnlySelectedShape", 1);
7934
+ __decorateClass([
7935
+ import_state.computed
7936
+ ], Editor.prototype, "getSelectionPageBounds", 1);
7937
+ __decorateClass([
7938
+ import_state.computed
7939
+ ], Editor.prototype, "getSelectionRotation", 1);
7940
+ __decorateClass([
7941
+ import_state.computed
7942
+ ], Editor.prototype, "getSelectionRotatedPageBounds", 1);
7943
+ __decorateClass([
7944
+ import_state.computed
7945
+ ], Editor.prototype, "getSelectionRotatedScreenBounds", 1);
7946
+ __decorateClass([
7947
+ import_state.computed
7948
+ ], Editor.prototype, "getFocusedGroupId", 1);
7949
+ __decorateClass([
7950
+ import_state.computed
7951
+ ], Editor.prototype, "getFocusedGroup", 1);
7952
+ __decorateClass([
7953
+ import_state.computed
7954
+ ], Editor.prototype, "getEditingShapeId", 1);
7955
+ __decorateClass([
7956
+ import_state.computed
7957
+ ], Editor.prototype, "getEditingShape", 1);
7958
+ __decorateClass([
7959
+ import_state.computed
7960
+ ], Editor.prototype, "getRichTextEditor", 1);
7961
+ __decorateClass([
7962
+ import_state.computed
7963
+ ], Editor.prototype, "getHoveredShapeId", 1);
7964
+ __decorateClass([
7965
+ import_state.computed
7966
+ ], Editor.prototype, "getHoveredShape", 1);
7967
+ __decorateClass([
7968
+ import_state.computed
7969
+ ], Editor.prototype, "getHintingShapeIds", 1);
7970
+ __decorateClass([
7971
+ import_state.computed
7972
+ ], Editor.prototype, "getHintingShape", 1);
7973
+ __decorateClass([
7974
+ import_state.computed
7975
+ ], Editor.prototype, "getErasingShapeIds", 1);
7976
+ __decorateClass([
7977
+ import_state.computed
7978
+ ], Editor.prototype, "getErasingShapes", 1);
7979
+ __decorateClass([
7980
+ import_state.computed
7981
+ ], Editor.prototype, "_unsafe_getCameraId", 1);
7982
+ __decorateClass([
7983
+ import_state.computed
7984
+ ], Editor.prototype, "getCamera", 1);
7985
+ __decorateClass([
7986
+ import_state.computed
7987
+ ], Editor.prototype, "getViewportPageBoundsForFollowing", 1);
7988
+ __decorateClass([
7989
+ import_state.computed
7990
+ ], Editor.prototype, "getCameraForFollowing", 1);
7991
+ __decorateClass([
7992
+ import_state.computed
7993
+ ], Editor.prototype, "getZoomLevel", 1);
7994
+ __decorateClass([
7995
+ import_state.computed
7996
+ ], Editor.prototype, "getResizeScaleFactor", 1);
7997
+ __decorateClass([
7998
+ import_state.computed
7999
+ ], Editor.prototype, "getDebouncedZoomLevel", 1);
8000
+ __decorateClass([
8001
+ import_state.computed
8002
+ ], Editor.prototype, "_getAboveDebouncedZoomThreshold", 1);
8003
+ __decorateClass([
8004
+ import_state.computed
8005
+ ], Editor.prototype, "getEfficientZoomLevel", 1);
8006
+ __decorateClass([
8007
+ import_state.computed
8008
+ ], Editor.prototype, "getViewportScreenBounds", 1);
8009
+ __decorateClass([
8010
+ import_state.computed
8011
+ ], Editor.prototype, "getViewportScreenCenter", 1);
8012
+ __decorateClass([
8013
+ import_state.computed
8014
+ ], Editor.prototype, "getViewportPageBounds", 1);
8015
+ __decorateClass([
8016
+ import_state.computed
8017
+ ], Editor.prototype, "_getCollaboratorsQuery", 1);
8018
+ __decorateClass([
8019
+ import_state.computed
8020
+ ], Editor.prototype, "getCollaborators", 1);
8021
+ __decorateClass([
8022
+ import_state.computed
8023
+ ], Editor.prototype, "getCollaboratorsOnCurrentPage", 1);
8024
+ __decorateClass([
8025
+ import_state.computed
8026
+ ], Editor.prototype, "getRenderingShapes", 1);
8027
+ __decorateClass([
8028
+ import_state.computed
8029
+ ], Editor.prototype, "_getAllPagesQuery", 1);
8030
+ __decorateClass([
8031
+ import_state.computed
8032
+ ], Editor.prototype, "getPages", 1);
8033
+ __decorateClass([
8034
+ import_state.computed
8035
+ ], Editor.prototype, "getCurrentPageId", 1);
8036
+ __decorateClass([
8037
+ import_state.computed
8038
+ ], Editor.prototype, "getCurrentPageShapeIdsSorted", 1);
8039
+ __decorateClass([
8040
+ import_state.computed
8041
+ ], Editor.prototype, "_getAllAssetsQuery", 1);
8042
+ __decorateClass([
8043
+ import_state.computed
8044
+ ], Editor.prototype, "_getShapeHandlesCache", 1);
8045
+ __decorateClass([
8046
+ import_state.computed
8047
+ ], Editor.prototype, "_getShapePageTransformCache", 1);
8048
+ __decorateClass([
8049
+ import_state.computed
8050
+ ], Editor.prototype, "_getShapePageBoundsCache", 1);
8051
+ __decorateClass([
8052
+ import_state.computed
8053
+ ], Editor.prototype, "_getShapeClipPathCache", 1);
8054
+ __decorateClass([
8055
+ import_state.computed
8056
+ ], Editor.prototype, "_getShapeMaskCache", 1);
8057
+ __decorateClass([
8058
+ import_state.computed
8059
+ ], Editor.prototype, "_getShapeMaskedPageBoundsCache", 1);
8060
+ __decorateClass([
8061
+ import_state.computed
8062
+ ], Editor.prototype, "getNotVisibleShapes", 1);
8063
+ __decorateClass([
8064
+ import_state.computed
8065
+ ], Editor.prototype, "getCulledShapes", 1);
8066
+ __decorateClass([
8067
+ import_state.computed
8068
+ ], Editor.prototype, "getCurrentPageBounds", 1);
8069
+ __decorateClass([
8070
+ import_state.computed
8071
+ ], Editor.prototype, "getCurrentPageShapes", 1);
8072
+ __decorateClass([
8073
+ import_state.computed
8074
+ ], Editor.prototype, "getCurrentPageShapesSorted", 1);
8075
+ __decorateClass([
8076
+ import_state.computed
8077
+ ], Editor.prototype, "getCurrentPageRenderingShapesSorted", 1);
8078
+ __decorateClass([
8079
+ import_state.computed
8080
+ ], Editor.prototype, "_getBindingsIndexCache", 1);
8081
+ __decorateClass([
8082
+ import_state.computed
8083
+ ], Editor.prototype, "_getSelectionSharedStyles", 1);
8084
+ __decorateClass([
8085
+ (0, import_state.computed)({ isEqual: (a, b) => a.equals(b) })
8086
+ ], Editor.prototype, "getSharedStyles", 1);
8087
+ __decorateClass([
8088
+ import_state.computed
8089
+ ], Editor.prototype, "getSharedOpacity", 1);
8090
+ __decorateClass([
8091
+ import_state.computed
8092
+ ], Editor.prototype, "getIsFocused", 1);
8093
+ __decorateClass([
8094
+ import_state.computed
8095
+ ], Editor.prototype, "getIsReadonly", 1);
8096
+ __decorateClass([
8097
+ import_utils.bind
8098
+ ], Editor.prototype, "_setShiftKeyTimeout", 1);
8099
+ __decorateClass([
8100
+ import_utils.bind
8101
+ ], Editor.prototype, "_setAltKeyTimeout", 1);
8102
+ __decorateClass([
8103
+ import_utils.bind
8104
+ ], Editor.prototype, "_setCtrlKeyTimeout", 1);
8105
+ __decorateClass([
8106
+ import_utils.bind
8107
+ ], Editor.prototype, "_setMetaKeyTimeout", 1);
7963
8108
  function alertMaxShapes(editor, pageId = editor.getCurrentPageId()) {
7964
8109
  const name = editor.getPage(pageId).name;
7965
8110
  editor.emit("max-shapes", { name, pageId, count: editor.options.maxShapesPerPage });