@tldraw/editor 3.16.0-next.fe14f1b4181f → 4.0.0

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 (143) hide show
  1. package/dist-cjs/index.d.ts +91 -109
  2. package/dist-cjs/index.js +3 -5
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +1 -7
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +11 -1
  7. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  8. package/dist-cjs/lib/config/TLUserPreferences.js +15 -4
  9. package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
  10. package/dist-cjs/lib/editor/Editor.js +58 -114
  11. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  12. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +4 -0
  13. package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
  14. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +4 -2
  15. package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +2 -2
  16. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +11 -6
  17. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  18. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +10 -0
  19. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  20. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  21. package/dist-cjs/lib/hooks/useCanvasEvents.js +19 -16
  22. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  23. package/dist-cjs/lib/hooks/useDocumentEvents.js +5 -5
  24. package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
  25. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js +1 -2
  26. package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
  27. package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
  28. package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
  29. package/dist-cjs/lib/hooks/useHandleEvents.js +6 -6
  30. package/dist-cjs/lib/hooks/useHandleEvents.js.map +2 -2
  31. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +4 -1
  32. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
  33. package/dist-cjs/lib/hooks/useSelectionEvents.js +8 -8
  34. package/dist-cjs/lib/hooks/useSelectionEvents.js.map +2 -2
  35. package/dist-cjs/lib/license/LicenseManager.js +143 -53
  36. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  37. package/dist-cjs/lib/license/LicenseProvider.js +39 -1
  38. package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
  39. package/dist-cjs/lib/license/Watermark.js +144 -75
  40. package/dist-cjs/lib/license/Watermark.js.map +3 -3
  41. package/dist-cjs/lib/license/useLicenseManagerState.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.map +2 -2
  49. package/dist-cjs/lib/utils/getPointerInfo.js +2 -3
  50. package/dist-cjs/lib/utils/getPointerInfo.js.map +2 -2
  51. package/dist-cjs/lib/utils/reparenting.js +7 -36
  52. package/dist-cjs/lib/utils/reparenting.js.map +3 -3
  53. package/dist-cjs/version.js +4 -4
  54. package/dist-cjs/version.js.map +1 -1
  55. package/dist-esm/index.d.mts +91 -109
  56. package/dist-esm/index.mjs +3 -5
  57. package/dist-esm/index.mjs.map +2 -2
  58. package/dist-esm/lib/TldrawEditor.mjs +1 -7
  59. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  60. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +11 -1
  61. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  62. package/dist-esm/lib/config/TLUserPreferences.mjs +15 -4
  63. package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
  64. package/dist-esm/lib/editor/Editor.mjs +58 -114
  65. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  66. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +4 -0
  67. package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
  68. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +4 -2
  69. package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +2 -2
  70. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +11 -6
  71. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  72. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +10 -0
  73. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  74. package/dist-esm/lib/hooks/useCanvasEvents.mjs +20 -22
  75. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  76. package/dist-esm/lib/hooks/useDocumentEvents.mjs +6 -6
  77. package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
  78. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs +1 -2
  79. package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
  80. package/dist-esm/lib/hooks/useGestureEvents.mjs +2 -2
  81. package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
  82. package/dist-esm/lib/hooks/useHandleEvents.mjs +6 -6
  83. package/dist-esm/lib/hooks/useHandleEvents.mjs.map +2 -2
  84. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +4 -1
  85. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
  86. package/dist-esm/lib/hooks/useSelectionEvents.mjs +9 -14
  87. package/dist-esm/lib/hooks/useSelectionEvents.mjs.map +2 -2
  88. package/dist-esm/lib/license/LicenseManager.mjs +144 -54
  89. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  90. package/dist-esm/lib/license/LicenseProvider.mjs +39 -2
  91. package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
  92. package/dist-esm/lib/license/Watermark.mjs +145 -76
  93. package/dist-esm/lib/license/Watermark.mjs.map +3 -3
  94. package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
  95. package/dist-esm/lib/primitives/Vec.mjs +0 -4
  96. package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
  97. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +53 -21
  98. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  99. package/dist-esm/lib/primitives/geometry/Group2d.mjs +8 -1
  100. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  101. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  102. package/dist-esm/lib/utils/getPointerInfo.mjs +2 -3
  103. package/dist-esm/lib/utils/getPointerInfo.mjs.map +2 -2
  104. package/dist-esm/lib/utils/reparenting.mjs +8 -41
  105. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  106. package/dist-esm/version.mjs +4 -4
  107. package/dist-esm/version.mjs.map +1 -1
  108. package/editor.css +8 -3
  109. package/package.json +7 -7
  110. package/src/index.ts +2 -9
  111. package/src/lib/TldrawEditor.tsx +1 -15
  112. package/src/lib/components/default-components/DefaultCanvas.tsx +7 -1
  113. package/src/lib/config/TLUserPreferences.ts +16 -3
  114. package/src/lib/editor/Editor.test.ts +90 -0
  115. package/src/lib/editor/Editor.ts +77 -151
  116. package/src/lib/editor/derivations/notVisibleShapes.ts +6 -0
  117. package/src/lib/editor/managers/FocusManager/FocusManager.ts +6 -2
  118. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +30 -8
  119. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +10 -3
  120. package/src/lib/editor/shapes/ShapeUtil.ts +32 -0
  121. package/src/lib/editor/types/misc-types.ts +0 -6
  122. package/src/lib/hooks/useCanvasEvents.ts +20 -20
  123. package/src/lib/hooks/useDocumentEvents.ts +6 -6
  124. package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +1 -1
  125. package/src/lib/hooks/useGestureEvents.ts +2 -2
  126. package/src/lib/hooks/useHandleEvents.ts +6 -6
  127. package/src/lib/hooks/usePassThroughMouseOverEvents.ts +4 -1
  128. package/src/lib/hooks/useSelectionEvents.ts +9 -14
  129. package/src/lib/license/LicenseManager.test.ts +721 -382
  130. package/src/lib/license/LicenseManager.ts +204 -58
  131. package/src/lib/license/LicenseProvider.tsx +74 -2
  132. package/src/lib/license/Watermark.tsx +152 -77
  133. package/src/lib/license/useLicenseManagerState.ts +2 -2
  134. package/src/lib/primitives/Vec.ts +0 -5
  135. package/src/lib/primitives/geometry/Geometry2d.test.ts +420 -0
  136. package/src/lib/primitives/geometry/Geometry2d.ts +78 -21
  137. package/src/lib/primitives/geometry/Group2d.ts +10 -1
  138. package/src/lib/test/InFrontOfTheCanvas.test.tsx +187 -0
  139. package/src/lib/utils/dom.test.ts +103 -0
  140. package/src/lib/utils/dom.ts +8 -1
  141. package/src/lib/utils/getPointerInfo.ts +3 -2
  142. package/src/lib/utils/reparenting.ts +10 -70
  143. package/src/version.ts +4 -4
@@ -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
  *
@@ -448,15 +438,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
448
438
  __publicField(this, "performanceTracker");
449
439
  /** @internal */
450
440
  __publicField(this, "performanceTrackerTimeout", -1);
441
+ /** @internal */
442
+ __publicField(this, "handledEvents", /* @__PURE__ */ new WeakSet());
451
443
  __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;
444
+ this._getShapeVisibility = getShapeVisibility;
460
445
  this.options = { ...defaultTldrawOptions, ...options };
461
446
  this.store = store;
462
447
  this.history = new HistoryManager({
@@ -482,6 +467,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
482
467
  }
483
468
  this.root = new NewRoot(this);
484
469
  this.root.children = {};
470
+ this.markEventAsHandled = this.markEventAsHandled.bind(this);
485
471
  const allShapeUtils = checkShapesAndAddCore(shapeUtils);
486
472
  const _shapeUtils = {};
487
473
  const _styleProps = {};
@@ -936,34 +922,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
936
922
  getCanRedo() {
937
923
  return this.history.getNumRedos() > 0;
938
924
  }
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
925
  /**
968
926
  * Create a new "mark", or stopping point, in the undo redo history. Creating a mark will clear
969
927
  * any redos. You typically want to do this just before a user interaction begins or is handled.
@@ -1079,12 +1037,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1079
1037
  }
1080
1038
  return this;
1081
1039
  }
1082
- /**
1083
- * @deprecated Use `Editor.run` instead.
1084
- */
1085
- batch(fn, opts) {
1086
- return this.run(fn, opts);
1087
- }
1088
1040
  /* --------------------- Errors --------------------- */
1089
1041
  /** @internal */
1090
1042
  annotateError(error, {
@@ -1306,39 +1258,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1306
1258
  ]);
1307
1259
  }, opts);
1308
1260
  }
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
1261
  /* --------------------- Cursor --------------------- */
1343
1262
  /**
1344
1263
  * Set the cursor.
@@ -3646,8 +3565,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3646
3565
  return this.store.createComputedCache("pageBoundsCache", (shape) => {
3647
3566
  const pageTransform = this.getShapePageTransform(shape);
3648
3567
  if (!pageTransform) return void 0;
3649
- const geometry = this.getShapeGeometry(shape);
3650
- return Box.FromPoints(pageTransform.applyToPoints(geometry.vertices));
3568
+ return Box.FromPoints(
3569
+ pageTransform.applyToPoints(this.getShapeGeometry(shape).boundsVertices)
3570
+ );
3651
3571
  });
3652
3572
  }
3653
3573
  /**
@@ -3700,16 +3620,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3700
3620
  _getShapeMaskCache() {
3701
3621
  return this.store.createComputedCache("pageMaskCache", (shape) => {
3702
3622
  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;
3623
+ const clipPaths = [];
3624
+ for (const ancestor of this.getShapeAncestors(shape.id)) {
3625
+ const util = this.getShapeUtil(ancestor);
3626
+ const clipPath = util.getClipPath?.(ancestor);
3627
+ if (!clipPath) continue;
3628
+ if (util.shouldClipChild?.(shape) === false) continue;
3629
+ const pageTransform = this.getShapePageTransform(ancestor.id);
3630
+ clipPaths.push(pageTransform.applyToPoints(clipPath));
3631
+ }
3632
+ if (clipPaths.length === 0) return void 0;
3633
+ const pageMask = clipPaths.reduce((acc, b) => {
3713
3634
  const intersection = intersectPolygonPolygon(acc, b);
3714
3635
  if (intersection) {
3715
3636
  return intersection.map(Vec.Cast);
@@ -4407,10 +4328,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4407
4328
  }
4408
4329
  return shapeIds;
4409
4330
  }
4410
- /** @deprecated Use {@link Editor.getDraggingOverShape} instead */
4411
- getDroppingOverShape(point, droppingShapes) {
4412
- return this.getDraggingOverShape(point, droppingShapes);
4413
- }
4414
4331
  /**
4415
4332
  * Get the shape that some shapes should be dropped on at a given point.
4416
4333
  *
@@ -6558,16 +6475,20 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6558
6475
  * 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
6476
  *
6560
6477
  * @param info - Info about the external content.
6478
+ * @param opts - Options for handling external content, including force flag to bypass readonly checks.
6561
6479
  */
6562
- async putExternalContent(info) {
6480
+ async putExternalContent(info, opts = {}) {
6481
+ if (!opts.force && this.getIsReadonly()) return;
6563
6482
  return this.externalContentHandlers[info.type]?.(info);
6564
6483
  }
6565
6484
  /**
6566
6485
  * Handle replacing external content.
6567
6486
  *
6568
6487
  * @param info - Info about the external content.
6488
+ * @param opts - Options for handling external content, including force flag to bypass readonly checks.
6569
6489
  */
6570
- async replaceExternalContent(info) {
6490
+ async replaceExternalContent(info, opts = {}) {
6491
+ if (!opts.force && this.getIsReadonly()) return;
6571
6492
  return this.externalContentHandlers[info.type]?.(info);
6572
6493
  }
6573
6494
  /**
@@ -6921,12 +6842,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6921
6842
  height: result.height
6922
6843
  };
6923
6844
  }
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
6845
  /**
6931
6846
  * Get an exported image of the given shapes.
6932
6847
  *
@@ -7493,6 +7408,32 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7493
7408
  code: "MetaLeft"
7494
7409
  });
7495
7410
  }
7411
+ /**
7412
+ * In tldraw, events are sometimes handled by multiple components. For example, the shapes might
7413
+ * have events, but the canvas handles events too. The way that the canvas handles events can
7414
+ * interfere with the with the shapes event handlers - for example, it calls `.preventDefault()`
7415
+ * on `pointerDown`, which also prevents `click` events from firing on the shapes.
7416
+ *
7417
+ * You can use `.stopPropagation()` to prevent the event from propagating to the rest of the
7418
+ * DOM, but that can impact non-tldraw event handlers set up elsewhere. By using
7419
+ * `markEventAsHandled`, you'll stop other parts of tldraw from handling the event without
7420
+ * impacting other, non-tldraw event handlers. See also {@link Editor.wasEventAlreadyHandled}.
7421
+ *
7422
+ * @public
7423
+ */
7424
+ markEventAsHandled(e) {
7425
+ const nativeEvent = "nativeEvent" in e ? e.nativeEvent : e;
7426
+ this.handledEvents.add(nativeEvent);
7427
+ }
7428
+ /**
7429
+ * Checks if an event has already been handled. See {@link Editor.markEventAsHandled}.
7430
+ *
7431
+ * @public
7432
+ */
7433
+ wasEventAlreadyHandled(e) {
7434
+ const nativeEvent = "nativeEvent" in e ? e.nativeEvent : e;
7435
+ return this.handledEvents.has(nativeEvent);
7436
+ }
7496
7437
  /**
7497
7438
  * Dispatch an event to the editor.
7498
7439
  *
@@ -7648,7 +7589,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7648
7589
  case "wheel": {
7649
7590
  if (cameraOptions.isLocked) return;
7650
7591
  this._updateInputsFromEvent(info);
7651
- const { panSpeed, zoomSpeed, wheelBehavior } = cameraOptions;
7592
+ const { panSpeed, zoomSpeed } = cameraOptions;
7593
+ let wheelBehavior = cameraOptions.wheelBehavior;
7594
+ const inputMode = this.user.getUserPreferences().inputMode;
7595
+ if (inputMode !== null) {
7596
+ wheelBehavior = inputMode === "trackpad" ? "pan" : "zoom";
7597
+ }
7652
7598
  if (wheelBehavior !== "none") {
7653
7599
  this.stopCameraAnimation();
7654
7600
  if (instanceState.followingUserId) {
@@ -7907,8 +7853,6 @@ __decorateElement(_init, 1, "getCurrentTool", _getCurrentTool_dec, Editor);
7907
7853
  __decorateElement(_init, 1, "getCurrentToolId", _getCurrentToolId_dec, Editor);
7908
7854
  __decorateElement(_init, 1, "getDocumentSettings", _getDocumentSettings_dec, Editor);
7909
7855
  __decorateElement(_init, 1, "getInstanceState", _getInstanceState_dec, Editor);
7910
- __decorateElement(_init, 1, "getOpenMenus", _getOpenMenus_dec, Editor);
7911
- __decorateElement(_init, 1, "getIsMenuOpen", _getIsMenuOpen_dec, Editor);
7912
7856
  __decorateElement(_init, 1, "getPageStates", _getPageStates_dec, Editor);
7913
7857
  __decorateElement(_init, 1, "_getPageStatesQuery", __getPageStatesQuery_dec, Editor);
7914
7858
  __decorateElement(_init, 1, "getCurrentPageState", _getCurrentPageState_dec, Editor);