@tldraw/editor 5.4.0-canary.e10ff229bb14 → 5.4.0-next.0d6e67d72615

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 +14 -17
  3. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  4. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js +3 -7
  5. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js.map +2 -2
  6. package/dist-cjs/lib/primitives/geometry/Group2d.js +21 -63
  7. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  8. package/dist-cjs/lib/utils/normalizeWheel.js +0 -2
  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 +14 -17
  14. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  15. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs +3 -7
  16. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs.map +2 -2
  17. package/dist-esm/lib/primitives/geometry/Group2d.mjs +21 -63
  18. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  19. package/dist-esm/lib/utils/normalizeWheel.mjs +0 -2
  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 +24 -25
  25. package/src/lib/editor/derivations/shapeIdsInCurrentPage.ts +3 -7
  26. package/src/lib/primitives/geometry/Group2d.ts +27 -63
  27. package/src/lib/utils/normalizeWheel.ts +0 -6
  28. package/src/version.ts +3 -3
  29. package/src/lib/utils/normalizeWheel.test.ts +0 -39
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.e10ff229bb14",
392
+ "5.4.0-next.0d6e67d72615",
393
393
  "cjs"
394
394
  );
395
395
  //# sourceMappingURL=index.js.map
@@ -4298,16 +4298,17 @@ 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();
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
+ });
4302
4310
  for (let i = shapesToCheck.length - 1; i >= 0; i--) {
4303
4311
  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;
4311
4312
  const geometry = this.getShapeGeometry(shape);
4312
4313
  const isGroup = geometry instanceof import_Group2d.Group2d;
4313
4314
  const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
@@ -4412,15 +4413,11 @@ class Editor extends import_eventemitter3.default {
4412
4413
  getShapesAtPoint(point, opts = {}) {
4413
4414
  const margin = opts.margin ?? 0;
4414
4415
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, margin);
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;
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();
4424
4421
  }
4425
4422
  /**
4426
4423
  * Get shape IDs within the given bounds.