@tldraw/editor 4.5.3 → 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
@@ -1,52 +1,13 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
5
- var __typeError = (msg) => {
6
- throw TypeError(msg);
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
7
10
  };
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
11
- var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
12
- var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
13
- var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
14
- var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
15
- var __runInitializers = (array, flags, self, value) => {
16
- for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
17
- return value;
18
- };
19
- var __decorateElement = (array, flags, name, decorators, target, extra) => {
20
- var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
21
- var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
22
- var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
23
- var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
24
- return __privateGet(this, extra);
25
- }, set [name](x) {
26
- return __privateSet(this, extra, x);
27
- } }, name));
28
- k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
29
- for (var i = decorators.length - 1; i >= 0; i--) {
30
- ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
31
- if (k) {
32
- ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
33
- if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
34
- if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
35
- }
36
- it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
37
- if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
38
- else if (typeof it !== "object" || it === null) __typeError("Object expected");
39
- else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
40
- }
41
- return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
42
- };
43
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
44
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
45
- var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
46
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
48
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
49
- var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getEfficientZoomLevel_dec, __getAboveDebouncedZoomThreshold_dec, _getDebouncedZoomLevel_dec, _getResizeScaleFactor_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _canRedo_dec, _canUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
50
11
  import {
51
12
  EMPTY_ARRAY,
52
13
  atom,
@@ -117,8 +78,9 @@ import {
117
78
  RIGHT_MOUSE_BUTTON,
118
79
  STYLUS_ERASER_BUTTON
119
80
  } from "../constants.mjs";
81
+ import { getOwnerWindow } from "../exports/domUtils.mjs";
120
82
  import { exportToSvg } from "../exports/exportToSvg.mjs";
121
- import { getSvgAsImage } from "../exports/getSvgAsImage.mjs";
83
+ import { getSvgAsImageWithOptions, trimSvgToContent } from "../exports/getSvgAsImage.mjs";
122
84
  import { tlmenus } from "../globals/menus.mjs";
123
85
  import { tltime } from "../globals/time.mjs";
124
86
  import { defaultTldrawOptions } from "../options.mjs";
@@ -158,7 +120,8 @@ import { TextManager } from "./managers/TextManager/TextManager.mjs";
158
120
  import { TickManager } from "./managers/TickManager/TickManager.mjs";
159
121
  import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
160
122
  import { RootState } from "./tools/RootState.mjs";
161
- class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _canUndo_dec = [computed], _canRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getResizeScaleFactor_dec = [computed], _getDebouncedZoomLevel_dec = [computed], __getAboveDebouncedZoomThreshold_dec = [computed], _getEfficientZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], _getNotVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
123
+ class Editor extends EventEmitter {
124
+ id = uniqueId();
162
125
  constructor({
163
126
  store,
164
127
  user,
@@ -180,233 +143,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
180
143
  fontAssetUrls
181
144
  }) {
182
145
  super();
183
- __runInitializers(_init, 5, this);
184
- __publicField(this, "id", uniqueId());
185
- __publicField(this, "_getShapeVisibility");
186
- __publicField(this, "options");
187
- __publicField(this, "contextId", uniqueId());
188
- /**
189
- * The editor's store
190
- *
191
- * @public
192
- */
193
- __publicField(this, "store");
194
- /**
195
- * The root state of the statechart.
196
- *
197
- * @public
198
- */
199
- __publicField(this, "root");
200
- /**
201
- * A set of functions to call when the editor is disposed.
202
- *
203
- * @public
204
- */
205
- __publicField(this, "disposables", /* @__PURE__ */ new Set());
206
- /**
207
- * Whether the editor is disposed.
208
- *
209
- * @public
210
- */
211
- __publicField(this, "isDisposed", false);
212
- /**
213
- * A manager for the editor's tick events.
214
- *
215
- * @internal */
216
- __publicField(this, "_tickManager");
217
- /**
218
- * A manager for the editor's input state.
219
- *
220
- * @public
221
- */
222
- __publicField(this, "inputs");
223
- /**
224
- * A manager for the editor's snapping feature.
225
- *
226
- * @public
227
- */
228
- __publicField(this, "snaps");
229
- __publicField(this, "_spatialIndex");
230
- /**
231
- * A manager for the any asynchronous events and making sure they're
232
- * cleaned up upon disposal.
233
- *
234
- * @public
235
- */
236
- __publicField(this, "timers", tltime.forContext(this.contextId));
237
- /**
238
- * A manager for the user and their preferences.
239
- *
240
- * @public
241
- */
242
- __publicField(this, "user");
243
- /**
244
- * A helper for measuring text.
245
- *
246
- * @public
247
- */
248
- __publicField(this, "textMeasure");
249
- /**
250
- * A utility for managing the set of fonts that should be rendered in the document.
251
- *
252
- * @public
253
- */
254
- __publicField(this, "fonts");
255
- /**
256
- * A manager for the editor's scribbles.
257
- *
258
- * @public
259
- */
260
- __publicField(this, "scribbles");
261
- /**
262
- * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
263
- *
264
- * @public
265
- */
266
- __publicField(this, "sideEffects");
267
- /**
268
- * A manager for moving the camera when the mouse is at the edge of the screen.
269
- *
270
- * @public
271
- */
272
- __publicField(this, "edgeScrollManager");
273
- /**
274
- * A manager for ensuring correct focus. See FocusManager for details.
275
- *
276
- * @internal
277
- */
278
- __publicField(this, "focusManager");
279
- /**
280
- * The current HTML element containing the editor.
281
- *
282
- * @example
283
- * ```ts
284
- * const container = editor.getContainer()
285
- * ```
286
- *
287
- * @public
288
- */
289
- __publicField(this, "getContainer");
290
- /* ------------------- Shape Utils ------------------ */
291
- /**
292
- * A map of shape utility classes (TLShapeUtils) by shape type.
293
- *
294
- * @public
295
- */
296
- __publicField(this, "shapeUtils");
297
- __publicField(this, "styleProps");
298
- /* ------------------- Binding Utils ------------------ */
299
- /**
300
- * A map of shape utility classes (TLShapeUtils) by shape type.
301
- *
302
- * @public
303
- */
304
- __publicField(this, "bindingUtils");
305
- /* --------------------- History -------------------- */
306
- /**
307
- * A manager for the editor's history.
308
- *
309
- * @readonly
310
- */
311
- __publicField(this, "history");
312
- __publicField(this, "_shouldIgnoreShapeLock", false);
313
- /** @internal */
314
- __publicField(this, "_crashingError", null);
315
- /** @internal */
316
- __publicField(this, "_isChangingStyleTimeout", -1);
317
- // Menus
318
- __publicField(this, "menus", tlmenus.forContext(this.contextId));
319
- // Rich text editor
320
- __publicField(this, "_currentRichTextEditor", atom("rich text editor", null));
321
- __publicField(this, "_textOptions");
322
- __publicField(this, "_debouncedZoomLevel", atom("debounced zoom level", 1));
323
- __publicField(this, "_cameraOptions", atom("camera options", DEFAULT_CAMERA_OPTIONS));
324
- /** @internal */
325
- __publicField(this, "_viewportAnimation", null);
326
- // Viewport
327
- /** @internal */
328
- __publicField(this, "_willSetInitialBounds", true);
329
- // Following
330
- // When we are 'locked on' to a user, our camera is derived from their camera.
331
- __publicField(this, "_isLockedOnFollowingUser", atom("isLockedOnFollowingUser", false));
332
- // Camera state
333
- // Camera state does two things: first, it allows us to subscribe to whether
334
- // the camera is moving or not; and second, it allows us to update the rendering
335
- // shapes on the canvas. Changing the rendering shapes may cause shapes to
336
- // unmount / remount in the DOM, which is expensive; and computing visibility is
337
- // also expensive in large projects. For this reason, we use a second bounding
338
- // box just for rendering, and we only update after the camera stops moving.
339
- __publicField(this, "_cameraStateTimeoutRemaining", 0);
340
- /* @internal */
341
- __publicField(this, "_currentPageShapeIds");
342
- /* --------------------- Shapes --------------------- */
343
- __publicField(this, "_shapeGeometryCaches", {});
344
- __publicField(this, "_notVisibleShapes", notVisibleShapes(this));
345
- __publicField(this, "_culledShapesCache", null);
346
- // Parents and children
347
- /**
348
- * A cache of parents to children.
349
- *
350
- * @internal
351
- */
352
- __publicField(this, "_parentIdsToChildIds");
353
- __publicField(this, "animatingShapes", /* @__PURE__ */ new Map());
354
- /* --------------------- Content -------------------- */
355
- /** @internal */
356
- __publicField(this, "externalAssetContentHandlers", {
357
- file: null,
358
- url: null
359
- });
360
- /** @internal */
361
- __publicField(this, "temporaryAssetPreview", /* @__PURE__ */ new Map());
362
- /** @internal */
363
- __publicField(this, "externalContentHandlers", {
364
- text: null,
365
- files: null,
366
- "file-replace": null,
367
- embed: null,
368
- "svg-text": null,
369
- url: null,
370
- tldraw: null,
371
- excalidraw: null
372
- });
373
- /**
374
- * A manager for recording multiple click events.
375
- *
376
- * @internal
377
- */
378
- __publicField(this, "_clickManager", new ClickManager(this));
379
- /**
380
- * The previous cursor. Used for restoring the cursor after pan events.
381
- *
382
- * @internal
383
- */
384
- __publicField(this, "_prevCursor", "default");
385
- /** @internal */
386
- __publicField(this, "_shiftKeyTimeout", -1);
387
- /** @internal */
388
- __publicField(this, "_altKeyTimeout", -1);
389
- /** @internal */
390
- __publicField(this, "_ctrlKeyTimeout", -1);
391
- /** @internal */
392
- __publicField(this, "_metaKeyTimeout", -1);
393
- /** @internal */
394
- __publicField(this, "_restoreToolId", "select");
395
- /** @internal */
396
- __publicField(this, "_didPinch", false);
397
- /** @internal */
398
- __publicField(this, "_selectedShapeIdsAtPointerDown", []);
399
- /** @internal */
400
- __publicField(this, "_longPressTimeout", -1);
401
- /** @internal */
402
- __publicField(this, "capturedPointerId", null);
403
- /** @internal */
404
- __publicField(this, "performanceTracker");
405
- /** @internal */
406
- __publicField(this, "performanceTrackerTimeout", -1);
407
- /** @internal */
408
- __publicField(this, "handledEvents", /* @__PURE__ */ new WeakSet());
409
- __publicField(this, "_pendingEventsForNextTick", []);
410
146
  this._getShapeVisibility = getShapeVisibility;
411
147
  const options = _textOptions ? { ..._options, text: _options?.text ?? _textOptions } : _options;
412
148
  this.options = { ...defaultTldrawOptions, ...options };
@@ -812,6 +548,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
812
548
  );
813
549
  }
814
550
  }
551
+ _getShapeVisibility;
815
552
  getIsShapeHiddenCache() {
816
553
  if (!this._getShapeVisibility) return null;
817
554
  return this.store.createComputedCache("isShapeHidden", (shape) => {
@@ -827,6 +564,20 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
827
564
  typeof shapeOrId === "string" ? shapeOrId : shapeOrId.id
828
565
  );
829
566
  }
567
+ options;
568
+ contextId = uniqueId();
569
+ /**
570
+ * The editor's store
571
+ *
572
+ * @public
573
+ */
574
+ store;
575
+ /**
576
+ * The root state of the statechart.
577
+ *
578
+ * @public
579
+ */
580
+ root;
830
581
  /**
831
582
  * Set a tool. Useful if you need to add a tool to the state chart on demand,
832
583
  * after the editor has already been initialized.
@@ -858,6 +609,114 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
858
609
  delete parent.children[Tool.id];
859
610
  }
860
611
  }
612
+ /**
613
+ * A set of functions to call when the editor is disposed.
614
+ *
615
+ * @public
616
+ */
617
+ disposables = /* @__PURE__ */ new Set();
618
+ /**
619
+ * Whether the editor is disposed.
620
+ *
621
+ * @public
622
+ */
623
+ isDisposed = false;
624
+ /**
625
+ * A manager for the editor's tick events.
626
+ *
627
+ * @internal */
628
+ _tickManager;
629
+ /**
630
+ * A manager for the editor's input state.
631
+ *
632
+ * @public
633
+ */
634
+ inputs;
635
+ /**
636
+ * A manager for the editor's snapping feature.
637
+ *
638
+ * @public
639
+ */
640
+ snaps;
641
+ _spatialIndex;
642
+ /**
643
+ * A manager for the any asynchronous events and making sure they're
644
+ * cleaned up upon disposal.
645
+ *
646
+ * @public
647
+ */
648
+ timers = tltime.forContext(this.contextId);
649
+ /**
650
+ * A manager for the user and their preferences.
651
+ *
652
+ * @public
653
+ */
654
+ user;
655
+ /**
656
+ * A helper for measuring text.
657
+ *
658
+ * @public
659
+ */
660
+ textMeasure;
661
+ /**
662
+ * A utility for managing the set of fonts that should be rendered in the document.
663
+ *
664
+ * @public
665
+ */
666
+ fonts;
667
+ /**
668
+ * A manager for the editor's scribbles.
669
+ *
670
+ * @public
671
+ */
672
+ scribbles;
673
+ /**
674
+ * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
675
+ *
676
+ * @public
677
+ */
678
+ sideEffects;
679
+ /**
680
+ * A manager for moving the camera when the mouse is at the edge of the screen.
681
+ *
682
+ * @public
683
+ */
684
+ edgeScrollManager;
685
+ /**
686
+ * A manager for ensuring correct focus. See FocusManager for details.
687
+ *
688
+ * @internal
689
+ */
690
+ focusManager;
691
+ /**
692
+ * The current HTML element containing the editor.
693
+ *
694
+ * @example
695
+ * ```ts
696
+ * const container = editor.getContainer()
697
+ * ```
698
+ *
699
+ * @public
700
+ */
701
+ getContainer;
702
+ /**
703
+ * The document that the editor's container element belongs to.
704
+ * Use this instead of the global `document` to support cross-window embedding.
705
+ *
706
+ * @internal
707
+ */
708
+ getContainerDocument() {
709
+ return this.getContainer().ownerDocument;
710
+ }
711
+ /**
712
+ * The window that the editor's container element belongs to.
713
+ * Use this instead of the global `window` to support cross-window embedding.
714
+ *
715
+ * @internal
716
+ */
717
+ getContainerWindow() {
718
+ return getOwnerWindow(this.getContainer());
719
+ }
861
720
  /**
862
721
  * Dispose the editor.
863
722
  *
@@ -870,6 +729,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
870
729
  this.isDisposed = true;
871
730
  this.emit("dispose");
872
731
  }
732
+ /* ------------------- Shape Utils ------------------ */
733
+ /**
734
+ * A map of shape utility classes (TLShapeUtils) by shape type.
735
+ *
736
+ * @public
737
+ */
738
+ shapeUtils;
739
+ styleProps;
873
740
  getShapeUtil(arg) {
874
741
  const type = typeof arg === "string" ? arg : arg.type;
875
742
  const shapeUtil = getOwnProperty(this.shapeUtils, type);
@@ -880,12 +747,26 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
880
747
  const type = typeof arg === "string" ? arg : arg.type;
881
748
  return hasOwnProperty(this.shapeUtils, type);
882
749
  }
750
+ /* ------------------- Binding Utils ------------------ */
751
+ /**
752
+ * A map of shape utility classes (TLShapeUtils) by shape type.
753
+ *
754
+ * @public
755
+ */
756
+ bindingUtils;
883
757
  getBindingUtil(arg) {
884
758
  const type = typeof arg === "string" ? arg : arg.type;
885
759
  const bindingUtil = getOwnProperty(this.bindingUtils, type);
886
760
  assert(bindingUtil, `No binding util found for type "${type}"`);
887
761
  return bindingUtil;
888
762
  }
763
+ /* --------------------- History -------------------- */
764
+ /**
765
+ * A manager for the editor's history.
766
+ *
767
+ * @readonly
768
+ */
769
+ history;
889
770
  /**
890
771
  * Undo to the last mark.
891
772
  *
@@ -1013,6 +894,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1013
894
  this.history.bailToMark(id);
1014
895
  return this;
1015
896
  }
897
+ _shouldIgnoreShapeLock = false;
1016
898
  /**
1017
899
  * Run a function in a transaction with optional options for context.
1018
900
  * You can use the options to change the way that history is treated
@@ -1104,6 +986,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1104
986
  };
1105
987
  }
1106
988
  }
989
+ /** @internal */
990
+ _crashingError = null;
1107
991
  /**
1108
992
  * We can't use an `atom` here because there's a chance that when `crashAndReportError` is called,
1109
993
  * we're in a transaction that's about to be rolled back due to the same error we're currently
@@ -1270,6 +1154,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1270
1154
  ]);
1271
1155
  }, opts);
1272
1156
  }
1157
+ /** @internal */
1158
+ _isChangingStyleTimeout = -1;
1159
+ // Menus
1160
+ menus = tlmenus.forContext(this.contextId);
1273
1161
  /* --------------------- Cursor --------------------- */
1274
1162
  /**
1275
1163
  * Set the cursor.
@@ -1835,6 +1723,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1835
1723
  );
1836
1724
  return this;
1837
1725
  }
1726
+ // Rich text editor
1727
+ _currentRichTextEditor = atom("rich text editor", null);
1838
1728
  getRichTextEditor() {
1839
1729
  return this._currentRichTextEditor.get();
1840
1730
  }
@@ -2014,6 +1904,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2014
1904
  }
2015
1905
  return this;
2016
1906
  }
1907
+ _textOptions;
2017
1908
  /**
2018
1909
  * Get the current text options.
2019
1910
  *
@@ -2084,6 +1975,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2084
1975
  getResizeScaleFactor() {
2085
1976
  return this.user.getIsDynamicResizeMode() ? 1 / this.getZoomLevel() : 1;
2086
1977
  }
1978
+ _debouncedZoomLevel = atom("debounced zoom level", 1);
2087
1979
  getDebouncedZoomLevel() {
2088
1980
  if (this.options.debouncedZoom) {
2089
1981
  if (this.getCameraState() === "idle") {
@@ -2188,6 +2080,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2188
2080
  }
2189
2081
  }
2190
2082
  }
2083
+ _cameraOptions = atom("camera options", DEFAULT_CAMERA_OPTIONS);
2191
2084
  /**
2192
2085
  * Get the current camera options.
2193
2086
  *
@@ -2662,6 +2555,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2662
2555
  return this;
2663
2556
  }
2664
2557
  /** @internal */
2558
+ _viewportAnimation = null;
2559
+ /** @internal */
2665
2560
  _animateViewport(ms) {
2666
2561
  if (!this._viewportAnimation) return;
2667
2562
  this._viewportAnimation.elapsed += ms;
@@ -2800,6 +2695,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2800
2695
  });
2801
2696
  return this;
2802
2697
  }
2698
+ // Viewport
2699
+ /** @internal */
2700
+ _willSetInitialBounds = true;
2803
2701
  /**
2804
2702
  * Update the viewport. The viewport will measure the size and screen position of its container
2805
2703
  * element. This should be done whenever the container's position on the screen changes.
@@ -2828,13 +2726,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2828
2726
  screenBounds.width = Math.max(screenBounds.width, 1);
2829
2727
  screenBounds.height = Math.max(screenBounds.height, 1);
2830
2728
  }
2729
+ const doc = this.getContainerDocument();
2831
2730
  const insets = [
2832
2731
  // top
2833
2732
  screenBounds.minY !== 0,
2834
2733
  // right
2835
- !approximately(document.body.scrollWidth, screenBounds.maxX, 1),
2734
+ !approximately(doc.body.scrollWidth, screenBounds.maxX, 1),
2836
2735
  // bottom
2837
- !approximately(document.body.scrollHeight, screenBounds.maxY, 1),
2736
+ !approximately(doc.body.scrollHeight, screenBounds.maxY, 1),
2838
2737
  // left
2839
2738
  screenBounds.minX !== 0
2840
2739
  ];
@@ -2954,6 +2853,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2954
2853
  const currentPageId = this.getCurrentPageId();
2955
2854
  return this.getCollaborators().filter((c) => c.currentPageId === currentPageId);
2956
2855
  }
2856
+ // Following
2857
+ // When we are 'locked on' to a user, our camera is derived from their camera.
2858
+ _isLockedOnFollowingUser = atom("isLockedOnFollowingUser", false);
2957
2859
  /**
2958
2860
  * Start viewport-following a user.
2959
2861
  *
@@ -3129,6 +3031,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3129
3031
  }
3130
3032
  return renderingShapes;
3131
3033
  }
3034
+ // Camera state
3035
+ // Camera state does two things: first, it allows us to subscribe to whether
3036
+ // the camera is moving or not; and second, it allows us to update the rendering
3037
+ // shapes on the canvas. Changing the rendering shapes may cause shapes to
3038
+ // unmount / remount in the DOM, which is expensive; and computing visibility is
3039
+ // also expensive in large projects. For this reason, we use a second bounding
3040
+ // box just for rendering, and we only update after the camera stops moving.
3041
+ _cameraStateTimeoutRemaining = 0;
3132
3042
  _decayCameraStateTimeout(elapsed) {
3133
3043
  this._cameraStateTimeoutRemaining -= elapsed;
3134
3044
  if (this._cameraStateTimeoutRemaining > 0) return;
@@ -3200,6 +3110,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3200
3110
  getPage(page) {
3201
3111
  return this.store.get(typeof page === "string" ? page : page.id);
3202
3112
  }
3113
+ /* @internal */
3114
+ _currentPageShapeIds;
3203
3115
  /**
3204
3116
  * An array of all of the shapes on the current page.
3205
3117
  *
@@ -3521,6 +3433,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3521
3433
  async uploadAsset(asset, file, abortSignal) {
3522
3434
  return await this.store.props.assets.upload(asset, file, abortSignal);
3523
3435
  }
3436
+ /* --------------------- Shapes --------------------- */
3437
+ _shapeGeometryCaches = {};
3524
3438
  /**
3525
3439
  * Get the geometry of a shape in shape-space.
3526
3440
  *
@@ -3891,6 +3805,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3891
3805
  getNotVisibleShapes() {
3892
3806
  return this._notVisibleShapes.get();
3893
3807
  }
3808
+ _notVisibleShapes = notVisibleShapes(this);
3809
+ _culledShapesCache = null;
3894
3810
  getCulledShapes() {
3895
3811
  const notVisibleShapes2 = this.getNotVisibleShapes();
3896
3812
  const selectedShapeIds = this.getSelectedShapeIds();
@@ -4305,6 +4221,13 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4305
4221
  return this.getAncestorPageId(this.getShape(_shape.parentId));
4306
4222
  }
4307
4223
  }
4224
+ // Parents and children
4225
+ /**
4226
+ * A cache of parents to children.
4227
+ *
4228
+ * @internal
4229
+ */
4230
+ _parentIdsToChildIds;
4308
4231
  /**
4309
4232
  * Reparent shapes to a new parent. This operation preserves the shape's current page positions /
4310
4233
  * rotations.
@@ -5949,6 +5872,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
5949
5872
  });
5950
5873
  return this;
5951
5874
  }
5875
+ animatingShapes = /* @__PURE__ */ new Map();
5952
5876
  /**
5953
5877
  * Animate a shape.
5954
5878
  *
@@ -6442,6 +6366,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6442
6366
  }
6443
6367
  return this;
6444
6368
  }
6369
+ /* --------------------- Content -------------------- */
6370
+ /** @internal */
6371
+ externalAssetContentHandlers = {
6372
+ file: null,
6373
+ url: null
6374
+ };
6375
+ /** @internal */
6376
+ temporaryAssetPreview = /* @__PURE__ */ new Map();
6445
6377
  /**
6446
6378
  * Register an external asset handler. This handler will be called when the editor needs to
6447
6379
  * create an asset for some external content, like an image/video file or a bookmark URL. For
@@ -6527,6 +6459,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6527
6459
  hasExternalAssetHandler(type) {
6528
6460
  return !!this.externalAssetContentHandlers[type];
6529
6461
  }
6462
+ /** @internal */
6463
+ externalContentHandlers = {
6464
+ text: null,
6465
+ files: null,
6466
+ "file-replace": null,
6467
+ embed: null,
6468
+ "svg-text": null,
6469
+ url: null,
6470
+ tldraw: null,
6471
+ excalidraw: null
6472
+ };
6530
6473
  /**
6531
6474
  * Register an external content handler. This handler will be called when the editor receives
6532
6475
  * external content of the provided type. For example, the 'image' type handler will be called
@@ -6947,7 +6890,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6947
6890
  return {
6948
6891
  svg: serializer.serializeToString(result.svg),
6949
6892
  width: result.width,
6950
- height: result.height
6893
+ height: result.height,
6894
+ trimPadding: result.trimPadding
6951
6895
  };
6952
6896
  }
6953
6897
  /**
@@ -6969,30 +6913,45 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6969
6913
  const result = await this.getSvgString(shapes, withDefaults);
6970
6914
  if (!result) throw new Error("Could not create SVG");
6971
6915
  switch (withDefaults.format) {
6972
- case "svg":
6916
+ case "svg": {
6917
+ let svg = result.svg;
6918
+ let w = result.width;
6919
+ let h = result.height;
6920
+ if (result.trimPadding > 0) {
6921
+ const trimmed = await trimSvgToContent(svg, {
6922
+ width: w,
6923
+ height: h,
6924
+ trimPadding: result.trimPadding,
6925
+ scale: withDefaults.scale
6926
+ });
6927
+ if (trimmed) {
6928
+ svg = trimmed.svg;
6929
+ w = trimmed.width;
6930
+ h = trimmed.height;
6931
+ }
6932
+ }
6973
6933
  return {
6974
- blob: new Blob([result.svg], { type: "image/svg+xml" }),
6975
- width: result.width,
6976
- height: result.height
6934
+ blob: new Blob([svg], { type: "image/svg+xml" }),
6935
+ width: w,
6936
+ height: h
6977
6937
  };
6938
+ }
6978
6939
  case "jpeg":
6979
6940
  case "png":
6980
6941
  case "webp": {
6981
- const blob = await getSvgAsImage(result.svg, {
6942
+ const imageResult = await getSvgAsImageWithOptions(result.svg, {
6982
6943
  type: withDefaults.format,
6983
6944
  quality: withDefaults.quality,
6984
6945
  pixelRatio: withDefaults.pixelRatio,
6985
6946
  width: result.width,
6986
- height: result.height
6947
+ height: result.height,
6948
+ trimPadding: result.trimPadding,
6949
+ scale: withDefaults.scale
6987
6950
  });
6988
- if (!blob) {
6951
+ if (!imageResult) {
6989
6952
  throw new Error("Could not construct image.");
6990
6953
  }
6991
- return {
6992
- blob,
6993
- width: result.width,
6994
- height: result.height
6995
- };
6954
+ return imageResult;
6996
6955
  }
6997
6956
  default: {
6998
6957
  exhaustiveSwitchError(withDefaults.format);
@@ -7387,7 +7346,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7387
7346
  param: opts?.param,
7388
7347
  to: opts?.getTarget?.(this)
7389
7348
  });
7390
- window.history.replaceState({}, document.title, url.toString());
7349
+ window.history.replaceState({}, this.getContainerDocument().title, url.toString());
7391
7350
  });
7392
7351
  const scheduleEffect = debounce((execute) => execute(), opts?.debounceMs ?? 500);
7393
7352
  const unlisten = react(
@@ -7400,6 +7359,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7400
7359
  scheduleEffect.cancel();
7401
7360
  };
7402
7361
  }
7362
+ /**
7363
+ * A manager for recording multiple click events.
7364
+ *
7365
+ * @internal
7366
+ */
7367
+ _clickManager = new ClickManager(this);
7403
7368
  /**
7404
7369
  * Prevent a double click event from firing the next time the user clicks
7405
7370
  *
@@ -7408,6 +7373,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7408
7373
  cancelDoubleClick() {
7409
7374
  this._clickManager.cancelDoubleClickTimeout();
7410
7375
  }
7376
+ /**
7377
+ * The previous cursor. Used for restoring the cursor after pan events.
7378
+ *
7379
+ * @internal
7380
+ */
7381
+ _prevCursor = "default";
7382
+ /** @internal */
7383
+ _shiftKeyTimeout = -1;
7411
7384
  _setShiftKeyTimeout() {
7412
7385
  this.inputs.setShiftKey(false);
7413
7386
  this.dispatch({
@@ -7422,6 +7395,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7422
7395
  code: "ShiftLeft"
7423
7396
  });
7424
7397
  }
7398
+ /** @internal */
7399
+ _altKeyTimeout = -1;
7425
7400
  _setAltKeyTimeout() {
7426
7401
  this.inputs.setAltKey(false);
7427
7402
  this.dispatch({
@@ -7436,6 +7411,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7436
7411
  code: "AltLeft"
7437
7412
  });
7438
7413
  }
7414
+ /** @internal */
7415
+ _ctrlKeyTimeout = -1;
7439
7416
  _setCtrlKeyTimeout() {
7440
7417
  this.inputs.setCtrlKey(false);
7441
7418
  this.dispatch({
@@ -7450,6 +7427,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7450
7427
  code: "ControlLeft"
7451
7428
  });
7452
7429
  }
7430
+ /** @internal */
7431
+ _metaKeyTimeout = -1;
7453
7432
  _setMetaKeyTimeout() {
7454
7433
  this.inputs.setMetaKey(false);
7455
7434
  this.dispatch({
@@ -7464,6 +7443,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7464
7443
  code: "MetaLeft"
7465
7444
  });
7466
7445
  }
7446
+ /** @internal */
7447
+ _restoreToolId = "select";
7448
+ /** @internal */
7449
+ _didPinch = false;
7450
+ /** @internal */
7451
+ _selectedShapeIdsAtPointerDown = [];
7452
+ /** @internal */
7453
+ _longPressTimeout = -1;
7454
+ /** @internal */
7455
+ capturedPointerId = null;
7456
+ /** @internal */
7457
+ performanceTracker;
7458
+ /** @internal */
7459
+ performanceTrackerTimeout = -1;
7460
+ /** @internal */
7461
+ handledEvents = /* @__PURE__ */ new WeakSet();
7467
7462
  /**
7468
7463
  * In tldraw, events are sometimes handled by multiple components. For example, the shapes might
7469
7464
  * have events, but the canvas handles events too. The way that the canvas handles events can
@@ -7509,6 +7504,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7509
7504
  }
7510
7505
  return this;
7511
7506
  }
7507
+ _pendingEventsForNextTick = [];
7512
7508
  _flushEventsForTick(elapsed) {
7513
7509
  this.run(() => {
7514
7510
  if (this._pendingEventsForNextTick.length > 0) {
@@ -7916,83 +7912,231 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7916
7912
  }
7917
7913
  }
7918
7914
  }
7919
- _init = __decoratorStart(_a);
7920
- __decorateElement(_init, 1, "getIsShapeHiddenCache", _getIsShapeHiddenCache_dec, Editor);
7921
- __decorateElement(_init, 1, "canUndo", _canUndo_dec, Editor);
7922
- __decorateElement(_init, 1, "canRedo", _canRedo_dec, Editor);
7923
- __decorateElement(_init, 1, "getPath", _getPath_dec, Editor);
7924
- __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
7925
- __decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
7926
- __decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
7927
- __decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
7928
- __decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
7929
- __decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
7930
- __decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);
7931
- __decorateElement(_init, 1, "_getCurrentPageStateId", __getCurrentPageStateId_dec, Editor);
7932
- __decorateElement(_init, 1, "getSelectedShapeIds", _getSelectedShapeIds_dec, Editor);
7933
- __decorateElement(_init, 1, "getSelectedShapes", _getSelectedShapes_dec, Editor);
7934
- __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPageShapesInReadingOrder_dec, Editor);
7935
- __decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
7936
- __decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
7937
- __decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
7938
- __decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
7939
- __decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
7940
- __decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);
7941
- __decorateElement(_init, 1, "getFocusedGroupId", _getFocusedGroupId_dec, Editor);
7942
- __decorateElement(_init, 1, "getFocusedGroup", _getFocusedGroup_dec, Editor);
7943
- __decorateElement(_init, 1, "getEditingShapeId", _getEditingShapeId_dec, Editor);
7944
- __decorateElement(_init, 1, "getEditingShape", _getEditingShape_dec, Editor);
7945
- __decorateElement(_init, 1, "getRichTextEditor", _getRichTextEditor_dec, Editor);
7946
- __decorateElement(_init, 1, "getHoveredShapeId", _getHoveredShapeId_dec, Editor);
7947
- __decorateElement(_init, 1, "getHoveredShape", _getHoveredShape_dec, Editor);
7948
- __decorateElement(_init, 1, "getHintingShapeIds", _getHintingShapeIds_dec, Editor);
7949
- __decorateElement(_init, 1, "getHintingShape", _getHintingShape_dec, Editor);
7950
- __decorateElement(_init, 1, "getErasingShapeIds", _getErasingShapeIds_dec, Editor);
7951
- __decorateElement(_init, 1, "getErasingShapes", _getErasingShapes_dec, Editor);
7952
- __decorateElement(_init, 1, "_unsafe_getCameraId", __unsafe_getCameraId_dec, Editor);
7953
- __decorateElement(_init, 1, "getCamera", _getCamera_dec, Editor);
7954
- __decorateElement(_init, 1, "getViewportPageBoundsForFollowing", _getViewportPageBoundsForFollowing_dec, Editor);
7955
- __decorateElement(_init, 1, "getCameraForFollowing", _getCameraForFollowing_dec, Editor);
7956
- __decorateElement(_init, 1, "getZoomLevel", _getZoomLevel_dec, Editor);
7957
- __decorateElement(_init, 1, "getResizeScaleFactor", _getResizeScaleFactor_dec, Editor);
7958
- __decorateElement(_init, 1, "getDebouncedZoomLevel", _getDebouncedZoomLevel_dec, Editor);
7959
- __decorateElement(_init, 1, "_getAboveDebouncedZoomThreshold", __getAboveDebouncedZoomThreshold_dec, Editor);
7960
- __decorateElement(_init, 1, "getEfficientZoomLevel", _getEfficientZoomLevel_dec, Editor);
7961
- __decorateElement(_init, 1, "getViewportScreenBounds", _getViewportScreenBounds_dec, Editor);
7962
- __decorateElement(_init, 1, "getViewportScreenCenter", _getViewportScreenCenter_dec, Editor);
7963
- __decorateElement(_init, 1, "getViewportPageBounds", _getViewportPageBounds_dec, Editor);
7964
- __decorateElement(_init, 1, "_getCollaboratorsQuery", __getCollaboratorsQuery_dec, Editor);
7965
- __decorateElement(_init, 1, "getCollaborators", _getCollaborators_dec, Editor);
7966
- __decorateElement(_init, 1, "getCollaboratorsOnCurrentPage", _getCollaboratorsOnCurrentPage_dec, Editor);
7967
- __decorateElement(_init, 1, "getRenderingShapes", _getRenderingShapes_dec, Editor);
7968
- __decorateElement(_init, 1, "_getAllPagesQuery", __getAllPagesQuery_dec, Editor);
7969
- __decorateElement(_init, 1, "getPages", _getPages_dec, Editor);
7970
- __decorateElement(_init, 1, "getCurrentPageId", _getCurrentPageId_dec, Editor);
7971
- __decorateElement(_init, 1, "getCurrentPageShapeIdsSorted", _getCurrentPageShapeIdsSorted_dec, Editor);
7972
- __decorateElement(_init, 1, "_getAllAssetsQuery", __getAllAssetsQuery_dec, Editor);
7973
- __decorateElement(_init, 1, "_getShapeHandlesCache", __getShapeHandlesCache_dec, Editor);
7974
- __decorateElement(_init, 1, "_getShapePageTransformCache", __getShapePageTransformCache_dec, Editor);
7975
- __decorateElement(_init, 1, "_getShapePageBoundsCache", __getShapePageBoundsCache_dec, Editor);
7976
- __decorateElement(_init, 1, "_getShapeClipPathCache", __getShapeClipPathCache_dec, Editor);
7977
- __decorateElement(_init, 1, "_getShapeMaskCache", __getShapeMaskCache_dec, Editor);
7978
- __decorateElement(_init, 1, "_getShapeMaskedPageBoundsCache", __getShapeMaskedPageBoundsCache_dec, Editor);
7979
- __decorateElement(_init, 1, "getNotVisibleShapes", _getNotVisibleShapes_dec, Editor);
7980
- __decorateElement(_init, 1, "getCulledShapes", _getCulledShapes_dec, Editor);
7981
- __decorateElement(_init, 1, "getCurrentPageBounds", _getCurrentPageBounds_dec, Editor);
7982
- __decorateElement(_init, 1, "getCurrentPageShapes", _getCurrentPageShapes_dec, Editor);
7983
- __decorateElement(_init, 1, "getCurrentPageShapesSorted", _getCurrentPageShapesSorted_dec, Editor);
7984
- __decorateElement(_init, 1, "getCurrentPageRenderingShapesSorted", _getCurrentPageRenderingShapesSorted_dec, Editor);
7985
- __decorateElement(_init, 1, "_getBindingsIndexCache", __getBindingsIndexCache_dec, Editor);
7986
- __decorateElement(_init, 1, "_getSelectionSharedStyles", __getSelectionSharedStyles_dec, Editor);
7987
- __decorateElement(_init, 1, "getSharedStyles", _getSharedStyles_dec, Editor);
7988
- __decorateElement(_init, 1, "getSharedOpacity", _getSharedOpacity_dec, Editor);
7989
- __decorateElement(_init, 1, "getIsFocused", _getIsFocused_dec, Editor);
7990
- __decorateElement(_init, 1, "getIsReadonly", _getIsReadonly_dec, Editor);
7991
- __decorateElement(_init, 1, "_setShiftKeyTimeout", __setShiftKeyTimeout_dec, Editor);
7992
- __decorateElement(_init, 1, "_setAltKeyTimeout", __setAltKeyTimeout_dec, Editor);
7993
- __decorateElement(_init, 1, "_setCtrlKeyTimeout", __setCtrlKeyTimeout_dec, Editor);
7994
- __decorateElement(_init, 1, "_setMetaKeyTimeout", __setMetaKeyTimeout_dec, Editor);
7995
- __decoratorMetadata(_init, Editor);
7915
+ __decorateClass([
7916
+ computed
7917
+ ], Editor.prototype, "getIsShapeHiddenCache", 1);
7918
+ __decorateClass([
7919
+ computed
7920
+ ], Editor.prototype, "canUndo", 1);
7921
+ __decorateClass([
7922
+ computed
7923
+ ], Editor.prototype, "canRedo", 1);
7924
+ __decorateClass([
7925
+ computed
7926
+ ], Editor.prototype, "getPath", 1);
7927
+ __decorateClass([
7928
+ computed
7929
+ ], Editor.prototype, "getCurrentTool", 1);
7930
+ __decorateClass([
7931
+ computed
7932
+ ], Editor.prototype, "getCurrentToolId", 1);
7933
+ __decorateClass([
7934
+ computed
7935
+ ], Editor.prototype, "getDocumentSettings", 1);
7936
+ __decorateClass([
7937
+ computed
7938
+ ], Editor.prototype, "getInstanceState", 1);
7939
+ __decorateClass([
7940
+ computed
7941
+ ], Editor.prototype, "getPageStates", 1);
7942
+ __decorateClass([
7943
+ computed
7944
+ ], Editor.prototype, "_getPageStatesQuery", 1);
7945
+ __decorateClass([
7946
+ computed
7947
+ ], Editor.prototype, "getCurrentPageState", 1);
7948
+ __decorateClass([
7949
+ computed
7950
+ ], Editor.prototype, "_getCurrentPageStateId", 1);
7951
+ __decorateClass([
7952
+ computed
7953
+ ], Editor.prototype, "getSelectedShapeIds", 1);
7954
+ __decorateClass([
7955
+ computed
7956
+ ], Editor.prototype, "getSelectedShapes", 1);
7957
+ __decorateClass([
7958
+ computed
7959
+ ], Editor.prototype, "getCurrentPageShapesInReadingOrder", 1);
7960
+ __decorateClass([
7961
+ computed
7962
+ ], Editor.prototype, "getOnlySelectedShapeId", 1);
7963
+ __decorateClass([
7964
+ computed
7965
+ ], Editor.prototype, "getOnlySelectedShape", 1);
7966
+ __decorateClass([
7967
+ computed
7968
+ ], Editor.prototype, "getSelectionPageBounds", 1);
7969
+ __decorateClass([
7970
+ computed
7971
+ ], Editor.prototype, "getSelectionRotation", 1);
7972
+ __decorateClass([
7973
+ computed
7974
+ ], Editor.prototype, "getSelectionRotatedPageBounds", 1);
7975
+ __decorateClass([
7976
+ computed
7977
+ ], Editor.prototype, "getSelectionRotatedScreenBounds", 1);
7978
+ __decorateClass([
7979
+ computed
7980
+ ], Editor.prototype, "getFocusedGroupId", 1);
7981
+ __decorateClass([
7982
+ computed
7983
+ ], Editor.prototype, "getFocusedGroup", 1);
7984
+ __decorateClass([
7985
+ computed
7986
+ ], Editor.prototype, "getEditingShapeId", 1);
7987
+ __decorateClass([
7988
+ computed
7989
+ ], Editor.prototype, "getEditingShape", 1);
7990
+ __decorateClass([
7991
+ computed
7992
+ ], Editor.prototype, "getRichTextEditor", 1);
7993
+ __decorateClass([
7994
+ computed
7995
+ ], Editor.prototype, "getHoveredShapeId", 1);
7996
+ __decorateClass([
7997
+ computed
7998
+ ], Editor.prototype, "getHoveredShape", 1);
7999
+ __decorateClass([
8000
+ computed
8001
+ ], Editor.prototype, "getHintingShapeIds", 1);
8002
+ __decorateClass([
8003
+ computed
8004
+ ], Editor.prototype, "getHintingShape", 1);
8005
+ __decorateClass([
8006
+ computed
8007
+ ], Editor.prototype, "getErasingShapeIds", 1);
8008
+ __decorateClass([
8009
+ computed
8010
+ ], Editor.prototype, "getErasingShapes", 1);
8011
+ __decorateClass([
8012
+ computed
8013
+ ], Editor.prototype, "_unsafe_getCameraId", 1);
8014
+ __decorateClass([
8015
+ computed
8016
+ ], Editor.prototype, "getCamera", 1);
8017
+ __decorateClass([
8018
+ computed
8019
+ ], Editor.prototype, "getViewportPageBoundsForFollowing", 1);
8020
+ __decorateClass([
8021
+ computed
8022
+ ], Editor.prototype, "getCameraForFollowing", 1);
8023
+ __decorateClass([
8024
+ computed
8025
+ ], Editor.prototype, "getZoomLevel", 1);
8026
+ __decorateClass([
8027
+ computed
8028
+ ], Editor.prototype, "getResizeScaleFactor", 1);
8029
+ __decorateClass([
8030
+ computed
8031
+ ], Editor.prototype, "getDebouncedZoomLevel", 1);
8032
+ __decorateClass([
8033
+ computed
8034
+ ], Editor.prototype, "_getAboveDebouncedZoomThreshold", 1);
8035
+ __decorateClass([
8036
+ computed
8037
+ ], Editor.prototype, "getEfficientZoomLevel", 1);
8038
+ __decorateClass([
8039
+ computed
8040
+ ], Editor.prototype, "getViewportScreenBounds", 1);
8041
+ __decorateClass([
8042
+ computed
8043
+ ], Editor.prototype, "getViewportScreenCenter", 1);
8044
+ __decorateClass([
8045
+ computed
8046
+ ], Editor.prototype, "getViewportPageBounds", 1);
8047
+ __decorateClass([
8048
+ computed
8049
+ ], Editor.prototype, "_getCollaboratorsQuery", 1);
8050
+ __decorateClass([
8051
+ computed
8052
+ ], Editor.prototype, "getCollaborators", 1);
8053
+ __decorateClass([
8054
+ computed
8055
+ ], Editor.prototype, "getCollaboratorsOnCurrentPage", 1);
8056
+ __decorateClass([
8057
+ computed
8058
+ ], Editor.prototype, "getRenderingShapes", 1);
8059
+ __decorateClass([
8060
+ computed
8061
+ ], Editor.prototype, "_getAllPagesQuery", 1);
8062
+ __decorateClass([
8063
+ computed
8064
+ ], Editor.prototype, "getPages", 1);
8065
+ __decorateClass([
8066
+ computed
8067
+ ], Editor.prototype, "getCurrentPageId", 1);
8068
+ __decorateClass([
8069
+ computed
8070
+ ], Editor.prototype, "getCurrentPageShapeIdsSorted", 1);
8071
+ __decorateClass([
8072
+ computed
8073
+ ], Editor.prototype, "_getAllAssetsQuery", 1);
8074
+ __decorateClass([
8075
+ computed
8076
+ ], Editor.prototype, "_getShapeHandlesCache", 1);
8077
+ __decorateClass([
8078
+ computed
8079
+ ], Editor.prototype, "_getShapePageTransformCache", 1);
8080
+ __decorateClass([
8081
+ computed
8082
+ ], Editor.prototype, "_getShapePageBoundsCache", 1);
8083
+ __decorateClass([
8084
+ computed
8085
+ ], Editor.prototype, "_getShapeClipPathCache", 1);
8086
+ __decorateClass([
8087
+ computed
8088
+ ], Editor.prototype, "_getShapeMaskCache", 1);
8089
+ __decorateClass([
8090
+ computed
8091
+ ], Editor.prototype, "_getShapeMaskedPageBoundsCache", 1);
8092
+ __decorateClass([
8093
+ computed
8094
+ ], Editor.prototype, "getNotVisibleShapes", 1);
8095
+ __decorateClass([
8096
+ computed
8097
+ ], Editor.prototype, "getCulledShapes", 1);
8098
+ __decorateClass([
8099
+ computed
8100
+ ], Editor.prototype, "getCurrentPageBounds", 1);
8101
+ __decorateClass([
8102
+ computed
8103
+ ], Editor.prototype, "getCurrentPageShapes", 1);
8104
+ __decorateClass([
8105
+ computed
8106
+ ], Editor.prototype, "getCurrentPageShapesSorted", 1);
8107
+ __decorateClass([
8108
+ computed
8109
+ ], Editor.prototype, "getCurrentPageRenderingShapesSorted", 1);
8110
+ __decorateClass([
8111
+ computed
8112
+ ], Editor.prototype, "_getBindingsIndexCache", 1);
8113
+ __decorateClass([
8114
+ computed
8115
+ ], Editor.prototype, "_getSelectionSharedStyles", 1);
8116
+ __decorateClass([
8117
+ computed({ isEqual: (a, b) => a.equals(b) })
8118
+ ], Editor.prototype, "getSharedStyles", 1);
8119
+ __decorateClass([
8120
+ computed
8121
+ ], Editor.prototype, "getSharedOpacity", 1);
8122
+ __decorateClass([
8123
+ computed
8124
+ ], Editor.prototype, "getIsFocused", 1);
8125
+ __decorateClass([
8126
+ computed
8127
+ ], Editor.prototype, "getIsReadonly", 1);
8128
+ __decorateClass([
8129
+ bind
8130
+ ], Editor.prototype, "_setShiftKeyTimeout", 1);
8131
+ __decorateClass([
8132
+ bind
8133
+ ], Editor.prototype, "_setAltKeyTimeout", 1);
8134
+ __decorateClass([
8135
+ bind
8136
+ ], Editor.prototype, "_setCtrlKeyTimeout", 1);
8137
+ __decorateClass([
8138
+ bind
8139
+ ], Editor.prototype, "_setMetaKeyTimeout", 1);
7996
8140
  function alertMaxShapes(editor, pageId = editor.getCurrentPageId()) {
7997
8141
  const name = editor.getPage(pageId).name;
7998
8142
  editor.emit("max-shapes", { name, pageId, count: editor.options.maxShapesPerPage });