@tldraw/editor 4.6.0-next.74727ac95b72 → 4.6.0-next.93a969f315b6
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 +733 -112
- package/dist-cjs/index.js +20 -6
- package/dist-cjs/index.js.map +3 -3
- package/dist-cjs/lib/TldrawEditor.js +59 -14
- package/dist-cjs/lib/TldrawEditor.js.map +3 -3
- package/dist-cjs/lib/components/LiveCollaborators.js +1 -0
- package/dist-cjs/lib/components/LiveCollaborators.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +16 -1
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +10 -3
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +3 -3
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +3 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +1 -0
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +2 -2
- package/dist-cjs/lib/config/{createTLUser.js → createTLCurrentUser.js} +9 -9
- package/dist-cjs/lib/config/createTLCurrentUser.js.map +7 -0
- package/dist-cjs/lib/config/createTLStore.js +30 -0
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/config/defaultAssets.js +36 -0
- package/dist-cjs/lib/config/defaultAssets.js.map +7 -0
- package/dist-cjs/lib/editor/Editor.js +325 -8
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/assets/AssetUtil.js +66 -0
- package/dist-cjs/lib/editor/assets/AssetUtil.js.map +7 -0
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js +80 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +466 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js +17 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +106 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +586 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +6 -4
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +21 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js +6 -0
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +14 -17
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
- package/dist-cjs/lib/editor/types/clipboard-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js +12 -7
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/globals/environment.js +18 -1
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
- package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
- package/dist-cjs/lib/hooks/useCursor.js +3 -7
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
- package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
- package/dist-cjs/lib/options.js +1 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +2 -1
- package/dist-cjs/lib/utils/reparenting.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js.map +2 -2
- package/dist-cjs/lib/utils/runtime.js +2 -1
- package/dist-cjs/lib/utils/runtime.js.map +2 -2
- package/dist-cjs/lib/utils/sync/hardReset.js +0 -8
- package/dist-cjs/lib/utils/sync/hardReset.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 +733 -112
- package/dist-esm/index.mjs +25 -9
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +62 -14
- package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
- package/dist-esm/lib/components/LiveCollaborators.mjs +1 -0
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +16 -1
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +10 -3
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +3 -3
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +3 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +1 -0
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +2 -2
- package/dist-esm/lib/config/{createTLUser.mjs → createTLCurrentUser.mjs} +6 -6
- package/dist-esm/lib/config/createTLCurrentUser.mjs.map +7 -0
- package/dist-esm/lib/config/createTLStore.mjs +36 -1
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/config/defaultAssets.mjs +16 -0
- package/dist-esm/lib/config/defaultAssets.mjs.map +7 -0
- package/dist-esm/lib/editor/Editor.mjs +327 -8
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/assets/AssetUtil.mjs +46 -0
- package/dist-esm/lib/editor/assets/AssetUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs +60 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +438 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs +1 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +88 -0
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +568 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +6 -4
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +21 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs +6 -0
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +14 -17
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +12 -10
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +18 -1
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
- package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
- package/dist-esm/lib/hooks/useCursor.mjs +3 -7
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
- package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
- package/dist-esm/lib/options.mjs +1 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +2 -1
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/runtime.mjs +2 -1
- package/dist-esm/lib/utils/runtime.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/hardReset.mjs +0 -8
- package/dist-esm/lib/utils/sync/hardReset.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +13 -33
- package/package.json +8 -9
- package/src/index.ts +29 -7
- package/src/lib/TldrawEditor.tsx +98 -19
- package/src/lib/components/LiveCollaborators.tsx +8 -2
- package/src/lib/components/MenuClickCapture.tsx +20 -0
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +14 -3
- package/src/lib/components/default-components/DefaultCanvas.tsx +4 -1
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +2 -2
- package/src/lib/components/default-components/DefaultShapeIndicators.tsx +2 -0
- package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +6 -6
- package/src/lib/config/createTLStore.ts +57 -2
- package/src/lib/config/defaultAssets.ts +19 -0
- package/src/lib/editor/Editor.ts +440 -29
- package/src/lib/editor/assets/AssetUtil.ts +85 -0
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
- package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
- package/src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts +82 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +522 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +583 -0
- package/src/lib/editor/managers/PerformanceManager/perf-types.ts +196 -0
- package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +605 -0
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +25 -31
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +7 -5
- package/src/lib/editor/shapes/ShapeUtil.ts +39 -3
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -1
- package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +7 -0
- package/src/lib/editor/tools/StateNode.ts +16 -18
- package/src/lib/editor/types/SvgExportContext.tsx +5 -0
- package/src/lib/editor/types/clipboard-types.ts +2 -1
- package/src/lib/editor/types/external-content.ts +1 -0
- package/src/lib/exports/getSvgJsx.tsx +21 -15
- package/src/lib/globals/environment.ts +18 -0
- package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
- package/src/lib/hooks/useCursor.ts +3 -7
- package/src/lib/hooks/useDarkMode.ts +4 -4
- package/src/lib/hooks/useGestureEvents.ts +240 -168
- package/src/lib/options.ts +7 -0
- package/src/lib/primitives/Box.test.ts +30 -0
- package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
- package/src/lib/utils/reparenting.ts +6 -2
- package/src/lib/utils/richText.ts +1 -1
- package/src/lib/utils/runtime.ts +3 -1
- package/src/lib/utils/sync/hardReset.ts +0 -8
- package/src/version.ts +3 -3
- package/dist-cjs/lib/config/createTLUser.js.map +0 -7
- package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
- package/dist-esm/lib/config/createTLUser.mjs.map +0 -7
- package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
- package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
package/dist-cjs/index.d.ts
CHANGED
|
@@ -57,9 +57,12 @@ import { TLCamera } from '@tldraw/tlschema';
|
|
|
57
57
|
import { TLCreateShapePartial } from '@tldraw/tlschema';
|
|
58
58
|
import { TLCursor } from '@tldraw/tlschema';
|
|
59
59
|
import { TLCursorType } from '@tldraw/tlschema';
|
|
60
|
+
import { TLDefaultColor } from '@tldraw/tlschema';
|
|
61
|
+
import { TLDefaultColorStyle } from '@tldraw/tlschema';
|
|
60
62
|
import { TLDefaultDashStyle } from '@tldraw/tlschema';
|
|
61
63
|
import { TLDefaultHorizontalAlignStyle } from '@tldraw/tlschema';
|
|
62
64
|
import { TLDocument } from '@tldraw/tlschema';
|
|
65
|
+
import { TLFontFace } from '@tldraw/tlschema';
|
|
63
66
|
import { TLGroupShape } from '@tldraw/tlschema';
|
|
64
67
|
import { TLHandle } from '@tldraw/tlschema';
|
|
65
68
|
import { TLImageAsset } from '@tldraw/tlschema';
|
|
@@ -81,8 +84,15 @@ import { TLStore } from '@tldraw/tlschema';
|
|
|
81
84
|
import { TLStoreProps } from '@tldraw/tlschema';
|
|
82
85
|
import { TLStoreSchema } from '@tldraw/tlschema';
|
|
83
86
|
import { TLStoreSnapshot } from '@tldraw/tlschema';
|
|
87
|
+
import { TLTheme } from '@tldraw/tlschema';
|
|
88
|
+
import { TLThemeColors } from '@tldraw/tlschema';
|
|
89
|
+
import { TLThemeId } from '@tldraw/tlschema';
|
|
90
|
+
import { TLThemes } from '@tldraw/tlschema';
|
|
91
|
+
import { TLUnknownAsset } from '@tldraw/tlschema';
|
|
84
92
|
import { TLUnknownBinding } from '@tldraw/tlschema';
|
|
85
93
|
import { TLUnknownShape } from '@tldraw/tlschema';
|
|
94
|
+
import { TLUser } from '@tldraw/tlschema';
|
|
95
|
+
import { TLUserStore } from '@tldraw/tlschema';
|
|
86
96
|
import { TLVideoAsset } from '@tldraw/tlschema';
|
|
87
97
|
import { UnknownRecord } from '@tldraw/store';
|
|
88
98
|
import { VecModel } from '@tldraw/tlschema';
|
|
@@ -145,6 +155,51 @@ export declare class Arc2d extends Geometry2d {
|
|
|
145
155
|
*/
|
|
146
156
|
export declare function areAnglesCompatible(a: number, b: number): boolean;
|
|
147
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Abstract base class for defining asset-type-specific behavior.
|
|
160
|
+
*
|
|
161
|
+
* Each asset type (image, video, bookmark, etc.) has a corresponding AssetUtil that handles
|
|
162
|
+
* type-specific operations like determining supported MIME types and creating assets from files.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export declare abstract class AssetUtil<Asset extends TLAsset = TLAsset> {
|
|
167
|
+
editor: Editor;
|
|
168
|
+
/** Configure this asset util's {@link AssetUtil.options | `options`}. */
|
|
169
|
+
static configure<T extends TLAssetUtilConstructor<any, any>>(this: T, options: T extends new (...args: any[]) => {
|
|
170
|
+
options: infer Options;
|
|
171
|
+
} ? Partial<Options> : never): T;
|
|
172
|
+
constructor(editor: Editor);
|
|
173
|
+
/**
|
|
174
|
+
* Options for this asset util. Override this to provide customization options for your asset.
|
|
175
|
+
* Use {@link AssetUtil.configure} to customize existing asset utils.
|
|
176
|
+
*/
|
|
177
|
+
options: {};
|
|
178
|
+
static props?: RecordProps<TLUnknownAsset>;
|
|
179
|
+
static migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
180
|
+
/**
|
|
181
|
+
* The type of the asset util, which should match the asset's type.
|
|
182
|
+
*/
|
|
183
|
+
static type: string;
|
|
184
|
+
/**
|
|
185
|
+
* Get the default props for an asset of this type.
|
|
186
|
+
*/
|
|
187
|
+
abstract getDefaultProps(): Asset['props'];
|
|
188
|
+
/**
|
|
189
|
+
* Get the MIME types that this asset type supports.
|
|
190
|
+
* Return an empty array if this asset type doesn't support files (e.g. bookmarks).
|
|
191
|
+
*/
|
|
192
|
+
getSupportedMimeTypes(): readonly string[];
|
|
193
|
+
/**
|
|
194
|
+
* Check whether this asset type accepts a given MIME type.
|
|
195
|
+
*/
|
|
196
|
+
acceptsMimeType(mimeType: string): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Create an asset from a file. Return null if this asset type can't handle the file.
|
|
199
|
+
*/
|
|
200
|
+
getAssetFromFile(_file: File, _assetId: TLAssetId): Promise<Asset | null>;
|
|
201
|
+
}
|
|
202
|
+
|
|
148
203
|
/** @public */
|
|
149
204
|
export declare function average(A: VecLike, B: VecLike): string;
|
|
150
205
|
|
|
@@ -718,6 +773,12 @@ export declare function createDeepLinkString(deepLink: TLDeepLink): string;
|
|
|
718
773
|
*/
|
|
719
774
|
export declare function createSessionStateSnapshotSignal(store: TLStore): Signal<null | TLSessionStateSnapshot>;
|
|
720
775
|
|
|
776
|
+
/** @public */
|
|
777
|
+
export declare function createTLCurrentUser(opts?: {
|
|
778
|
+
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
779
|
+
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
780
|
+
}): TLCurrentUser;
|
|
781
|
+
|
|
721
782
|
/**
|
|
722
783
|
* A helper for creating a TLStore schema from either an object with shapeUtils, bindingUtils, and
|
|
723
784
|
* migrations, or a schema.
|
|
@@ -735,13 +796,7 @@ export declare function createTLSchemaFromUtils(opts: TLStoreSchemaOptions): Sto
|
|
|
735
796
|
*
|
|
736
797
|
* @public
|
|
737
798
|
*/
|
|
738
|
-
export declare function createTLStore({ initialData, defaultName, id, assets, onMount, collaboration, ...rest }?: TLStoreOptions): TLStore;
|
|
739
|
-
|
|
740
|
-
/** @public */
|
|
741
|
-
export declare function createTLUser(opts?: {
|
|
742
|
-
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
743
|
-
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
744
|
-
}): TLUser;
|
|
799
|
+
export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, themes, ...rest }?: TLStoreOptions): TLStore;
|
|
745
800
|
|
|
746
801
|
/** @public */
|
|
747
802
|
export declare class CubicBezier2d extends Polyline2d {
|
|
@@ -816,6 +871,13 @@ export declare interface DebugFlagDefaults<T> {
|
|
|
816
871
|
|
|
817
872
|
/* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
|
|
818
873
|
|
|
874
|
+
/**
|
|
875
|
+
* The default theme definition containing color palettes for both light and dark modes.
|
|
876
|
+
*
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
export declare const DEFAULT_THEME: TLTheme;
|
|
880
|
+
|
|
819
881
|
/** @public @react */
|
|
820
882
|
export declare function DefaultBackground(): JSX.Element;
|
|
821
883
|
|
|
@@ -942,6 +1004,7 @@ export declare const defaultTldrawOptions: {
|
|
|
942
1004
|
readonly tooltipDelayMs: 700;
|
|
943
1005
|
readonly uiCoarseDragDistanceSquared: 625;
|
|
944
1006
|
readonly uiDragDistanceSquared: 16;
|
|
1007
|
+
readonly useCanvasIndicators: true;
|
|
945
1008
|
readonly zoomToFitPadding: 128;
|
|
946
1009
|
};
|
|
947
1010
|
|
|
@@ -963,6 +1026,9 @@ export declare const defaultUserPreferences: Readonly<{
|
|
|
963
1026
|
name: "";
|
|
964
1027
|
}>;
|
|
965
1028
|
|
|
1029
|
+
/** @public */
|
|
1030
|
+
export declare const defaultUserStore: TLUserStore;
|
|
1031
|
+
|
|
966
1032
|
/**
|
|
967
1033
|
* Convert degrees to radians.
|
|
968
1034
|
*
|
|
@@ -1038,7 +1104,7 @@ export declare class EdgeScrollManager {
|
|
|
1038
1104
|
/** @public */
|
|
1039
1105
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1040
1106
|
readonly id: string;
|
|
1041
|
-
constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus,
|
|
1107
|
+
constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
|
|
1042
1108
|
private readonly _getShapeVisibility?;
|
|
1043
1109
|
private getIsShapeHiddenCache;
|
|
1044
1110
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1101,7 +1167,13 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1101
1167
|
* @public
|
|
1102
1168
|
*/
|
|
1103
1169
|
readonly snaps: SnapManager;
|
|
1104
|
-
|
|
1170
|
+
/**
|
|
1171
|
+
* A manager for performance measurement hooks.
|
|
1172
|
+
*
|
|
1173
|
+
* @public
|
|
1174
|
+
*/
|
|
1175
|
+
readonly performance: PerformanceManager;
|
|
1176
|
+
/* Excluded from this release type: _spatialIndex */
|
|
1105
1177
|
/**
|
|
1106
1178
|
* A manager for the any asynchronous events and making sure they're
|
|
1107
1179
|
* cleaned up upon disposal.
|
|
@@ -1120,6 +1192,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1120
1192
|
* @public
|
|
1121
1193
|
*/
|
|
1122
1194
|
readonly user: UserPreferencesManager;
|
|
1195
|
+
/* Excluded from this release type: _themeManager */
|
|
1123
1196
|
/**
|
|
1124
1197
|
* A helper for measuring text.
|
|
1125
1198
|
*
|
|
@@ -1170,6 +1243,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1170
1243
|
* @public
|
|
1171
1244
|
*/
|
|
1172
1245
|
dispose(): void;
|
|
1246
|
+
/**
|
|
1247
|
+
* Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
|
|
1248
|
+
*
|
|
1249
|
+
* @public
|
|
1250
|
+
*/
|
|
1251
|
+
getColorMode(): 'dark' | 'light';
|
|
1252
|
+
/**
|
|
1253
|
+
* Set the color mode. Note that this is a convenience method that passes the mode to
|
|
1254
|
+
* `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
|
|
1255
|
+
*
|
|
1256
|
+
* @public
|
|
1257
|
+
*/
|
|
1258
|
+
setColorMode(mode: 'dark' | 'light'): this;
|
|
1259
|
+
/**
|
|
1260
|
+
* Get the id of the current theme.
|
|
1261
|
+
*
|
|
1262
|
+
* @public
|
|
1263
|
+
*/
|
|
1264
|
+
getCurrentThemeId(): TLThemeId;
|
|
1265
|
+
/**
|
|
1266
|
+
* Get the current theme definition.
|
|
1267
|
+
*
|
|
1268
|
+
* @public
|
|
1269
|
+
*/
|
|
1270
|
+
getCurrentTheme(): TLTheme;
|
|
1271
|
+
/**
|
|
1272
|
+
* Set the current theme by id.
|
|
1273
|
+
*
|
|
1274
|
+
* @public
|
|
1275
|
+
*/
|
|
1276
|
+
setCurrentTheme(id: TLThemeId): this;
|
|
1277
|
+
/**
|
|
1278
|
+
* Get all registered theme definitions.
|
|
1279
|
+
*
|
|
1280
|
+
* @public
|
|
1281
|
+
*/
|
|
1282
|
+
getThemes(): TLThemes;
|
|
1283
|
+
/**
|
|
1284
|
+
* Get a single theme definition by id.
|
|
1285
|
+
*
|
|
1286
|
+
* @public
|
|
1287
|
+
*/
|
|
1288
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
1289
|
+
/**
|
|
1290
|
+
* Replace all theme definitions, or update them via a callback that receives a deep copy.
|
|
1291
|
+
* The `'default'` theme must always be present in the result.
|
|
1292
|
+
*
|
|
1293
|
+
* @example
|
|
1294
|
+
* ```ts
|
|
1295
|
+
* // Replace all themes
|
|
1296
|
+
* editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
|
|
1297
|
+
*
|
|
1298
|
+
* // Update via callback
|
|
1299
|
+
* editor.updateThemes((themes) => {
|
|
1300
|
+
* delete themes.ocean
|
|
1301
|
+
* return themes
|
|
1302
|
+
* })
|
|
1303
|
+
* ```
|
|
1304
|
+
*
|
|
1305
|
+
* @public
|
|
1306
|
+
*/
|
|
1307
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): this;
|
|
1308
|
+
/**
|
|
1309
|
+
* Register or update a single theme definition. The theme is keyed by its `id` property.
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```ts
|
|
1313
|
+
* // Override a property on the default theme
|
|
1314
|
+
* editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
|
|
1315
|
+
*
|
|
1316
|
+
* // Register a new theme
|
|
1317
|
+
* editor.updateTheme({ id: 'ocean', ...myOceanTheme })
|
|
1318
|
+
* ```
|
|
1319
|
+
*
|
|
1320
|
+
* @public
|
|
1321
|
+
*/
|
|
1322
|
+
updateTheme(theme: TLTheme): this;
|
|
1173
1323
|
/**
|
|
1174
1324
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1175
1325
|
*
|
|
@@ -1178,6 +1328,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1178
1328
|
shapeUtils: {
|
|
1179
1329
|
readonly [K in string]?: ShapeUtil<TLShape>;
|
|
1180
1330
|
};
|
|
1331
|
+
/* Excluded from this release type: _shapeUtilsByAssetType */
|
|
1181
1332
|
styleProps: {
|
|
1182
1333
|
[key: string]: Map<StyleProp<any>, string>;
|
|
1183
1334
|
};
|
|
@@ -1209,6 +1360,15 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1209
1360
|
hasShapeUtil(shape: TLShape | TLShapePartial<TLShape>): boolean;
|
|
1210
1361
|
hasShapeUtil(type: TLShape['type']): boolean;
|
|
1211
1362
|
hasShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): boolean;
|
|
1363
|
+
/**
|
|
1364
|
+
* Get the shape util that handles the given asset type.
|
|
1365
|
+
* Returns the shape util whose {@link ShapeUtil.handledAssetTypes} includes
|
|
1366
|
+
* the given asset type, or undefined if none matches.
|
|
1367
|
+
*
|
|
1368
|
+
* @param assetType - The asset type string.
|
|
1369
|
+
* @public
|
|
1370
|
+
*/
|
|
1371
|
+
getShapeUtilForAssetType(assetType: string): ShapeUtil | undefined;
|
|
1212
1372
|
/**
|
|
1213
1373
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1214
1374
|
*
|
|
@@ -1239,6 +1399,40 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1239
1399
|
type: S['type'];
|
|
1240
1400
|
} | S): BindingUtil<S>;
|
|
1241
1401
|
getBindingUtil<T extends BindingUtil>(type: T extends BindingUtil<infer R> ? R['type'] : string): T;
|
|
1402
|
+
/**
|
|
1403
|
+
* A map of asset utility classes by asset type.
|
|
1404
|
+
*
|
|
1405
|
+
* @public
|
|
1406
|
+
*/
|
|
1407
|
+
assetUtils: {
|
|
1408
|
+
readonly [K in string]?: AssetUtil<TLAsset>;
|
|
1409
|
+
};
|
|
1410
|
+
/**
|
|
1411
|
+
* Get an asset util from an asset or asset type.
|
|
1412
|
+
*
|
|
1413
|
+
* @param arg - An asset, asset type string, or object with type.
|
|
1414
|
+
*
|
|
1415
|
+
* @public
|
|
1416
|
+
*/
|
|
1417
|
+
getAssetUtil<S extends TLAsset>(asset: {
|
|
1418
|
+
type: S['type'];
|
|
1419
|
+
} | S): AssetUtil<S>;
|
|
1420
|
+
getAssetUtil(type: string): AssetUtil;
|
|
1421
|
+
/**
|
|
1422
|
+
* Returns true if the editor has an asset util for the given asset type.
|
|
1423
|
+
*
|
|
1424
|
+
* @public
|
|
1425
|
+
*/
|
|
1426
|
+
hasAssetUtil(arg: {
|
|
1427
|
+
type: string;
|
|
1428
|
+
} | string): boolean;
|
|
1429
|
+
/**
|
|
1430
|
+
* Get the asset util that accepts the given MIME type.
|
|
1431
|
+
* Returns null if no registered asset util accepts the MIME type.
|
|
1432
|
+
*
|
|
1433
|
+
* @public
|
|
1434
|
+
*/
|
|
1435
|
+
getAssetUtilForMimeType(mimeType: string): AssetUtil | null;
|
|
1242
1436
|
/**
|
|
1243
1437
|
* A manager for the editor's history.
|
|
1244
1438
|
*
|
|
@@ -2269,6 +2463,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2269
2463
|
* @public
|
|
2270
2464
|
*/
|
|
2271
2465
|
getCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
2466
|
+
/**
|
|
2467
|
+
* Get the current user's ID for attribution purposes.
|
|
2468
|
+
* Also ensures a `user:` record exists in the store for the current user.
|
|
2469
|
+
* Returns `null` when the user store has no current user.
|
|
2470
|
+
*
|
|
2471
|
+
* @public
|
|
2472
|
+
*/
|
|
2473
|
+
getAttributionUserId(): null | string;
|
|
2474
|
+
/* Excluded from this release type: _ensureUserRecord */
|
|
2475
|
+
/**
|
|
2476
|
+
* Resolve a display name for a user ID. Asks the
|
|
2477
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2478
|
+
* falling back to the `user:` record in the store.
|
|
2479
|
+
*
|
|
2480
|
+
* @public
|
|
2481
|
+
*/
|
|
2482
|
+
getAttributionDisplayName(userId: null | string): null | string;
|
|
2483
|
+
/**
|
|
2484
|
+
* Resolve a user record by ID. Asks the
|
|
2485
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2486
|
+
* falling back to the `user:` record in the store.
|
|
2487
|
+
*
|
|
2488
|
+
* @public
|
|
2489
|
+
*/
|
|
2490
|
+
getAttributionUser(userId: null | string): null | TLUser;
|
|
2491
|
+
/* Excluded from this release type: _getReferencedUserIds */
|
|
2272
2492
|
private _isLockedOnFollowingUser;
|
|
2273
2493
|
/**
|
|
2274
2494
|
* Start viewport-following a user.
|
|
@@ -4363,6 +4583,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
|
|
|
4363
4583
|
*/
|
|
4364
4584
|
export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
|
|
4365
4585
|
|
|
4586
|
+
/**
|
|
4587
|
+
* Resolves a color style value to its actual CSS color string for a given theme and variant.
|
|
4588
|
+
* If the color is not a default theme color, returns the color value as-is.
|
|
4589
|
+
*
|
|
4590
|
+
* @param colors - The color palette for the current color mode (e.g. `theme.colors[colorMode]`)
|
|
4591
|
+
* @param color - The color style value to resolve
|
|
4592
|
+
* @param variant - Which variant of the color to return (solid, fill, pattern, etc.)
|
|
4593
|
+
* @returns The CSS color string for the specified color and variant
|
|
4594
|
+
*
|
|
4595
|
+
* @example
|
|
4596
|
+
* ```ts
|
|
4597
|
+
* import { getColorValue } from 'tldraw'
|
|
4598
|
+
*
|
|
4599
|
+
* const colors = editor.getCurrentTheme().colors[editor.getColorMode()]
|
|
4600
|
+
*
|
|
4601
|
+
* // Get the solid variant of red
|
|
4602
|
+
* const redSolid = getColorValue(colors, 'red', 'solid') // '#e03131'
|
|
4603
|
+
*
|
|
4604
|
+
* // Get the fill variant of blue
|
|
4605
|
+
* const blueFill = getColorValue(colors, 'blue', 'fill') // '#4465e9'
|
|
4606
|
+
*
|
|
4607
|
+
* // Custom color passes through unchanged
|
|
4608
|
+
* const customColor = getColorValue(colors, '#ff0000', 'solid') // '#ff0000'
|
|
4609
|
+
* ```
|
|
4610
|
+
*
|
|
4611
|
+
* @public
|
|
4612
|
+
*/
|
|
4613
|
+
export declare function getColorValue(colors: TLThemeColors, color: string | TLDefaultColorStyle, variant: keyof TLDefaultColor): string;
|
|
4614
|
+
|
|
4366
4615
|
/** @public */
|
|
4367
4616
|
export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
|
|
4368
4617
|
|
|
@@ -4533,7 +4782,7 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
|
|
|
4533
4782
|
static type: "group";
|
|
4534
4783
|
static props: RecordProps<TLGroupShape>;
|
|
4535
4784
|
static migrations: TLPropsMigrations;
|
|
4536
|
-
hideSelectionBoundsFg(): boolean;
|
|
4785
|
+
hideSelectionBoundsFg(shape: TLGroupShape): boolean;
|
|
4537
4786
|
canBind(): boolean;
|
|
4538
4787
|
canResize(): boolean;
|
|
4539
4788
|
canResizeChildren(): boolean;
|
|
@@ -5175,6 +5424,94 @@ export declare function parseDeepLinkString(deepLinkString: string): TLDeepLink;
|
|
|
5175
5424
|
/** @public */
|
|
5176
5425
|
export declare type PerfectDashTerminal = 'none' | 'outset' | 'skip';
|
|
5177
5426
|
|
|
5427
|
+
/**
|
|
5428
|
+
* Optional adapter that pipes PerformanceManager events into browser
|
|
5429
|
+
* `performance.mark()` / `performance.measure()` for DevTools integration.
|
|
5430
|
+
*
|
|
5431
|
+
* Tree-shakeable — only included if imported.
|
|
5432
|
+
*
|
|
5433
|
+
* @example
|
|
5434
|
+
* ```ts
|
|
5435
|
+
* const adapter = new PerformanceApiAdapter(editor.performance)
|
|
5436
|
+
* // ... later
|
|
5437
|
+
* adapter.dispose()
|
|
5438
|
+
* ```
|
|
5439
|
+
*
|
|
5440
|
+
* @public
|
|
5441
|
+
*/
|
|
5442
|
+
export declare class PerformanceApiAdapter {
|
|
5443
|
+
private cleanups;
|
|
5444
|
+
constructor(perfManager: PerformanceManager);
|
|
5445
|
+
/** Remove all listeners and stop piping events. @public */
|
|
5446
|
+
dispose(): void;
|
|
5447
|
+
}
|
|
5448
|
+
|
|
5449
|
+
/**
|
|
5450
|
+
* Manages performance event subscriptions for the editor. Available as `editor.performance`.
|
|
5451
|
+
*
|
|
5452
|
+
* Listeners are lazy — internal editor hooks (frame, shape events) are only attached while
|
|
5453
|
+
* at least one subscriber exists, so there is zero overhead when unused.
|
|
5454
|
+
*
|
|
5455
|
+
* @example
|
|
5456
|
+
* ```ts
|
|
5457
|
+
* const unsub = editor.performance.on('interaction-end', (event) => {
|
|
5458
|
+
* console.log(`${event.name}: ${event.fps.toFixed(1)} fps, p95=${event.p95FrameTime.toFixed(1)}ms`)
|
|
5459
|
+
* })
|
|
5460
|
+
* ```
|
|
5461
|
+
*
|
|
5462
|
+
* @public
|
|
5463
|
+
*/
|
|
5464
|
+
export declare class PerformanceManager {
|
|
5465
|
+
/* Excluded from this release type: emitter */
|
|
5466
|
+
private editor;
|
|
5467
|
+
private activeInteraction;
|
|
5468
|
+
private activeCamera;
|
|
5469
|
+
private frameCleanup;
|
|
5470
|
+
private shapeCreatedCleanup;
|
|
5471
|
+
private shapeEditedCleanup;
|
|
5472
|
+
private shapeDeletedCleanup;
|
|
5473
|
+
private loafObserver;
|
|
5474
|
+
constructor(editor: Editor);
|
|
5475
|
+
/**
|
|
5476
|
+
* Subscribe to a performance event. Returns an unsubscribe function.
|
|
5477
|
+
*
|
|
5478
|
+
* @example
|
|
5479
|
+
* ```ts
|
|
5480
|
+
* const unsub = editor.performance.on('interaction-end', (event) => {
|
|
5481
|
+
* sendToAnalytics({ name: event.name, fps: event.fps, p95: event.p95FrameTime })
|
|
5482
|
+
* })
|
|
5483
|
+
* // later: unsub()
|
|
5484
|
+
* ```
|
|
5485
|
+
*
|
|
5486
|
+
* @public
|
|
5487
|
+
*/
|
|
5488
|
+
on<K extends keyof TLPerfEventMap>(event: K, fn: (...args: TLPerfEventMap[K]) => void): () => void;
|
|
5489
|
+
/**
|
|
5490
|
+
* Subscribe to a performance event once. The listener is removed after the first invocation.
|
|
5491
|
+
* Returns an unsubscribe function for early removal.
|
|
5492
|
+
*
|
|
5493
|
+
* @public
|
|
5494
|
+
*/
|
|
5495
|
+
once<K extends keyof TLPerfEventMap>(event: K, fn: (...args: TLPerfEventMap[K]) => void): () => void;
|
|
5496
|
+
/* Excluded from this release type: dispose */
|
|
5497
|
+
/* Excluded from this release type: _notifyInteractionStart */
|
|
5498
|
+
/* Excluded from this release type: _notifyInteractionEnd */
|
|
5499
|
+
/* Excluded from this release type: _notifyCameraOperation */
|
|
5500
|
+
/* Excluded from this release type: _notifyUndoRedo */
|
|
5501
|
+
private _startCameraSession;
|
|
5502
|
+
private _endCameraSession;
|
|
5503
|
+
private _onFrame;
|
|
5504
|
+
private _onShapesCreated;
|
|
5505
|
+
private _onShapesEdited;
|
|
5506
|
+
private _onShapesDeleted;
|
|
5507
|
+
private _startLoafObserver;
|
|
5508
|
+
private _stopLoafObserver;
|
|
5509
|
+
private _needsFrameListener;
|
|
5510
|
+
private _needsLoafObserver;
|
|
5511
|
+
private _maybeAttachLazyListeners;
|
|
5512
|
+
private _maybeDetachLazyListeners;
|
|
5513
|
+
}
|
|
5514
|
+
|
|
5178
5515
|
/**
|
|
5179
5516
|
* Find the approximate perimeter of an ellipse.
|
|
5180
5517
|
*
|
|
@@ -5369,6 +5706,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
|
|
|
5369
5706
|
y: number;
|
|
5370
5707
|
};
|
|
5371
5708
|
|
|
5709
|
+
/**
|
|
5710
|
+
* Resolve a partial set of user-provided themes into a complete `TLThemes`
|
|
5711
|
+
* record by merging with `DEFAULT_THEME`. The result is suitable for passing to
|
|
5712
|
+
* `registerColorsFromThemes`, `registerFontsFromThemes`, and the
|
|
5713
|
+
* `ThemeManager` constructor.
|
|
5714
|
+
*
|
|
5715
|
+
* @public
|
|
5716
|
+
*/
|
|
5717
|
+
export declare function resolveThemes(themes?: Partial<TLThemes>): TLThemes;
|
|
5718
|
+
|
|
5372
5719
|
/** @public */
|
|
5373
5720
|
export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
|
|
5374
5721
|
|
|
@@ -5650,12 +5997,32 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5650
5997
|
* @public
|
|
5651
5998
|
*/
|
|
5652
5999
|
static type: string;
|
|
6000
|
+
/**
|
|
6001
|
+
* The asset types that this shape can be created from.
|
|
6002
|
+
* When a file is dropped on the canvas, the editor finds the shape util
|
|
6003
|
+
* whose `handledAssetTypes` includes the asset's type and calls
|
|
6004
|
+
* {@link ShapeUtil.createShapeForAsset} to produce the shape.
|
|
6005
|
+
*
|
|
6006
|
+
* @public
|
|
6007
|
+
*/
|
|
6008
|
+
static handledAssetTypes?: readonly string[];
|
|
5653
6009
|
/**
|
|
5654
6010
|
* Get the default props for a shape.
|
|
5655
6011
|
*
|
|
5656
6012
|
* @public
|
|
5657
6013
|
*/
|
|
5658
6014
|
abstract getDefaultProps(): Shape['props'];
|
|
6015
|
+
/**
|
|
6016
|
+
* Create a shape partial for placing an asset on the canvas.
|
|
6017
|
+
* Only called for shapes whose constructor declares matching
|
|
6018
|
+
* {@link ShapeUtil.handledAssetTypes | `handledAssetTypes`}.
|
|
6019
|
+
*
|
|
6020
|
+
* @param asset - The asset to create a shape for.
|
|
6021
|
+
* @param position - Where to place the shape.
|
|
6022
|
+
* @returns A shape partial, or null if this shape can't be created for the asset.
|
|
6023
|
+
* @public
|
|
6024
|
+
*/
|
|
6025
|
+
createShapeForAsset?(asset: TLAsset, position: VecModel): null | TLShapePartial;
|
|
5659
6026
|
/**
|
|
5660
6027
|
* Get the shape's geometry.
|
|
5661
6028
|
*
|
|
@@ -5736,7 +6103,7 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5736
6103
|
*
|
|
5737
6104
|
* @public
|
|
5738
6105
|
*/
|
|
5739
|
-
canBind(
|
|
6106
|
+
canBind(opts: TLShapeUtilCanBindOpts): boolean;
|
|
5740
6107
|
/**
|
|
5741
6108
|
* Whether the shape can be double clicked to edit.
|
|
5742
6109
|
*
|
|
@@ -5917,7 +6284,7 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5917
6284
|
* @param type - The shape type.
|
|
5918
6285
|
* @public
|
|
5919
6286
|
*/
|
|
5920
|
-
canReceiveNewChildrenOfType(shape: Shape,
|
|
6287
|
+
canReceiveNewChildrenOfType(shape: Shape, type: TLShape['type']): boolean;
|
|
5921
6288
|
/**
|
|
5922
6289
|
* Get the shape as an SVG object.
|
|
5923
6290
|
*
|
|
@@ -5957,6 +6324,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5957
6324
|
*/
|
|
5958
6325
|
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
|
|
5959
6326
|
getText(shape: Shape): string | undefined;
|
|
6327
|
+
/**
|
|
6328
|
+
* Return user IDs referenced in shape-specific props.
|
|
6329
|
+
* Used when copying shapes to include referenced users on the clipboard.
|
|
6330
|
+
* Override this if your shape stores user IDs in custom props.
|
|
6331
|
+
*
|
|
6332
|
+
* @public
|
|
6333
|
+
*/
|
|
6334
|
+
getReferencedUserIds(shape: Shape): string[];
|
|
5960
6335
|
getAriaDescriptor(shape: Shape): string | undefined;
|
|
5961
6336
|
/**
|
|
5962
6337
|
* A callback called just before a shape is created. This method provides a last chance to modify
|
|
@@ -6352,6 +6727,8 @@ export declare abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
6352
6727
|
static children?: () => TLStateNodeConstructor[];
|
|
6353
6728
|
static isLockable: boolean;
|
|
6354
6729
|
static useCoalescedEvents: boolean;
|
|
6730
|
+
/** Set to `true` in subclasses to emit interaction-start/end performance events when this state is entered/exited. */
|
|
6731
|
+
static trackPerformance: boolean;
|
|
6355
6732
|
id: string;
|
|
6356
6733
|
type: 'branch' | 'leaf' | 'root';
|
|
6357
6734
|
shapeType?: string;
|
|
@@ -6486,6 +6863,10 @@ export declare interface SvgExportContext {
|
|
|
6486
6863
|
* Whether the export should be in dark mode.
|
|
6487
6864
|
*/
|
|
6488
6865
|
readonly isDarkMode: boolean;
|
|
6866
|
+
/**
|
|
6867
|
+
* The color mode to use for this export.
|
|
6868
|
+
*/
|
|
6869
|
+
readonly colorMode: 'dark' | 'light';
|
|
6489
6870
|
/**
|
|
6490
6871
|
* The scale of the export - how much CSS pixels will be scaled up/down by.
|
|
6491
6872
|
*/
|
|
@@ -6556,6 +6937,47 @@ export declare class TextManager {
|
|
|
6556
6937
|
}[];
|
|
6557
6938
|
}
|
|
6558
6939
|
|
|
6940
|
+
/**
|
|
6941
|
+
* Manages the editor's color themes.
|
|
6942
|
+
*
|
|
6943
|
+
* Stores named theme definitions (each containing light and dark color palettes
|
|
6944
|
+
* alongside shared properties like font size). The current theme is resolved by
|
|
6945
|
+
* combining the current theme name with the user's color mode preference.
|
|
6946
|
+
*
|
|
6947
|
+
* **Terminology:**
|
|
6948
|
+
* - **Theme** (`TLTheme`): A named set of colors and typographic values for both light and dark modes.
|
|
6949
|
+
* - **Color mode** (`'light' | 'dark'`): The resolved appearance mode, derived from the user's
|
|
6950
|
+
* `colorScheme` preference (`'light' | 'dark' | 'system'`). Access via `getColorMode()`.
|
|
6951
|
+
*
|
|
6952
|
+
* @public
|
|
6953
|
+
*/
|
|
6954
|
+
export declare class ThemeManager {
|
|
6955
|
+
private readonly editor;
|
|
6956
|
+
private readonly _themes;
|
|
6957
|
+
private readonly _currentThemeId;
|
|
6958
|
+
constructor(editor: Editor, options: {
|
|
6959
|
+
initial: TLThemeId;
|
|
6960
|
+
themes: TLThemes;
|
|
6961
|
+
});
|
|
6962
|
+
/** Get the current color mode based on the user's dark mode preference. */
|
|
6963
|
+
getColorMode(): 'dark' | 'light';
|
|
6964
|
+
/** Get all registered theme definitions. */
|
|
6965
|
+
getThemes(): TLThemes;
|
|
6966
|
+
/** Get a single theme definition by id. */
|
|
6967
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
6968
|
+
/** Get the id of the current theme. */
|
|
6969
|
+
getCurrentThemeId(): TLThemeId;
|
|
6970
|
+
getCurrentTheme(): TLTheme;
|
|
6971
|
+
/** Set the current theme by id. The theme must have been previously registered. */
|
|
6972
|
+
setCurrentTheme(id: TLThemeId): void;
|
|
6973
|
+
/** Replace all theme definitions, or update them via a callback that receives a deep copy. */
|
|
6974
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): void;
|
|
6975
|
+
/** Register or update a named theme definition. */
|
|
6976
|
+
updateTheme(theme: TLTheme): void;
|
|
6977
|
+
/** Clean up any resources held by the manager. */
|
|
6978
|
+
dispose(): void;
|
|
6979
|
+
}
|
|
6980
|
+
|
|
6559
6981
|
/* Excluded from this release type: TickManager */
|
|
6560
6982
|
|
|
6561
6983
|
/**
|
|
@@ -6574,12 +6996,23 @@ export declare type TiptapNode = Node_2;
|
|
|
6574
6996
|
/** @public */
|
|
6575
6997
|
export declare type TLAdjacentDirection = 'down' | 'left' | 'next' | 'prev' | 'right' | 'up';
|
|
6576
6998
|
|
|
6999
|
+
/** @public */
|
|
7000
|
+
export declare type TLAnyAssetUtilConstructor = TLAssetUtilConstructor<any>;
|
|
7001
|
+
|
|
6577
7002
|
/** @public */
|
|
6578
7003
|
export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
6579
7004
|
|
|
6580
7005
|
/** @public */
|
|
6581
7006
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
6582
7007
|
|
|
7008
|
+
/** @public */
|
|
7009
|
+
export declare interface TLAssetUtilConstructor<T extends TLAsset = TLAsset, U extends AssetUtil<T> = AssetUtil<T>> {
|
|
7010
|
+
new (editor: Editor): U;
|
|
7011
|
+
type: T['type'];
|
|
7012
|
+
props?: RecordProps<T>;
|
|
7013
|
+
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
7014
|
+
}
|
|
7015
|
+
|
|
6583
7016
|
/** @public */
|
|
6584
7017
|
export declare type TLBaseBoxShape = ExtractShapeByProps<{
|
|
6585
7018
|
h: number;
|
|
@@ -6669,6 +7102,29 @@ export declare interface TLCameraConstraints {
|
|
|
6669
7102
|
};
|
|
6670
7103
|
}
|
|
6671
7104
|
|
|
7105
|
+
/**
|
|
7106
|
+
* Emitted when a camera operation ends (after a 50ms debounce), with aggregated frame time stats.
|
|
7107
|
+
* @public
|
|
7108
|
+
*/
|
|
7109
|
+
export declare interface TLCameraEndPerfEvent extends TLPerfFrameTimeStats {
|
|
7110
|
+
/** Whether this was a pan or zoom operation. */
|
|
7111
|
+
type: 'panning' | 'zooming';
|
|
7112
|
+
/** Total shapes on the current page. */
|
|
7113
|
+
shapeCount: number;
|
|
7114
|
+
/** Number of shapes visible (not culled) in the viewport. */
|
|
7115
|
+
visibleShapeCount: number;
|
|
7116
|
+
/** Number of shapes culled (off-screen) from rendering. */
|
|
7117
|
+
culledShapeCount: number;
|
|
7118
|
+
/** Viewport width in screen pixels. */
|
|
7119
|
+
viewportWidth: number;
|
|
7120
|
+
/** Viewport height in screen pixels. */
|
|
7121
|
+
viewportHeight: number;
|
|
7122
|
+
/** Camera zoom level (`camera.z`) at session end. */
|
|
7123
|
+
zoomLevel: number;
|
|
7124
|
+
/** `performance.now()` when the camera session ended. */
|
|
7125
|
+
timestamp: number;
|
|
7126
|
+
}
|
|
7127
|
+
|
|
6672
7128
|
/** @public */
|
|
6673
7129
|
export declare interface TLCameraMoveOptions {
|
|
6674
7130
|
/** Whether to move the camera immediately, rather than on the next tick. */
|
|
@@ -6707,6 +7163,17 @@ export declare interface TLCameraOptions {
|
|
|
6707
7163
|
constraints?: TLCameraConstraints;
|
|
6708
7164
|
}
|
|
6709
7165
|
|
|
7166
|
+
/**
|
|
7167
|
+
* Emitted when a camera operation (pan or zoom) begins.
|
|
7168
|
+
* @public
|
|
7169
|
+
*/
|
|
7170
|
+
export declare interface TLCameraStartPerfEvent {
|
|
7171
|
+
/** Whether this is a pan or zoom operation. */
|
|
7172
|
+
type: 'panning' | 'zooming';
|
|
7173
|
+
/** `performance.now()` when the camera session started. */
|
|
7174
|
+
timestamp: number;
|
|
7175
|
+
}
|
|
7176
|
+
|
|
6710
7177
|
/** @public */
|
|
6711
7178
|
export declare type TLCancelEvent = (info: TLCancelEventInfo) => void;
|
|
6712
7179
|
|
|
@@ -6801,6 +7268,7 @@ export declare interface TLContent {
|
|
|
6801
7268
|
rootShapeIds: TLShapeId[];
|
|
6802
7269
|
assets: TLAsset[];
|
|
6803
7270
|
schema: SerializedSchema;
|
|
7271
|
+
users?: TLUser[];
|
|
6804
7272
|
}
|
|
6805
7273
|
|
|
6806
7274
|
/**
|
|
@@ -6822,6 +7290,12 @@ export declare interface TLCropInfo<T extends TLShape> {
|
|
|
6822
7290
|
aspectRatioLocked?: boolean;
|
|
6823
7291
|
}
|
|
6824
7292
|
|
|
7293
|
+
/** @public */
|
|
7294
|
+
export declare interface TLCurrentUser {
|
|
7295
|
+
readonly userPreferences: Signal<TLUserPreferences>;
|
|
7296
|
+
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7297
|
+
}
|
|
7298
|
+
|
|
6825
7299
|
/** @public */
|
|
6826
7300
|
export declare interface TLCursorProps {
|
|
6827
7301
|
userId: string;
|
|
@@ -6922,6 +7396,10 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6922
7396
|
* An array of binding utils to use in the editor.
|
|
6923
7397
|
*/
|
|
6924
7398
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
7399
|
+
/**
|
|
7400
|
+
* An array of asset utils to use in the editor.
|
|
7401
|
+
*/
|
|
7402
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
6925
7403
|
/**
|
|
6926
7404
|
* An array of tools to add to the editor's state chart.
|
|
6927
7405
|
*/
|
|
@@ -6949,11 +7427,23 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6949
7427
|
/**
|
|
6950
7428
|
* The user interacting with the editor.
|
|
6951
7429
|
*/
|
|
6952
|
-
user?:
|
|
7430
|
+
user?: TLCurrentUser;
|
|
7431
|
+
/**
|
|
7432
|
+
* The editor's color scheme. Defaults to `'light'`.
|
|
7433
|
+
*
|
|
7434
|
+
* - `'light'` - Always use light mode.
|
|
7435
|
+
* - `'dark'` - Always use dark mode.
|
|
7436
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7437
|
+
*/
|
|
7438
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7439
|
+
/**
|
|
7440
|
+
* Named themes for the editor.
|
|
7441
|
+
*/
|
|
7442
|
+
themes?: Partial<TLThemes>;
|
|
6953
7443
|
/**
|
|
6954
|
-
*
|
|
7444
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
6955
7445
|
*/
|
|
6956
|
-
|
|
7446
|
+
initialTheme?: TLThemeId;
|
|
6957
7447
|
/**
|
|
6958
7448
|
* Camera options for the editor.
|
|
6959
7449
|
*
|
|
@@ -7213,6 +7703,12 @@ export declare interface TldrawOptions {
|
|
|
7213
7703
|
* viewport's page dimensions regardless of overview zoom changes.
|
|
7214
7704
|
*/
|
|
7215
7705
|
readonly quickZoomPreservesScreenBounds: boolean;
|
|
7706
|
+
/**
|
|
7707
|
+
* Whether to use 2D canvas rendering for shape indicators. When true (default),
|
|
7708
|
+
* shapes that support it will render indicators on a 2D canvas for better
|
|
7709
|
+
* performance. When false, all indicators use legacy SVG rendering.
|
|
7710
|
+
*/
|
|
7711
|
+
readonly useCanvasIndicators: boolean;
|
|
7216
7712
|
/**
|
|
7217
7713
|
* Called before content is written to the clipboard during a copy or cut operation.
|
|
7218
7714
|
* Receives the serialized content (shapes, bindings, assets) and can filter or transform
|
|
@@ -7346,18 +7842,17 @@ export declare interface TLEditorOptions {
|
|
|
7346
7842
|
*/
|
|
7347
7843
|
bindingUtils: readonly TLAnyBindingUtilConstructor[];
|
|
7348
7844
|
/**
|
|
7349
|
-
* An array of
|
|
7845
|
+
* An array of asset utils to use in the editor. These will be used to handle asset-type-specific behavior.
|
|
7350
7846
|
*/
|
|
7351
|
-
|
|
7847
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
7352
7848
|
/**
|
|
7353
|
-
*
|
|
7354
|
-
* given, the body element will be used.
|
|
7849
|
+
* An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
|
|
7355
7850
|
*/
|
|
7356
|
-
|
|
7851
|
+
tools: readonly TLStateNodeConstructor[];
|
|
7357
7852
|
/**
|
|
7358
7853
|
* A user defined externally to replace the default user.
|
|
7359
7854
|
*/
|
|
7360
|
-
user?:
|
|
7855
|
+
user?: TLCurrentUser;
|
|
7361
7856
|
/**
|
|
7362
7857
|
* The editor's initial active tool (or other state node id).
|
|
7363
7858
|
*/
|
|
@@ -7366,27 +7861,15 @@ export declare interface TLEditorOptions {
|
|
|
7366
7861
|
* Whether to automatically focus the editor when it mounts.
|
|
7367
7862
|
*/
|
|
7368
7863
|
autoFocus?: boolean;
|
|
7369
|
-
/**
|
|
7370
|
-
* Whether to infer dark mode from the user's system preferences. Defaults to false.
|
|
7371
|
-
*/
|
|
7372
|
-
inferDarkMode?: boolean;
|
|
7373
|
-
/**
|
|
7374
|
-
* Options for the editor's camera.
|
|
7375
|
-
*
|
|
7376
|
-
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7377
|
-
*/
|
|
7378
|
-
cameraOptions?: Partial<TLCameraOptions>;
|
|
7379
|
-
options?: Partial<TldrawOptions>;
|
|
7380
|
-
/**
|
|
7381
|
-
* Text options for the editor.
|
|
7382
|
-
*
|
|
7383
|
-
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7384
|
-
*/
|
|
7385
|
-
textOptions?: TLTextOptions;
|
|
7386
7864
|
licenseKey?: string;
|
|
7387
7865
|
fontAssetUrls?: {
|
|
7388
7866
|
[key: string]: string | undefined;
|
|
7389
7867
|
};
|
|
7868
|
+
/**
|
|
7869
|
+
* Should return a containing html element which has all the styles applied to the editor. If not
|
|
7870
|
+
* given, the body element will be used.
|
|
7871
|
+
*/
|
|
7872
|
+
getContainer(): HTMLElement;
|
|
7390
7873
|
/**
|
|
7391
7874
|
* Provides a way to hide shapes.
|
|
7392
7875
|
*
|
|
@@ -7403,6 +7886,40 @@ export declare interface TLEditorOptions {
|
|
|
7403
7886
|
* @param editor - The editor instance.
|
|
7404
7887
|
*/
|
|
7405
7888
|
getShapeVisibility?(shape: TLShape, editor: Editor): 'hidden' | 'inherit' | 'visible' | null | undefined;
|
|
7889
|
+
/**
|
|
7890
|
+
* Named theme definitions for the editor. Each theme contains shared
|
|
7891
|
+
* properties (font size, line height, stroke width) and color palettes
|
|
7892
|
+
* for both light and dark modes.
|
|
7893
|
+
*/
|
|
7894
|
+
themes?: Partial<TLThemes>;
|
|
7895
|
+
/**
|
|
7896
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7897
|
+
*/
|
|
7898
|
+
initialTheme?: TLThemeId;
|
|
7899
|
+
/**
|
|
7900
|
+
* The editor's color scheme preference, controls the default color mode. Defaults to `'light'`.
|
|
7901
|
+
*
|
|
7902
|
+
* - `'light'` - Always use light mode.
|
|
7903
|
+
* - `'dark'` - Always use dark mode.
|
|
7904
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7905
|
+
*/
|
|
7906
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7907
|
+
/**
|
|
7908
|
+
* Additional configuration options for the tldraw editor.
|
|
7909
|
+
*/
|
|
7910
|
+
options?: Partial<TldrawOptions>;
|
|
7911
|
+
/**
|
|
7912
|
+
* Options for the editor's camera.
|
|
7913
|
+
*
|
|
7914
|
+
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7915
|
+
*/
|
|
7916
|
+
cameraOptions?: Partial<TLCameraOptions>;
|
|
7917
|
+
/**
|
|
7918
|
+
* Text options for the editor.
|
|
7919
|
+
*
|
|
7920
|
+
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7921
|
+
*/
|
|
7922
|
+
textOptions?: TLTextOptions;
|
|
7406
7923
|
}
|
|
7407
7924
|
|
|
7408
7925
|
/**
|
|
@@ -7461,6 +7978,7 @@ export declare const tlenv: {
|
|
|
7461
7978
|
*/
|
|
7462
7979
|
export declare const tlenvReactive: Atom< {
|
|
7463
7980
|
isCoarsePointer: boolean;
|
|
7981
|
+
supportsP3ColorSpace: boolean;
|
|
7464
7982
|
}, unknown>;
|
|
7465
7983
|
|
|
7466
7984
|
/** @public */
|
|
@@ -7589,6 +8107,7 @@ export declare interface TLFileReplaceExternalContent extends TLBaseExternalCont
|
|
|
7589
8107
|
type: 'file-replace';
|
|
7590
8108
|
file: File;
|
|
7591
8109
|
shapeId: TLShapeId;
|
|
8110
|
+
/** @deprecated This field is no longer used by the default handler. It may be removed in a future version. */
|
|
7592
8111
|
isImage: boolean;
|
|
7593
8112
|
}
|
|
7594
8113
|
|
|
@@ -7600,69 +8119,18 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
|
7600
8119
|
}
|
|
7601
8120
|
|
|
7602
8121
|
/**
|
|
7603
|
-
*
|
|
7604
|
-
* ones in the
|
|
7605
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.
|
|
8122
|
+
* Emitted every animation frame when at least one `'frame'` listener is registered.
|
|
7606
8123
|
* @public
|
|
7607
8124
|
*/
|
|
7608
|
-
export declare interface
|
|
7609
|
-
/**
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
*/
|
|
7618
|
-
readonly src: TLFontFaceSource;
|
|
7619
|
-
/**
|
|
7620
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.
|
|
7621
|
-
*/
|
|
7622
|
-
readonly ascentOverride?: string;
|
|
7623
|
-
/**
|
|
7624
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.
|
|
7625
|
-
*/
|
|
7626
|
-
readonly descentOverride?: string;
|
|
7627
|
-
/**
|
|
7628
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.
|
|
7629
|
-
*/
|
|
7630
|
-
readonly stretch?: string;
|
|
7631
|
-
/**
|
|
7632
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.
|
|
7633
|
-
*/
|
|
7634
|
-
readonly style?: string;
|
|
7635
|
-
/**
|
|
7636
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.
|
|
7637
|
-
*/
|
|
7638
|
-
readonly weight?: string;
|
|
7639
|
-
/**
|
|
7640
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.
|
|
7641
|
-
*/
|
|
7642
|
-
readonly featureSettings?: string;
|
|
7643
|
-
/**
|
|
7644
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.
|
|
7645
|
-
*/
|
|
7646
|
-
readonly lineGapOverride?: string;
|
|
7647
|
-
/**
|
|
7648
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.
|
|
7649
|
-
*/
|
|
7650
|
-
readonly unicodeRange?: string;
|
|
7651
|
-
}
|
|
7652
|
-
|
|
7653
|
-
/**
|
|
7654
|
-
* Represents the `src` property of a {@link TLFontFace}.
|
|
7655
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.
|
|
7656
|
-
* @public
|
|
7657
|
-
*/
|
|
7658
|
-
export declare interface TLFontFaceSource {
|
|
7659
|
-
/**
|
|
7660
|
-
* A URL from which to load the font. If the value here is a key in
|
|
7661
|
-
* {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.
|
|
7662
|
-
*/
|
|
7663
|
-
url: string;
|
|
7664
|
-
format?: string;
|
|
7665
|
-
tech?: string;
|
|
8125
|
+
export declare interface TLFramePerfEvent {
|
|
8126
|
+
/** Time since the last frame in ms. */
|
|
8127
|
+
elapsed: number;
|
|
8128
|
+
/** Total shapes on the current page. */
|
|
8129
|
+
shapeCount: number;
|
|
8130
|
+
/** Number of shapes culled (off-screen) from rendering. */
|
|
8131
|
+
culledShapeCount: number;
|
|
8132
|
+
/** Number of shapes visible (not culled) in the viewport. */
|
|
8133
|
+
visibleShapeCount: number;
|
|
7666
8134
|
}
|
|
7667
8135
|
|
|
7668
8136
|
/** Additional options for the {@link ShapeUtil.getGeometry} method.
|
|
@@ -7807,6 +8275,38 @@ export declare type TLIndicatorPath = {
|
|
|
7807
8275
|
path: Path2D;
|
|
7808
8276
|
} | Path2D;
|
|
7809
8277
|
|
|
8278
|
+
/**
|
|
8279
|
+
* Emitted when an interaction state is exited, with aggregated frame time stats.
|
|
8280
|
+
* @public
|
|
8281
|
+
*/
|
|
8282
|
+
export declare interface TLInteractionEndPerfEvent extends TLPerfFrameTimeStats {
|
|
8283
|
+
/** The state node id (e.g. `'translating'`). */
|
|
8284
|
+
name: string;
|
|
8285
|
+
/** Full tool path (e.g. `'select.translating'`). */
|
|
8286
|
+
path: string;
|
|
8287
|
+
/** Total shapes on the current page. */
|
|
8288
|
+
shapeCount: number;
|
|
8289
|
+
/** Breakdown of selected shape types at interaction start (e.g. `{ geo: 2, draw: 1 }`). */
|
|
8290
|
+
selectedShapeTypes: Record<string, number>;
|
|
8291
|
+
/** Camera zoom level (`camera.z`) at interaction end. */
|
|
8292
|
+
zoomLevel: number;
|
|
8293
|
+
/** `performance.now()` when the interaction ended. */
|
|
8294
|
+
timestamp: number;
|
|
8295
|
+
}
|
|
8296
|
+
|
|
8297
|
+
/**
|
|
8298
|
+
* Emitted when an interaction state (e.g. translating, resizing) is entered.
|
|
8299
|
+
* @public
|
|
8300
|
+
*/
|
|
8301
|
+
export declare interface TLInteractionStartPerfEvent {
|
|
8302
|
+
/** The state node id (e.g. `'translating'`). */
|
|
8303
|
+
name: string;
|
|
8304
|
+
/** Full tool path (e.g. `'select.translating'`). */
|
|
8305
|
+
path: string;
|
|
8306
|
+
/** `performance.now()` when the interaction started. */
|
|
8307
|
+
timestamp: number;
|
|
8308
|
+
}
|
|
8309
|
+
|
|
7810
8310
|
/** @public */
|
|
7811
8311
|
export declare type TLInterruptEvent = (info: TLInterruptEventInfo) => void;
|
|
7812
8312
|
|
|
@@ -8054,6 +8554,94 @@ export declare const tlmenus: {
|
|
|
8054
8554
|
*/
|
|
8055
8555
|
export declare type TLOnMountHandler = (editor: Editor) => (() => undefined | void) | undefined | void;
|
|
8056
8556
|
|
|
8557
|
+
/**
|
|
8558
|
+
* Map of all performance event names to their payload types.
|
|
8559
|
+
* Used with {@link PerformanceManager.on} and {@link PerformanceManager.once}.
|
|
8560
|
+
* @public
|
|
8561
|
+
*/
|
|
8562
|
+
export declare interface TLPerfEventMap {
|
|
8563
|
+
/** An interaction state was entered. */
|
|
8564
|
+
'interaction-start': [TLInteractionStartPerfEvent];
|
|
8565
|
+
/** An interaction state was exited, with aggregated frame time stats. */
|
|
8566
|
+
'interaction-end': [TLInteractionEndPerfEvent];
|
|
8567
|
+
/** A camera operation (pan/zoom) began. */
|
|
8568
|
+
'camera-start': [TLCameraStartPerfEvent];
|
|
8569
|
+
/** A camera operation ended (after debounce), with aggregated frame time stats. */
|
|
8570
|
+
'camera-end': [TLCameraEndPerfEvent];
|
|
8571
|
+
/** Shapes were created. */
|
|
8572
|
+
'shapes-created': [TLShapeOperationPerfEvent];
|
|
8573
|
+
/** Shapes were updated. */
|
|
8574
|
+
'shapes-updated': [TLShapeOperationPerfEvent];
|
|
8575
|
+
/** Shapes were deleted. */
|
|
8576
|
+
'shapes-deleted': [TLShapeOperationPerfEvent];
|
|
8577
|
+
/** An animation frame was rendered. Only fires when listeners are registered. */
|
|
8578
|
+
frame: [TLFramePerfEvent];
|
|
8579
|
+
/** An undo operation was performed. */
|
|
8580
|
+
undo: [TLUndoRedoPerfEvent];
|
|
8581
|
+
/** A redo operation was performed. */
|
|
8582
|
+
redo: [TLUndoRedoPerfEvent];
|
|
8583
|
+
}
|
|
8584
|
+
|
|
8585
|
+
/**
|
|
8586
|
+
* Common frame time statistics shared by interaction and camera end events.
|
|
8587
|
+
* @public
|
|
8588
|
+
*/
|
|
8589
|
+
export declare interface TLPerfFrameTimeStats {
|
|
8590
|
+
/** Total duration of the session in ms. */
|
|
8591
|
+
duration: number;
|
|
8592
|
+
/** Average frames per second during the session. */
|
|
8593
|
+
fps: number;
|
|
8594
|
+
/** Total number of frames recorded. */
|
|
8595
|
+
frameCount: number;
|
|
8596
|
+
/** Mean frame duration in ms. */
|
|
8597
|
+
avgFrameTime: number;
|
|
8598
|
+
/** Median (p50) frame duration in ms. */
|
|
8599
|
+
medianFrameTime: number;
|
|
8600
|
+
/** 95th percentile frame duration in ms. */
|
|
8601
|
+
p95FrameTime: number;
|
|
8602
|
+
/** 99th percentile frame duration in ms. */
|
|
8603
|
+
p99FrameTime: number;
|
|
8604
|
+
/** Shortest frame duration in ms. */
|
|
8605
|
+
minFrameTime: number;
|
|
8606
|
+
/** Longest frame duration in ms. */
|
|
8607
|
+
maxFrameTime: number;
|
|
8608
|
+
/** Raw frame durations for local analysis. Exclude when sending to analytics. */
|
|
8609
|
+
frameTimes: number[];
|
|
8610
|
+
/**
|
|
8611
|
+
* Long animation frames observed during this period (Chromium 123+).
|
|
8612
|
+
* Only present when the browser supports the Long Animation Frames API and
|
|
8613
|
+
* at least one long frame was observed.
|
|
8614
|
+
* Exclude when sending to analytics — entries are large and contain script URLs.
|
|
8615
|
+
*/
|
|
8616
|
+
longAnimationFrames?: TLPerfLongAnimationFrame[];
|
|
8617
|
+
}
|
|
8618
|
+
|
|
8619
|
+
/**
|
|
8620
|
+
* A long animation frame observed by the browser during an interaction.
|
|
8621
|
+
* Available only in browsers that support the Long Animation Frames API (Chromium 123+).
|
|
8622
|
+
* @public
|
|
8623
|
+
*/
|
|
8624
|
+
export declare interface TLPerfLongAnimationFrame {
|
|
8625
|
+
/** Frame start time (relative to timeOrigin). */
|
|
8626
|
+
startTime: number;
|
|
8627
|
+
/** Total frame duration in ms. */
|
|
8628
|
+
duration: number;
|
|
8629
|
+
/** Time the main thread was blocked in ms. */
|
|
8630
|
+
blockingDuration: number;
|
|
8631
|
+
/** Scripts that contributed to the long frame. */
|
|
8632
|
+
scripts: TLPerfLongAnimationFrameScript[];
|
|
8633
|
+
}
|
|
8634
|
+
|
|
8635
|
+
/** A script attribution entry from a long animation frame. @public */
|
|
8636
|
+
export declare interface TLPerfLongAnimationFrameScript {
|
|
8637
|
+
/** The script source URL (may be empty for inline scripts). */
|
|
8638
|
+
sourceURL: string;
|
|
8639
|
+
/** The function name or invoker description. */
|
|
8640
|
+
invoker: string;
|
|
8641
|
+
/** Time spent in this script in ms. */
|
|
8642
|
+
duration: number;
|
|
8643
|
+
}
|
|
8644
|
+
|
|
8057
8645
|
/** @public */
|
|
8058
8646
|
export declare type TLPinchEvent = (info: TLPinchEventInfo) => void;
|
|
8059
8647
|
|
|
@@ -8241,6 +8829,21 @@ export declare interface TLShapeIndicatorsProps {
|
|
|
8241
8829
|
showAll?: boolean;
|
|
8242
8830
|
}
|
|
8243
8831
|
|
|
8832
|
+
/**
|
|
8833
|
+
* Emitted when shapes are created, updated, or deleted.
|
|
8834
|
+
* @public
|
|
8835
|
+
*/
|
|
8836
|
+
export declare interface TLShapeOperationPerfEvent {
|
|
8837
|
+
/** The operation type. */
|
|
8838
|
+
operation: 'create' | 'delete' | 'update';
|
|
8839
|
+
/** Number of shapes affected. */
|
|
8840
|
+
count: number;
|
|
8841
|
+
/** Breakdown by shape type (e.g. `{ geo: 2, draw: 1 }`). */
|
|
8842
|
+
shapeTypes: Record<string, number>;
|
|
8843
|
+
/** `performance.now()` when the operation occurred. */
|
|
8844
|
+
timestamp: number;
|
|
8845
|
+
}
|
|
8846
|
+
|
|
8244
8847
|
/**
|
|
8245
8848
|
* Options passed to {@link ShapeUtil.canBeLaidOut}.
|
|
8246
8849
|
*
|
|
@@ -8298,6 +8901,7 @@ export declare interface TLShapeUtilConstructor<T extends TLShape, U extends Sha
|
|
|
8298
8901
|
type: T['type'];
|
|
8299
8902
|
props?: RecordProps<T>;
|
|
8300
8903
|
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
8904
|
+
handledAssetTypes?: readonly string[];
|
|
8301
8905
|
}
|
|
8302
8906
|
|
|
8303
8907
|
/** @public */
|
|
@@ -8325,6 +8929,7 @@ export declare interface TLStateNodeConstructor {
|
|
|
8325
8929
|
children?(): TLStateNodeConstructor[];
|
|
8326
8930
|
isLockable: boolean;
|
|
8327
8931
|
useCoalescedEvents: boolean;
|
|
8932
|
+
trackPerformance: boolean;
|
|
8328
8933
|
}
|
|
8329
8934
|
|
|
8330
8935
|
/** @public */
|
|
@@ -8337,6 +8942,14 @@ export declare interface TLStoreBaseOptions {
|
|
|
8337
8942
|
defaultName?: string;
|
|
8338
8943
|
/** How should this store upload & resolve assets? */
|
|
8339
8944
|
assets?: TLAssetStore;
|
|
8945
|
+
/**
|
|
8946
|
+
* Named theme definitions. When provided, custom color names are automatically
|
|
8947
|
+
* registered before the store is constructed so persisted data with those
|
|
8948
|
+
* colors passes validation on load.
|
|
8949
|
+
*/
|
|
8950
|
+
themes?: Partial<TLThemes>;
|
|
8951
|
+
/** How should this store resolve users for attribution? */
|
|
8952
|
+
users?: TLUserStore;
|
|
8340
8953
|
/** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
|
|
8341
8954
|
onMount?(editor: Editor): (() => void) | void;
|
|
8342
8955
|
}
|
|
@@ -8356,6 +8969,7 @@ export declare type TLStoreOptions = TLStoreBaseOptions & {
|
|
|
8356
8969
|
|
|
8357
8970
|
/** @public */
|
|
8358
8971
|
export declare type TLStoreSchemaOptions = {
|
|
8972
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
8359
8973
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
8360
8974
|
migrations?: readonly MigrationSequence[];
|
|
8361
8975
|
records?: Record<string, CustomRecordInfo>;
|
|
@@ -8493,6 +9107,19 @@ export declare interface TLTldrawExternalContentSource {
|
|
|
8493
9107
|
data: TLContent;
|
|
8494
9108
|
}
|
|
8495
9109
|
|
|
9110
|
+
/**
|
|
9111
|
+
* Emitted after an undo or redo operation.
|
|
9112
|
+
* @public
|
|
9113
|
+
*/
|
|
9114
|
+
export declare interface TLUndoRedoPerfEvent {
|
|
9115
|
+
/** Whether this was an undo or redo. */
|
|
9116
|
+
type: 'redo' | 'undo';
|
|
9117
|
+
/** Number of undo steps remaining. */
|
|
9118
|
+
undoDepth: number;
|
|
9119
|
+
/** Number of redo steps remaining. */
|
|
9120
|
+
redoDepth: number;
|
|
9121
|
+
}
|
|
9122
|
+
|
|
8496
9123
|
/** @public */
|
|
8497
9124
|
export declare interface TLUpdatePointerOptions {
|
|
8498
9125
|
/** Whether to update the pointer immediately, rather than on the next tick. */
|
|
@@ -8524,12 +9151,6 @@ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
|
|
|
8524
9151
|
url: string;
|
|
8525
9152
|
}
|
|
8526
9153
|
|
|
8527
|
-
/** @public */
|
|
8528
|
-
export declare interface TLUser {
|
|
8529
|
-
readonly userPreferences: Signal<TLUserPreferences>;
|
|
8530
|
-
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
8531
|
-
}
|
|
8532
|
-
|
|
8533
9154
|
/**
|
|
8534
9155
|
* A user of tldraw
|
|
8535
9156
|
*
|
|
@@ -8630,6 +9251,9 @@ export declare function uniq<T>(array: {
|
|
|
8630
9251
|
readonly length: number;
|
|
8631
9252
|
} | null | undefined): T[];
|
|
8632
9253
|
|
|
9254
|
+
/** @public */
|
|
9255
|
+
export declare function useColorMode(): 'dark' | 'light';
|
|
9256
|
+
|
|
8633
9257
|
/** @public */
|
|
8634
9258
|
export declare function useContainer(): HTMLElement;
|
|
8635
9259
|
|
|
@@ -8668,9 +9292,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
|
|
|
8668
9292
|
/** @public */
|
|
8669
9293
|
export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
8670
9294
|
|
|
8671
|
-
/** @public */
|
|
8672
|
-
export declare function useIsDarkMode(): boolean;
|
|
8673
|
-
|
|
8674
9295
|
/** @public */
|
|
8675
9296
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
8676
9297
|
|
|
@@ -8708,11 +9329,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
|
|
|
8708
9329
|
/** @public */
|
|
8709
9330
|
export declare class UserPreferencesManager {
|
|
8710
9331
|
private readonly user;
|
|
8711
|
-
private readonly
|
|
9332
|
+
private readonly colorScheme;
|
|
8712
9333
|
systemColorScheme: Atom<"dark" | "light", unknown>;
|
|
8713
9334
|
disposables: Set<() => void>;
|
|
8714
9335
|
dispose(): void;
|
|
8715
|
-
constructor(user:
|
|
9336
|
+
constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
|
|
8716
9337
|
updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
|
|
8717
9338
|
getUserPreferences(): {
|
|
8718
9339
|
animationSpeed: number;
|
|
@@ -8783,10 +9404,10 @@ export declare function useSvgExportContext(): null | SvgExportContext;
|
|
|
8783
9404
|
/**
|
|
8784
9405
|
* @public
|
|
8785
9406
|
*/
|
|
8786
|
-
export declare function
|
|
9407
|
+
export declare function useTldrawCurrentUser(opts: {
|
|
8787
9408
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void;
|
|
8788
9409
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences;
|
|
8789
|
-
}):
|
|
9410
|
+
}): TLCurrentUser;
|
|
8790
9411
|
|
|
8791
9412
|
/** @public */
|
|
8792
9413
|
export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreSchema<TLRecord, TLStoreProps>;
|