@tldraw/editor 5.4.0-next.b120f7febb0f → 5.4.0-next.ebc95cf01337

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 (31) hide show
  1. package/dist-cjs/index.d.ts +47 -46
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/editor/Editor.js +17 -14
  4. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  5. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js +7 -3
  6. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js.map +2 -2
  7. package/dist-cjs/lib/primitives/geometry/Group2d.js +63 -21
  8. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  9. package/dist-cjs/lib/utils/normalizeWheel.js +2 -0
  10. package/dist-cjs/lib/utils/normalizeWheel.js.map +2 -2
  11. package/dist-cjs/version.js +3 -3
  12. package/dist-cjs/version.js.map +1 -1
  13. package/dist-esm/index.d.mts +47 -46
  14. package/dist-esm/index.mjs +1 -1
  15. package/dist-esm/lib/editor/Editor.mjs +17 -14
  16. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  17. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs +7 -3
  18. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs.map +2 -2
  19. package/dist-esm/lib/primitives/geometry/Group2d.mjs +63 -21
  20. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  21. package/dist-esm/lib/utils/normalizeWheel.mjs +2 -0
  22. package/dist-esm/lib/utils/normalizeWheel.mjs.map +2 -2
  23. package/dist-esm/version.mjs +3 -3
  24. package/dist-esm/version.mjs.map +1 -1
  25. package/package.json +7 -7
  26. package/src/lib/editor/Editor.ts +25 -24
  27. package/src/lib/editor/derivations/shapeIdsInCurrentPage.ts +7 -3
  28. package/src/lib/primitives/geometry/Group2d.ts +63 -27
  29. package/src/lib/utils/normalizeWheel.test.ts +39 -0
  30. package/src/lib/utils/normalizeWheel.ts +6 -0
  31. package/src/version.ts +3 -3
@@ -305,7 +305,7 @@ import { LocalIndexedDb, Table } from "./lib/utils/sync/LocalIndexedDb.mjs";
305
305
  import { uniq } from "./lib/utils/uniq.mjs";
306
306
  registerTldrawLibraryVersion(
307
307
  "@tldraw/editor",
308
- "5.4.0-next.b120f7febb0f",
308
+ "5.4.0-next.ebc95cf01337",
309
309
  "esm"
310
310
  );
311
311
  import { getColorValue } from "./lib/editor/managers/ThemeManager/defaultThemes.mjs";
@@ -4331,17 +4331,16 @@ class Editor extends EventEmitter {
4331
4331
  let inMarginClosestToEdgeHit = null;
4332
4332
  const searchMargin = Math.max(innerMargin, outerMargin, this.getHitTestMargin());
4333
4333
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, searchMargin);
4334
- const shapesToCheck = (opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted()).filter((shape) => {
4335
- if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
4336
- if (shape.isLocked && !hitLocked || this.isShapeHidden(shape) || this.isShapeOfType(shape, "group"))
4337
- return false;
4338
- const pageMask = this.getShapeMask(shape);
4339
- if (pageMask && !pointInPolygon(point, pageMask)) return false;
4340
- if (filter && !filter(shape)) return false;
4341
- return true;
4342
- });
4334
+ const shapesToCheck = opts.renderingOnly ? this.getCurrentPageRenderingShapesSorted() : this.getCurrentPageShapesSorted();
4343
4335
  for (let i = shapesToCheck.length - 1; i >= 0; i--) {
4344
4336
  const shape = shapesToCheck[i];
4337
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) continue;
4338
+ if (shape.isLocked && !hitLocked || this.isShapeHidden(shape) || this.isShapeOfType(shape, "group")) {
4339
+ continue;
4340
+ }
4341
+ const pageMask = this.getShapeMask(shape);
4342
+ if (pageMask && !pointInPolygon(point, pageMask)) continue;
4343
+ if (filter && !filter(shape)) continue;
4345
4344
  const geometry = this.getShapeGeometry(shape);
4346
4345
  const isGroup = geometry instanceof Group2d;
4347
4346
  const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
@@ -4446,11 +4445,15 @@ class Editor extends EventEmitter {
4446
4445
  getShapesAtPoint(point, opts = {}) {
4447
4446
  const margin = opts.margin ?? 0;
4448
4447
  const candidateIds = this._spatialIndex.getShapeIdsAtPoint(point, margin);
4449
- return this.getCurrentPageShapesSorted().filter((shape) => {
4450
- if (this.isShapeHidden(shape)) return false;
4451
- if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) return false;
4452
- return this.isPointInShape(shape, point, opts);
4453
- }).reverse();
4448
+ const sorted = this.getCurrentPageShapesSorted();
4449
+ const result = [];
4450
+ for (let i = sorted.length - 1; i >= 0; i--) {
4451
+ const shape = sorted[i];
4452
+ if (this.isShapeHidden(shape)) continue;
4453
+ if (!candidateIds.has(shape.id) && !this.isShapeFrameLike(shape)) continue;
4454
+ if (this.isPointInShape(shape, point, opts)) result.push(shape);
4455
+ }
4456
+ return result;
4454
4457
  }
4455
4458
  /**
4456
4459
  * Get shape IDs within the given bounds.