@tldraw/editor 4.6.0-canary.ba8f2c41e1ba → 4.6.0-canary.bda13b9dbf8f
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.
- package/dist-cjs/index.d.ts +446 -167
- package/dist-cjs/index.js +12 -21
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +3 -0
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/CanvasOverlays.js +180 -0
- package/dist-cjs/lib/components/default-components/CanvasOverlays.js.map +7 -0
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +33 -238
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
- package/dist-cjs/lib/editor/Editor.js +102 -32
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +98 -0
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +14 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +2 -2
- package/dist-cjs/lib/editor/overlays/OverlayManager.js +154 -0
- package/dist-cjs/lib/editor/overlays/OverlayManager.js.map +7 -0
- package/dist-cjs/lib/editor/overlays/OverlayUtil.js +92 -0
- package/dist-cjs/lib/editor/overlays/OverlayUtil.js.map +7 -0
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +161 -0
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +7 -0
- package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js +76 -0
- package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js.map +7 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +17 -22
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +32 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/types/event-types.js.map +2 -2
- package/dist-cjs/lib/exports/fetchCache.js +1 -1
- package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +2 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +0 -28
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePeerIds.js +1 -36
- package/dist-cjs/lib/hooks/usePeerIds.js.map +2 -2
- package/dist-cjs/lib/hooks/useShapeCulling.js +2 -1
- package/dist-cjs/lib/hooks/useShapeCulling.js.map +2 -2
- package/dist-cjs/lib/options.js +0 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -0
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +446 -167
- package/dist-esm/index.mjs +17 -39
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +3 -0
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/CanvasOverlays.mjs +160 -0
- package/dist-esm/lib/components/default-components/CanvasOverlays.mjs.map +7 -0
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +34 -239
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +3 -3
- package/dist-esm/lib/editor/Editor.mjs +102 -33
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +83 -0
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +14 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +2 -2
- package/dist-esm/lib/editor/overlays/OverlayManager.mjs +136 -0
- package/dist-esm/lib/editor/overlays/OverlayManager.mjs.map +7 -0
- package/dist-esm/lib/editor/overlays/OverlayUtil.mjs +72 -0
- package/dist-esm/lib/editor/overlays/OverlayUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +141 -0
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs +56 -0
- package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +17 -22
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +32 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/types/event-types.mjs.map +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +2 -1
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -28
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePeerIds.mjs +2 -40
- package/dist-esm/lib/hooks/usePeerIds.mjs.map +2 -2
- package/dist-esm/lib/hooks/useShapeCulling.mjs +2 -1
- package/dist-esm/lib/hooks/useShapeCulling.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +0 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -0
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +3 -219
- package/package.json +7 -7
- package/src/index.ts +14 -38
- package/src/lib/TldrawEditor.tsx +9 -0
- package/src/lib/components/default-components/CanvasOverlays.tsx +208 -0
- package/src/lib/components/default-components/DefaultCanvas.tsx +38 -313
- package/src/lib/editor/Editor.test.ts +3 -1
- package/src/lib/editor/Editor.ts +109 -32
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +98 -0
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +13 -2
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +1 -1
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +14 -0
- package/src/lib/editor/overlays/OverlayManager.ts +183 -0
- package/src/lib/editor/overlays/OverlayUtil.ts +143 -0
- package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +216 -0
- package/src/lib/editor/shapes/BaseFrameLikeShapeUtil.tsx +123 -0
- package/src/lib/editor/shapes/ShapeUtil.ts +26 -25
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +40 -3
- package/src/lib/editor/types/event-types.ts +2 -0
- package/src/lib/exports/fetchCache.ts +2 -4
- package/src/lib/exports/getSvgJsx.test.ts +3 -1
- package/src/lib/exports/getSvgJsx.tsx +2 -1
- package/src/lib/hooks/EditorComponentsContext.tsx +0 -27
- package/src/lib/hooks/useEditorComponents.tsx +0 -28
- package/src/lib/hooks/usePeerIds.ts +6 -55
- package/src/lib/hooks/useShapeCulling.tsx +3 -1
- package/src/lib/options.ts +0 -7
- package/src/lib/utils/sync/TLLocalSyncClient.ts +3 -0
- package/src/version.ts +3 -3
- package/dist-cjs/lib/components/LiveCollaborators.js +0 -152
- package/dist-cjs/lib/components/LiveCollaborators.js.map +0 -7
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +0 -234
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultBrush.js +0 -38
- package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +0 -71
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultHandle.js +0 -56
- package/dist-cjs/lib/components/default-components/DefaultHandle.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultHandles.js +0 -28
- package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultScribble.js +0 -51
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js +0 -69
- package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +0 -107
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js +0 -28
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +0 -102
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +0 -170
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +0 -7
- package/dist-esm/lib/components/LiveCollaborators.mjs +0 -135
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +0 -214
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs +0 -18
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +0 -41
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultHandle.mjs +0 -26
- package/dist-esm/lib/components/default-components/DefaultHandle.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs +0 -8
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs +0 -21
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs +0 -39
- package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +0 -77
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs +0 -8
- package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +0 -82
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +0 -142
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +0 -7
- package/src/lib/components/LiveCollaborators.tsx +0 -180
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +0 -300
- package/src/lib/components/default-components/DefaultBrush.tsx +0 -35
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +0 -52
- package/src/lib/components/default-components/DefaultHandle.tsx +0 -42
- package/src/lib/components/default-components/DefaultHandles.tsx +0 -15
- package/src/lib/components/default-components/DefaultScribble.tsx +0 -31
- package/src/lib/components/default-components/DefaultSelectionForeground.tsx +0 -50
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +0 -104
- package/src/lib/components/default-components/DefaultShapeIndicatorErrorFallback.tsx +0 -9
- package/src/lib/components/default-components/DefaultShapeIndicators.tsx +0 -118
- package/src/lib/components/default-components/DefaultSnapIndictor.tsx +0 -174
package/dist-cjs/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -220,6 +219,56 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
220
219
|
getInterpolatedProps(startShape: Shape, endShape: Shape, t: number): Shape['props'];
|
|
221
220
|
}
|
|
222
221
|
|
|
222
|
+
/**
|
|
223
|
+
* A base class for frame-like shapes — containers that clip their children,
|
|
224
|
+
* require full-brush selection, block erasure from inside, and support
|
|
225
|
+
* drag-and-drop reparenting.
|
|
226
|
+
*
|
|
227
|
+
* Extending this class is the easiest way to create a custom frame-like shape.
|
|
228
|
+
* It provides sensible defaults for all frame-like behaviors:
|
|
229
|
+
*
|
|
230
|
+
* - `isFrameLike()` returns `true`
|
|
231
|
+
* - `providesBackgroundForChildren()` returns `true`
|
|
232
|
+
* - `canReceiveNewChildrenOfType()` returns `true` unless the container is locked
|
|
233
|
+
* - `getClipPath()` returns the shape geometry's vertices
|
|
234
|
+
* - `onDragShapesIn()` reparents shapes into the frame (with index restoration)
|
|
235
|
+
* - `onDragShapesOut()` reparents shapes back to the page
|
|
236
|
+
*
|
|
237
|
+
* All methods can be overridden for custom behavior.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* class MyContainerUtil extends BaseFrameLikeShapeUtil<MyContainerShape> {
|
|
242
|
+
* static override type = 'my-container' as const
|
|
243
|
+
* static override props = myContainerShapeProps
|
|
244
|
+
*
|
|
245
|
+
* override getDefaultProps() {
|
|
246
|
+
* return { w: 300, h: 200 }
|
|
247
|
+
* }
|
|
248
|
+
*
|
|
249
|
+
* override component(shape: MyContainerShape) {
|
|
250
|
+
* return <SVGContainer>...</SVGContainer>
|
|
251
|
+
* }
|
|
252
|
+
*
|
|
253
|
+
* override getIndicatorPath(shape: MyContainerShape) {
|
|
254
|
+
* const path = new Path2D()
|
|
255
|
+
* path.rect(0, 0, shape.props.w, shape.props.h)
|
|
256
|
+
* return path
|
|
257
|
+
* }
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
export declare abstract class BaseFrameLikeShapeUtil<Shape extends TLBaseBoxShape> extends BaseBoxShapeUtil<Shape> {
|
|
264
|
+
isFrameLike(_shape: Shape): boolean;
|
|
265
|
+
providesBackgroundForChildren(): boolean;
|
|
266
|
+
canReceiveNewChildrenOfType(shape: Shape, _type: TLShape['type']): boolean;
|
|
267
|
+
getClipPath(shape: Shape): undefined | Vec[];
|
|
268
|
+
onDragShapesIn(shape: Shape, draggingShapes: TLShape[], { initialParentIds, initialIndices }: TLDragShapesInInfo): void;
|
|
269
|
+
onDragShapesOut(shape: Shape, draggingShapes: TLShape[], info: TLDragShapesOutInfo): void;
|
|
270
|
+
}
|
|
271
|
+
|
|
223
272
|
/** @public */
|
|
224
273
|
export declare interface BatchMeasurementRequest {
|
|
225
274
|
html: string;
|
|
@@ -719,6 +768,49 @@ export declare class ClickManager {
|
|
|
719
768
|
*/
|
|
720
769
|
export declare function clockwiseAngleDist(a0: number, a1: number): number;
|
|
721
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Tracks remote peers and exposes the collaborator-related queries used by the
|
|
773
|
+
* editor and its overlays. Encapsulates the visibility clock that periodically
|
|
774
|
+
* re-evaluates which collaborators should be visible based on activity.
|
|
775
|
+
*
|
|
776
|
+
* Accessed via {@link Editor.collaborators}.
|
|
777
|
+
*
|
|
778
|
+
* @public
|
|
779
|
+
*/
|
|
780
|
+
export declare class CollaboratorsManager {
|
|
781
|
+
private readonly editor;
|
|
782
|
+
constructor(editor: Editor);
|
|
783
|
+
/**
|
|
784
|
+
* Drives reactive re-evaluation of {@link CollaboratorsManager.getVisibleCollaborators}.
|
|
785
|
+
* Ticked on a fixed interval so callers don't need to manage their own activity timers.
|
|
786
|
+
*/
|
|
787
|
+
private readonly _visibilityClock;
|
|
788
|
+
private _getCollaboratorsQuery;
|
|
789
|
+
/**
|
|
790
|
+
* Returns a list of presence records for all peer collaborators.
|
|
791
|
+
* This will return the latest presence record for each connected user.
|
|
792
|
+
*/
|
|
793
|
+
getCollaborators(): TLInstancePresence[];
|
|
794
|
+
/**
|
|
795
|
+
* Returns a list of presence records for all peer collaborators on the current page.
|
|
796
|
+
* This will return the latest presence record for each connected user.
|
|
797
|
+
*/
|
|
798
|
+
getCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
799
|
+
/**
|
|
800
|
+
* Returns a list of presence records for peer collaborators who should currently be
|
|
801
|
+
* shown in the UI. Filters {@link CollaboratorsManager.getCollaborators} by activity
|
|
802
|
+
* state (active / idle / inactive) and visibility rules such as following and
|
|
803
|
+
* highlighted users. Re-evaluates on the visibility clock, so callers don't need to
|
|
804
|
+
* drive their own activity timer.
|
|
805
|
+
*/
|
|
806
|
+
getVisibleCollaborators(): TLInstancePresence[];
|
|
807
|
+
/**
|
|
808
|
+
* Returns a list of presence records for peer collaborators who should currently be
|
|
809
|
+
* shown in the UI, filtered to those on the current page.
|
|
810
|
+
*/
|
|
811
|
+
getVisibleCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
812
|
+
}
|
|
813
|
+
|
|
722
814
|
/**
|
|
723
815
|
* @public
|
|
724
816
|
* @react
|
|
@@ -881,51 +973,21 @@ export declare const DEFAULT_THEME: TLTheme;
|
|
|
881
973
|
/** @public @react */
|
|
882
974
|
export declare function DefaultBackground(): JSX.Element;
|
|
883
975
|
|
|
884
|
-
/** @public @react */
|
|
885
|
-
export declare const DefaultBrush: ({ brush, color, opacity, className }: TLBrushProps) => JSX.Element;
|
|
886
|
-
|
|
887
976
|
/** @public @react */
|
|
888
977
|
export declare function DefaultCanvas({ className }: TLCanvasComponentProps): JSX.Element;
|
|
889
978
|
|
|
890
|
-
/** @public @react */
|
|
891
|
-
export declare function DefaultCollaboratorHint({ className, zoom, point, color, viewport, opacity }: TLCollaboratorHintProps): JSX.Element;
|
|
892
|
-
|
|
893
|
-
/** @public @react */
|
|
894
|
-
export declare const DefaultCursor: NamedExoticComponent<TLCursorProps>;
|
|
895
|
-
|
|
896
979
|
/** @public @react */
|
|
897
980
|
export declare const DefaultErrorFallback: TLErrorFallbackComponent;
|
|
898
981
|
|
|
899
982
|
/** @public @react */
|
|
900
983
|
export declare function DefaultGrid({ x, y, z, size }: TLGridProps): JSX.Element;
|
|
901
984
|
|
|
902
|
-
/** @public @react */
|
|
903
|
-
export declare function DefaultHandle({ handle, isCoarse, className, zoom }: TLHandleProps): JSX.Element;
|
|
904
|
-
|
|
905
|
-
/** @public @react */
|
|
906
|
-
export declare const DefaultHandles: ({ children }: TLHandlesProps) => JSX.Element;
|
|
907
|
-
|
|
908
|
-
/** @public @react */
|
|
909
|
-
export declare function DefaultScribble({ scribble, zoom, color, opacity, className }: TLScribbleProps): JSX.Element | null;
|
|
910
|
-
|
|
911
985
|
/** @public @react */
|
|
912
986
|
export declare function DefaultSelectionBackground({ bounds, rotation }: TLSelectionBackgroundProps): JSX.Element;
|
|
913
987
|
|
|
914
|
-
/** @public @react */
|
|
915
|
-
export declare function DefaultSelectionForeground({ bounds, rotation }: TLSelectionForegroundProps): JSX.Element;
|
|
916
|
-
|
|
917
|
-
/** @public @react */
|
|
918
|
-
export declare const DefaultShapeIndicator: NamedExoticComponent<TLShapeIndicatorProps>;
|
|
919
|
-
|
|
920
|
-
/** @public @react */
|
|
921
|
-
export declare const DefaultShapeIndicators: NamedExoticComponent<TLShapeIndicatorsProps>;
|
|
922
|
-
|
|
923
988
|
/** @public @react */
|
|
924
989
|
export declare const DefaultShapeWrapper: ForwardRefExoticComponent<TLShapeWrapperProps & RefAttributes<HTMLDivElement>>;
|
|
925
990
|
|
|
926
|
-
/** @public @react */
|
|
927
|
-
export declare function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps): JSX.Element;
|
|
928
|
-
|
|
929
991
|
/** @public @react */
|
|
930
992
|
export declare function DefaultSpinner(props: React.SVGProps<SVGSVGElement>): JSX.Element;
|
|
931
993
|
|
|
@@ -1005,7 +1067,6 @@ export declare const defaultTldrawOptions: {
|
|
|
1005
1067
|
readonly tooltipDelayMs: 700;
|
|
1006
1068
|
readonly uiCoarseDragDistanceSquared: 625;
|
|
1007
1069
|
readonly uiDragDistanceSquared: 16;
|
|
1008
|
-
readonly useCanvasIndicators: true;
|
|
1009
1070
|
readonly zoomToFitPadding: 128;
|
|
1010
1071
|
};
|
|
1011
1072
|
|
|
@@ -1105,7 +1166,7 @@ export declare class EdgeScrollManager {
|
|
|
1105
1166
|
/** @public */
|
|
1106
1167
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1107
1168
|
readonly id: string;
|
|
1108
|
-
constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
|
|
1169
|
+
constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, overlayUtils: overlayUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
|
|
1109
1170
|
private readonly _getShapeVisibility?;
|
|
1110
1171
|
private getIsShapeHiddenCache;
|
|
1111
1172
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1187,6 +1248,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1187
1248
|
setInterval: (handler: TimerHandler, timeout?: number | undefined, ...args: any[]) => number;
|
|
1188
1249
|
setTimeout: (handler: TimerHandler, timeout?: number | undefined, ...args: any[]) => number;
|
|
1189
1250
|
};
|
|
1251
|
+
/**
|
|
1252
|
+
* A manager for remote peer collaborators connected to this editor.
|
|
1253
|
+
*
|
|
1254
|
+
* @public
|
|
1255
|
+
*/
|
|
1256
|
+
readonly collaborators: CollaboratorsManager;
|
|
1190
1257
|
/**
|
|
1191
1258
|
* A manager for the user and their preferences.
|
|
1192
1259
|
*
|
|
@@ -1212,6 +1279,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1212
1279
|
* @public
|
|
1213
1280
|
*/
|
|
1214
1281
|
readonly scribbles: ScribbleManager;
|
|
1282
|
+
/**
|
|
1283
|
+
* A manager for canvas overlay UI elements (selection handles, shape handles, etc.).
|
|
1284
|
+
*
|
|
1285
|
+
* @public
|
|
1286
|
+
*/
|
|
1287
|
+
readonly overlays: OverlayManager;
|
|
1215
1288
|
/**
|
|
1216
1289
|
* A manager for side effects and correct state enforcement. See {@link @tldraw/store#StoreSideEffects} for details.
|
|
1217
1290
|
*
|
|
@@ -1690,6 +1763,11 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1690
1763
|
/**
|
|
1691
1764
|
* Set the cursor.
|
|
1692
1765
|
*
|
|
1766
|
+
* No-op when the partial wouldn't change the current cursor — `setCursor`
|
|
1767
|
+
* is called from pointer-move hot paths (see `updateHoveredOverlayId`,
|
|
1768
|
+
* various tool states) and skipping redundant writes avoids needlessly
|
|
1769
|
+
* dirtying instance state.
|
|
1770
|
+
*
|
|
1693
1771
|
* @param cursor - The cursor to set.
|
|
1694
1772
|
* @public
|
|
1695
1773
|
*/
|
|
@@ -2449,11 +2527,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2449
2527
|
* @public
|
|
2450
2528
|
*/
|
|
2451
2529
|
pageToViewport(point: VecLike): Vec;
|
|
2452
|
-
private _getCollaboratorsQuery;
|
|
2453
2530
|
/**
|
|
2454
2531
|
* Returns a list of presence records for all peer collaborators.
|
|
2455
2532
|
* This will return the latest presence record for each connected user.
|
|
2456
2533
|
*
|
|
2534
|
+
* Convenience wrapper for {@link CollaboratorsManager.getCollaborators}.
|
|
2535
|
+
*
|
|
2457
2536
|
* @public
|
|
2458
2537
|
*/
|
|
2459
2538
|
getCollaborators(): TLInstancePresence[];
|
|
@@ -2461,9 +2540,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2461
2540
|
* Returns a list of presence records for all peer collaborators on the current page.
|
|
2462
2541
|
* This will return the latest presence record for each connected user.
|
|
2463
2542
|
*
|
|
2543
|
+
* Convenience wrapper for {@link CollaboratorsManager.getCollaboratorsOnCurrentPage}.
|
|
2544
|
+
*
|
|
2464
2545
|
* @public
|
|
2465
2546
|
*/
|
|
2466
2547
|
getCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
2548
|
+
/**
|
|
2549
|
+
* Returns a list of presence records for peer collaborators who should currently be
|
|
2550
|
+
* shown in the UI. Filters {@link Editor.getCollaborators} by activity state
|
|
2551
|
+
* (active / idle / inactive) and visibility rules such as following and highlighted
|
|
2552
|
+
* users. Re-evaluates on the collaborator visibility clock, so callers don't need to
|
|
2553
|
+
* drive their own activity timer.
|
|
2554
|
+
*
|
|
2555
|
+
* Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaborators}.
|
|
2556
|
+
*
|
|
2557
|
+
* @public
|
|
2558
|
+
*/
|
|
2559
|
+
getVisibleCollaborators(): TLInstancePresence[];
|
|
2560
|
+
/**
|
|
2561
|
+
* Returns a list of presence records for peer collaborators who should currently be
|
|
2562
|
+
* shown in the UI, filtered to those on the current page.
|
|
2563
|
+
*
|
|
2564
|
+
* Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaboratorsOnCurrentPage}.
|
|
2565
|
+
*
|
|
2566
|
+
* @public
|
|
2567
|
+
*/
|
|
2568
|
+
getVisibleCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
2467
2569
|
/**
|
|
2468
2570
|
* Get the current user's ID for attribution purposes.
|
|
2469
2571
|
* Also ensures a `user:` record exists in the store for the current user.
|
|
@@ -3124,6 +3226,20 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3124
3226
|
type: T['type'];
|
|
3125
3227
|
}>;
|
|
3126
3228
|
isShapeOfType<T extends TLShape = TLShape>(shapeId: TLShapeId, type: T['type']): boolean;
|
|
3229
|
+
/**
|
|
3230
|
+
* Get whether a shape behaves like a frame — a container that has child
|
|
3231
|
+
* shapes, requires full-brush selection, blocks erasure from inside, etc.
|
|
3232
|
+
*
|
|
3233
|
+
* @example
|
|
3234
|
+
* ```ts
|
|
3235
|
+
* const isFrameLike = editor.isShapeFrameLike(someShape)
|
|
3236
|
+
* ```
|
|
3237
|
+
*
|
|
3238
|
+
* @param shape - The shape (or shape id) to test.
|
|
3239
|
+
*
|
|
3240
|
+
* @public
|
|
3241
|
+
*/
|
|
3242
|
+
isShapeFrameLike(shape: TLShape | TLShapeId): boolean;
|
|
3127
3243
|
/**
|
|
3128
3244
|
* Get a shape by its id.
|
|
3129
3245
|
*
|
|
@@ -4790,7 +4906,7 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
|
|
|
4790
4906
|
getDefaultProps(): TLGroupShape['props'];
|
|
4791
4907
|
getGeometry(shape: TLGroupShape): Geometry2d;
|
|
4792
4908
|
component(shape: TLGroupShape): JSX.Element | null;
|
|
4793
|
-
|
|
4909
|
+
getIndicatorPath(shape: TLGroupShape): Path2D;
|
|
4794
4910
|
onChildrenChange(group: TLGroupShape): void;
|
|
4795
4911
|
}
|
|
4796
4912
|
|
|
@@ -5418,6 +5534,179 @@ export declare function openWindow(url: string, target?: string, allowReferrer?:
|
|
|
5418
5534
|
/** @public */
|
|
5419
5535
|
export declare type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
5420
5536
|
|
|
5537
|
+
/** @public */
|
|
5538
|
+
export declare class OverlayManager {
|
|
5539
|
+
readonly editor: Editor;
|
|
5540
|
+
constructor(editor: Editor);
|
|
5541
|
+
/* Excluded from this release type: _overlayUtils */
|
|
5542
|
+
/* Excluded from this release type: registerUtil */
|
|
5543
|
+
/**
|
|
5544
|
+
* Get an overlay util by type string, overlay instance, or by passing
|
|
5545
|
+
* a util class as a generic parameter for type-safe lookup.
|
|
5546
|
+
*
|
|
5547
|
+
* @example
|
|
5548
|
+
* ```ts
|
|
5549
|
+
* const util = editor.overlays.getOverlayUtil('brush')
|
|
5550
|
+
* const util = editor.overlays.getOverlayUtil<BrushOverlayUtil>('brush')
|
|
5551
|
+
* const util = editor.overlays.getOverlayUtil(myOverlay)
|
|
5552
|
+
* ```
|
|
5553
|
+
*
|
|
5554
|
+
* @public
|
|
5555
|
+
*/
|
|
5556
|
+
getOverlayUtil<T extends OverlayUtil>(type: T extends OverlayUtil<infer O> ? O['type'] : string): T;
|
|
5557
|
+
getOverlayUtil<O extends TLOverlay>(overlay: O): OverlayUtil<O>;
|
|
5558
|
+
/**
|
|
5559
|
+
* Returns all registered overlay utils in paint order (ascending zIndex).
|
|
5560
|
+
* Utils with the same zIndex preserve their registration order.
|
|
5561
|
+
*
|
|
5562
|
+
* @public
|
|
5563
|
+
*/
|
|
5564
|
+
getOverlayUtilsInZOrder(): OverlayUtil[];
|
|
5565
|
+
/**
|
|
5566
|
+
* Reactive list of active overlay utils paired with the overlays they
|
|
5567
|
+
* produced for the current editor state, in paint order (ascending
|
|
5568
|
+
* zIndex). Both the hit-test and render paths read from this single
|
|
5569
|
+
* cached scan instead of each re-deriving the active set. Active utils
|
|
5570
|
+
* are included even when their `getOverlays()` returns an empty array,
|
|
5571
|
+
* since `render()` may still draw non-interactive UI (e.g. the selection
|
|
5572
|
+
* bounding box during brushing).
|
|
5573
|
+
*
|
|
5574
|
+
* @public
|
|
5575
|
+
*/
|
|
5576
|
+
getActiveOverlayEntries(): TLOverlayEntry[];
|
|
5577
|
+
/**
|
|
5578
|
+
* Reactively computed list of all currently active overlays, in paint order.
|
|
5579
|
+
* @public
|
|
5580
|
+
*/
|
|
5581
|
+
getCurrentOverlays(): TLOverlay[];
|
|
5582
|
+
private _geometryCache;
|
|
5583
|
+
/**
|
|
5584
|
+
* Get hit-test geometry for an overlay, cached by overlay identity. Lets
|
|
5585
|
+
* hit-testing on a pointermove storm skip the per-overlay geometry
|
|
5586
|
+
* allocation that {@link OverlayUtil.getGeometry} would otherwise do on
|
|
5587
|
+
* every call.
|
|
5588
|
+
*
|
|
5589
|
+
* @public
|
|
5590
|
+
*/
|
|
5591
|
+
getOverlayGeometry(overlay: TLOverlay): Geometry2d | null;
|
|
5592
|
+
/**
|
|
5593
|
+
* The currently hovered overlay id.
|
|
5594
|
+
* @public
|
|
5595
|
+
*/
|
|
5596
|
+
private _hoveredOverlayId;
|
|
5597
|
+
getHoveredOverlayId(): null | string;
|
|
5598
|
+
getHoveredOverlay(): null | TLOverlay;
|
|
5599
|
+
setHoveredOverlay(id: null | string): void;
|
|
5600
|
+
/**
|
|
5601
|
+
* Hit test all active overlays at a given page point.
|
|
5602
|
+
* Returns the topmost overlay whose geometry contains the point, or null.
|
|
5603
|
+
* Utils are walked from highest zIndex to lowest so the overlay painted on
|
|
5604
|
+
* top also wins the hit test. Within a util, overlays are walked in
|
|
5605
|
+
* array order: the first overlay whose geometry contains the point wins,
|
|
5606
|
+
* so utils should place highest-priority overlays first in `getOverlays`.
|
|
5607
|
+
* Interactive overlays (those with geometry) are checked; non-interactive are skipped.
|
|
5608
|
+
*
|
|
5609
|
+
* @param point - Point in page coordinates
|
|
5610
|
+
* @param margin - Hit test margin
|
|
5611
|
+
* @public
|
|
5612
|
+
*/
|
|
5613
|
+
getOverlayAtPoint(point: VecLike, margin?: number): null | TLOverlay;
|
|
5614
|
+
}
|
|
5615
|
+
|
|
5616
|
+
/**
|
|
5617
|
+
* Base class for overlay utilities. Overlays are ephemeral UI elements rendered
|
|
5618
|
+
* on top of the canvas (selection handles, rotation corners, shape handles, etc.).
|
|
5619
|
+
*
|
|
5620
|
+
* Each OverlayUtil defines a type of overlay and knows how to:
|
|
5621
|
+
* - Determine when its overlays should be active (predicate)
|
|
5622
|
+
* - Produce overlay instances from current editor state
|
|
5623
|
+
* - Provide hit-test geometry for interactive overlays
|
|
5624
|
+
* - Provide cursor style on hover
|
|
5625
|
+
* - Render into a canvas 2D context
|
|
5626
|
+
*
|
|
5627
|
+
* @public
|
|
5628
|
+
*/
|
|
5629
|
+
export declare abstract class OverlayUtil<T extends TLOverlay = TLOverlay> {
|
|
5630
|
+
editor: Editor;
|
|
5631
|
+
constructor(editor: Editor);
|
|
5632
|
+
static type: string;
|
|
5633
|
+
/**
|
|
5634
|
+
* Options for this overlay util. Override this to provide customization options.
|
|
5635
|
+
* Use {@link OverlayUtil.configure} to customize existing overlay utils.
|
|
5636
|
+
*
|
|
5637
|
+
* `zIndex` controls paint and hit-test order across utils — higher numbers
|
|
5638
|
+
* paint on top and are hit-tested first. Ties resolve by registration order.
|
|
5639
|
+
* Defaults to `0`; built-in utils use larger integers (100, 200, …) with
|
|
5640
|
+
* gaps so custom utils can slot between.
|
|
5641
|
+
*
|
|
5642
|
+
* @public
|
|
5643
|
+
*/
|
|
5644
|
+
options: {
|
|
5645
|
+
zIndex?: number;
|
|
5646
|
+
};
|
|
5647
|
+
/**
|
|
5648
|
+
* Create a new overlay util class with the given options merged in.
|
|
5649
|
+
*
|
|
5650
|
+
* @example
|
|
5651
|
+
* ```ts
|
|
5652
|
+
* const MyBrush = BrushOverlayUtil.configure({ fill: 'rgba(0,0,255,0.1)' })
|
|
5653
|
+
* ```
|
|
5654
|
+
*
|
|
5655
|
+
* @public
|
|
5656
|
+
*/
|
|
5657
|
+
static configure<T extends TLOverlayUtilConstructor<any>>(this: T, options: T extends new (...args: any[]) => {
|
|
5658
|
+
options: infer Options;
|
|
5659
|
+
} ? Partial<Options> : never): T;
|
|
5660
|
+
/**
|
|
5661
|
+
* Whether this overlay util's overlays should currently be active.
|
|
5662
|
+
* Checked reactively to determine which overlays exist at any given time.
|
|
5663
|
+
*/
|
|
5664
|
+
abstract isActive(): boolean;
|
|
5665
|
+
/**
|
|
5666
|
+
* Returns the overlay instances that currently exist.
|
|
5667
|
+
* Called only when `isActive()` returns true.
|
|
5668
|
+
*/
|
|
5669
|
+
abstract getOverlays(): T[];
|
|
5670
|
+
/**
|
|
5671
|
+
* Returns hit-test geometry for an overlay instance, in page coordinates.
|
|
5672
|
+
* Return null for non-interactive overlays (e.g. snap indicators, scribbles).
|
|
5673
|
+
*/
|
|
5674
|
+
getGeometry(_overlay: T): Geometry2d | null;
|
|
5675
|
+
/**
|
|
5676
|
+
* Returns the cursor type to show when hovering this overlay.
|
|
5677
|
+
*/
|
|
5678
|
+
getCursor(_overlay: T): TLCursorType | undefined;
|
|
5679
|
+
/**
|
|
5680
|
+
* Called when the user points down on this overlay, before the default
|
|
5681
|
+
* routing runs. Acts as an interrupt: define it to take over the event.
|
|
5682
|
+
*
|
|
5683
|
+
* Return `false` to continue with the default behavior (e.g. the
|
|
5684
|
+
* built-in rotate/resize handle transitions or shape-handle dispatch).
|
|
5685
|
+
* Return `true` — or nothing at all — to skip the default. In other
|
|
5686
|
+
* words, once you override this method you own the event unless you
|
|
5687
|
+
* explicitly opt back in by returning `false`.
|
|
5688
|
+
*/
|
|
5689
|
+
onPointerDown?(overlay: T, info: TLPointerEventInfo): boolean | void;
|
|
5690
|
+
/**
|
|
5691
|
+
* Render all active overlays into the canvas context.
|
|
5692
|
+
* The context is already transformed to page space (camera transform applied).
|
|
5693
|
+
* Called reactively when overlays or editor state changes.
|
|
5694
|
+
*/
|
|
5695
|
+
render(_ctx: CanvasRenderingContext2D, _overlays: T[]): void;
|
|
5696
|
+
/**
|
|
5697
|
+
* Optional: render all active overlays into the minimap canvas.
|
|
5698
|
+
* The context is already transformed to page space (minimap camera applied),
|
|
5699
|
+
* so overlays can use the same page-space coordinates as in {@link OverlayUtil.render}.
|
|
5700
|
+
*
|
|
5701
|
+
* `zoom` is the minimap's screen-pixels-per-page-unit, analogous to
|
|
5702
|
+
* `editor.getCamera().z`; use `1 / zoom` for one-minimap-pixel line widths.
|
|
5703
|
+
*
|
|
5704
|
+
* Most overlays should leave this blank — only overlays that are meaningful
|
|
5705
|
+
* at minimap scale (e.g. brushes, collaborator cursors) should opt in.
|
|
5706
|
+
*/
|
|
5707
|
+
renderMinimap(_ctx: CanvasRenderingContext2D, _overlays: T[], _zoom: number): void;
|
|
5708
|
+
}
|
|
5709
|
+
|
|
5421
5710
|
/**
|
|
5422
5711
|
* Parses a string created by {@link createDeepLinkString} back into a deep link descriptor.
|
|
5423
5712
|
*
|
|
@@ -5950,6 +6239,32 @@ export declare function setRuntimeOverrides(input: Partial<typeof runtime>): voi
|
|
|
5950
6239
|
/** @public */
|
|
5951
6240
|
export declare function setUserPreferences(user: TLUserPreferences): void;
|
|
5952
6241
|
|
|
6242
|
+
/**
|
|
6243
|
+
* Overlay util for shape indicators — the selection / hover / hint outlines drawn
|
|
6244
|
+
* under the selection foreground. Paints local indicators in the theme's
|
|
6245
|
+
* selection color.
|
|
6246
|
+
*
|
|
6247
|
+
* Remote collaborator selection indicators are drawn by a separate overlay util
|
|
6248
|
+
* (e.g. `CollaboratorShapeIndicatorOverlayUtil` from `tldraw`) that runs at a
|
|
6249
|
+
* lower z-index so peer selections appear under the local indicators.
|
|
6250
|
+
*
|
|
6251
|
+
* Non-interactive: contributes no hit-test geometry.
|
|
6252
|
+
*
|
|
6253
|
+
* @public
|
|
6254
|
+
*/
|
|
6255
|
+
export declare class ShapeIndicatorOverlayUtil extends OverlayUtil<TLShapeIndicatorOverlay> {
|
|
6256
|
+
static type: string;
|
|
6257
|
+
options: {
|
|
6258
|
+
hintedLineWidth: number;
|
|
6259
|
+
lineWidth: number;
|
|
6260
|
+
zIndex: number;
|
|
6261
|
+
};
|
|
6262
|
+
private _instanceFlags$;
|
|
6263
|
+
isActive(): boolean;
|
|
6264
|
+
getOverlays(): TLShapeIndicatorOverlay[];
|
|
6265
|
+
render(ctx: CanvasRenderingContext2D, overlays: TLShapeIndicatorOverlay[]): void;
|
|
6266
|
+
}
|
|
6267
|
+
|
|
5953
6268
|
/** @public */
|
|
5954
6269
|
export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
5955
6270
|
editor: Editor;
|
|
@@ -6046,37 +6361,30 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
6046
6361
|
*/
|
|
6047
6362
|
abstract component(shape: Shape): any;
|
|
6048
6363
|
/**
|
|
6049
|
-
* Get
|
|
6050
|
-
*
|
|
6051
|
-
*
|
|
6052
|
-
* @public
|
|
6053
|
-
*/
|
|
6054
|
-
abstract indicator(shape: Shape): any;
|
|
6055
|
-
/**
|
|
6056
|
-
* Whether to use the legacy React-based indicator rendering.
|
|
6364
|
+
* Get a Path2D (or a richer object with clip/additional paths) for rendering the
|
|
6365
|
+
* shape's indicator on the canvas. Shapes that return `undefined` will not render
|
|
6366
|
+
* an indicator.
|
|
6057
6367
|
*
|
|
6058
|
-
*
|
|
6059
|
-
*
|
|
6368
|
+
* For complex indicators that need clipping (e.g., arrows with labels), return an
|
|
6369
|
+
* object with `path`, `clipPath`, and `additionalPaths` properties.
|
|
6060
6370
|
*
|
|
6061
|
-
* @
|
|
6371
|
+
* @param shape - The shape.
|
|
6372
|
+
* @returns A Path2D to stroke, or an object with clipping info, or undefined to skip.
|
|
6062
6373
|
* @public
|
|
6063
6374
|
*/
|
|
6064
|
-
|
|
6375
|
+
abstract getIndicatorPath(shape: Shape): TLIndicatorPath | undefined;
|
|
6065
6376
|
/**
|
|
6066
|
-
* Get
|
|
6067
|
-
*
|
|
6068
|
-
* When implemented, this is used instead of {@link ShapeUtil.indicator} for more
|
|
6069
|
-
* efficient canvas-based indicator rendering. Shapes that return `undefined` will
|
|
6070
|
-
* fall back to SVG-based rendering via {@link ShapeUtil.indicator}.
|
|
6377
|
+
* Get JSX describing the shape's indicator (as an SVG element).
|
|
6071
6378
|
*
|
|
6072
|
-
*
|
|
6073
|
-
*
|
|
6379
|
+
* @deprecated SVG indicators are no longer rendered. Override
|
|
6380
|
+
* {@link ShapeUtil.getIndicatorPath} instead. This stub is retained so legacy
|
|
6381
|
+
* subclasses that still call `super.indicator()` keep type-checking; new shapes
|
|
6382
|
+
* should not implement it.
|
|
6074
6383
|
*
|
|
6075
6384
|
* @param shape - The shape.
|
|
6076
|
-
* @returns A Path2D to stroke, or an object with clipping info, or undefined to use SVG fallback.
|
|
6077
6385
|
* @public
|
|
6078
6386
|
*/
|
|
6079
|
-
|
|
6387
|
+
indicator(_shape: Shape): any;
|
|
6080
6388
|
/**
|
|
6081
6389
|
* Get the font faces that should be rendered in the document in order for this shape to render
|
|
6082
6390
|
* correctly.
|
|
@@ -6244,6 +6552,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
6244
6552
|
* @public
|
|
6245
6553
|
*/
|
|
6246
6554
|
isAspectRatioLocked(shape: Shape): boolean;
|
|
6555
|
+
/**
|
|
6556
|
+
* Whether the shape behaves like a frame — a container that has child shapes,
|
|
6557
|
+
* requires full-brush selection, blocks erasure from inside, etc.
|
|
6558
|
+
*
|
|
6559
|
+
* @param shape - The shape.
|
|
6560
|
+
* @public
|
|
6561
|
+
*/
|
|
6562
|
+
isFrameLike(_shape: Shape): boolean;
|
|
6247
6563
|
/**
|
|
6248
6564
|
* By default, the bounds of an image export are the bounds of all the shapes it contains, plus
|
|
6249
6565
|
* some padding. If an export includes a shape where `isExportBoundsContainer` is true, then the
|
|
@@ -6835,6 +7151,19 @@ export declare const stopEventPropagation: (e: any) => any;
|
|
|
6835
7151
|
|
|
6836
7152
|
/* Excluded from this release type: StoreName */
|
|
6837
7153
|
|
|
7154
|
+
/**
|
|
7155
|
+
* Combine every batchable shape indicator into a single page-space `Path2D` and
|
|
7156
|
+
* emit one stroke call. Shapes whose indicator needs an evenodd clip (e.g.
|
|
7157
|
+
* arrows with labels or complex arrowheads) can't be batched — they still
|
|
7158
|
+
* stroke individually inside a save/restore with `ctx.clip` applied.
|
|
7159
|
+
*
|
|
7160
|
+
* Shared by {@link ShapeIndicatorOverlayUtil} and any overlay util that paints
|
|
7161
|
+
* shape indicators (e.g. collaborator selections).
|
|
7162
|
+
*
|
|
7163
|
+
* @public
|
|
7164
|
+
*/
|
|
7165
|
+
export declare function strokeShapeIndicators(editor: Editor, ctx: CanvasRenderingContext2D, shapeIds: TLShapeId[]): void;
|
|
7166
|
+
|
|
6838
7167
|
/** @public */
|
|
6839
7168
|
export declare function suffixSafeId(id: SafeId, suffix: string): SafeId;
|
|
6840
7169
|
|
|
@@ -7009,6 +7338,9 @@ export declare type TLAnyAssetUtilConstructor = TLAssetUtilConstructor<any>;
|
|
|
7009
7338
|
/** @public */
|
|
7010
7339
|
export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
7011
7340
|
|
|
7341
|
+
/** @public */
|
|
7342
|
+
export declare type TLAnyOverlayUtilConstructor = TLOverlayUtilConstructor<any>;
|
|
7343
|
+
|
|
7012
7344
|
/** @public */
|
|
7013
7345
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
7014
7346
|
|
|
@@ -7052,15 +7384,6 @@ export declare interface TLBindingUtilConstructor<T extends TLBinding, U extends
|
|
|
7052
7384
|
migrations?: TLPropsMigrations;
|
|
7053
7385
|
}
|
|
7054
7386
|
|
|
7055
|
-
/** @public */
|
|
7056
|
-
export declare interface TLBrushProps {
|
|
7057
|
-
userId?: string;
|
|
7058
|
-
brush: BoxModel;
|
|
7059
|
-
color?: string;
|
|
7060
|
-
opacity?: number;
|
|
7061
|
-
className?: string;
|
|
7062
|
-
}
|
|
7063
|
-
|
|
7064
7387
|
/** @public */
|
|
7065
7388
|
export declare interface TLCameraConstraints {
|
|
7066
7389
|
/** The bounds (in page space) of the constrained space */
|
|
@@ -7248,17 +7571,6 @@ export declare interface TLClipboardWriteInfo {
|
|
|
7248
7571
|
readonly source: 'menu' | 'native';
|
|
7249
7572
|
}
|
|
7250
7573
|
|
|
7251
|
-
/** @public */
|
|
7252
|
-
export declare interface TLCollaboratorHintProps {
|
|
7253
|
-
userId: string;
|
|
7254
|
-
className?: string;
|
|
7255
|
-
point: VecModel;
|
|
7256
|
-
viewport: Box;
|
|
7257
|
-
zoom: number;
|
|
7258
|
-
opacity?: number;
|
|
7259
|
-
color: string;
|
|
7260
|
-
}
|
|
7261
|
-
|
|
7262
7574
|
/** @public */
|
|
7263
7575
|
export declare type TLCompleteEvent = (info: TLCompleteEventInfo) => void;
|
|
7264
7576
|
|
|
@@ -7303,17 +7615,6 @@ export declare interface TLCurrentUser {
|
|
|
7303
7615
|
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7304
7616
|
}
|
|
7305
7617
|
|
|
7306
|
-
/** @public */
|
|
7307
|
-
export declare interface TLCursorProps {
|
|
7308
|
-
userId: string;
|
|
7309
|
-
className?: string;
|
|
7310
|
-
point: null | VecModel;
|
|
7311
|
-
zoom: number;
|
|
7312
|
-
color?: string;
|
|
7313
|
-
name: null | string;
|
|
7314
|
-
chatMessage: string;
|
|
7315
|
-
}
|
|
7316
|
-
|
|
7317
7618
|
/** @public */
|
|
7318
7619
|
export declare type TLDeepLink = {
|
|
7319
7620
|
bounds: BoxModel;
|
|
@@ -7407,6 +7708,10 @@ export declare interface TldrawEditorBaseProps {
|
|
|
7407
7708
|
* An array of asset utils to use in the editor.
|
|
7408
7709
|
*/
|
|
7409
7710
|
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
7711
|
+
/**
|
|
7712
|
+
* An array of overlay utils to use in the editor for canvas overlay UI elements.
|
|
7713
|
+
*/
|
|
7714
|
+
overlayUtils?: readonly TLAnyOverlayUtilConstructor[];
|
|
7410
7715
|
/**
|
|
7411
7716
|
* An array of tools to add to the editor's state chart.
|
|
7412
7717
|
*/
|
|
@@ -7716,12 +8021,6 @@ export declare interface TldrawOptions {
|
|
|
7716
8021
|
* viewport's page dimensions regardless of overview zoom changes.
|
|
7717
8022
|
*/
|
|
7718
8023
|
readonly quickZoomPreservesScreenBounds: boolean;
|
|
7719
|
-
/**
|
|
7720
|
-
* Whether to use 2D canvas rendering for shape indicators. When true (default),
|
|
7721
|
-
* shapes that support it will render indicators on a 2D canvas for better
|
|
7722
|
-
* performance. When false, all indicators use legacy SVG rendering.
|
|
7723
|
-
*/
|
|
7724
|
-
readonly useCanvasIndicators: boolean;
|
|
7725
8024
|
/**
|
|
7726
8025
|
* Called before content is written to the clipboard during a copy or cut operation.
|
|
7727
8026
|
* Receives the serialized content (shapes, bindings, assets) and can filter or transform
|
|
@@ -7809,34 +8108,17 @@ export declare interface TLDropShapesOverInfo {
|
|
|
7809
8108
|
/** @public */
|
|
7810
8109
|
export declare interface TLEditorComponents {
|
|
7811
8110
|
Background?: ComponentType | null;
|
|
7812
|
-
Brush?: ComponentType<TLBrushProps> | null;
|
|
7813
8111
|
Canvas?: ComponentType<TLCanvasComponentProps> | null;
|
|
7814
|
-
CollaboratorBrush?: ComponentType<TLBrushProps> | null;
|
|
7815
|
-
CollaboratorCursor?: ComponentType<TLCursorProps> | null;
|
|
7816
|
-
CollaboratorHint?: ComponentType<TLCollaboratorHintProps> | null;
|
|
7817
|
-
CollaboratorScribble?: ComponentType<TLScribbleProps> | null;
|
|
7818
|
-
CollaboratorShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null;
|
|
7819
|
-
Cursor?: ComponentType<TLCursorProps> | null;
|
|
7820
8112
|
Grid?: ComponentType<TLGridProps> | null;
|
|
7821
|
-
Handle?: ComponentType<TLHandleProps> | null;
|
|
7822
|
-
Handles?: ComponentType<TLHandlesProps> | null;
|
|
7823
8113
|
InFrontOfTheCanvas?: ComponentType | null;
|
|
7824
8114
|
LoadingScreen?: ComponentType | null;
|
|
7825
8115
|
OnTheCanvas?: ComponentType | null;
|
|
7826
|
-
Overlays?: ComponentType | null;
|
|
7827
|
-
Scribble?: ComponentType<TLScribbleProps> | null;
|
|
7828
8116
|
SelectionBackground?: ComponentType<TLSelectionBackgroundProps> | null;
|
|
7829
|
-
SelectionForeground?: ComponentType<TLSelectionForegroundProps> | null;
|
|
7830
|
-
ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null;
|
|
7831
|
-
ShapeIndicators?: ComponentType | null;
|
|
7832
8117
|
ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null;
|
|
7833
|
-
SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null;
|
|
7834
8118
|
Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null;
|
|
7835
8119
|
SvgDefs?: ComponentType | null;
|
|
7836
|
-
ZoomBrush?: ComponentType<TLBrushProps> | null;
|
|
7837
8120
|
ErrorFallback?: TLErrorFallbackComponent;
|
|
7838
8121
|
ShapeErrorFallback?: TLShapeErrorFallbackComponent;
|
|
7839
|
-
ShapeIndicatorErrorFallback?: TLShapeIndicatorErrorFallbackComponent;
|
|
7840
8122
|
}
|
|
7841
8123
|
|
|
7842
8124
|
/** @public */
|
|
@@ -7858,6 +8140,11 @@ export declare interface TLEditorOptions {
|
|
|
7858
8140
|
* An array of asset utils to use in the editor. These will be used to handle asset-type-specific behavior.
|
|
7859
8141
|
*/
|
|
7860
8142
|
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
8143
|
+
/**
|
|
8144
|
+
* An array of overlay utils to use in the editor. These define canvas overlay UI elements
|
|
8145
|
+
* like selection handles, rotation corners, shape handles, etc.
|
|
8146
|
+
*/
|
|
8147
|
+
overlayUtils?: readonly TLAnyOverlayUtilConstructor[];
|
|
7861
8148
|
/**
|
|
7862
8149
|
* An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
|
|
7863
8150
|
*/
|
|
@@ -8224,20 +8511,6 @@ export declare interface TLHandleDragInfo<T extends TLShape> {
|
|
|
8224
8511
|
initial?: T | undefined;
|
|
8225
8512
|
}
|
|
8226
8513
|
|
|
8227
|
-
/** @public */
|
|
8228
|
-
export declare interface TLHandleProps {
|
|
8229
|
-
shapeId: TLShapeId;
|
|
8230
|
-
handle: TLHandle;
|
|
8231
|
-
zoom: number;
|
|
8232
|
-
isCoarse: boolean;
|
|
8233
|
-
className?: string;
|
|
8234
|
-
}
|
|
8235
|
-
|
|
8236
|
-
/** @public */
|
|
8237
|
-
export declare interface TLHandlesProps {
|
|
8238
|
-
children: ReactNode;
|
|
8239
|
-
}
|
|
8240
|
-
|
|
8241
8514
|
/** @public */
|
|
8242
8515
|
export declare interface TLHistoryBatchOptions {
|
|
8243
8516
|
/**
|
|
@@ -8567,6 +8840,42 @@ export declare const tlmenus: {
|
|
|
8567
8840
|
*/
|
|
8568
8841
|
export declare type TLOnMountHandler = (editor: Editor) => (() => undefined | void) | undefined | void;
|
|
8569
8842
|
|
|
8843
|
+
/** @public */
|
|
8844
|
+
export declare interface TLOverlay<Props = Record<string, unknown>> {
|
|
8845
|
+
/**
|
|
8846
|
+
* Globally unique id for this overlay instance across all overlay utils.
|
|
8847
|
+
* Hit-test and hover lookup key on `id` alone, so utils must namespace their
|
|
8848
|
+
* ids (e.g. `'selection_fg:top_left'`, `'handle:<shapeId>:<handleId>'`) to
|
|
8849
|
+
* avoid colliding with overlays from other utils.
|
|
8850
|
+
*/
|
|
8851
|
+
id: string;
|
|
8852
|
+
/** The overlay util type that owns this instance */
|
|
8853
|
+
type: string;
|
|
8854
|
+
/** Arbitrary props for the overlay (handle id, corner name, etc.) */
|
|
8855
|
+
props: Props;
|
|
8856
|
+
}
|
|
8857
|
+
|
|
8858
|
+
/**
|
|
8859
|
+
* An active overlay util paired with the overlays it produced for the current
|
|
8860
|
+
* editor state. Returned by {@link OverlayManager.getActiveOverlayEntries} so
|
|
8861
|
+
* hit-test, render, and debug paths share a single scan per reactive tick.
|
|
8862
|
+
*
|
|
8863
|
+
* @public
|
|
8864
|
+
*/
|
|
8865
|
+
export declare interface TLOverlayEntry {
|
|
8866
|
+
util: OverlayUtil;
|
|
8867
|
+
overlays: TLOverlay[];
|
|
8868
|
+
}
|
|
8869
|
+
|
|
8870
|
+
/** @public */
|
|
8871
|
+
export declare interface TLOverlayUtilConstructor<U extends OverlayUtil = OverlayUtil> {
|
|
8872
|
+
new (editor: Editor): U;
|
|
8873
|
+
type: string;
|
|
8874
|
+
configure<T extends TLOverlayUtilConstructor<any>>(this: T, options: T extends new (...args: any[]) => {
|
|
8875
|
+
options: infer Options;
|
|
8876
|
+
} ? Partial<Options> : never): T;
|
|
8877
|
+
}
|
|
8878
|
+
|
|
8570
8879
|
/**
|
|
8571
8880
|
* Map of all performance event names to their payload types.
|
|
8572
8881
|
* Used with {@link PerformanceManager.on} and {@link PerformanceManager.once}.
|
|
@@ -8694,6 +9003,10 @@ export declare type TLPointerEventTarget = {
|
|
|
8694
9003
|
handle?: TLSelectionHandle;
|
|
8695
9004
|
shape?: undefined;
|
|
8696
9005
|
target: 'selection';
|
|
9006
|
+
} | {
|
|
9007
|
+
overlay: TLOverlay;
|
|
9008
|
+
shape?: undefined;
|
|
9009
|
+
target: 'overlay';
|
|
8697
9010
|
} | {
|
|
8698
9011
|
shape: TLShape;
|
|
8699
9012
|
target: 'shape';
|
|
@@ -8764,28 +9077,12 @@ export declare type TLResizeShapeOptions = Partial<{
|
|
|
8764
9077
|
|
|
8765
9078
|
/* Excluded from this release type: TLRotationSnapshot */
|
|
8766
9079
|
|
|
8767
|
-
/** @public */
|
|
8768
|
-
export declare interface TLScribbleProps {
|
|
8769
|
-
userId?: string;
|
|
8770
|
-
scribble: TLScribble;
|
|
8771
|
-
zoom: number;
|
|
8772
|
-
color?: string;
|
|
8773
|
-
opacity?: number;
|
|
8774
|
-
className?: string;
|
|
8775
|
-
}
|
|
8776
|
-
|
|
8777
9080
|
/** @public */
|
|
8778
9081
|
export declare interface TLSelectionBackgroundProps {
|
|
8779
9082
|
bounds: Box;
|
|
8780
9083
|
rotation: number;
|
|
8781
9084
|
}
|
|
8782
9085
|
|
|
8783
|
-
/** @public */
|
|
8784
|
-
export declare interface TLSelectionForegroundProps {
|
|
8785
|
-
bounds: Box;
|
|
8786
|
-
rotation: number;
|
|
8787
|
-
}
|
|
8788
|
-
|
|
8789
9086
|
/** @public */
|
|
8790
9087
|
export declare type TLSelectionHandle = RotateCorner | SelectionCorner | SelectionEdge;
|
|
8791
9088
|
|
|
@@ -8820,26 +9117,11 @@ export declare type TLShapeErrorFallbackComponent = ComponentType<{
|
|
|
8820
9117
|
}>;
|
|
8821
9118
|
|
|
8822
9119
|
/** @public */
|
|
8823
|
-
export declare
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
export declare interface TLShapeIndicatorProps {
|
|
8829
|
-
userId?: string;
|
|
8830
|
-
shapeId: TLShapeId;
|
|
8831
|
-
color?: string | undefined;
|
|
8832
|
-
opacity?: number;
|
|
8833
|
-
className?: string;
|
|
8834
|
-
hidden?: boolean;
|
|
8835
|
-
}
|
|
8836
|
-
|
|
8837
|
-
/** @public */
|
|
8838
|
-
export declare interface TLShapeIndicatorsProps {
|
|
8839
|
-
/** Whether to hide all of the indicators */
|
|
8840
|
-
hideAll?: boolean;
|
|
8841
|
-
/** Whether to show all of the indicators */
|
|
8842
|
-
showAll?: boolean;
|
|
9120
|
+
export declare interface TLShapeIndicatorOverlay extends TLOverlay {
|
|
9121
|
+
props: {
|
|
9122
|
+
hintingShapeIds: TLShapeId[];
|
|
9123
|
+
idsToDisplay: TLShapeId[];
|
|
9124
|
+
};
|
|
8843
9125
|
}
|
|
8844
9126
|
|
|
8845
9127
|
/**
|
|
@@ -8927,13 +9209,6 @@ export declare interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDi
|
|
|
8927
9209
|
children: ReactNode;
|
|
8928
9210
|
}
|
|
8929
9211
|
|
|
8930
|
-
/** @public */
|
|
8931
|
-
export declare interface TLSnapIndicatorProps {
|
|
8932
|
-
className?: string;
|
|
8933
|
-
line: SnapIndicator;
|
|
8934
|
-
zoom: number;
|
|
8935
|
-
}
|
|
8936
|
-
|
|
8937
9212
|
/** @public */
|
|
8938
9213
|
export declare interface TLStateNodeConstructor {
|
|
8939
9214
|
new (editor: Editor, parent?: StateNode): StateNode;
|
|
@@ -9322,6 +9597,10 @@ export declare function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement
|
|
|
9322
9597
|
export declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>): void;
|
|
9323
9598
|
|
|
9324
9599
|
/**
|
|
9600
|
+
* Reactive list of peer user IDs for collaborators currently shown in the UI.
|
|
9601
|
+
* Mirrors {@link Editor.getVisibleCollaborators} — peers fade out as they
|
|
9602
|
+
* transition to idle/inactive, without requiring a manual re-render.
|
|
9603
|
+
*
|
|
9325
9604
|
* @returns The list of peer UserIDs
|
|
9326
9605
|
* @public
|
|
9327
9606
|
*/
|