@tldraw/editor 3.16.0-canary.dbaaa1b0049c → 3.16.0-canary.dd88abb16ede

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 (146) hide show
  1. package/dist-cjs/index.d.ts +109 -104
  2. package/dist-cjs/index.js +6 -6
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +7 -7
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +12 -2
  7. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  8. package/dist-cjs/lib/editor/Editor.js +40 -113
  9. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  10. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +4 -0
  11. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
  12. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +23 -0
  13. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  14. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  15. package/dist-cjs/lib/exports/getSvgJsx.js +34 -14
  16. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  17. package/dist-cjs/lib/hooks/useCanvasEvents.js +22 -17
  18. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  19. package/dist-cjs/lib/hooks/useDocumentEvents.js +5 -5
  20. package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
  21. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js +1 -2
  22. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
  23. package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
  24. package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
  25. package/dist-cjs/lib/hooks/useHandleEvents.js +3 -3
  26. package/dist-cjs/lib/hooks/useHandleEvents.js.map +2 -2
  27. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +4 -1
  28. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
  29. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -1
  30. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
  31. package/dist-cjs/lib/hooks/useSelectionEvents.js +4 -4
  32. package/dist-cjs/lib/hooks/useSelectionEvents.js.map +2 -2
  33. package/dist-cjs/lib/license/LicenseManager.js +143 -53
  34. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  35. package/dist-cjs/lib/license/LicenseProvider.js +39 -1
  36. package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
  37. package/dist-cjs/lib/license/Watermark.js +69 -7
  38. package/dist-cjs/lib/license/Watermark.js.map +3 -3
  39. package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
  40. package/dist-cjs/lib/primitives/Box.js +3 -0
  41. package/dist-cjs/lib/primitives/Box.js.map +2 -2
  42. package/dist-cjs/lib/primitives/Vec.js +0 -4
  43. package/dist-cjs/lib/primitives/Vec.js.map +2 -2
  44. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +50 -20
  45. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  46. package/dist-cjs/lib/primitives/geometry/Group2d.js +8 -1
  47. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  48. package/dist-cjs/lib/utils/dom.js +12 -1
  49. package/dist-cjs/lib/utils/dom.js.map +2 -2
  50. package/dist-cjs/lib/utils/getPointerInfo.js +2 -2
  51. package/dist-cjs/lib/utils/getPointerInfo.js.map +2 -2
  52. package/dist-cjs/lib/utils/reparenting.js +2 -35
  53. package/dist-cjs/lib/utils/reparenting.js.map +3 -3
  54. package/dist-cjs/version.js +3 -3
  55. package/dist-cjs/version.js.map +1 -1
  56. package/dist-esm/index.d.mts +109 -104
  57. package/dist-esm/index.mjs +9 -7
  58. package/dist-esm/index.mjs.map +2 -2
  59. package/dist-esm/lib/TldrawEditor.mjs +8 -8
  60. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  61. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +13 -3
  62. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  63. package/dist-esm/lib/editor/Editor.mjs +40 -113
  64. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  65. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +4 -0
  66. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
  67. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +23 -0
  68. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  69. package/dist-esm/lib/exports/getSvgJsx.mjs +34 -14
  70. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  71. package/dist-esm/lib/hooks/useCanvasEvents.mjs +24 -18
  72. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  73. package/dist-esm/lib/hooks/useDocumentEvents.mjs +11 -6
  74. package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
  75. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs +2 -3
  76. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
  77. package/dist-esm/lib/hooks/useGestureEvents.mjs +2 -2
  78. package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
  79. package/dist-esm/lib/hooks/useHandleEvents.mjs +9 -4
  80. package/dist-esm/lib/hooks/useHandleEvents.mjs.map +2 -2
  81. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +4 -1
  82. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
  83. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -1
  84. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
  85. package/dist-esm/lib/hooks/useSelectionEvents.mjs +6 -5
  86. package/dist-esm/lib/hooks/useSelectionEvents.mjs.map +2 -2
  87. package/dist-esm/lib/license/LicenseManager.mjs +144 -54
  88. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  89. package/dist-esm/lib/license/LicenseProvider.mjs +39 -2
  90. package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
  91. package/dist-esm/lib/license/Watermark.mjs +70 -8
  92. package/dist-esm/lib/license/Watermark.mjs.map +3 -3
  93. package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
  94. package/dist-esm/lib/primitives/Box.mjs +4 -1
  95. package/dist-esm/lib/primitives/Box.mjs.map +2 -2
  96. package/dist-esm/lib/primitives/Vec.mjs +0 -4
  97. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  98. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +53 -21
  99. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  100. package/dist-esm/lib/primitives/geometry/Group2d.mjs +8 -1
  101. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  102. package/dist-esm/lib/utils/dom.mjs +12 -1
  103. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  104. package/dist-esm/lib/utils/getPointerInfo.mjs +2 -2
  105. package/dist-esm/lib/utils/getPointerInfo.mjs.map +2 -2
  106. package/dist-esm/lib/utils/reparenting.mjs +3 -40
  107. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  108. package/dist-esm/version.mjs +3 -3
  109. package/dist-esm/version.mjs.map +1 -1
  110. package/editor.css +16 -3
  111. package/package.json +7 -7
  112. package/src/index.ts +4 -9
  113. package/src/lib/TldrawEditor.tsx +9 -16
  114. package/src/lib/components/default-components/DefaultCanvas.tsx +10 -2
  115. package/src/lib/editor/Editor.test.ts +90 -0
  116. package/src/lib/editor/Editor.ts +54 -150
  117. package/src/lib/editor/derivations/notVisibleShapes.ts +6 -0
  118. package/src/lib/editor/shapes/ShapeUtil.ts +46 -0
  119. package/src/lib/editor/types/misc-types.ts +0 -6
  120. package/src/lib/exports/getSvgJsx.test.ts +868 -0
  121. package/src/lib/exports/getSvgJsx.tsx +76 -19
  122. package/src/lib/hooks/useCanvasEvents.ts +23 -17
  123. package/src/lib/hooks/useDocumentEvents.ts +11 -6
  124. package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +2 -2
  125. package/src/lib/hooks/useGestureEvents.ts +2 -2
  126. package/src/lib/hooks/useHandleEvents.ts +9 -4
  127. package/src/lib/hooks/usePassThroughMouseOverEvents.ts +4 -1
  128. package/src/lib/hooks/usePassThroughWheelEvents.ts +6 -1
  129. package/src/lib/hooks/useSelectionEvents.ts +6 -5
  130. package/src/lib/license/LicenseManager.test.ts +721 -382
  131. package/src/lib/license/LicenseManager.ts +204 -58
  132. package/src/lib/license/LicenseProvider.tsx +74 -2
  133. package/src/lib/license/Watermark.tsx +75 -8
  134. package/src/lib/license/useLicenseManagerState.ts +2 -2
  135. package/src/lib/primitives/Box.test.ts +126 -0
  136. package/src/lib/primitives/Box.ts +10 -1
  137. package/src/lib/primitives/Vec.ts +0 -5
  138. package/src/lib/primitives/geometry/Geometry2d.test.ts +420 -0
  139. package/src/lib/primitives/geometry/Geometry2d.ts +78 -21
  140. package/src/lib/primitives/geometry/Group2d.ts +10 -1
  141. package/src/lib/test/InFrontOfTheCanvas.test.tsx +187 -0
  142. package/src/lib/utils/dom.test.ts +94 -0
  143. package/src/lib/utils/dom.ts +38 -1
  144. package/src/lib/utils/getPointerInfo.ts +2 -1
  145. package/src/lib/utils/reparenting.ts +3 -69
  146. package/src/version.ts +3 -3
@@ -46,7 +46,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
46
46
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
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
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, _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, _getIsMenuOpen_dec, _getOpenMenus_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
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, _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, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
50
50
  import {
51
51
  EMPTY_ARRAY,
52
52
  atom,
@@ -120,7 +120,6 @@ import {
120
120
  } from "../constants.mjs";
121
121
  import { exportToSvg } from "../exports/exportToSvg.mjs";
122
122
  import { getSvgAsImage } from "../exports/getSvgAsImage.mjs";
123
- import { tlenv } from "../globals/environment.mjs";
124
123
  import { tlmenus } from "../globals/menus.mjs";
125
124
  import { tltime } from "../globals/time.mjs";
126
125
  import { defaultTldrawOptions } from "../options.mjs";
@@ -158,7 +157,7 @@ import { TextManager } from "./managers/TextManager/TextManager.mjs";
158
157
  import { TickManager } from "./managers/TickManager/TickManager.mjs";
159
158
  import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
160
159
  import { RootState } from "./tools/RootState.mjs";
161
- class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_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], _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) {
160
+ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_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], _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) {
162
161
  constructor({
163
162
  store,
164
163
  user,
@@ -172,8 +171,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
172
171
  autoFocus,
173
172
  inferDarkMode,
174
173
  options,
175
- // eslint-disable-next-line @typescript-eslint/no-deprecated
176
- isShapeHidden,
177
174
  getShapeVisibility,
178
175
  fontAssetUrls
179
176
  }) {
@@ -240,13 +237,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
240
237
  * @public
241
238
  */
242
239
  __publicField(this, "fonts");
243
- /**
244
- * A manager for the editor's environment.
245
- *
246
- * @deprecated This is deprecated and will be removed in a future version. Use the `tlenv` global export instead.
247
- * @public
248
- */
249
- __publicField(this, "environment", tlenv);
250
240
  /**
251
241
  * A manager for the editor's scribbles.
252
242
  *
@@ -449,14 +439,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
449
439
  /** @internal */
450
440
  __publicField(this, "performanceTrackerTimeout", -1);
451
441
  __publicField(this, "_pendingEventsForNextTick", []);
452
- assert(
453
- !(isShapeHidden && getShapeVisibility),
454
- "Cannot use both isShapeHidden and getShapeVisibility"
455
- );
456
- this._getShapeVisibility = isShapeHidden ? (
457
- // eslint-disable-next-line @typescript-eslint/no-deprecated
458
- ((shape, editor) => isShapeHidden(shape, editor) ? "hidden" : "inherit")
459
- ) : getShapeVisibility;
442
+ this._getShapeVisibility = getShapeVisibility;
460
443
  this.options = { ...defaultTldrawOptions, ...options };
461
444
  this.store = store;
462
445
  this.history = new HistoryManager({
@@ -936,34 +919,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
936
919
  getCanRedo() {
937
920
  return this.history.getNumRedos() > 0;
938
921
  }
939
- /**
940
- * Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
941
- * any redos.
942
- *
943
- * @example
944
- * ```ts
945
- * editor.mark()
946
- * editor.mark('flip shapes')
947
- * ```
948
- *
949
- * @param markId - The mark's id, usually the reason for adding the mark.
950
- *
951
- * @public
952
- * @deprecated use {@link Editor.markHistoryStoppingPoint} instead
953
- */
954
- mark(markId) {
955
- if (typeof markId === "string") {
956
- console.warn(
957
- `[tldraw] \`editor.history.mark("${markId}")\` is deprecated. Please use \`const myMarkId = editor.markHistoryStoppingPoint()\` instead.`
958
- );
959
- } else {
960
- console.warn(
961
- "[tldraw] `editor.mark()` is deprecated. Use `editor.markHistoryStoppingPoint()` instead."
962
- );
963
- }
964
- this.history._mark(markId ?? uniqueId());
965
- return this;
966
- }
967
922
  /**
968
923
  * Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
969
924
  * any redos. You typically want to do this just before a user interaction begins or is handled.
@@ -1079,12 +1034,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1079
1034
  }
1080
1035
  return this;
1081
1036
  }
1082
- /**
1083
- * @deprecated Use `Editor.run` instead.
1084
- */
1085
- batch(fn, opts) {
1086
- return this.run(fn, opts);
1087
- }
1088
1037
  /* --------------------- Errors --------------------- */
1089
1038
  /** @internal */
1090
1039
  annotateError(error, {
@@ -1306,39 +1255,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1306
1255
  ]);
1307
1256
  }, opts);
1308
1257
  }
1309
- getOpenMenus() {
1310
- return this.menus.getOpenMenus();
1311
- }
1312
- /**
1313
- * @deprecated Use `editor.menus.addOpenMenu` instead.
1314
- *
1315
- * @public
1316
- */
1317
- addOpenMenu(id) {
1318
- this.menus.addOpenMenu(id);
1319
- return this;
1320
- }
1321
- /**
1322
- * @deprecated Use `editor.menus.deleteOpenMenu` instead.
1323
- *
1324
- * @public
1325
- */
1326
- deleteOpenMenu(id) {
1327
- this.menus.deleteOpenMenu(id);
1328
- return this;
1329
- }
1330
- /**
1331
- * @deprecated Use `editor.menus.clearOpenMenus` instead.
1332
- *
1333
- * @public
1334
- */
1335
- clearOpenMenus() {
1336
- this.menus.clearOpenMenus();
1337
- return this;
1338
- }
1339
- getIsMenuOpen() {
1340
- return this.menus.hasAnyOpenMenus();
1341
- }
1342
1258
  /* --------------------- Cursor --------------------- */
1343
1259
  /**
1344
1260
  * Set the cursor.
@@ -3646,8 +3562,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3646
3562
  return this.store.createComputedCache("pageBoundsCache", (shape) => {
3647
3563
  const pageTransform = this.getShapePageTransform(shape);
3648
3564
  if (!pageTransform) return void 0;
3649
- const geometry = this.getShapeGeometry(shape);
3650
- return Box.FromPoints(pageTransform.applyToPoints(geometry.vertices));
3565
+ return Box.FromPoints(
3566
+ pageTransform.applyToPoints(this.getShapeGeometry(shape).boundsVertices)
3567
+ );
3651
3568
  });
3652
3569
  }
3653
3570
  /**
@@ -3700,16 +3617,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3700
3617
  _getShapeMaskCache() {
3701
3618
  return this.store.createComputedCache("pageMaskCache", (shape) => {
3702
3619
  if (isPageId(shape.parentId)) return void 0;
3703
- const frameAncestors = this.getShapeAncestors(shape.id).filter(
3704
- (shape2) => this.isShapeOfType(shape2, "frame")
3705
- );
3706
- if (frameAncestors.length === 0) return void 0;
3707
- const pageMask = frameAncestors.map((s) => {
3708
- const geometry = this.getShapeGeometry(s.id);
3709
- const pageTransform = this.getShapePageTransform(s.id);
3710
- return pageTransform.applyToPoints(geometry.vertices);
3711
- }).reduce((acc, b) => {
3712
- if (!(b && acc)) return void 0;
3620
+ const clipPaths = [];
3621
+ for (const ancestor of this.getShapeAncestors(shape.id)) {
3622
+ const util = this.getShapeUtil(ancestor);
3623
+ const clipPath = util.getClipPath?.(ancestor);
3624
+ if (!clipPath) continue;
3625
+ if (util.shouldClipChild?.(shape) === false) continue;
3626
+ const pageTransform = this.getShapePageTransform(ancestor.id);
3627
+ clipPaths.push(pageTransform.applyToPoints(clipPath));
3628
+ }
3629
+ if (clipPaths.length === 0) return void 0;
3630
+ const pageMask = clipPaths.reduce((acc, b) => {
3713
3631
  const intersection = intersectPolygonPolygon(acc, b);
3714
3632
  if (intersection) {
3715
3633
  return intersection.map(Vec.Cast);
@@ -4407,10 +4325,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4407
4325
  }
4408
4326
  return shapeIds;
4409
4327
  }
4410
- /** @deprecated Use {@link Editor.getDraggingOverShape} instead */
4411
- getDroppingOverShape(point, droppingShapes) {
4412
- return this.getDraggingOverShape(point, droppingShapes);
4413
- }
4414
4328
  /**
4415
4329
  * Get the shape that some shapes should be dropped on at a given point.
4416
4330
  *
@@ -6558,16 +6472,20 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6558
6472
  * Handle external content, such as files, urls, embeds, or plain text which has been put into the app, for example by pasting external text or dropping external images onto canvas.
6559
6473
  *
6560
6474
  * @param info - Info about the external content.
6475
+ * @param opts - Options for handling external content, including force flag to bypass readonly checks.
6561
6476
  */
6562
- async putExternalContent(info) {
6477
+ async putExternalContent(info, opts = {}) {
6478
+ if (!opts.force && this.getIsReadonly()) return;
6563
6479
  return this.externalContentHandlers[info.type]?.(info);
6564
6480
  }
6565
6481
  /**
6566
6482
  * Handle replacing external content.
6567
6483
  *
6568
6484
  * @param info - Info about the external content.
6485
+ * @param opts - Options for handling external content, including force flag to bypass readonly checks.
6569
6486
  */
6570
- async replaceExternalContent(info) {
6487
+ async replaceExternalContent(info, opts = {}) {
6488
+ if (!opts.force && this.getIsReadonly()) return;
6571
6489
  return this.externalContentHandlers[info.type]?.(info);
6572
6490
  }
6573
6491
  /**
@@ -6921,12 +6839,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6921
6839
  height: result.height
6922
6840
  };
6923
6841
  }
6924
- /** @deprecated Use {@link Editor.getSvgString} or {@link Editor.getSvgElement} instead. */
6925
- async getSvg(shapes, opts = {}) {
6926
- const result = await this.getSvgElement(shapes, opts);
6927
- if (!result) return void 0;
6928
- return result.svg;
6929
- }
6930
6842
  /**
6931
6843
  * Get an exported image of the given shapes.
6932
6844
  *
@@ -6976,6 +6888,23 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6976
6888
  }
6977
6889
  }
6978
6890
  }
6891
+ /**
6892
+ * Get an exported image of the given shapes as a data URL.
6893
+ *
6894
+ * @param shapes - The shapes (or shape ids) to export.
6895
+ * @param opts - Options for the export.
6896
+ *
6897
+ * @returns A data URL of the image.
6898
+ * @public
6899
+ */
6900
+ async toImageDataUrl(shapes, opts = {}) {
6901
+ const { blob, width, height } = await this.toImage(shapes, opts);
6902
+ return {
6903
+ url: await FileHelpers.blobToDataUrl(blob),
6904
+ width,
6905
+ height
6906
+ };
6907
+ }
6979
6908
  /**
6980
6909
  * Update the input points from a pointer, pinch, or wheel event.
6981
6910
  *
@@ -7890,8 +7819,6 @@ __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
7890
7819
  __decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
7891
7820
  __decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
7892
7821
  __decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
7893
- __decorateElement(_init, 1, "getOpenMenus", _getOpenMenus_dec, Editor);
7894
- __decorateElement(_init, 1, "getIsMenuOpen", _getIsMenuOpen_dec, Editor);
7895
7822
  __decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
7896
7823
  __decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
7897
7824
  __decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);