@tldraw/editor 4.5.0-canary.034ea85352da → 4.5.0-canary.0d748e7df5db

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 (38) hide show
  1. package/dist-cjs/index.d.ts +24 -1
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +13 -16
  4. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  5. package/dist-cjs/lib/editor/Editor.js +206 -254
  6. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  7. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +15 -16
  8. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +3 -3
  9. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +1 -1
  10. package/dist-cjs/lib/hooks/useCanvasEvents.js +1 -1
  11. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  12. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +10 -0
  13. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  14. package/dist-cjs/version.js +3 -3
  15. package/dist-cjs/version.js.map +1 -1
  16. package/dist-esm/index.d.mts +24 -1
  17. package/dist-esm/index.mjs +1 -1
  18. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +13 -16
  19. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  20. package/dist-esm/lib/editor/Editor.mjs +207 -255
  21. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  22. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +15 -16
  23. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +3 -3
  24. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +1 -1
  25. package/dist-esm/lib/hooks/useCanvasEvents.mjs +1 -1
  26. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  27. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +10 -0
  28. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  29. package/dist-esm/version.mjs +3 -3
  30. package/dist-esm/version.mjs.map +1 -1
  31. package/package.json +7 -7
  32. package/src/lib/components/default-components/DefaultCanvas.tsx +19 -26
  33. package/src/lib/editor/Editor.ts +283 -393
  34. package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +6 -5
  35. package/src/lib/editor/shapes/ShapeUtil.ts +1 -1
  36. package/src/lib/hooks/useCanvasEvents.ts +1 -1
  37. package/src/lib/primitives/geometry/Geometry2d.ts +12 -0
  38. package/src/version.ts +3 -3
@@ -11,11 +11,12 @@ import {
11
11
  import { exhaustiveSwitchError, noop } from '@tldraw/utils'
12
12
  import { TLHistoryBatchOptions, TLHistoryEntry } from '../../types/history-types'
13
13
 
14
- enum HistoryRecorderState {
15
- Recording = 'recording',
16
- RecordingPreserveRedoStack = 'recordingPreserveRedoStack',
17
- Paused = 'paused',
18
- }
14
+ const HistoryRecorderState = {
15
+ Recording: 'recording',
16
+ RecordingPreserveRedoStack: 'recordingPreserveRedoStack',
17
+ Paused: 'paused',
18
+ } as const
19
+ type HistoryRecorderState = (typeof HistoryRecorderState)[keyof typeof HistoryRecorderState]
19
20
 
20
21
  /** @public */
21
22
  export class HistoryManager<R extends UnknownRecord> {
@@ -69,7 +69,7 @@ export interface TLShapeUtilCanBindOpts<Shape extends TLShape = TLShape> {
69
69
  */
70
70
  export interface TLShapeUtilCanBeLaidOutOpts {
71
71
  /** The type of action causing the layout. */
72
- type?: 'align' | 'distribute' | 'pack' | 'stack' | 'flip' | 'stretch'
72
+ type?: 'align' | 'distribute' | 'pack' | 'stack' | 'flip' | 'stretch' | 'resize_to_bounds'
73
73
  /** The other shapes being laid out */
74
74
  shapes?: TLShape[]
75
75
  }
@@ -78,7 +78,7 @@ export function useCanvasEvents() {
78
78
  // check that e.target is an HTMLElement
79
79
  if (!(e.target instanceof HTMLElement)) return
80
80
 
81
- const editingShapeId = editor.getEditingShape()?.id
81
+ const editingShapeId = editor.getEditingShapeId()
82
82
  if (
83
83
  // if the target is not inside the editing shape
84
84
  !(editingShapeId && e.target.closest(`[data-shape-id="${editingShapeId}"]`)) &&
@@ -420,6 +420,14 @@ export abstract class Geometry2d {
420
420
  return length
421
421
  }
422
422
 
423
+ /**
424
+ * Called after a hit test succeeds. Return `true` to reject the hit and allow
425
+ * shapes behind this one to be selected instead (e.g. transparent image pixels).
426
+ */
427
+ ignoreHit(_point: VecLike): boolean {
428
+ return false
429
+ }
430
+
423
431
  abstract getSvgPathData(first: boolean): string
424
432
  }
425
433
 
@@ -551,6 +559,10 @@ export class TransformedGeometry2d extends Geometry2d {
551
559
  )
552
560
  }
553
561
 
562
+ override ignoreHit(point: VecLike): boolean {
563
+ return this.geometry.ignoreHit(Mat.applyToPoint(this.inverse, point))
564
+ }
565
+
554
566
  override transform(transform: MatModel, opts?: TransformedGeometry2dOptions): Geometry2d {
555
567
  return new TransformedGeometry2d(this.geometry, Mat.Multiply(transform, this.matrix), {
556
568
  isLabel: opts?.isLabel ?? this.isLabel,
package/src/version.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated by internal/scripts/refresh-assets.ts.
2
2
  // Do not edit manually. Or do, I'm a comment, not a cop.
3
3
 
4
- export const version = '4.5.0-canary.034ea85352da'
4
+ export const version = '4.5.0-canary.0d748e7df5db'
5
5
  export const publishDates = {
6
6
  major: '2025-09-18T14:39:22.803Z',
7
- minor: '2026-02-19T10:36:24.329Z',
8
- patch: '2026-02-19T10:36:24.329Z',
7
+ minor: '2026-03-09T10:08:37.649Z',
8
+ patch: '2026-03-09T10:08:37.649Z',
9
9
  }