@tldraw/editor 5.4.0-canary.597011293a17 → 5.4.0-canary.5a084792df77

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 (35) hide show
  1. package/dist-cjs/index.js +1 -1
  2. package/dist-cjs/lib/editor/Editor.js +13 -11
  3. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  4. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +3 -3
  5. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
  6. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +1 -0
  7. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
  8. package/dist-cjs/lib/utils/deepLinks.js +5 -1
  9. package/dist-cjs/lib/utils/deepLinks.js.map +2 -2
  10. package/dist-cjs/lib/utils/sync/alerts.js +1 -1
  11. package/dist-cjs/lib/utils/sync/alerts.js.map +1 -1
  12. package/dist-cjs/version.js +3 -3
  13. package/dist-cjs/version.js.map +1 -1
  14. package/dist-esm/index.mjs +1 -1
  15. package/dist-esm/lib/editor/Editor.mjs +13 -11
  16. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  17. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +3 -3
  18. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
  19. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +1 -0
  20. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
  21. package/dist-esm/lib/utils/deepLinks.mjs +5 -1
  22. package/dist-esm/lib/utils/deepLinks.mjs.map +2 -2
  23. package/dist-esm/lib/utils/sync/alerts.mjs +1 -1
  24. package/dist-esm/lib/utils/sync/alerts.mjs.map +1 -1
  25. package/dist-esm/version.mjs +3 -3
  26. package/dist-esm/version.mjs.map +1 -1
  27. package/package.json +7 -7
  28. package/src/lib/editor/Editor.ts +26 -17
  29. package/src/lib/editor/managers/ClickManager/ClickManager.ts +5 -3
  30. package/src/lib/hooks/usePassThroughWheelEvents.ts +3 -0
  31. package/src/lib/test/usePassThroughWheelEvents.test.tsx +25 -2
  32. package/src/lib/utils/deepLinks.test.ts +15 -0
  33. package/src/lib/utils/deepLinks.ts +7 -1
  34. package/src/lib/utils/sync/alerts.ts +1 -1
  35. package/src/version.ts +3 -3
package/dist-cjs/index.js CHANGED
@@ -392,7 +392,7 @@ var import_uniq = require("./lib/utils/uniq");
392
392
  var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
393
393
  (0, import_utils.registerTldrawLibraryVersion)(
394
394
  "@tldraw/editor",
395
- "5.4.0-canary.597011293a17",
395
+ "5.4.0-canary.5a084792df77",
396
396
  "cjs"
397
397
  );
398
398
  //# sourceMappingURL=index.js.map
@@ -2128,6 +2128,7 @@ class Editor extends import_eventemitter3.default {
2128
2128
  if (!_shape) return false;
2129
2129
  const util = this.getShapeUtil(_shape);
2130
2130
  if (!util.canCrop(_shape)) return false;
2131
+ if (this.getIsReadonly()) return false;
2131
2132
  if (this.isShapeOrAncestorLocked(_shape)) return false;
2132
2133
  return true;
2133
2134
  }
@@ -2358,8 +2359,8 @@ class Editor extends import_eventemitter3.default {
2358
2359
  const vsb = this.getViewportScreenBounds();
2359
2360
  if (cameraOptions.constraints) {
2360
2361
  const { constraints } = cameraOptions;
2361
- const py = Math.min(constraints.padding.y, vsb.w / 2);
2362
- const px = Math.min(constraints.padding.x, vsb.h / 2);
2362
+ const px = Math.min(constraints.padding.x, vsb.w / 2);
2363
+ const py = Math.min(constraints.padding.y, vsb.h / 2);
2363
2364
  const bounds = import_Box.Box.From(cameraOptions.constraints.bounds);
2364
2365
  const zx = (vsb.w - px * 2) / bounds.w;
2365
2366
  const zy = (vsb.h - py * 2) / bounds.h;
@@ -2398,12 +2399,12 @@ class Editor extends import_eventemitter3.default {
2398
2399
  break;
2399
2400
  }
2400
2401
  case "inside": {
2401
- if (z < zx) x = (0, import_utils2.clamp)(x, minX, (vsb.w - px) / z - bounds.w);
2402
+ if (z < zx) x = (0, import_utils2.clamp)(x, minX, (vsb.w - px) / z - bounds.w - bounds.x);
2402
2403
  else x = (0, import_utils2.clamp)(x, minX + freeW, minX);
2403
2404
  break;
2404
2405
  }
2405
2406
  case "outside": {
2406
- x = (0, import_utils2.clamp)(x, px / z - bounds.w, (vsb.w - px) / z);
2407
+ x = (0, import_utils2.clamp)(x, px / z - bounds.w - bounds.x, (vsb.w - px) / z - bounds.x);
2407
2408
  break;
2408
2409
  }
2409
2410
  case "free": {
@@ -2424,12 +2425,12 @@ class Editor extends import_eventemitter3.default {
2424
2425
  break;
2425
2426
  }
2426
2427
  case "inside": {
2427
- if (z < zy) y = (0, import_utils2.clamp)(y, minY, (vsb.h - py) / z - bounds.h);
2428
+ if (z < zy) y = (0, import_utils2.clamp)(y, minY, (vsb.h - py) / z - bounds.h - bounds.y);
2428
2429
  else y = (0, import_utils2.clamp)(y, minY + freeH, minY);
2429
2430
  break;
2430
2431
  }
2431
2432
  case "outside": {
2432
- y = (0, import_utils2.clamp)(y, py / z - bounds.h, (vsb.h - py) / z);
2433
+ y = (0, import_utils2.clamp)(y, py / z - bounds.h - bounds.y, (vsb.h - py) / z - bounds.y);
2433
2434
  break;
2434
2435
  }
2435
2436
  case "free": {
@@ -4041,7 +4042,9 @@ class Editor extends import_eventemitter3.default {
4041
4042
  if (pageMask) {
4042
4043
  if (pageMask.length === 0) return void 0;
4043
4044
  const { corners } = pageBounds;
4044
- if (corners.every((p, i) => p && import_Vec.Vec.Equals(p, pageMask[i]))) return pageBounds.clone();
4045
+ if (pageMask.length === corners.length && corners.every((p, i) => import_Vec.Vec.Equals(p, pageMask[i]))) {
4046
+ return pageBounds.clone();
4047
+ }
4045
4048
  const intersection = (0, import_intersect.intersectPolygonPolygon)(pageMask, corners);
4046
4049
  if (!intersection) return;
4047
4050
  return import_Box.Box.FromPoints(intersection);
@@ -4280,7 +4283,7 @@ class Editor extends import_eventemitter3.default {
4280
4283
  const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
4281
4284
  const shapeUtil = this.getShapeUtil(shape);
4282
4285
  const isShapeFrameLike = this.isShapeFrameLike(shape);
4283
- if (isShapeFrameLike || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && shapeUtil.getText(shape)?.trim()) {
4286
+ if (isGroup && (isShapeFrameLike || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "arrow") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && shapeUtil.getText(shape)?.trim())) {
4284
4287
  for (const childGeometry of geometry.children) {
4285
4288
  if (childGeometry.isLabel && childGeometry.isPointInBounds(pointInShapeSpace)) {
4286
4289
  return shape;
@@ -8703,10 +8706,9 @@ function withIsolatedShapes(editor, shapeIds, callback) {
8703
8706
  }
8704
8707
  function getCameraFitXFitY(editor, cameraOptions) {
8705
8708
  if (!cameraOptions.constraints) throw Error("Should have constraints here");
8706
- const {
8707
- padding: { x: px, y: py }
8708
- } = cameraOptions.constraints;
8709
8709
  const vsb = editor.getViewportScreenBounds();
8710
+ const px = Math.min(cameraOptions.constraints.padding.x, vsb.w / 2);
8711
+ const py = Math.min(cameraOptions.constraints.padding.y, vsb.h / 2);
8710
8712
  const bounds = import_Box.Box.From(cameraOptions.constraints.bounds);
8711
8713
  const zx = (vsb.w - px * 2) / bounds.w;
8712
8714
  const zy = (vsb.h - py * 2) / bounds.h;