@tldraw/editor 3.15.0 → 3.16.0-next.c30b1b5e551a

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 (39) hide show
  1. package/dist-cjs/index.d.ts +101 -0
  2. package/dist-cjs/index.js +3 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/components/Shape.js +4 -26
  5. package/dist-cjs/lib/components/Shape.js.map +2 -2
  6. package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js +53 -0
  7. package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js.map +7 -0
  8. package/dist-cjs/lib/editor/Editor.js +64 -35
  9. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  10. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  11. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  12. package/dist-cjs/lib/hooks/useEditorComponents.js +2 -0
  13. package/dist-cjs/lib/hooks/useEditorComponents.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 +101 -0
  17. package/dist-esm/index.mjs +5 -1
  18. package/dist-esm/index.mjs.map +2 -2
  19. package/dist-esm/lib/components/Shape.mjs +4 -26
  20. package/dist-esm/lib/components/Shape.mjs.map +2 -2
  21. package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs +23 -0
  22. package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs.map +7 -0
  23. package/dist-esm/lib/editor/Editor.mjs +64 -35
  24. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  25. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  26. package/dist-esm/lib/hooks/useEditorComponents.mjs +4 -0
  27. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  28. package/dist-esm/version.mjs +3 -3
  29. package/dist-esm/version.mjs.map +1 -1
  30. package/editor.css +4 -23
  31. package/package.json +7 -7
  32. package/src/index.ts +5 -0
  33. package/src/lib/components/Shape.tsx +6 -21
  34. package/src/lib/components/default-components/DefaultShapeWrapper.tsx +35 -0
  35. package/src/lib/editor/Editor.ts +71 -35
  36. package/src/lib/editor/shapes/ShapeUtil.ts +57 -0
  37. package/src/lib/editor/types/misc-types.ts +19 -0
  38. package/src/lib/hooks/useEditorComponents.tsx +7 -1
  39. package/src/version.ts +3 -3
@@ -584,6 +584,15 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
584
584
  */
585
585
  onResizeEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void
586
586
 
587
+ /**
588
+ * A callback called when a shape resize is cancelled.
589
+ *
590
+ * @param initial - The shape at the start of the resize.
591
+ * @param current - The current shape.
592
+ * @public
593
+ */
594
+ onResizeCancel?(initial: Shape, current: Shape): void
595
+
587
596
  /**
588
597
  * A callback called when a shape starts being translated.
589
598
  *
@@ -613,6 +622,25 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
613
622
  */
614
623
  onTranslateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void
615
624
 
625
+ /**
626
+ * A callback called when a shape translation is cancelled.
627
+ *
628
+ * @param initial - The shape at the start of the translation.
629
+ * @param current - The current shape.
630
+ * @public
631
+ */
632
+ onTranslateCancel?(initial: Shape, current: Shape): void
633
+
634
+ /**
635
+ * A callback called when a shape's handle starts being dragged.
636
+ *
637
+ * @param shape - The shape.
638
+ * @param info - An object containing the handle and whether the handle is 'precise' or not.
639
+ * @returns A change to apply to the shape, or void.
640
+ * @public
641
+ */
642
+ onHandleDragStart?(shape: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void
643
+
616
644
  /**
617
645
  * A callback called when a shape's handle changes.
618
646
  *
@@ -623,6 +651,25 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
623
651
  */
624
652
  onHandleDrag?(shape: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void
625
653
 
654
+ /**
655
+ * A callback called when a shape's handle finishes being dragged.
656
+ *
657
+ * @param current - The current shape.
658
+ * @param info - An object containing the handle and whether the handle is 'precise' or not.
659
+ * @returns A change to apply to the shape, or void.
660
+ * @public
661
+ */
662
+ onHandleDragEnd?(current: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void
663
+
664
+ /**
665
+ * A callback called when a shape's handle drag is cancelled.
666
+ *
667
+ * @param current - The current shape.
668
+ * @param info - An object containing the handle and whether the handle is 'precise' or not.
669
+ * @public
670
+ */
671
+ onHandleDragCancel?(current: Shape, info: TLHandleDragInfo<Shape>): void
672
+
626
673
  /**
627
674
  * A callback called when a shape starts being rotated.
628
675
  *
@@ -652,6 +699,15 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
652
699
  */
653
700
  onRotateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void
654
701
 
702
+ /**
703
+ * A callback called when a shape rotation is cancelled.
704
+ *
705
+ * @param initial - The shape at the start of the rotation.
706
+ * @param current - The current shape.
707
+ * @public
708
+ */
709
+ onRotateCancel?(initial: Shape, current: Shape): void
710
+
655
711
  /**
656
712
  * Not currently used.
657
713
  *
@@ -819,5 +875,6 @@ export interface TLResizeInfo<T extends TLShape> {
819
875
  export interface TLHandleDragInfo<T extends TLShape> {
820
876
  handle: TLHandle
821
877
  isPrecise: boolean
878
+ isCreatingShape: boolean
822
879
  initial?: T | undefined
823
880
  }
@@ -187,3 +187,22 @@ export interface TLCameraConstraints {
187
187
  y: 'free' | 'fixed' | 'inside' | 'outside' | 'contain'
188
188
  }
189
189
  }
190
+
191
+ /** @public */
192
+ export interface TLUpdatePointerOptions {
193
+ /** Whether to update the pointer immediately, rather than on the next tick. */
194
+ immediate?: boolean
195
+ /**
196
+ * The point, in screen-space, to update the pointer to. Defaults to the position of the last
197
+ * pointer event.
198
+ */
199
+ point?: VecLike
200
+ pointerId?: number
201
+ ctrlKey?: boolean
202
+ altKey?: boolean
203
+ shiftKey?: boolean
204
+ metaKey?: boolean
205
+ accelKey?: boolean
206
+ isPen?: boolean
207
+ button?: number
208
+ }
@@ -1,4 +1,4 @@
1
- import { ComponentType, ReactNode, createContext, useContext, useMemo } from 'react'
1
+ import { ComponentType, ReactNode, RefAttributes, createContext, useContext, useMemo } from 'react'
2
2
  import { DefaultBackground } from '../components/default-components/DefaultBackground'
3
3
  import { DefaultBrush, TLBrushProps } from '../components/default-components/DefaultBrush'
4
4
  import {
@@ -37,6 +37,10 @@ import {
37
37
  TLShapeIndicatorErrorFallbackComponent,
38
38
  } from '../components/default-components/DefaultShapeIndicatorErrorFallback'
39
39
  import { DefaultShapeIndicators } from '../components/default-components/DefaultShapeIndicators'
40
+ import {
41
+ DefaultShapeWrapper,
42
+ TLShapeWrapperProps,
43
+ } from '../components/default-components/DefaultShapeWrapper'
40
44
  import {
41
45
  DefaultSnapIndicator,
42
46
  TLSnapIndicatorProps,
@@ -68,6 +72,7 @@ export interface TLEditorComponents {
68
72
  SelectionForeground?: ComponentType<TLSelectionForegroundProps> | null
69
73
  ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null
70
74
  ShapeIndicators?: ComponentType | null
75
+ ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null
71
76
  SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null
72
77
  Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null
73
78
  SvgDefs?: ComponentType | null
@@ -114,6 +119,7 @@ export function EditorComponentsProvider({
114
119
  SelectionForeground: DefaultSelectionForeground,
115
120
  ShapeIndicator: DefaultShapeIndicator,
116
121
  ShapeIndicators: DefaultShapeIndicators,
122
+ ShapeWrapper: DefaultShapeWrapper,
117
123
  SnapIndicator: DefaultSnapIndicator,
118
124
  Spinner: DefaultSpinner,
119
125
  SvgDefs: DefaultSvgDefs,
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 = '3.15.0'
4
+ export const version = '3.16.0-next.c30b1b5e551a'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-07-30T09:07:27.887Z',
8
- patch: '2025-07-30T09:07:27.887Z',
7
+ minor: '2025-07-30T09:52:11.036Z',
8
+ patch: '2025-07-30T09:52:11.036Z',
9
9
  }