@tldraw/editor 5.4.0-canary.b41840d4f0e4 → 5.4.0-canary.b8ec00e16e3a

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 (29) hide show
  1. package/dist-cjs/index.js +1 -1
  2. package/dist-cjs/lib/editor/Editor.js +17 -14
  3. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  4. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js +7 -3
  5. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js.map +2 -2
  6. package/dist-cjs/lib/primitives/geometry/Group2d.js +63 -21
  7. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  8. package/dist-cjs/lib/utils/normalizeWheel.js +2 -0
  9. package/dist-cjs/lib/utils/normalizeWheel.js.map +2 -2
  10. package/dist-cjs/version.js +3 -3
  11. package/dist-cjs/version.js.map +1 -1
  12. package/dist-esm/index.mjs +1 -1
  13. package/dist-esm/lib/editor/Editor.mjs +17 -14
  14. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  15. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs +7 -3
  16. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs.map +2 -2
  17. package/dist-esm/lib/primitives/geometry/Group2d.mjs +63 -21
  18. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  19. package/dist-esm/lib/utils/normalizeWheel.mjs +2 -0
  20. package/dist-esm/lib/utils/normalizeWheel.mjs.map +2 -2
  21. package/dist-esm/version.mjs +3 -3
  22. package/dist-esm/version.mjs.map +1 -1
  23. package/package.json +7 -7
  24. package/src/lib/editor/Editor.ts +25 -24
  25. package/src/lib/editor/derivations/shapeIdsInCurrentPage.ts +7 -3
  26. package/src/lib/primitives/geometry/Group2d.ts +63 -27
  27. package/src/lib/utils/normalizeWheel.test.ts +39 -0
  28. package/src/lib/utils/normalizeWheel.ts +6 -0
  29. package/src/version.ts +3 -3
package/dist-cjs/index.js CHANGED
@@ -389,7 +389,7 @@ var import_uniq = require("./lib/utils/uniq");
389
389
  var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
390
390
  (0, import_utils.registerTldrawLibraryVersion)(
391
391
  "@tldraw/editor",
392
- "5.4.0-canary.b41840d4f0e4",
392
+ "5.4.0-canary.b8ec00e16e3a",
393
393
  "cjs"
394
394
  );
395
395
  //# sourceMappingURL=index.js.map
@@ -4298,17 +4298,16 @@ class Editor extends import_eventemitter3.default {
4298
4298
  let inMarginClosestToEdgeHit = null;
4299
4299
  const searchMargin = Math.max(innerMargin, outerMargin, this.getHitTestMargin());
4300
4300
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, searchMargin);
4301
- const shapesToCheck = (opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted()).filter((shape) => {
4302
- if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
4303
- if (shape.isLocked && !hitLocked || this.isShapeHidden(shape) || this.isShapeOfType(shape, "group"))
4304
- return false;
4305
- const pageMask = this.getShapeMask(shape);
4306
- if (pageMask && !(0, import_utils2.pointInPolygon)(point, pageMask)) return false;
4307
- if (filter && !filter(shape)) return false;
4308
- return true;
4309
- });
4301
+ const shapesToCheck = opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted();
4310
4302
  for (let i = shapesToCheck.length - 1; i >= 0; i--) {
4311
4303
  const shape = shapesToCheck[i];
4304
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) continue;
4305
+ if (shape.isLocked && !hitLocked || this.isShapeHidden(shape) || this.isShapeOfType(shape, "group")) {
4306
+ continue;
4307
+ }
4308
+ const pageMask = this.getShapeMask(shape);
4309
+ if (pageMask && !(0, import_utils2.pointInPolygon)(point, pageMask)) continue;
4310
+ if (filter && !filter(shape)) continue;
4312
4311
  const geometry = this.getShapeGeometry(shape);
4313
4312
  const isGroup = geometry instanceof import_Group2d.Group2d;
4314
4313
  const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
@@ -4413,11 +4412,15 @@ class Editor extends import_eventemitter3.default {
4413
4412
  getShapesAtPoint(point, opts = {}) {
4414
4413
  const margin = opts.margin ?? 0;
4415
4414
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, margin);
4416
- return this.getCurrentPageShapesSorted().filter((shape) => {
4417
- if (this.isShapeHidden(shape)) return false;
4418
- if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
4419
- return this.isPointInShape(shape, point, opts);
4420
- }).reverse();
4415
+ const sorted = this.getCurrentPageShapesSorted();
4416
+ const result = [];
4417
+ for (let i = sorted.length - 1; i >= 0; i--) {
4418
+ const shape = sorted[i];
4419
+ if (this.isShapeHidden(shape)) continue;
4420
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) continue;
4421
+ if (this.isPointInShape(shape, point, opts)) result.push(shape);
4422
+ }
4423
+ return result;
4421
4424
  }
4422
4425
  /**
4423
4426
  * Get shape IDs within the given bounds.