@tldraw/editor 4.6.0-canary.4cdadeb38507 → 4.6.0-canary.4ea2b430d7bb
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 +558 -120
- package/dist-cjs/index.js +16 -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/default-components/CanvasShapeIndicators.js +3 -3
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.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 +31 -1
- 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/config/defaultShapes.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +314 -12
- 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/EdgeScrollManager/EdgeScrollManager.js +1 -1
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +4 -4
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +102 -30
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- 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 +19 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.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/StyleEmbedder.js +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- 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/useEditorComponents.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/hooks/useLocalStore.js.map +2 -2
- package/dist-cjs/lib/options.js +3 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +1 -1
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +4 -3
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
- package/dist-cjs/lib/utils/getSvgPathFromPoints.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/sync/TLLocalSyncClient.js +1 -1
- 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 +558 -120
- package/dist-esm/index.mjs +24 -10
- 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/default-components/CanvasShapeIndicators.mjs +3 -3
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.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 +37 -2
- 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/config/defaultShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +317 -13
- 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/EdgeScrollManager/EdgeScrollManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +4 -4
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +102 -30
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- 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 +19 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
- package/dist-esm/lib/exports/StyleEmbedder.mjs +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.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/useEditorComponents.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/hooks/useLocalStore.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +3 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +1 -1
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +4 -3
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
- package/dist-esm/lib/utils/getSvgPathFromPoints.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/sync/TLLocalSyncClient.mjs +1 -1
- 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 +13 -33
- package/package.json +8 -9
- package/src/index.ts +22 -8
- package/src/lib/TldrawEditor.tsx +99 -20
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +3 -3
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
- package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
- package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +6 -6
- package/src/lib/config/createTLStore.ts +58 -3
- package/src/lib/config/defaultAssets.ts +19 -0
- package/src/lib/config/defaultShapes.ts +1 -1
- package/src/lib/editor/Editor.ts +432 -36
- package/src/lib/editor/assets/AssetUtil.ts +85 -0
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
- 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/SnapManager/BoundsSnaps.ts +1 -1
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
- package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
- 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/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/StyleEmbedder.ts +1 -1
- package/src/lib/exports/getSvgJsx.tsx +22 -16
- 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/useEditorComponents.tsx +1 -1
- package/src/lib/hooks/useGestureEvents.ts +240 -168
- package/src/lib/hooks/useLocalStore.ts +1 -1
- package/src/lib/options.ts +108 -0
- package/src/lib/primitives/Box.test.ts +30 -0
- package/src/lib/primitives/Box.ts +1 -1
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/Ellipse2d.ts +2 -2
- package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +4 -3
- package/src/lib/primitives/geometry/Polyline2d.ts +1 -1
- package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
- package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
- package/src/lib/utils/reparenting.ts +6 -2
- package/src/lib/utils/richText.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +1 -1
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Atom } from '@tldraw/state';
|
|
2
2
|
import { AtomSet } from '@tldraw/store';
|
|
3
|
+
import { Awaitable } from '@tldraw/utils';
|
|
3
4
|
import { BoxModel } from '@tldraw/tlschema';
|
|
4
5
|
import { ComponentType } from 'react';
|
|
5
6
|
import { Computed } from '@tldraw/state';
|
|
@@ -56,9 +57,12 @@ import { TLCamera } from '@tldraw/tlschema';
|
|
|
56
57
|
import { TLCreateShapePartial } from '@tldraw/tlschema';
|
|
57
58
|
import { TLCursor } from '@tldraw/tlschema';
|
|
58
59
|
import { TLCursorType } from '@tldraw/tlschema';
|
|
60
|
+
import { TLDefaultColor } from '@tldraw/tlschema';
|
|
61
|
+
import { TLDefaultColorStyle } from '@tldraw/tlschema';
|
|
59
62
|
import { TLDefaultDashStyle } from '@tldraw/tlschema';
|
|
60
63
|
import { TLDefaultHorizontalAlignStyle } from '@tldraw/tlschema';
|
|
61
64
|
import { TLDocument } from '@tldraw/tlschema';
|
|
65
|
+
import { TLFontFace } from '@tldraw/tlschema';
|
|
62
66
|
import { TLGroupShape } from '@tldraw/tlschema';
|
|
63
67
|
import { TLHandle } from '@tldraw/tlschema';
|
|
64
68
|
import { TLImageAsset } from '@tldraw/tlschema';
|
|
@@ -80,8 +84,15 @@ import { TLStore } from '@tldraw/tlschema';
|
|
|
80
84
|
import { TLStoreProps } from '@tldraw/tlschema';
|
|
81
85
|
import { TLStoreSchema } from '@tldraw/tlschema';
|
|
82
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';
|
|
83
92
|
import { TLUnknownBinding } from '@tldraw/tlschema';
|
|
84
93
|
import { TLUnknownShape } from '@tldraw/tlschema';
|
|
94
|
+
import { TLUser } from '@tldraw/tlschema';
|
|
95
|
+
import { TLUserStore } from '@tldraw/tlschema';
|
|
85
96
|
import { TLVideoAsset } from '@tldraw/tlschema';
|
|
86
97
|
import { UnknownRecord } from '@tldraw/store';
|
|
87
98
|
import { VecModel } from '@tldraw/tlschema';
|
|
@@ -144,6 +155,51 @@ export declare class Arc2d extends Geometry2d {
|
|
|
144
155
|
*/
|
|
145
156
|
export declare function areAnglesCompatible(a: number, b: number): boolean;
|
|
146
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
|
+
|
|
147
203
|
/** @public */
|
|
148
204
|
export declare function average(A: VecLike, B: VecLike): string;
|
|
149
205
|
|
|
@@ -164,6 +220,12 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
164
220
|
getInterpolatedProps(startShape: Shape, endShape: Shape, t: number): Shape['props'];
|
|
165
221
|
}
|
|
166
222
|
|
|
223
|
+
/** @public */
|
|
224
|
+
export declare interface BatchMeasurementRequest {
|
|
225
|
+
html: string;
|
|
226
|
+
opts: TLMeasureTextOpts;
|
|
227
|
+
}
|
|
228
|
+
|
|
167
229
|
/**
|
|
168
230
|
* Options passed to {@link BindingUtil.onBeforeChange} and {@link BindingUtil.onAfterChange},
|
|
169
231
|
* describing the data associated with a binding being changed.
|
|
@@ -711,6 +773,12 @@ export declare function createDeepLinkString(deepLink: TLDeepLink): string;
|
|
|
711
773
|
*/
|
|
712
774
|
export declare function createSessionStateSnapshotSignal(store: TLStore): Signal<null | TLSessionStateSnapshot>;
|
|
713
775
|
|
|
776
|
+
/** @public */
|
|
777
|
+
export declare function createTLCurrentUser(opts?: {
|
|
778
|
+
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
779
|
+
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
780
|
+
}): TLCurrentUser;
|
|
781
|
+
|
|
714
782
|
/**
|
|
715
783
|
* A helper for creating a TLStore schema from either an object with shapeUtils, bindingUtils, and
|
|
716
784
|
* migrations, or a schema.
|
|
@@ -728,13 +796,7 @@ export declare function createTLSchemaFromUtils(opts: TLStoreSchemaOptions): Sto
|
|
|
728
796
|
*
|
|
729
797
|
* @public
|
|
730
798
|
*/
|
|
731
|
-
export declare function createTLStore({ initialData, defaultName, id, assets, onMount, collaboration, ...rest }?: TLStoreOptions): TLStore;
|
|
732
|
-
|
|
733
|
-
/** @public */
|
|
734
|
-
export declare function createTLUser(opts?: {
|
|
735
|
-
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
736
|
-
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
737
|
-
}): TLUser;
|
|
799
|
+
export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, themes, ...rest }?: TLStoreOptions): TLStore;
|
|
738
800
|
|
|
739
801
|
/** @public */
|
|
740
802
|
export declare class CubicBezier2d extends Polyline2d {
|
|
@@ -809,6 +871,13 @@ export declare interface DebugFlagDefaults<T> {
|
|
|
809
871
|
|
|
810
872
|
/* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
|
|
811
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
|
+
|
|
812
881
|
/** @public @react */
|
|
813
882
|
export declare function DefaultBackground(): JSX.Element;
|
|
814
883
|
|
|
@@ -923,6 +992,9 @@ export declare const defaultTldrawOptions: {
|
|
|
923
992
|
readonly maxShapesPerPage: 4000;
|
|
924
993
|
readonly multiClickDurationMs: 200;
|
|
925
994
|
readonly nonce: undefined;
|
|
995
|
+
readonly onBeforeCopyToClipboard: undefined;
|
|
996
|
+
readonly onBeforePasteFromClipboard: undefined;
|
|
997
|
+
readonly onClipboardPasteRaw: undefined;
|
|
926
998
|
readonly quickZoomPreservesScreenBounds: true;
|
|
927
999
|
readonly snapThreshold: 8;
|
|
928
1000
|
readonly spacebarPanning: true;
|
|
@@ -953,6 +1025,9 @@ export declare const defaultUserPreferences: Readonly<{
|
|
|
953
1025
|
name: "";
|
|
954
1026
|
}>;
|
|
955
1027
|
|
|
1028
|
+
/** @public */
|
|
1029
|
+
export declare const defaultUserStore: TLUserStore;
|
|
1030
|
+
|
|
956
1031
|
/**
|
|
957
1032
|
* Convert degrees to radians.
|
|
958
1033
|
*
|
|
@@ -1028,7 +1103,7 @@ export declare class EdgeScrollManager {
|
|
|
1028
1103
|
/** @public */
|
|
1029
1104
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1030
1105
|
readonly id: string;
|
|
1031
|
-
constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus,
|
|
1106
|
+
constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
|
|
1032
1107
|
private readonly _getShapeVisibility?;
|
|
1033
1108
|
private getIsShapeHiddenCache;
|
|
1034
1109
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1091,7 +1166,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1091
1166
|
* @public
|
|
1092
1167
|
*/
|
|
1093
1168
|
readonly snaps: SnapManager;
|
|
1094
|
-
|
|
1169
|
+
/* Excluded from this release type: _spatialIndex */
|
|
1095
1170
|
/**
|
|
1096
1171
|
* A manager for the any asynchronous events and making sure they're
|
|
1097
1172
|
* cleaned up upon disposal.
|
|
@@ -1110,6 +1185,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1110
1185
|
* @public
|
|
1111
1186
|
*/
|
|
1112
1187
|
readonly user: UserPreferencesManager;
|
|
1188
|
+
/* Excluded from this release type: _themeManager */
|
|
1113
1189
|
/**
|
|
1114
1190
|
* A helper for measuring text.
|
|
1115
1191
|
*
|
|
@@ -1160,6 +1236,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1160
1236
|
* @public
|
|
1161
1237
|
*/
|
|
1162
1238
|
dispose(): void;
|
|
1239
|
+
/**
|
|
1240
|
+
* Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
|
|
1241
|
+
*
|
|
1242
|
+
* @public
|
|
1243
|
+
*/
|
|
1244
|
+
getColorMode(): 'dark' | 'light';
|
|
1245
|
+
/**
|
|
1246
|
+
* Set the color mode. Note that this is a convenience method that passes the mode to
|
|
1247
|
+
* `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
|
|
1248
|
+
*
|
|
1249
|
+
* @public
|
|
1250
|
+
*/
|
|
1251
|
+
setColorMode(mode: 'dark' | 'light'): this;
|
|
1252
|
+
/**
|
|
1253
|
+
* Get the id of the current theme.
|
|
1254
|
+
*
|
|
1255
|
+
* @public
|
|
1256
|
+
*/
|
|
1257
|
+
getCurrentThemeId(): TLThemeId;
|
|
1258
|
+
/**
|
|
1259
|
+
* Get the current theme definition.
|
|
1260
|
+
*
|
|
1261
|
+
* @public
|
|
1262
|
+
*/
|
|
1263
|
+
getCurrentTheme(): TLTheme;
|
|
1264
|
+
/**
|
|
1265
|
+
* Set the current theme by id.
|
|
1266
|
+
*
|
|
1267
|
+
* @public
|
|
1268
|
+
*/
|
|
1269
|
+
setCurrentTheme(id: TLThemeId): this;
|
|
1270
|
+
/**
|
|
1271
|
+
* Get all registered theme definitions.
|
|
1272
|
+
*
|
|
1273
|
+
* @public
|
|
1274
|
+
*/
|
|
1275
|
+
getThemes(): TLThemes;
|
|
1276
|
+
/**
|
|
1277
|
+
* Get a single theme definition by id.
|
|
1278
|
+
*
|
|
1279
|
+
* @public
|
|
1280
|
+
*/
|
|
1281
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
1282
|
+
/**
|
|
1283
|
+
* Replace all theme definitions, or update them via a callback that receives a deep copy.
|
|
1284
|
+
* The `'default'` theme must always be present in the result.
|
|
1285
|
+
*
|
|
1286
|
+
* @example
|
|
1287
|
+
* ```ts
|
|
1288
|
+
* // Replace all themes
|
|
1289
|
+
* editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
|
|
1290
|
+
*
|
|
1291
|
+
* // Update via callback
|
|
1292
|
+
* editor.updateThemes((themes) => {
|
|
1293
|
+
* delete themes.ocean
|
|
1294
|
+
* return themes
|
|
1295
|
+
* })
|
|
1296
|
+
* ```
|
|
1297
|
+
*
|
|
1298
|
+
* @public
|
|
1299
|
+
*/
|
|
1300
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): this;
|
|
1301
|
+
/**
|
|
1302
|
+
* Register or update a single theme definition. The theme is keyed by its `id` property.
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts
|
|
1306
|
+
* // Override a property on the default theme
|
|
1307
|
+
* editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
|
|
1308
|
+
*
|
|
1309
|
+
* // Register a new theme
|
|
1310
|
+
* editor.updateTheme({ id: 'ocean', ...myOceanTheme })
|
|
1311
|
+
* ```
|
|
1312
|
+
*
|
|
1313
|
+
* @public
|
|
1314
|
+
*/
|
|
1315
|
+
updateTheme(theme: TLTheme): this;
|
|
1163
1316
|
/**
|
|
1164
1317
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1165
1318
|
*
|
|
@@ -1168,6 +1321,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1168
1321
|
shapeUtils: {
|
|
1169
1322
|
readonly [K in string]?: ShapeUtil<TLShape>;
|
|
1170
1323
|
};
|
|
1324
|
+
/* Excluded from this release type: _shapeUtilsByAssetType */
|
|
1171
1325
|
styleProps: {
|
|
1172
1326
|
[key: string]: Map<StyleProp<any>, string>;
|
|
1173
1327
|
};
|
|
@@ -1199,6 +1353,15 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1199
1353
|
hasShapeUtil(shape: TLShape | TLShapePartial<TLShape>): boolean;
|
|
1200
1354
|
hasShapeUtil(type: TLShape['type']): boolean;
|
|
1201
1355
|
hasShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): boolean;
|
|
1356
|
+
/**
|
|
1357
|
+
* Get the shape util that handles the given asset type.
|
|
1358
|
+
* Returns the shape util whose {@link ShapeUtil.handledAssetTypes} includes
|
|
1359
|
+
* the given asset type, or undefined if none matches.
|
|
1360
|
+
*
|
|
1361
|
+
* @param assetType - The asset type string.
|
|
1362
|
+
* @public
|
|
1363
|
+
*/
|
|
1364
|
+
getShapeUtilForAssetType(assetType: string): ShapeUtil | undefined;
|
|
1202
1365
|
/**
|
|
1203
1366
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1204
1367
|
*
|
|
@@ -1229,6 +1392,40 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1229
1392
|
type: S['type'];
|
|
1230
1393
|
} | S): BindingUtil<S>;
|
|
1231
1394
|
getBindingUtil<T extends BindingUtil>(type: T extends BindingUtil<infer R> ? R['type'] : string): T;
|
|
1395
|
+
/**
|
|
1396
|
+
* A map of asset utility classes by asset type.
|
|
1397
|
+
*
|
|
1398
|
+
* @public
|
|
1399
|
+
*/
|
|
1400
|
+
assetUtils: {
|
|
1401
|
+
readonly [K in string]?: AssetUtil<TLAsset>;
|
|
1402
|
+
};
|
|
1403
|
+
/**
|
|
1404
|
+
* Get an asset util from an asset or asset type.
|
|
1405
|
+
*
|
|
1406
|
+
* @param arg - An asset, asset type string, or object with type.
|
|
1407
|
+
*
|
|
1408
|
+
* @public
|
|
1409
|
+
*/
|
|
1410
|
+
getAssetUtil<S extends TLAsset>(asset: {
|
|
1411
|
+
type: S['type'];
|
|
1412
|
+
} | S): AssetUtil<S>;
|
|
1413
|
+
getAssetUtil(type: string): AssetUtil;
|
|
1414
|
+
/**
|
|
1415
|
+
* Returns true if the editor has an asset util for the given asset type.
|
|
1416
|
+
*
|
|
1417
|
+
* @public
|
|
1418
|
+
*/
|
|
1419
|
+
hasAssetUtil(arg: {
|
|
1420
|
+
type: string;
|
|
1421
|
+
} | string): boolean;
|
|
1422
|
+
/**
|
|
1423
|
+
* Get the asset util that accepts the given MIME type.
|
|
1424
|
+
* Returns null if no registered asset util accepts the MIME type.
|
|
1425
|
+
*
|
|
1426
|
+
* @public
|
|
1427
|
+
*/
|
|
1428
|
+
getAssetUtilForMimeType(mimeType: string): AssetUtil | null;
|
|
1232
1429
|
/**
|
|
1233
1430
|
* A manager for the editor's history.
|
|
1234
1431
|
*
|
|
@@ -2259,6 +2456,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2259
2456
|
* @public
|
|
2260
2457
|
*/
|
|
2261
2458
|
getCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
2459
|
+
/**
|
|
2460
|
+
* Get the current user's ID for attribution purposes.
|
|
2461
|
+
* Also ensures a `user:` record exists in the store for the current user.
|
|
2462
|
+
* Returns `null` when the user store has no current user.
|
|
2463
|
+
*
|
|
2464
|
+
* @public
|
|
2465
|
+
*/
|
|
2466
|
+
getAttributionUserId(): null | string;
|
|
2467
|
+
/* Excluded from this release type: _ensureUserRecord */
|
|
2468
|
+
/**
|
|
2469
|
+
* Resolve a display name for a user ID. Asks the
|
|
2470
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2471
|
+
* falling back to the `user:` record in the store.
|
|
2472
|
+
*
|
|
2473
|
+
* @public
|
|
2474
|
+
*/
|
|
2475
|
+
getAttributionDisplayName(userId: null | string): null | string;
|
|
2476
|
+
/**
|
|
2477
|
+
* Resolve a user record by ID. Asks the
|
|
2478
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2479
|
+
* falling back to the `user:` record in the store.
|
|
2480
|
+
*
|
|
2481
|
+
* @public
|
|
2482
|
+
*/
|
|
2483
|
+
getAttributionUser(userId: null | string): null | TLUser;
|
|
2484
|
+
/* Excluded from this release type: _getReferencedUserIds */
|
|
2262
2485
|
private _isLockedOnFollowingUser;
|
|
2263
2486
|
/**
|
|
2264
2487
|
* Start viewport-following a user.
|
|
@@ -4353,6 +4576,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
|
|
|
4353
4576
|
*/
|
|
4354
4577
|
export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
|
|
4355
4578
|
|
|
4579
|
+
/**
|
|
4580
|
+
* Resolves a color style value to its actual CSS color string for a given theme and variant.
|
|
4581
|
+
* If the color is not a default theme color, returns the color value as-is.
|
|
4582
|
+
*
|
|
4583
|
+
* @param colors - The color palette for the current color mode (e.g. `theme.colors[colorMode]`)
|
|
4584
|
+
* @param color - The color style value to resolve
|
|
4585
|
+
* @param variant - Which variant of the color to return (solid, fill, pattern, etc.)
|
|
4586
|
+
* @returns The CSS color string for the specified color and variant
|
|
4587
|
+
*
|
|
4588
|
+
* @example
|
|
4589
|
+
* ```ts
|
|
4590
|
+
* import { getColorValue } from 'tldraw'
|
|
4591
|
+
*
|
|
4592
|
+
* const colors = editor.getCurrentTheme().colors[editor.getColorMode()]
|
|
4593
|
+
*
|
|
4594
|
+
* // Get the solid variant of red
|
|
4595
|
+
* const redSolid = getColorValue(colors, 'red', 'solid') // '#e03131'
|
|
4596
|
+
*
|
|
4597
|
+
* // Get the fill variant of blue
|
|
4598
|
+
* const blueFill = getColorValue(colors, 'blue', 'fill') // '#4465e9'
|
|
4599
|
+
*
|
|
4600
|
+
* // Custom color passes through unchanged
|
|
4601
|
+
* const customColor = getColorValue(colors, '#ff0000', 'solid') // '#ff0000'
|
|
4602
|
+
* ```
|
|
4603
|
+
*
|
|
4604
|
+
* @public
|
|
4605
|
+
*/
|
|
4606
|
+
export declare function getColorValue(colors: TLThemeColors, color: string | TLDefaultColorStyle, variant: keyof TLDefaultColor): string;
|
|
4607
|
+
|
|
4356
4608
|
/** @public */
|
|
4357
4609
|
export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
|
|
4358
4610
|
|
|
@@ -5359,6 +5611,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
|
|
|
5359
5611
|
y: number;
|
|
5360
5612
|
};
|
|
5361
5613
|
|
|
5614
|
+
/**
|
|
5615
|
+
* Resolve a partial set of user-provided themes into a complete `TLThemes`
|
|
5616
|
+
* record by merging with `DEFAULT_THEME`. The result is suitable for passing to
|
|
5617
|
+
* `registerColorsFromThemes`, `registerFontsFromThemes`, and the
|
|
5618
|
+
* `ThemeManager` constructor.
|
|
5619
|
+
*
|
|
5620
|
+
* @public
|
|
5621
|
+
*/
|
|
5622
|
+
export declare function resolveThemes(themes?: Partial<TLThemes>): TLThemes;
|
|
5623
|
+
|
|
5362
5624
|
/** @public */
|
|
5363
5625
|
export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
|
|
5364
5626
|
|
|
@@ -5640,12 +5902,32 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5640
5902
|
* @public
|
|
5641
5903
|
*/
|
|
5642
5904
|
static type: string;
|
|
5905
|
+
/**
|
|
5906
|
+
* The asset types that this shape can be created from.
|
|
5907
|
+
* When a file is dropped on the canvas, the editor finds the shape util
|
|
5908
|
+
* whose `handledAssetTypes` includes the asset's type and calls
|
|
5909
|
+
* {@link ShapeUtil.createShapeForAsset} to produce the shape.
|
|
5910
|
+
*
|
|
5911
|
+
* @public
|
|
5912
|
+
*/
|
|
5913
|
+
static handledAssetTypes?: readonly string[];
|
|
5643
5914
|
/**
|
|
5644
5915
|
* Get the default props for a shape.
|
|
5645
5916
|
*
|
|
5646
5917
|
* @public
|
|
5647
5918
|
*/
|
|
5648
5919
|
abstract getDefaultProps(): Shape['props'];
|
|
5920
|
+
/**
|
|
5921
|
+
* Create a shape partial for placing an asset on the canvas.
|
|
5922
|
+
* Only called for shapes whose constructor declares matching
|
|
5923
|
+
* {@link ShapeUtil.handledAssetTypes | `handledAssetTypes`}.
|
|
5924
|
+
*
|
|
5925
|
+
* @param asset - The asset to create a shape for.
|
|
5926
|
+
* @param position - Where to place the shape.
|
|
5927
|
+
* @returns A shape partial, or null if this shape can't be created for the asset.
|
|
5928
|
+
* @public
|
|
5929
|
+
*/
|
|
5930
|
+
createShapeForAsset?(asset: TLAsset, position: VecModel): null | TLShapePartial;
|
|
5649
5931
|
/**
|
|
5650
5932
|
* Get the shape's geometry.
|
|
5651
5933
|
*
|
|
@@ -5947,6 +6229,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5947
6229
|
*/
|
|
5948
6230
|
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
|
|
5949
6231
|
getText(shape: Shape): string | undefined;
|
|
6232
|
+
/**
|
|
6233
|
+
* Return user IDs referenced in shape-specific props.
|
|
6234
|
+
* Used when copying shapes to include referenced users on the clipboard.
|
|
6235
|
+
* Override this if your shape stores user IDs in custom props.
|
|
6236
|
+
*
|
|
6237
|
+
* @public
|
|
6238
|
+
*/
|
|
6239
|
+
getReferencedUserIds(shape: Shape): string[];
|
|
5950
6240
|
getAriaDescriptor(shape: Shape): string | undefined;
|
|
5951
6241
|
/**
|
|
5952
6242
|
* A callback called just before a shape is created. This method provides a last chance to modify
|
|
@@ -6476,6 +6766,10 @@ export declare interface SvgExportContext {
|
|
|
6476
6766
|
* Whether the export should be in dark mode.
|
|
6477
6767
|
*/
|
|
6478
6768
|
readonly isDarkMode: boolean;
|
|
6769
|
+
/**
|
|
6770
|
+
* The color mode to use for this export.
|
|
6771
|
+
*/
|
|
6772
|
+
readonly colorMode: 'dark' | 'light';
|
|
6479
6773
|
/**
|
|
6480
6774
|
* The scale of the export - how much CSS pixels will be scaled up/down by.
|
|
6481
6775
|
*/
|
|
@@ -6507,15 +6801,18 @@ export declare const TAB_ID: string;
|
|
|
6507
6801
|
export declare class TextManager {
|
|
6508
6802
|
editor: Editor;
|
|
6509
6803
|
private elm;
|
|
6804
|
+
private poolElms;
|
|
6510
6805
|
constructor(editor: Editor);
|
|
6806
|
+
private createMeasurementEl;
|
|
6807
|
+
private resetElementStyles;
|
|
6511
6808
|
private setElementStyles;
|
|
6809
|
+
private getMeasureStyles;
|
|
6512
6810
|
dispose(): void;
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
};
|
|
6811
|
+
private ensurePoolSize;
|
|
6812
|
+
private getPoolItem;
|
|
6813
|
+
measureHtmlBatch(requests: BatchMeasurementRequest[]): TLMeasuredTextSize[];
|
|
6814
|
+
measureText(textToMeasure: string, opts: TLMeasureTextOpts): TLMeasuredTextSize;
|
|
6815
|
+
measureHtml(html: string, opts: TLMeasureTextOpts): TLMeasuredTextSize;
|
|
6519
6816
|
/**
|
|
6520
6817
|
* Given an html element, measure the position of each span of unbroken
|
|
6521
6818
|
* word/white-space characters within any text nodes it contains.
|
|
@@ -6543,6 +6840,47 @@ export declare class TextManager {
|
|
|
6543
6840
|
}[];
|
|
6544
6841
|
}
|
|
6545
6842
|
|
|
6843
|
+
/**
|
|
6844
|
+
* Manages the editor's color themes.
|
|
6845
|
+
*
|
|
6846
|
+
* Stores named theme definitions (each containing light and dark color palettes
|
|
6847
|
+
* alongside shared properties like font size). The current theme is resolved by
|
|
6848
|
+
* combining the current theme name with the user's color mode preference.
|
|
6849
|
+
*
|
|
6850
|
+
* **Terminology:**
|
|
6851
|
+
* - **Theme** (`TLTheme`): A named set of colors and typographic values for both light and dark modes.
|
|
6852
|
+
* - **Color mode** (`'light' | 'dark'`): The resolved appearance mode, derived from the user's
|
|
6853
|
+
* `colorScheme` preference (`'light' | 'dark' | 'system'`). Access via `getColorMode()`.
|
|
6854
|
+
*
|
|
6855
|
+
* @public
|
|
6856
|
+
*/
|
|
6857
|
+
export declare class ThemeManager {
|
|
6858
|
+
private readonly editor;
|
|
6859
|
+
private readonly _themes;
|
|
6860
|
+
private readonly _currentThemeId;
|
|
6861
|
+
constructor(editor: Editor, options: {
|
|
6862
|
+
initial: TLThemeId;
|
|
6863
|
+
themes: TLThemes;
|
|
6864
|
+
});
|
|
6865
|
+
/** Get the current color mode based on the user's dark mode preference. */
|
|
6866
|
+
getColorMode(): 'dark' | 'light';
|
|
6867
|
+
/** Get all registered theme definitions. */
|
|
6868
|
+
getThemes(): TLThemes;
|
|
6869
|
+
/** Get a single theme definition by id. */
|
|
6870
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
6871
|
+
/** Get the id of the current theme. */
|
|
6872
|
+
getCurrentThemeId(): TLThemeId;
|
|
6873
|
+
getCurrentTheme(): TLTheme;
|
|
6874
|
+
/** Set the current theme by id. The theme must have been previously registered. */
|
|
6875
|
+
setCurrentTheme(id: TLThemeId): void;
|
|
6876
|
+
/** Replace all theme definitions, or update them via a callback that receives a deep copy. */
|
|
6877
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): void;
|
|
6878
|
+
/** Register or update a named theme definition. */
|
|
6879
|
+
updateTheme(theme: TLTheme): void;
|
|
6880
|
+
/** Clean up any resources held by the manager. */
|
|
6881
|
+
dispose(): void;
|
|
6882
|
+
}
|
|
6883
|
+
|
|
6546
6884
|
/* Excluded from this release type: TickManager */
|
|
6547
6885
|
|
|
6548
6886
|
/**
|
|
@@ -6561,12 +6899,23 @@ export declare type TiptapNode = Node_2;
|
|
|
6561
6899
|
/** @public */
|
|
6562
6900
|
export declare type TLAdjacentDirection = 'down' | 'left' | 'next' | 'prev' | 'right' | 'up';
|
|
6563
6901
|
|
|
6902
|
+
/** @public */
|
|
6903
|
+
export declare type TLAnyAssetUtilConstructor = TLAssetUtilConstructor<any>;
|
|
6904
|
+
|
|
6564
6905
|
/** @public */
|
|
6565
6906
|
export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
6566
6907
|
|
|
6567
6908
|
/** @public */
|
|
6568
6909
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
6569
6910
|
|
|
6911
|
+
/** @public */
|
|
6912
|
+
export declare interface TLAssetUtilConstructor<T extends TLAsset = TLAsset, U extends AssetUtil<T> = AssetUtil<T>> {
|
|
6913
|
+
new (editor: Editor): U;
|
|
6914
|
+
type: T['type'];
|
|
6915
|
+
props?: RecordProps<T>;
|
|
6916
|
+
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
6917
|
+
}
|
|
6918
|
+
|
|
6570
6919
|
/** @public */
|
|
6571
6920
|
export declare type TLBaseBoxShape = ExtractShapeByProps<{
|
|
6572
6921
|
h: number;
|
|
@@ -6727,6 +7076,40 @@ export declare type TLCLickEventName = 'double_click' | 'quadruple_click' | 'tri
|
|
|
6727
7076
|
/** @public */
|
|
6728
7077
|
export declare type TLClickState = 'idle' | 'overflow' | 'pendingDouble' | 'pendingOverflow' | 'pendingQuadruple' | 'pendingTriple';
|
|
6729
7078
|
|
|
7079
|
+
/**
|
|
7080
|
+
* Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.
|
|
7081
|
+
*
|
|
7082
|
+
* - `native-event`: from the `paste` event — `clipboardData` is available synchronously (unlike async
|
|
7083
|
+
* `navigator.clipboard.read()`).
|
|
7084
|
+
* - `clipboard-read`: from an explicit `navigator.clipboard.read()` call — only `ClipboardItem[]`
|
|
7085
|
+
* exists
|
|
7086
|
+
* (no `DataTransfer`).
|
|
7087
|
+
*
|
|
7088
|
+
* @public
|
|
7089
|
+
*/
|
|
7090
|
+
export declare type TLClipboardPasteRawInfo = {
|
|
7091
|
+
readonly clipboardData: DataTransfer | null;
|
|
7092
|
+
readonly editor: Editor;
|
|
7093
|
+
readonly event: ClipboardEvent;
|
|
7094
|
+
readonly point: undefined | VecLike;
|
|
7095
|
+
readonly source: 'native-event';
|
|
7096
|
+
} | {
|
|
7097
|
+
readonly clipboardItems: readonly ClipboardItem[];
|
|
7098
|
+
readonly editor: Editor;
|
|
7099
|
+
readonly point: undefined | VecLike;
|
|
7100
|
+
readonly source: 'clipboard-read';
|
|
7101
|
+
};
|
|
7102
|
+
|
|
7103
|
+
/**
|
|
7104
|
+
* Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).
|
|
7105
|
+
*
|
|
7106
|
+
* @public
|
|
7107
|
+
*/
|
|
7108
|
+
export declare interface TLClipboardWriteInfo {
|
|
7109
|
+
readonly operation: 'copy' | 'cut';
|
|
7110
|
+
readonly source: 'menu' | 'native';
|
|
7111
|
+
}
|
|
7112
|
+
|
|
6730
7113
|
/** @public */
|
|
6731
7114
|
export declare interface TLCollaboratorHintProps {
|
|
6732
7115
|
userId: string;
|
|
@@ -6754,6 +7137,7 @@ export declare interface TLContent {
|
|
|
6754
7137
|
rootShapeIds: TLShapeId[];
|
|
6755
7138
|
assets: TLAsset[];
|
|
6756
7139
|
schema: SerializedSchema;
|
|
7140
|
+
users?: TLUser[];
|
|
6757
7141
|
}
|
|
6758
7142
|
|
|
6759
7143
|
/**
|
|
@@ -6775,6 +7159,12 @@ export declare interface TLCropInfo<T extends TLShape> {
|
|
|
6775
7159
|
aspectRatioLocked?: boolean;
|
|
6776
7160
|
}
|
|
6777
7161
|
|
|
7162
|
+
/** @public */
|
|
7163
|
+
export declare interface TLCurrentUser {
|
|
7164
|
+
readonly userPreferences: Signal<TLUserPreferences>;
|
|
7165
|
+
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7166
|
+
}
|
|
7167
|
+
|
|
6778
7168
|
/** @public */
|
|
6779
7169
|
export declare interface TLCursorProps {
|
|
6780
7170
|
userId: string;
|
|
@@ -6875,6 +7265,10 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6875
7265
|
* An array of binding utils to use in the editor.
|
|
6876
7266
|
*/
|
|
6877
7267
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
7268
|
+
/**
|
|
7269
|
+
* An array of asset utils to use in the editor.
|
|
7270
|
+
*/
|
|
7271
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
6878
7272
|
/**
|
|
6879
7273
|
* An array of tools to add to the editor's state chart.
|
|
6880
7274
|
*/
|
|
@@ -6902,11 +7296,23 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6902
7296
|
/**
|
|
6903
7297
|
* The user interacting with the editor.
|
|
6904
7298
|
*/
|
|
6905
|
-
user?:
|
|
7299
|
+
user?: TLCurrentUser;
|
|
7300
|
+
/**
|
|
7301
|
+
* The editor's color scheme. Defaults to `'light'`.
|
|
7302
|
+
*
|
|
7303
|
+
* - `'light'` - Always use light mode.
|
|
7304
|
+
* - `'dark'` - Always use dark mode.
|
|
7305
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7306
|
+
*/
|
|
7307
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
6906
7308
|
/**
|
|
6907
|
-
*
|
|
7309
|
+
* Named themes for the editor.
|
|
6908
7310
|
*/
|
|
6909
|
-
|
|
7311
|
+
themes?: Partial<TLThemes>;
|
|
7312
|
+
/**
|
|
7313
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7314
|
+
*/
|
|
7315
|
+
initialTheme?: TLThemeId;
|
|
6910
7316
|
/**
|
|
6911
7317
|
* Camera options for the editor.
|
|
6912
7318
|
*
|
|
@@ -7166,6 +7572,72 @@ export declare interface TldrawOptions {
|
|
|
7166
7572
|
* viewport's page dimensions regardless of overview zoom changes.
|
|
7167
7573
|
*/
|
|
7168
7574
|
readonly quickZoomPreservesScreenBounds: boolean;
|
|
7575
|
+
/**
|
|
7576
|
+
* Called before content is written to the clipboard during a copy or cut operation.
|
|
7577
|
+
* Receives the serialized content (shapes, bindings, assets) and can filter or transform
|
|
7578
|
+
* it before it reaches the clipboard.
|
|
7579
|
+
*
|
|
7580
|
+
* Return a modified `TLContent` object to change what is copied or cut. Return `false` to
|
|
7581
|
+
* cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`
|
|
7582
|
+
* (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if
|
|
7583
|
+
* the hook is async.
|
|
7584
|
+
*
|
|
7585
|
+
* @example
|
|
7586
|
+
* ```tsx
|
|
7587
|
+
* // Filter out "locked" shapes from copy
|
|
7588
|
+
* onBeforeCopyToClipboard({ content, operation }) {
|
|
7589
|
+
* return {
|
|
7590
|
+
* ...content,
|
|
7591
|
+
* shapes: content.shapes.filter(s => !s.meta.locked),
|
|
7592
|
+
* rootShapeIds: content.rootShapeIds.filter(id =>
|
|
7593
|
+
* content.shapes.find(s => s.id === id && !s.meta.locked)
|
|
7594
|
+
* ),
|
|
7595
|
+
* }
|
|
7596
|
+
* }
|
|
7597
|
+
* ```
|
|
7598
|
+
*/
|
|
7599
|
+
onBeforeCopyToClipboard?(info: {
|
|
7600
|
+
content: TLContent;
|
|
7601
|
+
editor: Editor;
|
|
7602
|
+
} & TLClipboardWriteInfo): Awaitable<false | TLContent | void>;
|
|
7603
|
+
/**
|
|
7604
|
+
* Called before pasted content is processed and shapes are created. Receives the parsed
|
|
7605
|
+
* external content from the clipboard and can filter, transform, or cancel it.
|
|
7606
|
+
*
|
|
7607
|
+
* Return `false` to cancel the paste. Return a modified content object to transform it.
|
|
7608
|
+
* Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of
|
|
7609
|
+
* those values if the hook is async.
|
|
7610
|
+
*
|
|
7611
|
+
* This only fires for clipboard paste operations (keyboard shortcuts and menu actions),
|
|
7612
|
+
* not for file drops or programmatic `putExternalContent` calls.
|
|
7613
|
+
*
|
|
7614
|
+
* @example
|
|
7615
|
+
* ```tsx
|
|
7616
|
+
* // Block pasting of image files
|
|
7617
|
+
* onBeforePasteFromClipboard({ content }) {
|
|
7618
|
+
* if (content.type === 'files') {
|
|
7619
|
+
* const nonImages = content.files.filter(f => !f.type.startsWith('image/'))
|
|
7620
|
+
* if (nonImages.length === 0) return false
|
|
7621
|
+
* return { ...content, files: nonImages }
|
|
7622
|
+
* }
|
|
7623
|
+
* }
|
|
7624
|
+
* ```
|
|
7625
|
+
*/
|
|
7626
|
+
onBeforePasteFromClipboard?(info: {
|
|
7627
|
+
content: TLExternalContent<unknown>;
|
|
7628
|
+
editor: Editor;
|
|
7629
|
+
point?: VecLike;
|
|
7630
|
+
source: 'clipboard-read' | 'native-event';
|
|
7631
|
+
}): Awaitable<false | TLExternalContent<unknown> | void>;
|
|
7632
|
+
/**
|
|
7633
|
+
* Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data
|
|
7634
|
+
* (and before {@link TldrawOptions.onBeforePasteFromClipboard}).
|
|
7635
|
+
*
|
|
7636
|
+
* Return `false` to cancel tldraw's default paste handling for this gesture (same convention as
|
|
7637
|
+
* {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from
|
|
7638
|
+
* raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.
|
|
7639
|
+
*/
|
|
7640
|
+
onClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void;
|
|
7169
7641
|
/**
|
|
7170
7642
|
* Called when content is dropped on the canvas. Provides the page position
|
|
7171
7643
|
* where the drop occurred and the underlying drag event object.
|
|
@@ -7233,18 +7705,17 @@ export declare interface TLEditorOptions {
|
|
|
7233
7705
|
*/
|
|
7234
7706
|
bindingUtils: readonly TLAnyBindingUtilConstructor[];
|
|
7235
7707
|
/**
|
|
7236
|
-
* An array of
|
|
7708
|
+
* An array of asset utils to use in the editor. These will be used to handle asset-type-specific behavior.
|
|
7237
7709
|
*/
|
|
7238
|
-
|
|
7710
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
7239
7711
|
/**
|
|
7240
|
-
*
|
|
7241
|
-
* given, the body element will be used.
|
|
7712
|
+
* An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
|
|
7242
7713
|
*/
|
|
7243
|
-
|
|
7714
|
+
tools: readonly TLStateNodeConstructor[];
|
|
7244
7715
|
/**
|
|
7245
7716
|
* A user defined externally to replace the default user.
|
|
7246
7717
|
*/
|
|
7247
|
-
user?:
|
|
7718
|
+
user?: TLCurrentUser;
|
|
7248
7719
|
/**
|
|
7249
7720
|
* The editor's initial active tool (or other state node id).
|
|
7250
7721
|
*/
|
|
@@ -7253,27 +7724,15 @@ export declare interface TLEditorOptions {
|
|
|
7253
7724
|
* Whether to automatically focus the editor when it mounts.
|
|
7254
7725
|
*/
|
|
7255
7726
|
autoFocus?: boolean;
|
|
7256
|
-
/**
|
|
7257
|
-
* Whether to infer dark mode from the user's system preferences. Defaults to false.
|
|
7258
|
-
*/
|
|
7259
|
-
inferDarkMode?: boolean;
|
|
7260
|
-
/**
|
|
7261
|
-
* Options for the editor's camera.
|
|
7262
|
-
*
|
|
7263
|
-
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7264
|
-
*/
|
|
7265
|
-
cameraOptions?: Partial<TLCameraOptions>;
|
|
7266
|
-
options?: Partial<TldrawOptions>;
|
|
7267
|
-
/**
|
|
7268
|
-
* Text options for the editor.
|
|
7269
|
-
*
|
|
7270
|
-
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7271
|
-
*/
|
|
7272
|
-
textOptions?: TLTextOptions;
|
|
7273
7727
|
licenseKey?: string;
|
|
7274
7728
|
fontAssetUrls?: {
|
|
7275
7729
|
[key: string]: string | undefined;
|
|
7276
7730
|
};
|
|
7731
|
+
/**
|
|
7732
|
+
* Should return a containing html element which has all the styles applied to the editor. If not
|
|
7733
|
+
* given, the body element will be used.
|
|
7734
|
+
*/
|
|
7735
|
+
getContainer(): HTMLElement;
|
|
7277
7736
|
/**
|
|
7278
7737
|
* Provides a way to hide shapes.
|
|
7279
7738
|
*
|
|
@@ -7290,6 +7749,40 @@ export declare interface TLEditorOptions {
|
|
|
7290
7749
|
* @param editor - The editor instance.
|
|
7291
7750
|
*/
|
|
7292
7751
|
getShapeVisibility?(shape: TLShape, editor: Editor): 'hidden' | 'inherit' | 'visible' | null | undefined;
|
|
7752
|
+
/**
|
|
7753
|
+
* Named theme definitions for the editor. Each theme contains shared
|
|
7754
|
+
* properties (font size, line height, stroke width) and color palettes
|
|
7755
|
+
* for both light and dark modes.
|
|
7756
|
+
*/
|
|
7757
|
+
themes?: Partial<TLThemes>;
|
|
7758
|
+
/**
|
|
7759
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7760
|
+
*/
|
|
7761
|
+
initialTheme?: TLThemeId;
|
|
7762
|
+
/**
|
|
7763
|
+
* The editor's color scheme preference, controls the default color mode. Defaults to `'light'`.
|
|
7764
|
+
*
|
|
7765
|
+
* - `'light'` - Always use light mode.
|
|
7766
|
+
* - `'dark'` - Always use dark mode.
|
|
7767
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7768
|
+
*/
|
|
7769
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7770
|
+
/**
|
|
7771
|
+
* Additional configuration options for the tldraw editor.
|
|
7772
|
+
*/
|
|
7773
|
+
options?: Partial<TldrawOptions>;
|
|
7774
|
+
/**
|
|
7775
|
+
* Options for the editor's camera.
|
|
7776
|
+
*
|
|
7777
|
+
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7778
|
+
*/
|
|
7779
|
+
cameraOptions?: Partial<TLCameraOptions>;
|
|
7780
|
+
/**
|
|
7781
|
+
* Text options for the editor.
|
|
7782
|
+
*
|
|
7783
|
+
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7784
|
+
*/
|
|
7785
|
+
textOptions?: TLTextOptions;
|
|
7293
7786
|
}
|
|
7294
7787
|
|
|
7295
7788
|
/**
|
|
@@ -7348,6 +7841,7 @@ export declare const tlenv: {
|
|
|
7348
7841
|
*/
|
|
7349
7842
|
export declare const tlenvReactive: Atom< {
|
|
7350
7843
|
isCoarsePointer: boolean;
|
|
7844
|
+
supportsP3ColorSpace: boolean;
|
|
7351
7845
|
}, unknown>;
|
|
7352
7846
|
|
|
7353
7847
|
/** @public */
|
|
@@ -7476,6 +7970,7 @@ export declare interface TLFileReplaceExternalContent extends TLBaseExternalCont
|
|
|
7476
7970
|
type: 'file-replace';
|
|
7477
7971
|
file: File;
|
|
7478
7972
|
shapeId: TLShapeId;
|
|
7973
|
+
/** @deprecated This field is no longer used by the default handler. It may be removed in a future version. */
|
|
7479
7974
|
isImage: boolean;
|
|
7480
7975
|
}
|
|
7481
7976
|
|
|
@@ -7486,72 +7981,6 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
|
7486
7981
|
ignoreParent?: boolean;
|
|
7487
7982
|
}
|
|
7488
7983
|
|
|
7489
|
-
/**
|
|
7490
|
-
* A font face that can be used in the editor. The properties of this are largely the same as the
|
|
7491
|
-
* ones in the
|
|
7492
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.
|
|
7493
|
-
* @public
|
|
7494
|
-
*/
|
|
7495
|
-
export declare interface TLFontFace {
|
|
7496
|
-
/**
|
|
7497
|
-
* How this font can be referred to in CSS.
|
|
7498
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family | `font-family`}.
|
|
7499
|
-
*/
|
|
7500
|
-
readonly family: string;
|
|
7501
|
-
/**
|
|
7502
|
-
* The source of the font. This
|
|
7503
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`}.
|
|
7504
|
-
*/
|
|
7505
|
-
readonly src: TLFontFaceSource;
|
|
7506
|
-
/**
|
|
7507
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.
|
|
7508
|
-
*/
|
|
7509
|
-
readonly ascentOverride?: string;
|
|
7510
|
-
/**
|
|
7511
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.
|
|
7512
|
-
*/
|
|
7513
|
-
readonly descentOverride?: string;
|
|
7514
|
-
/**
|
|
7515
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.
|
|
7516
|
-
*/
|
|
7517
|
-
readonly stretch?: string;
|
|
7518
|
-
/**
|
|
7519
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.
|
|
7520
|
-
*/
|
|
7521
|
-
readonly style?: string;
|
|
7522
|
-
/**
|
|
7523
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.
|
|
7524
|
-
*/
|
|
7525
|
-
readonly weight?: string;
|
|
7526
|
-
/**
|
|
7527
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.
|
|
7528
|
-
*/
|
|
7529
|
-
readonly featureSettings?: string;
|
|
7530
|
-
/**
|
|
7531
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.
|
|
7532
|
-
*/
|
|
7533
|
-
readonly lineGapOverride?: string;
|
|
7534
|
-
/**
|
|
7535
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.
|
|
7536
|
-
*/
|
|
7537
|
-
readonly unicodeRange?: string;
|
|
7538
|
-
}
|
|
7539
|
-
|
|
7540
|
-
/**
|
|
7541
|
-
* Represents the `src` property of a {@link TLFontFace}.
|
|
7542
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.
|
|
7543
|
-
* @public
|
|
7544
|
-
*/
|
|
7545
|
-
export declare interface TLFontFaceSource {
|
|
7546
|
-
/**
|
|
7547
|
-
* A URL from which to load the font. If the value here is a key in
|
|
7548
|
-
* {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.
|
|
7549
|
-
*/
|
|
7550
|
-
url: string;
|
|
7551
|
-
format?: string;
|
|
7552
|
-
tech?: string;
|
|
7553
|
-
}
|
|
7554
|
-
|
|
7555
7984
|
/** Additional options for the {@link ShapeUtil.getGeometry} method.
|
|
7556
7985
|
*
|
|
7557
7986
|
* @public
|
|
@@ -7743,6 +8172,11 @@ export declare interface TLLoadSnapshotOptions {
|
|
|
7743
8172
|
forceOverwriteSessionState?: boolean;
|
|
7744
8173
|
}
|
|
7745
8174
|
|
|
8175
|
+
/** @public */
|
|
8176
|
+
export declare type TLMeasuredTextSize = BoxModel & {
|
|
8177
|
+
scrollWidth: number;
|
|
8178
|
+
};
|
|
8179
|
+
|
|
7746
8180
|
/** @public */
|
|
7747
8181
|
export declare interface TLMeasureTextOpts {
|
|
7748
8182
|
fontStyle: string;
|
|
@@ -8180,6 +8614,7 @@ export declare interface TLShapeUtilConstructor<T extends TLShape, U extends Sha
|
|
|
8180
8614
|
type: T['type'];
|
|
8181
8615
|
props?: RecordProps<T>;
|
|
8182
8616
|
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
8617
|
+
handledAssetTypes?: readonly string[];
|
|
8183
8618
|
}
|
|
8184
8619
|
|
|
8185
8620
|
/** @public */
|
|
@@ -8219,6 +8654,14 @@ export declare interface TLStoreBaseOptions {
|
|
|
8219
8654
|
defaultName?: string;
|
|
8220
8655
|
/** How should this store upload & resolve assets? */
|
|
8221
8656
|
assets?: TLAssetStore;
|
|
8657
|
+
/**
|
|
8658
|
+
* Named theme definitions. When provided, custom color names are automatically
|
|
8659
|
+
* registered before the store is constructed so persisted data with those
|
|
8660
|
+
* colors passes validation on load.
|
|
8661
|
+
*/
|
|
8662
|
+
themes?: Partial<TLThemes>;
|
|
8663
|
+
/** How should this store resolve users for attribution? */
|
|
8664
|
+
users?: TLUserStore;
|
|
8222
8665
|
/** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
|
|
8223
8666
|
onMount?(editor: Editor): (() => void) | void;
|
|
8224
8667
|
}
|
|
@@ -8238,6 +8681,7 @@ export declare type TLStoreOptions = TLStoreBaseOptions & {
|
|
|
8238
8681
|
|
|
8239
8682
|
/** @public */
|
|
8240
8683
|
export declare type TLStoreSchemaOptions = {
|
|
8684
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
8241
8685
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
8242
8686
|
migrations?: readonly MigrationSequence[];
|
|
8243
8687
|
records?: Record<string, CustomRecordInfo>;
|
|
@@ -8406,12 +8850,6 @@ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
|
|
|
8406
8850
|
url: string;
|
|
8407
8851
|
}
|
|
8408
8852
|
|
|
8409
|
-
/** @public */
|
|
8410
|
-
export declare interface TLUser {
|
|
8411
|
-
readonly userPreferences: Signal<TLUserPreferences>;
|
|
8412
|
-
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
8413
|
-
}
|
|
8414
|
-
|
|
8415
8853
|
/**
|
|
8416
8854
|
* A user of tldraw
|
|
8417
8855
|
*
|
|
@@ -8512,6 +8950,9 @@ export declare function uniq<T>(array: {
|
|
|
8512
8950
|
readonly length: number;
|
|
8513
8951
|
} | null | undefined): T[];
|
|
8514
8952
|
|
|
8953
|
+
/** @public */
|
|
8954
|
+
export declare function useColorMode(): 'dark' | 'light';
|
|
8955
|
+
|
|
8515
8956
|
/** @public */
|
|
8516
8957
|
export declare function useContainer(): HTMLElement;
|
|
8517
8958
|
|
|
@@ -8550,9 +8991,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
|
|
|
8550
8991
|
/** @public */
|
|
8551
8992
|
export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
8552
8993
|
|
|
8553
|
-
/** @public */
|
|
8554
|
-
export declare function useIsDarkMode(): boolean;
|
|
8555
|
-
|
|
8556
8994
|
/** @public */
|
|
8557
8995
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
8558
8996
|
|
|
@@ -8590,11 +9028,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
|
|
|
8590
9028
|
/** @public */
|
|
8591
9029
|
export declare class UserPreferencesManager {
|
|
8592
9030
|
private readonly user;
|
|
8593
|
-
private readonly
|
|
9031
|
+
private readonly colorScheme;
|
|
8594
9032
|
systemColorScheme: Atom<"dark" | "light", unknown>;
|
|
8595
9033
|
disposables: Set<() => void>;
|
|
8596
9034
|
dispose(): void;
|
|
8597
|
-
constructor(user:
|
|
9035
|
+
constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
|
|
8598
9036
|
updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
|
|
8599
9037
|
getUserPreferences(): {
|
|
8600
9038
|
animationSpeed: number;
|
|
@@ -8665,10 +9103,10 @@ export declare function useSvgExportContext(): null | SvgExportContext;
|
|
|
8665
9103
|
/**
|
|
8666
9104
|
* @public
|
|
8667
9105
|
*/
|
|
8668
|
-
export declare function
|
|
9106
|
+
export declare function useTldrawCurrentUser(opts: {
|
|
8669
9107
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void;
|
|
8670
9108
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences;
|
|
8671
|
-
}):
|
|
9109
|
+
}): TLCurrentUser;
|
|
8672
9110
|
|
|
8673
9111
|
/** @public */
|
|
8674
9112
|
export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreSchema<TLRecord, TLStoreProps>;
|