@tldraw/editor 4.6.0-canary.1b07ed20aa1f → 4.6.0-canary.2152ec021b75

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 (155) hide show
  1. package/dist-cjs/index.d.ts +305 -168
  2. package/dist-cjs/index.js +7 -21
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js +3 -0
  5. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  6. package/dist-cjs/lib/components/default-components/CanvasOverlays.js +180 -0
  7. package/dist-cjs/lib/components/default-components/CanvasOverlays.js.map +7 -0
  8. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +31 -237
  9. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
  10. package/dist-cjs/lib/editor/Editor.js +40 -0
  11. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  12. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +14 -0
  13. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +2 -2
  14. package/dist-cjs/lib/editor/overlays/OverlayManager.js +154 -0
  15. package/dist-cjs/lib/editor/overlays/OverlayManager.js.map +7 -0
  16. package/dist-cjs/lib/editor/overlays/OverlayUtil.js +92 -0
  17. package/dist-cjs/lib/editor/overlays/OverlayUtil.js.map +7 -0
  18. package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +180 -0
  19. package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +7 -0
  20. package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js.map +2 -2
  21. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +7 -22
  22. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  23. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +32 -2
  24. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  25. package/dist-cjs/lib/editor/types/event-types.js.map +2 -2
  26. package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
  27. package/dist-cjs/lib/hooks/useEditorComponents.js +0 -28
  28. package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
  29. package/dist-cjs/lib/hooks/usePeerIds.js +1 -36
  30. package/dist-cjs/lib/hooks/usePeerIds.js.map +2 -2
  31. package/dist-cjs/lib/hooks/useShapeCulling.js +2 -1
  32. package/dist-cjs/lib/hooks/useShapeCulling.js.map +2 -2
  33. package/dist-cjs/lib/options.js +0 -1
  34. package/dist-cjs/lib/options.js.map +2 -2
  35. package/dist-cjs/version.js +3 -3
  36. package/dist-cjs/version.js.map +1 -1
  37. package/dist-esm/index.d.mts +305 -168
  38. package/dist-esm/index.mjs +11 -39
  39. package/dist-esm/index.mjs.map +2 -2
  40. package/dist-esm/lib/TldrawEditor.mjs +3 -0
  41. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  42. package/dist-esm/lib/components/default-components/CanvasOverlays.mjs +160 -0
  43. package/dist-esm/lib/components/default-components/CanvasOverlays.mjs.map +7 -0
  44. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +32 -238
  45. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +3 -3
  46. package/dist-esm/lib/editor/Editor.mjs +43 -0
  47. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  48. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +14 -0
  49. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +2 -2
  50. package/dist-esm/lib/editor/overlays/OverlayManager.mjs +136 -0
  51. package/dist-esm/lib/editor/overlays/OverlayManager.mjs.map +7 -0
  52. package/dist-esm/lib/editor/overlays/OverlayUtil.mjs +72 -0
  53. package/dist-esm/lib/editor/overlays/OverlayUtil.mjs.map +7 -0
  54. package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +160 -0
  55. package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +7 -0
  56. package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs.map +2 -2
  57. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +7 -22
  58. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  59. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +32 -2
  60. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  61. package/dist-esm/lib/editor/types/event-types.mjs.map +2 -2
  62. package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
  63. package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -28
  64. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
  65. package/dist-esm/lib/hooks/usePeerIds.mjs +2 -40
  66. package/dist-esm/lib/hooks/usePeerIds.mjs.map +2 -2
  67. package/dist-esm/lib/hooks/useShapeCulling.mjs +2 -1
  68. package/dist-esm/lib/hooks/useShapeCulling.mjs.map +2 -2
  69. package/dist-esm/lib/options.mjs +0 -1
  70. package/dist-esm/lib/options.mjs.map +2 -2
  71. package/dist-esm/version.mjs +3 -3
  72. package/dist-esm/version.mjs.map +1 -1
  73. package/editor.css +3 -219
  74. package/package.json +7 -7
  75. package/src/index.ts +11 -38
  76. package/src/lib/TldrawEditor.tsx +9 -0
  77. package/src/lib/components/default-components/CanvasOverlays.tsx +208 -0
  78. package/src/lib/components/default-components/DefaultCanvas.tsx +36 -312
  79. package/src/lib/editor/Editor.test.ts +3 -1
  80. package/src/lib/editor/Editor.ts +66 -0
  81. package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +14 -0
  82. package/src/lib/editor/overlays/OverlayManager.ts +183 -0
  83. package/src/lib/editor/overlays/OverlayUtil.ts +143 -0
  84. package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +230 -0
  85. package/src/lib/editor/shapes/BaseFrameLikeShapeUtil.tsx +4 -2
  86. package/src/lib/editor/shapes/ShapeUtil.ts +15 -25
  87. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +40 -3
  88. package/src/lib/editor/types/event-types.ts +2 -0
  89. package/src/lib/exports/getSvgJsx.test.ts +3 -1
  90. package/src/lib/hooks/EditorComponentsContext.tsx +0 -27
  91. package/src/lib/hooks/useEditorComponents.tsx +0 -28
  92. package/src/lib/hooks/usePeerIds.ts +6 -55
  93. package/src/lib/hooks/useShapeCulling.tsx +3 -1
  94. package/src/lib/options.ts +0 -7
  95. package/src/version.ts +3 -3
  96. package/dist-cjs/lib/components/LiveCollaborators.js +0 -152
  97. package/dist-cjs/lib/components/LiveCollaborators.js.map +0 -7
  98. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +0 -234
  99. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +0 -7
  100. package/dist-cjs/lib/components/default-components/DefaultBrush.js +0 -38
  101. package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +0 -7
  102. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +0 -71
  103. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +0 -7
  104. package/dist-cjs/lib/components/default-components/DefaultHandle.js +0 -56
  105. package/dist-cjs/lib/components/default-components/DefaultHandle.js.map +0 -7
  106. package/dist-cjs/lib/components/default-components/DefaultHandles.js +0 -28
  107. package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +0 -7
  108. package/dist-cjs/lib/components/default-components/DefaultScribble.js +0 -51
  109. package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +0 -7
  110. package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js +0 -69
  111. package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js.map +0 -7
  112. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +0 -107
  113. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +0 -7
  114. package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js +0 -28
  115. package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js.map +0 -7
  116. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +0 -102
  117. package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +0 -7
  118. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +0 -170
  119. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +0 -7
  120. package/dist-esm/lib/components/LiveCollaborators.mjs +0 -135
  121. package/dist-esm/lib/components/LiveCollaborators.mjs.map +0 -7
  122. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +0 -214
  123. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +0 -7
  124. package/dist-esm/lib/components/default-components/DefaultBrush.mjs +0 -18
  125. package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +0 -7
  126. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +0 -41
  127. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +0 -7
  128. package/dist-esm/lib/components/default-components/DefaultHandle.mjs +0 -26
  129. package/dist-esm/lib/components/default-components/DefaultHandle.mjs.map +0 -7
  130. package/dist-esm/lib/components/default-components/DefaultHandles.mjs +0 -8
  131. package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +0 -7
  132. package/dist-esm/lib/components/default-components/DefaultScribble.mjs +0 -21
  133. package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +0 -7
  134. package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs +0 -39
  135. package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs.map +0 -7
  136. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +0 -77
  137. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +0 -7
  138. package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs +0 -8
  139. package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs.map +0 -7
  140. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +0 -82
  141. package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +0 -7
  142. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +0 -142
  143. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +0 -7
  144. package/src/lib/components/LiveCollaborators.tsx +0 -180
  145. package/src/lib/components/default-components/CanvasShapeIndicators.tsx +0 -300
  146. package/src/lib/components/default-components/DefaultBrush.tsx +0 -35
  147. package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +0 -52
  148. package/src/lib/components/default-components/DefaultHandle.tsx +0 -42
  149. package/src/lib/components/default-components/DefaultHandles.tsx +0 -15
  150. package/src/lib/components/default-components/DefaultScribble.tsx +0 -31
  151. package/src/lib/components/default-components/DefaultSelectionForeground.tsx +0 -50
  152. package/src/lib/components/default-components/DefaultShapeIndicator.tsx +0 -104
  153. package/src/lib/components/default-components/DefaultShapeIndicatorErrorFallback.tsx +0 -9
  154. package/src/lib/components/default-components/DefaultShapeIndicators.tsx +0 -118
  155. package/src/lib/components/default-components/DefaultSnapIndictor.tsx +0 -174
@@ -19,7 +19,6 @@ import { JsonObject } from '@tldraw/utils';
19
19
  import { JSX } from 'react/jsx-runtime';
20
20
  import { LegacyMigrations } from '@tldraw/store';
21
21
  import { MigrationSequence } from '@tldraw/store';
22
- import { NamedExoticComponent } from 'react';
23
22
  import { Node as Node_2 } from '@tiptap/pm/model';
24
23
  import { PerformanceTracker } from '@tldraw/utils';
25
24
  import { PointerEvent as PointerEvent_2 } from 'react';
@@ -251,8 +250,10 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
251
250
  * return <SVGContainer>...</SVGContainer>
252
251
  * }
253
252
  *
254
- * override indicator(shape: MyContainerShape) {
255
- * return <rect width={shape.props.w} height={shape.props.h} />
253
+ * override getIndicatorPath(shape: MyContainerShape) {
254
+ * const path = new Path2D()
255
+ * path.rect(0, 0, shape.props.w, shape.props.h)
256
+ * return path
256
257
  * }
257
258
  * }
258
259
  * ```
@@ -929,51 +930,21 @@ export declare const DEFAULT_THEME: TLTheme;
929
930
  /** @public @react */
930
931
  export declare function DefaultBackground(): JSX.Element;
931
932
 
932
- /** @public @react */
933
- export declare const DefaultBrush: ({ brush, color, opacity, className }: TLBrushProps) => JSX.Element;
934
-
935
933
  /** @public @react */
936
934
  export declare function DefaultCanvas({ className }: TLCanvasComponentProps): JSX.Element;
937
935
 
938
- /** @public @react */
939
- export declare function DefaultCollaboratorHint({ className, zoom, point, color, viewport, opacity }: TLCollaboratorHintProps): JSX.Element;
940
-
941
- /** @public @react */
942
- export declare const DefaultCursor: NamedExoticComponent<TLCursorProps>;
943
-
944
936
  /** @public @react */
945
937
  export declare const DefaultErrorFallback: TLErrorFallbackComponent;
946
938
 
947
939
  /** @public @react */
948
940
  export declare function DefaultGrid({ x, y, z, size }: TLGridProps): JSX.Element;
949
941
 
950
- /** @public @react */
951
- export declare function DefaultHandle({ handle, isCoarse, className, zoom }: TLHandleProps): JSX.Element;
952
-
953
- /** @public @react */
954
- export declare const DefaultHandles: ({ children }: TLHandlesProps) => JSX.Element;
955
-
956
- /** @public @react */
957
- export declare function DefaultScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX.Element | null;
958
-
959
942
  /** @public @react */
960
943
  export declare function DefaultSelectionBackground({ bounds, rotation }: TLSelectionBackgroundProps): JSX.Element;
961
944
 
962
- /** @public @react */
963
- export declare function DefaultSelectionForeground({ bounds, rotation }: TLSelectionForegroundProps): JSX.Element;
964
-
965
- /** @public @react */
966
- export declare const DefaultShapeIndicator: NamedExoticComponent<TLShapeIndicatorProps>;
967
-
968
- /** @public @react */
969
- export declare const DefaultShapeIndicators: NamedExoticComponent<TLShapeIndicatorsProps>;
970
-
971
945
  /** @public @react */
972
946
  export declare const DefaultShapeWrapper: ForwardRefExoticComponent<TLShapeWrapperProps & RefAttributes<HTMLDivElement>>;
973
947
 
974
- /** @public @react */
975
- export declare function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps): JSX.Element;
976
-
977
948
  /** @public @react */
978
949
  export declare function DefaultSpinner(props: React.SVGProps<SVGSVGElement>): JSX.Element;
979
950
 
@@ -1053,7 +1024,6 @@ export declare const defaultTldrawOptions: {
1053
1024
  readonly tooltipDelayMs: 700;
1054
1025
  readonly uiCoarseDragDistanceSquared: 625;
1055
1026
  readonly uiDragDistanceSquared: 16;
1056
- readonly useCanvasIndicators: true;
1057
1027
  readonly zoomToFitPadding: 128;
1058
1028
  };
1059
1029
 
@@ -1153,7 +1123,7 @@ export declare class EdgeScrollManager {
1153
1123
  /** @public */
1154
1124
  export declare class Editor extends EventEmitter<TLEventMap> {
1155
1125
  readonly id: string;
1156
- constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
1126
+ constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, overlayUtils: overlayUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
1157
1127
  private readonly _getShapeVisibility?;
1158
1128
  private getIsShapeHiddenCache;
1159
1129
  isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
@@ -1235,6 +1205,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1235
1205
  setInterval: (handler: TimerHandler, timeout?: number | undefined, ...args: any[]) => number;
1236
1206
  setTimeout: (handler: TimerHandler, timeout?: number | undefined, ...args: any[]) => number;
1237
1207
  };
1208
+ /* Excluded from this release type: _collaboratorVisibilityClock */
1238
1209
  /**
1239
1210
  * A manager for the user and their preferences.
1240
1211
  *
@@ -1260,6 +1231,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1260
1231
  * @public
1261
1232
  */
1262
1233
  readonly scribbles: ScribbleManager;
1234
+ /**
1235
+ * A manager for canvas overlay UI elements (selection handles, shape handles, etc.).
1236
+ *
1237
+ * @public
1238
+ */
1239
+ readonly overlays: OverlayManager;
1263
1240
  /**
1264
1241
  * A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
1265
1242
  *
@@ -2512,6 +2489,23 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2512
2489
  * @public
2513
2490
  */
2514
2491
  getCollaboratorsOnCurrentPage(): TLInstancePresence[];
2492
+ /**
2493
+ * Returns a list of presence records for peer collaborators who should currently be
2494
+ * shown in the UI. Filters {@link Editor.getCollaborators} by activity state
2495
+ * (active / idle / inactive) and visibility rules such as following and highlighted
2496
+ * users. Re-evaluates on the collaborator visibility clock, so callers don't need to
2497
+ * drive their own activity timer.
2498
+ *
2499
+ * @public
2500
+ */
2501
+ getVisibleCollaborators(): TLInstancePresence[];
2502
+ /**
2503
+ * Returns a list of presence records for peer collaborators who should currently be
2504
+ * shown in the UI, filtered to those on the current page.
2505
+ *
2506
+ * @public
2507
+ */
2508
+ getVisibleCollaboratorsOnCurrentPage(): TLInstancePresence[];
2515
2509
  /**
2516
2510
  * Get the current user's ID for attribution purposes.
2517
2511
  * Also ensures a `user:` record exists in the store for the current user.
@@ -4852,7 +4846,7 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
4852
4846
  getDefaultProps(): TLGroupShape['props'];
4853
4847
  getGeometry(shape: TLGroupShape): Geometry2d;
4854
4848
  component(shape: TLGroupShape): JSX.Element | null;
4855
- indicator(shape: TLGroupShape): JSX.Element;
4849
+ getIndicatorPath(shape: TLGroupShape): Path2D;
4856
4850
  onChildrenChange(group: TLGroupShape): void;
4857
4851
  }
4858
4852
 
@@ -5480,6 +5474,179 @@ export declare function openWindow(url: string, target?: string, allowReferrer?:
5480
5474
  /** @public */
5481
5475
  export declare type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5482
5476
 
5477
+ /** @public */
5478
+ export declare class OverlayManager {
5479
+ readonly editor: Editor;
5480
+ constructor(editor: Editor);
5481
+ /* Excluded from this release type: _overlayUtils */
5482
+ /* Excluded from this release type: registerUtil */
5483
+ /**
5484
+ * Get an overlay util by type string, overlay instance, or by passing
5485
+ * a util class as a generic parameter for type-safe lookup.
5486
+ *
5487
+ * @example
5488
+ * ```ts
5489
+ * const util = editor.overlays.getOverlayUtil('brush')
5490
+ * const util = editor.overlays.getOverlayUtil<BrushOverlayUtil>('brush')
5491
+ * const util = editor.overlays.getOverlayUtil(myOverlay)
5492
+ * ```
5493
+ *
5494
+ * @public
5495
+ */
5496
+ getOverlayUtil<T extends OverlayUtil>(type: T extends OverlayUtil<infer O> ? O['type'] : string): T;
5497
+ getOverlayUtil<O extends TLOverlay>(overlay: O): OverlayUtil<O>;
5498
+ /**
5499
+ * Returns all registered overlay utils in paint order (ascending zIndex).
5500
+ * Utils with the same zIndex preserve their registration order.
5501
+ *
5502
+ * @public
5503
+ */
5504
+ getOverlayUtilsInZOrder(): OverlayUtil[];
5505
+ /**
5506
+ * Reactive list of active overlay utils paired with the overlays they
5507
+ * produced for the current editor state, in paint order (ascending
5508
+ * zIndex). Both the hit-test and render paths read from this single
5509
+ * cached scan instead of each re-deriving the active set. Active utils
5510
+ * are included even when their `getOverlays()` returns an empty array,
5511
+ * since `render()` may still draw non-interactive UI (e.g. the selection
5512
+ * bounding box during brushing).
5513
+ *
5514
+ * @public
5515
+ */
5516
+ getActiveOverlayEntries(): TLOverlayEntry[];
5517
+ /**
5518
+ * Reactively computed list of all currently active overlays, in paint order.
5519
+ * @public
5520
+ */
5521
+ getCurrentOverlays(): TLOverlay[];
5522
+ private _geometryCache;
5523
+ /**
5524
+ * Get hit-test geometry for an overlay, cached by overlay identity. Lets
5525
+ * hit-testing on a pointermove storm skip the per-overlay geometry
5526
+ * allocation that {@link OverlayUtil.getGeometry} would otherwise do on
5527
+ * every call.
5528
+ *
5529
+ * @public
5530
+ */
5531
+ getOverlayGeometry(overlay: TLOverlay): Geometry2d | null;
5532
+ /**
5533
+ * The currently hovered overlay id.
5534
+ * @public
5535
+ */
5536
+ private _hoveredOverlayId;
5537
+ getHoveredOverlayId(): null | string;
5538
+ getHoveredOverlay(): null | TLOverlay;
5539
+ setHoveredOverlay(id: null | string): void;
5540
+ /**
5541
+ * Hit test all active overlays at a given page point.
5542
+ * Returns the topmost overlay whose geometry contains the point, or null.
5543
+ * Utils are walked from highest zIndex to lowest so the overlay painted on
5544
+ * top also wins the hit test. Within a util, overlays are walked in
5545
+ * array order: the first overlay whose geometry contains the point wins,
5546
+ * so utils should place highest-priority overlays first in `getOverlays`.
5547
+ * Interactive overlays (those with geometry) are checked; non-interactive are skipped.
5548
+ *
5549
+ * @param point - Point in page coordinates
5550
+ * @param margin - Hit test margin
5551
+ * @public
5552
+ */
5553
+ getOverlayAtPoint(point: VecLike, margin?: number): null | TLOverlay;
5554
+ }
5555
+
5556
+ /**
5557
+ * Base class for overlay utilities. Overlays are ephemeral UI elements rendered
5558
+ * on top of the canvas (selection handles, rotation corners, shape handles, etc.).
5559
+ *
5560
+ * Each OverlayUtil defines a type of overlay and knows how to:
5561
+ * - Determine when its overlays should be active (predicate)
5562
+ * - Produce overlay instances from current editor state
5563
+ * - Provide hit-test geometry for interactive overlays
5564
+ * - Provide cursor style on hover
5565
+ * - Render into a canvas 2D context
5566
+ *
5567
+ * @public
5568
+ */
5569
+ export declare abstract class OverlayUtil<T extends TLOverlay = TLOverlay> {
5570
+ editor: Editor;
5571
+ constructor(editor: Editor);
5572
+ static type: string;
5573
+ /**
5574
+ * Options for this overlay util. Override this to provide customization options.
5575
+ * Use {@link OverlayUtil.configure} to customize existing overlay utils.
5576
+ *
5577
+ * `zIndex` controls paint and hit-test order across utils — higher numbers
5578
+ * paint on top and are hit-tested first. Ties resolve by registration order.
5579
+ * Defaults to `0`; built-in utils use larger integers (100, 200, …) with
5580
+ * gaps so custom utils can slot between.
5581
+ *
5582
+ * @public
5583
+ */
5584
+ options: {
5585
+ zIndex?: number;
5586
+ };
5587
+ /**
5588
+ * Create a new overlay util class with the given options merged in.
5589
+ *
5590
+ * @example
5591
+ * ```ts
5592
+ * const MyBrush = BrushOverlayUtil.configure({ fill: 'rgba(0,0,255,0.1)' })
5593
+ * ```
5594
+ *
5595
+ * @public
5596
+ */
5597
+ static configure<T extends TLOverlayUtilConstructor<any>>(this: T, options: T extends new (...args: any[]) => {
5598
+ options: infer Options;
5599
+ } ? Partial<Options> : never): T;
5600
+ /**
5601
+ * Whether this overlay util's overlays should currently be active.
5602
+ * Checked reactively to determine which overlays exist at any given time.
5603
+ */
5604
+ abstract isActive(): boolean;
5605
+ /**
5606
+ * Returns the overlay instances that currently exist.
5607
+ * Called only when `isActive()` returns true.
5608
+ */
5609
+ abstract getOverlays(): T[];
5610
+ /**
5611
+ * Returns hit-test geometry for an overlay instance, in page coordinates.
5612
+ * Return null for non-interactive overlays (e.g. snap indicators, scribbles).
5613
+ */
5614
+ getGeometry(_overlay: T): Geometry2d | null;
5615
+ /**
5616
+ * Returns the cursor type to show when hovering this overlay.
5617
+ */
5618
+ getCursor(_overlay: T): TLCursorType | undefined;
5619
+ /**
5620
+ * Called when the user points down on this overlay, before the default
5621
+ * routing runs. Acts as an interrupt: define it to take over the event.
5622
+ *
5623
+ * Return `false` to continue with the default behavior (e.g. the
5624
+ * built-in rotate/resize handle transitions or shape-handle dispatch).
5625
+ * Return `true` — or nothing at all — to skip the default. In other
5626
+ * words, once you override this method you own the event unless you
5627
+ * explicitly opt back in by returning `false`.
5628
+ */
5629
+ onPointerDown?(overlay: T, info: TLPointerEventInfo): boolean | void;
5630
+ /**
5631
+ * Render all active overlays into the canvas context.
5632
+ * The context is already transformed to page space (camera transform applied).
5633
+ * Called reactively when overlays or editor state changes.
5634
+ */
5635
+ render(_ctx: CanvasRenderingContext2D, _overlays: T[]): void;
5636
+ /**
5637
+ * Optional: render all active overlays into the minimap canvas.
5638
+ * The context is already transformed to page space (minimap camera applied),
5639
+ * so overlays can use the same page-space coordinates as in {@link OverlayUtil.render}.
5640
+ *
5641
+ * `zoom` is the minimap's screen-pixels-per-page-unit, analogous to
5642
+ * `editor.getCamera().z`; use `1 / zoom` for one-minimap-pixel line widths.
5643
+ *
5644
+ * Most overlays should leave this blank — only overlays that are meaningful
5645
+ * at minimap scale (e.g. brushes, collaborator cursors) should opt in.
5646
+ */
5647
+ renderMinimap(_ctx: CanvasRenderingContext2D, _overlays: T[], _zoom: number): void;
5648
+ }
5649
+
5483
5650
  /**
5484
5651
  * Parses a string created by {@link createDeepLinkString} back into a deep link descriptor.
5485
5652
  *
@@ -6012,6 +6179,29 @@ export declare function setRuntimeOverrides(input: Partial<typeof runtime>): voi
6012
6179
  /** @public */
6013
6180
  export declare function setUserPreferences(user: TLUserPreferences): void;
6014
6181
 
6182
+ /**
6183
+ * Overlay util for shape indicators — the selection / hover / hint outlines drawn
6184
+ * under the selection foreground. Paints local indicators in the theme's
6185
+ * selection color and remote collaborator indicators in each peer's color.
6186
+ *
6187
+ * Non-interactive: contributes no hit-test geometry.
6188
+ *
6189
+ * @public
6190
+ */
6191
+ export declare class ShapeIndicatorOverlayUtil extends OverlayUtil<TLShapeIndicatorOverlay> {
6192
+ static type: string;
6193
+ options: {
6194
+ hintedLineWidth: number;
6195
+ lineWidth: number;
6196
+ zIndex: number;
6197
+ };
6198
+ private _instanceFlags$;
6199
+ isActive(): boolean;
6200
+ getOverlays(): TLShapeIndicatorOverlay[];
6201
+ render(ctx: CanvasRenderingContext2D, overlays: TLShapeIndicatorOverlay[]): void;
6202
+ private _strokeIndicatorBatch;
6203
+ }
6204
+
6015
6205
  /** @public */
6016
6206
  export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
6017
6207
  editor: Editor;
@@ -6108,37 +6298,30 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
6108
6298
  */
6109
6299
  abstract component(shape: Shape): any;
6110
6300
  /**
6111
- * Get JSX describing the shape's indicator (as an SVG element).
6112
- *
6113
- * @param shape - The shape.
6114
- * @public
6115
- */
6116
- abstract indicator(shape: Shape): any;
6117
- /**
6118
- * Whether to use the legacy React-based indicator rendering.
6301
+ * Get a Path2D (or a richer object with clip/additional paths) for rendering the
6302
+ * shape's indicator on the canvas. Shapes that return `undefined` will not render
6303
+ * an indicator.
6119
6304
  *
6120
- * Override this to return `false` if your shape implements {@link ShapeUtil.getIndicatorPath}
6121
- * for canvas-based indicator rendering.
6305
+ * For complex indicators that need clipping (e.g., arrows with labels), return an
6306
+ * object with `path`, `clipPath`, and `additionalPaths` properties.
6122
6307
  *
6123
- * @returns `true` to use SVG indicators (default), `false` to use canvas indicators.
6308
+ * @param shape - The shape.
6309
+ * @returns A Path2D to stroke, or an object with clipping info, or undefined to skip.
6124
6310
  * @public
6125
6311
  */
6126
- useLegacyIndicator(): boolean;
6312
+ abstract getIndicatorPath(shape: Shape): TLIndicatorPath | undefined;
6127
6313
  /**
6128
- * Get a Path2D for rendering the shape's indicator on the canvas.
6129
- *
6130
- * When implemented, this is used instead of {@link ShapeUtil.indicator} for more
6131
- * efficient canvas-based indicator rendering. Shapes that return `undefined` will
6132
- * fall back to SVG-based rendering via {@link ShapeUtil.indicator}.
6314
+ * Get JSX describing the shape's indicator (as an SVG element).
6133
6315
  *
6134
- * For complex indicators that need clipping (e.g., arrows with labels), return an
6135
- * object with `path`, `clipPath`, and `additionalPaths` properties.
6316
+ * @deprecated SVG indicators are no longer rendered. Override
6317
+ * {@link ShapeUtil.getIndicatorPath} instead. This stub is retained so legacy
6318
+ * subclasses that still call `super.indicator()` keep type-checking; new shapes
6319
+ * should not implement it.
6136
6320
  *
6137
6321
  * @param shape - The shape.
6138
- * @returns A Path2D to stroke, or an object with clipping info, or undefined to use SVG fallback.
6139
6322
  * @public
6140
6323
  */
6141
- getIndicatorPath(shape: Shape): TLIndicatorPath | undefined;
6324
+ indicator(_shape: Shape): any;
6142
6325
  /**
6143
6326
  * Get the font faces that should be rendered in the document in order for this shape to render
6144
6327
  * correctly.
@@ -7079,6 +7262,9 @@ export declare type TLAnyAssetUtilConstructor = TLAssetUtilConstructor<any>;
7079
7262
  /** @public */
7080
7263
  export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
7081
7264
 
7265
+ /** @public */
7266
+ export declare type TLAnyOverlayUtilConstructor = TLOverlayUtilConstructor<any>;
7267
+
7082
7268
  /** @public */
7083
7269
  export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
7084
7270
 
@@ -7122,15 +7308,6 @@ export declare interface TLBindingUtilConstructor<T extends TLBinding, U extends
7122
7308
  migrations?: TLPropsMigrations;
7123
7309
  }
7124
7310
 
7125
- /** @public */
7126
- export declare interface TLBrushProps {
7127
- userId?: string;
7128
- brush: BoxModel;
7129
- color?: string;
7130
- opacity?: number;
7131
- className?: string;
7132
- }
7133
-
7134
7311
  /** @public */
7135
7312
  export declare interface TLCameraConstraints {
7136
7313
  /** The bounds (in page space) of the constrained space */
@@ -7318,17 +7495,6 @@ export declare interface TLClipboardWriteInfo {
7318
7495
  readonly source: 'menu' | 'native';
7319
7496
  }
7320
7497
 
7321
- /** @public */
7322
- export declare interface TLCollaboratorHintProps {
7323
- userId: string;
7324
- className?: string;
7325
- point: VecModel;
7326
- viewport: Box;
7327
- zoom: number;
7328
- opacity?: number;
7329
- color: string;
7330
- }
7331
-
7332
7498
  /** @public */
7333
7499
  export declare type TLCompleteEvent = (info: TLCompleteEventInfo) => void;
7334
7500
 
@@ -7373,17 +7539,6 @@ export declare interface TLCurrentUser {
7373
7539
  readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
7374
7540
  }
7375
7541
 
7376
- /** @public */
7377
- export declare interface TLCursorProps {
7378
- userId: string;
7379
- className?: string;
7380
- point: null | VecModel;
7381
- zoom: number;
7382
- color?: string;
7383
- name: null | string;
7384
- chatMessage: string;
7385
- }
7386
-
7387
7542
  /** @public */
7388
7543
  export declare type TLDeepLink = {
7389
7544
  bounds: BoxModel;
@@ -7477,6 +7632,10 @@ export declare interface TldrawEditorBaseProps {
7477
7632
  * An array of asset utils to use in the editor.
7478
7633
  */
7479
7634
  assetUtils?: readonly TLAnyAssetUtilConstructor[];
7635
+ /**
7636
+ * An array of overlay utils to use in the editor for canvas overlay UI elements.
7637
+ */
7638
+ overlayUtils?: readonly TLAnyOverlayUtilConstructor[];
7480
7639
  /**
7481
7640
  * An array of tools to add to the editor's state chart.
7482
7641
  */
@@ -7786,12 +7945,6 @@ export declare interface TldrawOptions {
7786
7945
  * viewport's page dimensions regardless of overview zoom changes.
7787
7946
  */
7788
7947
  readonly quickZoomPreservesScreenBounds: boolean;
7789
- /**
7790
- * Whether to use 2D canvas rendering for shape indicators. When true (default),
7791
- * shapes that support it will render indicators on a 2D canvas for better
7792
- * performance. When false, all indicators use legacy SVG rendering.
7793
- */
7794
- readonly useCanvasIndicators: boolean;
7795
7948
  /**
7796
7949
  * Called before content is written to the clipboard during a copy or cut operation.
7797
7950
  * Receives the serialized content (shapes, bindings, assets) and can filter or transform
@@ -7879,34 +8032,17 @@ export declare interface TLDropShapesOverInfo {
7879
8032
  /** @public */
7880
8033
  export declare interface TLEditorComponents {
7881
8034
  Background?: ComponentType | null;
7882
- Brush?: ComponentType<TLBrushProps> | null;
7883
8035
  Canvas?: ComponentType<TLCanvasComponentProps> | null;
7884
- CollaboratorBrush?: ComponentType<TLBrushProps> | null;
7885
- CollaboratorCursor?: ComponentType<TLCursorProps> | null;
7886
- CollaboratorHint?: ComponentType<TLCollaboratorHintProps> | null;
7887
- CollaboratorScribble?: ComponentType<TLScribbleProps> | null;
7888
- CollaboratorShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null;
7889
- Cursor?: ComponentType<TLCursorProps> | null;
7890
8036
  Grid?: ComponentType<TLGridProps> | null;
7891
- Handle?: ComponentType<TLHandleProps> | null;
7892
- Handles?: ComponentType<TLHandlesProps> | null;
7893
8037
  InFrontOfTheCanvas?: ComponentType | null;
7894
8038
  LoadingScreen?: ComponentType | null;
7895
8039
  OnTheCanvas?: ComponentType | null;
7896
- Overlays?: ComponentType | null;
7897
- Scribble?: ComponentType<TLScribbleProps> | null;
7898
8040
  SelectionBackground?: ComponentType<TLSelectionBackgroundProps> | null;
7899
- SelectionForeground?: ComponentType<TLSelectionForegroundProps> | null;
7900
- ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null;
7901
- ShapeIndicators?: ComponentType | null;
7902
8041
  ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null;
7903
- SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null;
7904
8042
  Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null;
7905
8043
  SvgDefs?: ComponentType | null;
7906
- ZoomBrush?: ComponentType<TLBrushProps> | null;
7907
8044
  ErrorFallback?: TLErrorFallbackComponent;
7908
8045
  ShapeErrorFallback?: TLShapeErrorFallbackComponent;
7909
- ShapeIndicatorErrorFallback?: TLShapeIndicatorErrorFallbackComponent;
7910
8046
  }
7911
8047
 
7912
8048
  /** @public */
@@ -7928,6 +8064,11 @@ export declare interface TLEditorOptions {
7928
8064
  * An array of asset utils to use in the editor. These will be used to handle asset-type-specific behavior.
7929
8065
  */
7930
8066
  assetUtils?: readonly TLAnyAssetUtilConstructor[];
8067
+ /**
8068
+ * An array of overlay utils to use in the editor. These define canvas overlay UI elements
8069
+ * like selection handles, rotation corners, shape handles, etc.
8070
+ */
8071
+ overlayUtils?: readonly TLAnyOverlayUtilConstructor[];
7931
8072
  /**
7932
8073
  * An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
7933
8074
  */
@@ -8294,20 +8435,6 @@ export declare interface TLHandleDragInfo<T extends TLShape> {
8294
8435
  initial?: T | undefined;
8295
8436
  }
8296
8437
 
8297
- /** @public */
8298
- export declare interface TLHandleProps {
8299
- shapeId: TLShapeId;
8300
- handle: TLHandle;
8301
- zoom: number;
8302
- isCoarse: boolean;
8303
- className?: string;
8304
- }
8305
-
8306
- /** @public */
8307
- export declare interface TLHandlesProps {
8308
- children: ReactNode;
8309
- }
8310
-
8311
8438
  /** @public */
8312
8439
  export declare interface TLHistoryBatchOptions {
8313
8440
  /**
@@ -8637,6 +8764,42 @@ export declare const tlmenus: {
8637
8764
  */
8638
8765
  export declare type TLOnMountHandler = (editor: Editor) => (() => undefined | void) | undefined | void;
8639
8766
 
8767
+ /** @public */
8768
+ export declare interface TLOverlay<Props = Record<string, unknown>> {
8769
+ /**
8770
+ * Globally unique id for this overlay instance across all overlay utils.
8771
+ * Hit-test and hover lookup key on `id` alone, so utils must namespace their
8772
+ * ids (e.g. `'selection_fg:top_left'`, `'handle:<shapeId>:<handleId>'`) to
8773
+ * avoid colliding with overlays from other utils.
8774
+ */
8775
+ id: string;
8776
+ /** The overlay util type that owns this instance */
8777
+ type: string;
8778
+ /** Arbitrary props for the overlay (handle id, corner name, etc.) */
8779
+ props: Props;
8780
+ }
8781
+
8782
+ /**
8783
+ * An active overlay util paired with the overlays it produced for the current
8784
+ * editor state. Returned by {@link OverlayManager.getActiveOverlayEntries} so
8785
+ * hit-test, render, and debug paths share a single scan per reactive tick.
8786
+ *
8787
+ * @public
8788
+ */
8789
+ export declare interface TLOverlayEntry {
8790
+ util: OverlayUtil;
8791
+ overlays: TLOverlay[];
8792
+ }
8793
+
8794
+ /** @public */
8795
+ export declare interface TLOverlayUtilConstructor<U extends OverlayUtil = OverlayUtil> {
8796
+ new (editor: Editor): U;
8797
+ type: string;
8798
+ configure<T extends TLOverlayUtilConstructor<any>>(this: T, options: T extends new (...args: any[]) => {
8799
+ options: infer Options;
8800
+ } ? Partial<Options> : never): T;
8801
+ }
8802
+
8640
8803
  /**
8641
8804
  * Map of all performance event names to their payload types.
8642
8805
  * Used with {@link PerformanceManager.on} and {@link PerformanceManager.once}.
@@ -8764,6 +8927,10 @@ export declare type TLPointerEventTarget = {
8764
8927
  handle?: TLSelectionHandle;
8765
8928
  shape?: undefined;
8766
8929
  target: 'selection';
8930
+ } | {
8931
+ overlay: TLOverlay;
8932
+ shape?: undefined;
8933
+ target: 'overlay';
8767
8934
  } | {
8768
8935
  shape: TLShape;
8769
8936
  target: 'shape';
@@ -8834,28 +9001,12 @@ export declare type TLResizeShapeOptions = Partial<{
8834
9001
 
8835
9002
  /* Excluded from this release type: TLRotationSnapshot */
8836
9003
 
8837
- /** @public */
8838
- export declare interface TLScribbleProps {
8839
- userId?: string;
8840
- scribble: TLScribble;
8841
- zoom: number;
8842
- color?: string;
8843
- opacity?: number;
8844
- className?: string;
8845
- }
8846
-
8847
9004
  /** @public */
8848
9005
  export declare interface TLSelectionBackgroundProps {
8849
9006
  bounds: Box;
8850
9007
  rotation: number;
8851
9008
  }
8852
9009
 
8853
- /** @public */
8854
- export declare interface TLSelectionForegroundProps {
8855
- bounds: Box;
8856
- rotation: number;
8857
- }
8858
-
8859
9010
  /** @public */
8860
9011
  export declare type TLSelectionHandle = RotateCorner | SelectionCorner | SelectionEdge;
8861
9012
 
@@ -8890,26 +9041,15 @@ export declare type TLShapeErrorFallbackComponent = ComponentType<{
8890
9041
  }>;
8891
9042
 
8892
9043
  /** @public */
8893
- export declare type TLShapeIndicatorErrorFallbackComponent = ComponentType<{
8894
- error: unknown;
8895
- }>;
8896
-
8897
- /** @public */
8898
- export declare interface TLShapeIndicatorProps {
8899
- userId?: string;
8900
- shapeId: TLShapeId;
8901
- color?: string | undefined;
8902
- opacity?: number;
8903
- className?: string;
8904
- hidden?: boolean;
8905
- }
8906
-
8907
- /** @public */
8908
- export declare interface TLShapeIndicatorsProps {
8909
- /** Whether to hide all of the indicators */
8910
- hideAll?: boolean;
8911
- /** Whether to show all of the indicators */
8912
- showAll?: boolean;
9044
+ export declare interface TLShapeIndicatorOverlay extends TLOverlay {
9045
+ props: {
9046
+ collaboratorIndicators: Array<{
9047
+ color: string;
9048
+ shapeIds: TLShapeId[];
9049
+ }>;
9050
+ hintingShapeIds: TLShapeId[];
9051
+ idsToDisplay: TLShapeId[];
9052
+ };
8913
9053
  }
8914
9054
 
8915
9055
  /**
@@ -8997,13 +9137,6 @@ export declare interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDi
8997
9137
  children: ReactNode;
8998
9138
  }
8999
9139
 
9000
- /** @public */
9001
- export declare interface TLSnapIndicatorProps {
9002
- className?: string;
9003
- line: SnapIndicator;
9004
- zoom: number;
9005
- }
9006
-
9007
9140
  /** @public */
9008
9141
  export declare interface TLStateNodeConstructor {
9009
9142
  new (editor: Editor, parent?: StateNode): StateNode;
@@ -9392,6 +9525,10 @@ export declare function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement
9392
9525
  export declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>): void;
9393
9526
 
9394
9527
  /**
9528
+ * Reactive list of peer user IDs for collaborators currently shown in the UI.
9529
+ * Mirrors {@link Editor.getVisibleCollaborators} — peers fade out as they
9530
+ * transition to idle/inactive, without requiring a manual re-render.
9531
+ *
9395
9532
  * @returns The list of peer UserIDs
9396
9533
  * @public
9397
9534
  */