@tldraw/editor 5.3.0-next.fc37bd96825b → 5.4.0-canary.074b19f2c11f

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 (132) hide show
  1. package/dist-cjs/index.d.ts +198 -53
  2. package/dist-cjs/index.js +13 -3
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +24 -19
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/EditorPortal.js +44 -0
  7. package/dist-cjs/lib/components/EditorPortal.js.map +7 -0
  8. package/dist-cjs/lib/components/LiveCollaborators.js +102 -0
  9. package/dist-cjs/lib/components/LiveCollaborators.js.map +7 -0
  10. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +4 -10
  11. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
  12. package/dist-cjs/lib/components/default-components/DefaultCursor.js +59 -0
  13. package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +7 -0
  14. package/dist-cjs/lib/editor/Editor.js +89 -28
  15. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  16. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js +7 -3
  17. package/dist-cjs/lib/editor/derivations/shapeIdsInCurrentPage.js.map +2 -2
  18. package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +4 -4
  19. package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +2 -2
  20. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +5 -1
  21. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
  22. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  23. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  24. package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
  25. package/dist-cjs/lib/hooks/useCursor.js +1 -0
  26. package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
  27. package/dist-cjs/lib/hooks/useEditorComponents.js +2 -0
  28. package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
  29. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +49 -18
  30. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +3 -3
  31. package/dist-cjs/lib/hooks/useTransform.js +45 -0
  32. package/dist-cjs/lib/hooks/useTransform.js.map +7 -0
  33. package/dist-cjs/lib/hooks/useViewportHeight.js.map +2 -2
  34. package/dist-cjs/lib/license/LicenseManager.js +51 -2
  35. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  36. package/dist-cjs/lib/license/useLicenseManagerState.js +7 -0
  37. package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
  38. package/dist-cjs/lib/primitives/geometry/Group2d.js +63 -21
  39. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  40. package/dist-cjs/lib/utils/collaborators.js +27 -0
  41. package/dist-cjs/lib/utils/collaborators.js.map +7 -0
  42. package/dist-cjs/lib/utils/getHtmlLayerTransform.js +33 -0
  43. package/dist-cjs/lib/utils/getHtmlLayerTransform.js.map +7 -0
  44. package/dist-cjs/lib/utils/normalizeWheel.js +2 -0
  45. package/dist-cjs/lib/utils/normalizeWheel.js.map +2 -2
  46. package/dist-cjs/version.js +3 -3
  47. package/dist-cjs/version.js.map +1 -1
  48. package/dist-esm/index.d.mts +198 -53
  49. package/dist-esm/index.mjs +19 -4
  50. package/dist-esm/index.mjs.map +2 -2
  51. package/dist-esm/lib/TldrawEditor.mjs +23 -18
  52. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  53. package/dist-esm/lib/components/EditorPortal.mjs +24 -0
  54. package/dist-esm/lib/components/EditorPortal.mjs.map +7 -0
  55. package/dist-esm/lib/components/LiveCollaborators.mjs +82 -0
  56. package/dist-esm/lib/components/LiveCollaborators.mjs.map +7 -0
  57. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +5 -11
  58. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  59. package/dist-esm/lib/components/default-components/DefaultCursor.mjs +29 -0
  60. package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +7 -0
  61. package/dist-esm/lib/editor/Editor.mjs +89 -28
  62. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  63. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs +7 -3
  64. package/dist-esm/lib/editor/derivations/shapeIdsInCurrentPage.mjs.map +2 -2
  65. package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +5 -5
  66. package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +2 -2
  67. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +5 -1
  68. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
  69. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  70. package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
  71. package/dist-esm/lib/hooks/useCursor.mjs +1 -0
  72. package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
  73. package/dist-esm/lib/hooks/useEditorComponents.mjs +2 -0
  74. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  75. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +50 -19
  76. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +3 -3
  77. package/dist-esm/lib/hooks/useTransform.mjs +25 -0
  78. package/dist-esm/lib/hooks/useTransform.mjs.map +7 -0
  79. package/dist-esm/lib/hooks/useViewportHeight.mjs.map +2 -2
  80. package/dist-esm/lib/license/LicenseManager.mjs +52 -3
  81. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  82. package/dist-esm/lib/license/useLicenseManagerState.mjs +7 -0
  83. package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
  84. package/dist-esm/lib/primitives/geometry/Group2d.mjs +63 -21
  85. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  86. package/dist-esm/lib/utils/collaborators.mjs +7 -0
  87. package/dist-esm/lib/utils/collaborators.mjs.map +7 -0
  88. package/dist-esm/lib/utils/getHtmlLayerTransform.mjs +13 -0
  89. package/dist-esm/lib/utils/getHtmlLayerTransform.mjs.map +7 -0
  90. package/dist-esm/lib/utils/normalizeWheel.mjs +2 -0
  91. package/dist-esm/lib/utils/normalizeWheel.mjs.map +2 -2
  92. package/dist-esm/version.mjs +3 -3
  93. package/dist-esm/version.mjs.map +1 -1
  94. package/editor.css +43 -4
  95. package/package.json +7 -7
  96. package/src/index.ts +15 -2
  97. package/src/lib/TldrawEditor.tsx +21 -13
  98. package/src/lib/components/EditorPortal.tsx +77 -0
  99. package/src/lib/components/LiveCollaborators.tsx +133 -0
  100. package/src/lib/components/default-components/DefaultCanvas.tsx +5 -17
  101. package/src/lib/components/default-components/DefaultCursor.tsx +65 -0
  102. package/src/lib/editor/Editor.ts +134 -39
  103. package/src/lib/editor/derivations/shapeIdsInCurrentPage.ts +7 -3
  104. package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.test.ts +46 -1
  105. package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +10 -5
  106. package/src/lib/editor/managers/TextManager/TextManager.test.ts +42 -0
  107. package/src/lib/editor/managers/TextManager/TextManager.ts +8 -2
  108. package/src/lib/editor/shapes/ShapeUtil.ts +24 -0
  109. package/src/lib/editor/types/external-content.ts +5 -0
  110. package/src/lib/hooks/EditorComponentsContext.tsx +2 -0
  111. package/src/lib/hooks/useCursor.ts +1 -0
  112. package/src/lib/hooks/useEditorComponents.tsx +2 -0
  113. package/src/lib/hooks/usePassThroughWheelEvents.ts +83 -24
  114. package/src/lib/hooks/useTransform.ts +38 -0
  115. package/src/lib/hooks/useViewportHeight.ts +9 -1
  116. package/src/lib/license/LicenseManager.test.ts +146 -0
  117. package/src/lib/license/LicenseManager.ts +98 -2
  118. package/src/lib/license/useLicenseManagerState.ts +17 -1
  119. package/src/lib/primitives/geometry/Group2d.ts +63 -27
  120. package/src/lib/test/EditorPortal.test.tsx +48 -0
  121. package/src/lib/test/usePassThroughWheelEvents.test.tsx +77 -0
  122. package/src/lib/utils/collaborators.test.ts +34 -0
  123. package/src/lib/utils/collaborators.ts +25 -0
  124. package/src/lib/utils/getHtmlLayerTransform.ts +22 -0
  125. package/src/lib/utils/normalizeWheel.test.ts +39 -0
  126. package/src/lib/utils/normalizeWheel.ts +6 -0
  127. package/src/version.ts +3 -3
  128. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +0 -51
  129. package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +0 -7
  130. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +0 -31
  131. package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +0 -7
  132. package/src/lib/hooks/usePassThroughMouseOverEvents.ts +0 -32
@@ -18,6 +18,7 @@ import { IndexKey } from '@tldraw/utils';
18
18
  import { JsonObject } from '@tldraw/utils';
19
19
  import { JSX } from 'react/jsx-runtime';
20
20
  import { LegacyMigrations } from '@tldraw/store';
21
+ import { MemoExoticComponent } from 'react';
21
22
  import { MigrationSequence } from '@tldraw/store';
22
23
  import { Node as Node_2 } from '@tiptap/pm/model';
23
24
  import { PerformanceTracker } from '@tldraw/utils';
@@ -25,6 +26,7 @@ import * as React_2 from 'react';
25
26
  import { default as React_3 } from 'react';
26
27
  import { ReactElement } from 'react';
27
28
  import { ReactNode } from 'react';
29
+ import { ReactPortal } from 'react';
28
30
  import { RecordProps } from '@tldraw/tlschema';
29
31
  import { RecordsDiff } from '@tldraw/store';
30
32
  import { RefAttributes } from 'react';
@@ -66,6 +68,7 @@ import { TLImageAsset } from '@tldraw/tlschema';
66
68
  import { TLInstance } from '@tldraw/tlschema';
67
69
  import { TLInstancePageState } from '@tldraw/tlschema';
68
70
  import { TLInstancePresence } from '@tldraw/tlschema';
71
+ import { TLOpacityType } from '@tldraw/tlschema';
69
72
  import { TLPage } from '@tldraw/tlschema';
70
73
  import { TLPageId } from '@tldraw/tlschema';
71
74
  import { TLParentId } from '@tldraw/tlschema';
@@ -554,13 +557,13 @@ export declare class BoundsSnaps {
554
557
  private getSnappablePoints;
555
558
  private getSnappableGapNodes;
556
559
  private getVisibleGaps;
557
- snapTranslateShapes({ lockedAxis, initialSelectionPageBounds, initialSelectionSnapPoints, dragDelta }: {
560
+ snapTranslateShapes({ lockedAxis, initialSelectionPageBounds, initialSelectionSnapPoints, dragDelta, }: {
558
561
  dragDelta: Vec;
559
562
  initialSelectionPageBounds: Box;
560
563
  initialSelectionSnapPoints: BoundsSnapPoint[];
561
564
  lockedAxis: 'x' | 'y' | null;
562
565
  }): SnapData;
563
- snapResizeShapes({ initialSelectionPageBounds, dragDelta, handle: originalHandle, isAspectRatioLocked, isResizingFromCenter }: {
566
+ snapResizeShapes({ initialSelectionPageBounds, dragDelta, handle: originalHandle, isAspectRatioLocked, isResizingFromCenter, }: {
564
567
  dragDelta: Vec;
565
568
  handle: SelectionCorner | SelectionEdge;
566
569
  initialSelectionPageBounds: Box;
@@ -842,7 +845,7 @@ export declare const coreShapes: readonly [typeof GroupShapeUtil];
842
845
  export declare function counterClockwiseAngleDist(a0: number, a1: number): number;
843
846
 
844
847
  /** @public */
845
- export declare function createDebugValue<T>(name: string, { defaults, shouldStoreForSession }: {
848
+ export declare function createDebugValue<T>(name: string, { defaults, shouldStoreForSession, }: {
846
849
  defaults: DebugFlagDefaults<T>;
847
850
  shouldStoreForSession?: boolean;
848
851
  }): DebugFlag<T>;
@@ -873,8 +876,8 @@ export declare function createSessionStateSnapshotSignal(store: TLStore): Signal
873
876
 
874
877
  /** @public */
875
878
  export declare function createTLCurrentUser(opts?: {
876
- setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
877
- userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
879
+ setUserPreferences?: (userPreferences: TLUserPreferences) => void;
880
+ userPreferences?: Signal<TLUserPreferences>;
878
881
  }): TLCurrentUser;
879
882
 
880
883
  /**
@@ -982,6 +985,15 @@ export declare function DefaultBackground(): JSX.Element;
982
985
  /** @public @react */
983
986
  export declare function DefaultCanvas({ className }: TLCanvasComponentProps): JSX.Element;
984
987
 
988
+ /**
989
+ * The default collaborator cursor: the arrow glyph plus a name tag or chat bubble. The arrow is a
990
+ * `<use>` of a shared `<defs>` symbol that `LiveCollaborators` renders, so a `DefaultCursor`
991
+ * used outside that layer draws no arrow.
992
+ *
993
+ * @public @react
994
+ */
995
+ export declare const DefaultCursor: MemoExoticComponent<({ className, zoom, point, color, name, chatMessage, }: TLCursorProps) => JSX.Element | null>;
996
+
985
997
  /** @public @react */
986
998
  export declare const DefaultErrorFallback: TLErrorFallbackComponent;
987
999
 
@@ -999,7 +1011,7 @@ export declare function DefaultSvgDefs(): null;
999
1011
 
1000
1012
  /** @public */
1001
1013
  export declare const defaultTldrawOptions: {
1002
- readonly actionShortcutsLocation: "swap";
1014
+ readonly actionShortcutsLocation: 'swap';
1003
1015
  readonly adjacentShapeMargin: 10;
1004
1016
  readonly animationMediumMs: 320;
1005
1017
  readonly camera: TLCameraOptions;
@@ -1171,7 +1183,7 @@ export declare class EdgeScrollManager {
1171
1183
  /** @public */
1172
1184
  export declare class Editor extends EventEmitter<TLEventMap> {
1173
1185
  readonly id: string;
1174
- constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, overlayUtils: overlayUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
1186
+ constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, overlayUtils: overlayUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme, }: TLEditorOptions);
1175
1187
  private readonly _getShapeVisibility?;
1176
1188
  private getIsShapeHiddenCache;
1177
1189
  isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
@@ -1263,8 +1275,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1263
1275
  readonly timers: {
1264
1276
  dispose: () => void;
1265
1277
  requestAnimationFrame: (callback: FrameRequestCallback) => number;
1266
- setInterval: (handler: TimerHandler, timeout?: number | undefined, ...args: any[]) => number;
1267
- setTimeout: (handler: TimerHandler, timeout?: number | undefined, ...args: any[]) => number;
1278
+ setInterval: (handler: TimerHandler, timeout?: number, ...args: any[]) => number;
1279
+ setTimeout: (handler: TimerHandler, timeout?: number, ...args: any[]) => number;
1268
1280
  };
1269
1281
  /**
1270
1282
  * A manager for remote peer collaborators connected to this editor.
@@ -1797,14 +1809,14 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1797
1809
  * @public
1798
1810
  */
1799
1811
  getPageStates(): TLInstancePageState[];
1800
- private _getPageStatesQuery;
1812
+ /* Excluded from this release type: _getPageStatesQuery */
1801
1813
  /**
1802
1814
  * The current page state.
1803
1815
  *
1804
1816
  * @public
1805
1817
  */
1806
1818
  getCurrentPageState(): TLInstancePageState;
1807
- private _getCurrentPageStateId;
1819
+ /* Excluded from this release type: _getCurrentPageStateId */
1808
1820
  /**
1809
1821
  * Update this instance's page state.
1810
1822
  *
@@ -2197,7 +2209,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2197
2209
  *
2198
2210
  * @public */
2199
2211
  getTextOptions(): TLTextOptions;
2200
- private _unsafe_getCameraId;
2212
+ /* Excluded from this release type: _unsafe_getCameraId */
2201
2213
  /**
2202
2214
  * The current camera.
2203
2215
  *
@@ -2453,10 +2465,10 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2453
2465
  */
2454
2466
  slideCamera(opts?: {
2455
2467
  direction: VecLike;
2456
- force?: boolean | undefined;
2457
- friction?: number | undefined;
2468
+ force?: boolean;
2469
+ friction?: number;
2458
2470
  speed: number;
2459
- speedThreshold?: number | undefined;
2471
+ speedThreshold?: number;
2460
2472
  }): this;
2461
2473
  /**
2462
2474
  * Animate the camera to a user's cursor position. This also briefly show the user's cursor if it's not currently visible.
@@ -2815,7 +2827,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2815
2827
  * @public
2816
2828
  */
2817
2829
  renamePage(page: TLPage | TLPageId, name: string): this;
2818
- private _getAllAssetsQuery;
2830
+ /* Excluded from this release type: _getAllAssetsQuery */
2819
2831
  /**
2820
2832
  * Get all assets in the editor.
2821
2833
  *
@@ -2904,7 +2916,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2904
2916
  * @public
2905
2917
  */
2906
2918
  getShapeGeometry<T extends Geometry2d>(shape: TLShape | TLShapeId, opts?: TLGeometryOpts): T;
2907
- private _getShapeHandlesCache;
2919
+ /* Excluded from this release type: _getShapeHandlesCache */
2908
2920
  /**
2909
2921
  * Get the handles (if any) for a shape.
2910
2922
  *
@@ -2934,7 +2946,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2934
2946
  * @public
2935
2947
  */
2936
2948
  getShapeLocalTransform(shape: TLShape | TLShapeId): Mat;
2937
- private _getShapePageTransformCache;
2949
+ /* Excluded from this release type: _getShapePageTransformCache */
2938
2950
  /**
2939
2951
  * Get the local transform of a shape's parent as a matrix model.
2940
2952
  *
@@ -2962,7 +2974,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2962
2974
  * @public
2963
2975
  */
2964
2976
  getShapePageTransform(shape: TLShape | TLShapeId): Mat;
2965
- private _getShapePageBoundsCache;
2977
+ /* Excluded from this release type: _getShapePageBoundsCache */
2966
2978
  /**
2967
2979
  * Get the bounds of a shape in the current page space.
2968
2980
  *
@@ -2977,7 +2989,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2977
2989
  * @public
2978
2990
  */
2979
2991
  getShapePageBounds(shape: TLShape | TLShapeId): Box | undefined;
2980
- private _getShapeClipPathCache;
2992
+ /* Excluded from this release type: _getShapeClipPathCache */
2981
2993
  /**
2982
2994
  * Get the clip path for a shape.
2983
2995
  *
@@ -2994,7 +3006,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2994
3006
  * @public
2995
3007
  */
2996
3008
  getShapeClipPath(shape: TLShape | TLShapeId): string | undefined;
2997
- private _getShapeMaskCache;
3009
+ /* Excluded from this release type: _getShapeMaskCache */
2998
3010
  /**
2999
3011
  * Get the mask (in the current page space) for a shape.
3000
3012
  *
@@ -3026,7 +3038,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3026
3038
  * @public
3027
3039
  */
3028
3040
  getShapeMaskedPageBounds(shape: TLShape | TLShapeId): Box | undefined;
3029
- private _getShapeMaskedPageBoundsCache;
3041
+ /* Excluded from this release type: _getShapeMaskedPageBoundsCache */
3030
3042
  /**
3031
3043
  * Get the ancestors of a shape.
3032
3044
  *
@@ -3147,8 +3159,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3147
3159
  * @public
3148
3160
  */
3149
3161
  getShapesAtPoint(point: VecLike, opts?: {
3150
- hitInside?: boolean | undefined;
3151
- margin?: number | undefined;
3162
+ hitInside?: boolean;
3163
+ margin?: number;
3152
3164
  }): TLShape[];
3153
3165
  /**
3154
3166
  * Get shape IDs within the given bounds.
@@ -3184,8 +3196,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3184
3196
  * @public
3185
3197
  */
3186
3198
  isPointInShape(shape: TLShape | TLShapeId, point: VecLike, opts?: {
3187
- hitInside?: boolean | undefined;
3188
- margin?: number | undefined;
3199
+ hitInside?: boolean;
3200
+ margin?: number;
3189
3201
  }): boolean;
3190
3202
  /**
3191
3203
  * Convert a point in the current page space to a point in the local space of a shape. For example, if a
@@ -3473,7 +3485,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3473
3485
  * Delete a binding by its ID. If the binding doesn't exist, it's ignored.
3474
3486
  */
3475
3487
  deleteBinding(binding: TLBinding | TLBindingId, opts?: Parameters<this['deleteBindings']>[1]): this;
3476
- canBindShapes({ fromShape, toShape, binding }: {
3488
+ canBindShapes({ fromShape, toShape, binding, }: {
3477
3489
  binding: {
3478
3490
  type: TLBinding['type'];
3479
3491
  } | TLBinding | TLBinding['type'];
@@ -3689,7 +3701,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3689
3701
  *
3690
3702
  * @public
3691
3703
  */
3692
- alignShapes(shapes: TLShape[] | TLShapeId[], operation: 'bottom' | 'center-horizontal' | 'center-vertical' | 'left' | 'right' | 'top'): this;
3704
+ alignShapes(shapes: TLShape[] | TLShapeId[], operation: 'bottom' | 'center-horizontal' | 'center-vertical' | 'center' | 'left' | 'right' | 'top'): this;
3693
3705
  /**
3694
3706
  * Distribute shape positions.
3695
3707
  *
@@ -3940,7 +3952,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3940
3952
  deleteShape(id: TLShapeId): this;
3941
3953
  deleteShape(shape: TLShape): this;
3942
3954
  /* Excluded from this release type: _extractSharedStyles */
3943
- private _getSelectionSharedStyles;
3955
+ /* Excluded from this release type: _getSelectionSharedStyles */
3944
3956
  /**
3945
3957
  * Get the style for the next shape.
3946
3958
  *
@@ -4129,7 +4141,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
4129
4141
  * @param opts - Options for handling external content, including force flag to bypass readonly checks.
4130
4142
  */
4131
4143
  putExternalContent<E>(info: TLExternalContent<E>, opts?: {
4132
- force?: boolean | undefined;
4144
+ force?: boolean;
4133
4145
  }): Promise<void>;
4134
4146
  /**
4135
4147
  * Handle replacing external content.
@@ -4138,7 +4150,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
4138
4150
  * @param opts - Options for handling external content, including force flag to bypass readonly checks.
4139
4151
  */
4140
4152
  replaceExternalContent<E>(info: TLExternalContent<E>, opts?: {
4141
- force?: boolean | undefined;
4153
+ force?: boolean;
4142
4154
  }): Promise<void>;
4143
4155
  /**
4144
4156
  * Get content that can be exported for the given shape ids.
@@ -4462,13 +4474,14 @@ export declare class Editor extends EventEmitter<TLEventMap> {
4462
4474
  cancelDoubleClick(): void;
4463
4475
  /* Excluded from this release type: _prevCursor */
4464
4476
  /* Excluded from this release type: _shiftKeyTimeout */
4465
- /* Excluded from this release type: _setShiftKeyTimeout */
4477
+ /* Excluded from this release type: _releaseShiftKey */
4466
4478
  /* Excluded from this release type: _altKeyTimeout */
4467
- /* Excluded from this release type: _setAltKeyTimeout */
4479
+ /* Excluded from this release type: _releaseAltKey */
4468
4480
  /* Excluded from this release type: _ctrlKeyTimeout */
4469
- /* Excluded from this release type: _setCtrlKeyTimeout */
4481
+ /* Excluded from this release type: _releaseCtrlKey */
4470
4482
  /* Excluded from this release type: _metaKeyTimeout */
4471
- /* Excluded from this release type: _setMetaKeyTimeout */
4483
+ /* Excluded from this release type: _releaseMetaKey */
4484
+ /* Excluded from this release type: _releaseDebouncedModifiers */
4472
4485
  /* Excluded from this release type: _restoreToolId */
4473
4486
  /* Excluded from this release type: _didPinch */
4474
4487
  /* Excluded from this release type: _selectedShapeIdsAtPointerDown */
@@ -4586,6 +4599,52 @@ export declare abstract class EditorManager {
4586
4599
  /* Excluded from this release type: dispose */
4587
4600
  }
4588
4601
 
4602
+ /**
4603
+ * Renders its children into the end of the editor's container, escaping the canvas layer.
4604
+ *
4605
+ * Use this for anything anchored to canvas coordinates that also has to draw over the UI — a
4606
+ * popover on a shape, a comment thread, an annotation panel. The `OnTheCanvas` and
4607
+ * `InFrontOfTheCanvas` slots are fixed layers, each its own stacking context, so content mounted
4608
+ * there can't paint above whatever outranks its layer whatever z-index it asks for. Mount in
4609
+ * whichever slot suits your data flow, wrap the part that needs its own layer in this, and give
4610
+ * that part a z-index.
4611
+ *
4612
+ * This package's own layers stop at 250 (`--tl-layer-canvas-in-front`); above that belongs to
4613
+ * whatever renders the UI. In `tldraw` that's `--tl-layer-panels` (300) and `--tl-layer-menus`
4614
+ * (400), defined by `tldraw`'s stylesheet rather than this one.
4615
+ *
4616
+ * Positioning still resolves against the editor's container, so a `position: absolute` child uses
4617
+ * ordinary container coordinates.
4618
+ *
4619
+ * Prefer this over `createPortal(children, useContainer())`, which picks its DOM position from the
4620
+ * commit that mounts it — landing the node ahead of the UI and of the "skip to main content" link
4621
+ * that only works while nothing precedes it. This host is a real element placed last, so ordering
4622
+ * is fixed rather than dependent on mount timing.
4623
+ *
4624
+ * @example
4625
+ * ```tsx
4626
+ * // 400 clears tldraw's menus layer; the bare editor's own layers stop at 250.
4627
+ * function ShapeAnnotation({ point }: { point: VecLike }) {
4628
+ * return (
4629
+ * <EditorPortal>
4630
+ * <div style={{ position: 'absolute', left: point.x, top: point.y, zIndex: 400 }}>
4631
+ * Above the UI
4632
+ * </div>
4633
+ * </EditorPortal>
4634
+ * )
4635
+ * }
4636
+ * ```
4637
+ *
4638
+ * @public
4639
+ * @react
4640
+ */
4641
+ export declare function EditorPortal({ children }: EditorPortalProps): ReactPortal | null;
4642
+
4643
+ /** @public */
4644
+ export declare interface EditorPortalProps {
4645
+ children: ReactNode;
4646
+ }
4647
+
4589
4648
  /** @public @react */
4590
4649
  export declare function EditorProvider({ editor, children }: EditorProviderProps): JSX.Element;
4591
4650
 
@@ -4982,7 +5041,7 @@ export declare class Group2d extends Geometry2d {
4982
5041
 
4983
5042
  /** @public */
4984
5043
  export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
4985
- static type: "group";
5044
+ static type: 'group';
4986
5045
  static props: RecordProps<TLGroupShape>;
4987
5046
  static migrations: TLPropsMigrations;
4988
5047
  hideSelectionBoundsFg(shape: TLGroupShape): boolean;
@@ -5046,7 +5105,7 @@ export declare class HandleSnaps {
5046
5105
  private iterateSnapOutlines;
5047
5106
  private getHandleSnapPosition;
5048
5107
  private getHandleSnapData;
5049
- snapHandle({ currentShapeId, handle }: {
5108
+ snapHandle({ currentShapeId, handle, }: {
5050
5109
  currentShapeId: TLShapeId;
5051
5110
  handle: TLHandle;
5052
5111
  }): null | SnapData;
@@ -5449,6 +5508,24 @@ export declare function intersectPolygonPolygon(polygonA: VecLike[], polygonB: V
5449
5508
 
5450
5509
  /* Excluded from this release type: isAccelKey */
5451
5510
 
5511
+ /**
5512
+ * Whether a collaborator's cursor (page coords) is inside the viewport, with a small margin for the
5513
+ * cursor glyph so it isn't culled the instant its hotspot crosses the edge.
5514
+ *
5515
+ * Single source of truth for the cursor/hint split: the DOM cursor layer renders a collaborator
5516
+ * when this is true, and `CollaboratorHintOverlayUtil` draws the viewport-edge hint when it's
5517
+ * false. Sharing the predicate keeps those two exhaustive and mutually exclusive — a margin change
5518
+ * can't open a dead zone (neither renders) or a double-render (both).
5519
+ *
5520
+ * @public
5521
+ */
5522
+ export declare function isCursorInViewport(cursor: VecLike, viewport: {
5523
+ maxX: number;
5524
+ maxY: number;
5525
+ minX: number;
5526
+ minY: number;
5527
+ }, zoom: number): boolean;
5528
+
5452
5529
  /**
5453
5530
  * Check if a float is safe to use. ie: Not too big or small.
5454
5531
  * @public
@@ -5470,6 +5547,8 @@ export declare function kickoutOccludedShapes(editor: Editor, shapeIds: TLShapeI
5470
5547
 
5471
5548
  /* Excluded from this release type: LICENSE_TIMEOUT */
5472
5549
 
5550
+ /* Excluded from this release type: LicenseFeatureName */
5551
+
5473
5552
  /* Excluded from this release type: LicenseFromKeyResult */
5474
5553
 
5475
5554
  /* Excluded from this release type: LicenseInfo */
@@ -6155,11 +6234,11 @@ export declare interface RichTextFontVisitorState {
6155
6234
 
6156
6235
  /** @public */
6157
6236
  export declare const ROTATE_CORNER_TO_SELECTION_CORNER: {
6158
- readonly bottom_left_rotate: "bottom_left";
6159
- readonly bottom_right_rotate: "bottom_right";
6160
- readonly mobile_rotate: "top_left";
6161
- readonly top_left_rotate: "top_left";
6162
- readonly top_right_rotate: "top_right";
6237
+ readonly bottom_left_rotate: 'bottom_left';
6238
+ readonly bottom_right_rotate: 'bottom_right';
6239
+ readonly mobile_rotate: 'top_left';
6240
+ readonly top_left_rotate: 'top_left';
6241
+ readonly top_right_rotate: 'top_right';
6163
6242
  };
6164
6243
 
6165
6244
  /** @public */
@@ -6793,6 +6872,29 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
6793
6872
  * @public
6794
6873
  */
6795
6874
  onBeforeCreate?(next: Shape): Shape | void;
6875
+ /**
6876
+ * A callback called when a shape is reproduced from an existing shape, either by duplicating
6877
+ * ({@link Editor.duplicateShapes}) or by pasting/putting content onto the page
6878
+ * ({@link Editor.putContentOntoCurrentPage}). This provides a last chance to modify the copy
6879
+ * before it's created — for example, to re-stamp attribution so the copy is credited to the
6880
+ * current user rather than the original author. It is not called when content is put with
6881
+ * `preserveIds` (e.g. {@link Editor.moveShapesToPage}), since the shape keeps its identity
6882
+ * and no copy is made.
6883
+ *
6884
+ * @example
6885
+ *
6886
+ * ```ts
6887
+ * onBeforeDuplicate = (source, duplicate) => {
6888
+ * return { ...duplicate, props: { ...duplicate.props, editedBy: this.editor.getAttributionUserId() } }
6889
+ * }
6890
+ * ```
6891
+ *
6892
+ * @param source - The shape being copied from.
6893
+ * @param duplicate - The new copy (with its own id), before it's created.
6894
+ * @returns The next shape or void.
6895
+ * @public
6896
+ */
6897
+ onBeforeDuplicate?(source: Shape, duplicate: Shape): Shape | void;
6796
6898
  /**
6797
6899
  * A callback called just before a shape is updated. This method provides a last chance to modify
6798
6900
  * the updated shape.
@@ -7135,7 +7237,7 @@ export declare type SharedStyle<T> = {
7135
7237
  export declare function shortAngleDist(a0: number, a1: number): number;
7136
7238
 
7137
7239
  /** @public */
7138
- export declare const SIDES: readonly ["top", "right", "bottom", "left"];
7240
+ export declare const SIDES: readonly ['top', 'right', 'bottom', 'left'];
7139
7241
 
7140
7242
  /** @public */
7141
7243
  export declare const SIN: (x: number) => number;
@@ -7525,6 +7627,11 @@ export declare interface TLBaseEventInfo {
7525
7627
 
7526
7628
  /** @public */
7527
7629
  export declare interface TLBaseExternalContent {
7630
+ /**
7631
+ * The other content sources found on the clipboard alongside this content. For example, when
7632
+ * pasting an image copied together with HTML and plain text, the `files` content will have
7633
+ * text sources for the HTML and plain text parts.
7634
+ */
7528
7635
  sources?: TLExternalContentSource[];
7529
7636
  point?: VecLike;
7530
7637
  }
@@ -7771,6 +7878,17 @@ export declare interface TLCurrentUser {
7771
7878
  readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
7772
7879
  }
7773
7880
 
7881
+ /** @public */
7882
+ export declare interface TLCursorProps {
7883
+ userId: string;
7884
+ className?: string;
7885
+ point: null | VecModel;
7886
+ zoom: number;
7887
+ color?: string;
7888
+ name: null | string;
7889
+ chatMessage: string;
7890
+ }
7891
+
7774
7892
  /** @public */
7775
7893
  export declare type TLDeepLink = {
7776
7894
  bounds: BoxModel;
@@ -7840,7 +7958,7 @@ export declare interface TLDragShapesOverInfo {
7840
7958
  }
7841
7959
 
7842
7960
  /** @public @react */
7843
- export declare const TldrawEditor: React_3.NamedExoticComponent<TldrawEditorProps>;
7961
+ export declare const TldrawEditor: React_3.MemoExoticComponent<({ store, components, className, user: _user, options: _options, textOptions: _textOptions, deepLinks: _deepLinks, ...rest }: TldrawEditorProps) => JSX.Element>;
7844
7962
 
7845
7963
  /**
7846
7964
  * Base props for the {@link tldraw#Tldraw} and {@link TldrawEditor} components.
@@ -8273,6 +8391,7 @@ export declare interface TLDropShapesOverInfo {
8273
8391
  export declare interface TLEditorComponents {
8274
8392
  Background?: ComponentType | null;
8275
8393
  Canvas?: ComponentType<TLCanvasComponentProps> | null;
8394
+ CollaboratorCursor?: ComponentType<TLCursorProps> | null;
8276
8395
  Grid?: ComponentType<TLGridProps> | null;
8277
8396
  InFrontOfTheCanvas?: ComponentType | null;
8278
8397
  LoadingScreen?: ComponentType | null;
@@ -8890,7 +9009,7 @@ export declare const tlmenus: {
8890
9009
  *
8891
9010
  * @public
8892
9011
  */
8893
- clearOpenMenus(contextId?: string | undefined): void;
9012
+ clearOpenMenus(contextId?: string): void;
8894
9013
  /**
8895
9014
  * Delete an open menu.
8896
9015
  *
@@ -8913,7 +9032,7 @@ export declare const tlmenus: {
8913
9032
  *
8914
9033
  * @public
8915
9034
  */
8916
- getOpenMenus(contextId?: string | undefined): string[];
9035
+ getOpenMenus(contextId?: string): string[];
8917
9036
  /**
8918
9037
  * Get whether a menu is open for a given context.
8919
9038
  *
@@ -8927,7 +9046,7 @@ export declare const tlmenus: {
8927
9046
  *
8928
9047
  * @public
8929
9048
  */
8930
- isMenuOpen(id: string, contextId?: string | undefined): boolean;
9049
+ isMenuOpen(id: string, contextId?: string): boolean;
8931
9050
  /**
8932
9051
  * Get whether any menus are open for a given context.
8933
9052
  *
@@ -8965,7 +9084,7 @@ export declare const tlmenus: {
8965
9084
  *
8966
9085
  * @public
8967
9086
  */
8968
- hideOpenMenus(contextId?: string | undefined): void;
9087
+ hideOpenMenus(contextId?: string): void;
8969
9088
  /**
8970
9089
  * Show all hidden menus.
8971
9090
  *
@@ -8979,7 +9098,7 @@ export declare const tlmenus: {
8979
9098
  *
8980
9099
  * @public
8981
9100
  */
8982
- showOpenMenus(contextId?: string | undefined): void;
9101
+ showOpenMenus(contextId?: string): void;
8983
9102
  forContext(contextId: string): {
8984
9103
  addOpenMenu: (id: string) => void;
8985
9104
  clearOpenMenus: () => void;
@@ -9728,6 +9847,16 @@ export declare function useEditor(): Editor;
9728
9847
  /** @public */
9729
9848
  export declare function useEditorComponents(): Required<TLEditorComponents>;
9730
9849
 
9850
+ /**
9851
+ * The DOM node that {@link EditorPortal} renders into: an empty `display: contents` element the
9852
+ * editor renders last among its container's children, after the canvas and after the UI.
9853
+ *
9854
+ * Null until the container has mounted, so prefer {@link EditorPortal}, which handles that for you.
9855
+ *
9856
+ * @public
9857
+ */
9858
+ export declare function useEditorPortalHost(): HTMLElement | null;
9859
+
9731
9860
  /* Excluded from this release type: useEvent */
9732
9861
 
9733
9862
  /** @public */
@@ -9739,6 +9868,10 @@ export declare function useIsCropping(shapeId: TLShapeId): boolean;
9739
9868
  /** @public */
9740
9869
  export declare function useIsEditing(shapeId: TLShapeId): boolean;
9741
9870
 
9871
+ /* Excluded from this release type: useLicenseContext */
9872
+
9873
+ /* Excluded from this release type: useLicenseFeatureFlag */
9874
+
9742
9875
  /* Excluded from this release type: useLocalStore */
9743
9876
 
9744
9877
  /** @public */
@@ -9746,9 +9879,6 @@ export declare function useMaybeEditor(): Editor | null;
9746
9879
 
9747
9880
  /* Excluded from this release type: useOnMount */
9748
9881
 
9749
- /** @public */
9750
- export declare function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement | null>): void;
9751
-
9752
9882
  /** @public */
9753
9883
  export declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>): void;
9754
9884
 
@@ -9875,6 +10005,13 @@ export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreS
9875
10005
  /** @public */
9876
10006
  export declare function useTLStore(opts: TLStoreOptions): TLStore;
9877
10007
 
10008
+ /**
10009
+ * Position an element by writing its `transform` directly, outside React's render output — the
10010
+ * cheap path for elements that move at pointer/presence frequency.
10011
+ * @public
10012
+ */
10013
+ export declare function useTransform(ref: React.RefObject<HTMLElement | null | SVGElement>, x?: number, y?: number, scale?: number, rotate?: number, additionalOffset?: VecLike): void;
10014
+
9878
10015
  /**
9879
10016
  * React's useId hook returns a unique id for the component. However, it uses a colon in the id,
9880
10017
  * which is not valid for CSS selectors. This hook replaces the colon with an underscore.
@@ -9883,7 +10020,15 @@ export declare function useTLStore(opts: TLStoreOptions): TLStore;
9883
10020
  */
9884
10021
  export declare function useUniqueSafeId(suffix?: string): SafeId;
9885
10022
 
9886
- /** @public */
10023
+ /**
10024
+ * The height of the visible viewport, including the visual viewport's own offset.
10025
+ *
10026
+ * @deprecated Read `window.visualViewport` directly: this flattens the visible rectangle to a
10027
+ * single scalar, and keeping UI clear of the software keyboard usually needs the other edges too.
10028
+ * Unused since v3.14; will be removed in a future release.
10029
+ *
10030
+ * @public
10031
+ */
9887
10032
  export declare function useViewportHeight(): number;
9888
10033
 
9889
10034
  /* Excluded from this release type: ValidLicenseKeyResult */