@tldraw/editor 4.6.0-next.d15997ff5a4b → 4.6.0-next.e0f85e824397
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 +434 -114
- 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/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 +310 -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/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/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/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/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +434 -114
- package/dist-esm/index.mjs +21 -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/default-components/CanvasShapeIndicators.mjs +3 -3
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.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 +312 -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/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/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/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/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 +14 -7
- package/src/lib/TldrawEditor.tsx +98 -19
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +3 -3
- 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 +424 -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/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 +37 -1
- 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/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/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
|
|
|
@@ -963,6 +1025,9 @@ export declare const defaultUserPreferences: Readonly<{
|
|
|
963
1025
|
name: "";
|
|
964
1026
|
}>;
|
|
965
1027
|
|
|
1028
|
+
/** @public */
|
|
1029
|
+
export declare const defaultUserStore: TLUserStore;
|
|
1030
|
+
|
|
966
1031
|
/**
|
|
967
1032
|
* Convert degrees to radians.
|
|
968
1033
|
*
|
|
@@ -1038,7 +1103,7 @@ export declare class EdgeScrollManager {
|
|
|
1038
1103
|
/** @public */
|
|
1039
1104
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1040
1105
|
readonly id: string;
|
|
1041
|
-
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);
|
|
1042
1107
|
private readonly _getShapeVisibility?;
|
|
1043
1108
|
private getIsShapeHiddenCache;
|
|
1044
1109
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1101,7 +1166,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1101
1166
|
* @public
|
|
1102
1167
|
*/
|
|
1103
1168
|
readonly snaps: SnapManager;
|
|
1104
|
-
|
|
1169
|
+
/* Excluded from this release type: _spatialIndex */
|
|
1105
1170
|
/**
|
|
1106
1171
|
* A manager for the any asynchronous events and making sure they're
|
|
1107
1172
|
* cleaned up upon disposal.
|
|
@@ -1120,6 +1185,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1120
1185
|
* @public
|
|
1121
1186
|
*/
|
|
1122
1187
|
readonly user: UserPreferencesManager;
|
|
1188
|
+
/* Excluded from this release type: _themeManager */
|
|
1123
1189
|
/**
|
|
1124
1190
|
* A helper for measuring text.
|
|
1125
1191
|
*
|
|
@@ -1170,6 +1236,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1170
1236
|
* @public
|
|
1171
1237
|
*/
|
|
1172
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;
|
|
1173
1316
|
/**
|
|
1174
1317
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1175
1318
|
*
|
|
@@ -1178,6 +1321,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1178
1321
|
shapeUtils: {
|
|
1179
1322
|
readonly [K in string]?: ShapeUtil<TLShape>;
|
|
1180
1323
|
};
|
|
1324
|
+
/* Excluded from this release type: _shapeUtilsByAssetType */
|
|
1181
1325
|
styleProps: {
|
|
1182
1326
|
[key: string]: Map<StyleProp<any>, string>;
|
|
1183
1327
|
};
|
|
@@ -1209,6 +1353,15 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1209
1353
|
hasShapeUtil(shape: TLShape | TLShapePartial<TLShape>): boolean;
|
|
1210
1354
|
hasShapeUtil(type: TLShape['type']): boolean;
|
|
1211
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;
|
|
1212
1365
|
/**
|
|
1213
1366
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1214
1367
|
*
|
|
@@ -1239,6 +1392,40 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1239
1392
|
type: S['type'];
|
|
1240
1393
|
} | S): BindingUtil<S>;
|
|
1241
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;
|
|
1242
1429
|
/**
|
|
1243
1430
|
* A manager for the editor's history.
|
|
1244
1431
|
*
|
|
@@ -2269,6 +2456,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2269
2456
|
* @public
|
|
2270
2457
|
*/
|
|
2271
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 */
|
|
2272
2485
|
private _isLockedOnFollowingUser;
|
|
2273
2486
|
/**
|
|
2274
2487
|
* Start viewport-following a user.
|
|
@@ -4363,6 +4576,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
|
|
|
4363
4576
|
*/
|
|
4364
4577
|
export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
|
|
4365
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
|
+
|
|
4366
4608
|
/** @public */
|
|
4367
4609
|
export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
|
|
4368
4610
|
|
|
@@ -5369,6 +5611,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
|
|
|
5369
5611
|
y: number;
|
|
5370
5612
|
};
|
|
5371
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
|
+
|
|
5372
5624
|
/** @public */
|
|
5373
5625
|
export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
|
|
5374
5626
|
|
|
@@ -5650,12 +5902,32 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5650
5902
|
* @public
|
|
5651
5903
|
*/
|
|
5652
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[];
|
|
5653
5914
|
/**
|
|
5654
5915
|
* Get the default props for a shape.
|
|
5655
5916
|
*
|
|
5656
5917
|
* @public
|
|
5657
5918
|
*/
|
|
5658
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;
|
|
5659
5931
|
/**
|
|
5660
5932
|
* Get the shape's geometry.
|
|
5661
5933
|
*
|
|
@@ -5957,6 +6229,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5957
6229
|
*/
|
|
5958
6230
|
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
|
|
5959
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[];
|
|
5960
6240
|
getAriaDescriptor(shape: Shape): string | undefined;
|
|
5961
6241
|
/**
|
|
5962
6242
|
* A callback called just before a shape is created. This method provides a last chance to modify
|
|
@@ -6486,6 +6766,10 @@ export declare interface SvgExportContext {
|
|
|
6486
6766
|
* Whether the export should be in dark mode.
|
|
6487
6767
|
*/
|
|
6488
6768
|
readonly isDarkMode: boolean;
|
|
6769
|
+
/**
|
|
6770
|
+
* The color mode to use for this export.
|
|
6771
|
+
*/
|
|
6772
|
+
readonly colorMode: 'dark' | 'light';
|
|
6489
6773
|
/**
|
|
6490
6774
|
* The scale of the export - how much CSS pixels will be scaled up/down by.
|
|
6491
6775
|
*/
|
|
@@ -6556,6 +6840,47 @@ export declare class TextManager {
|
|
|
6556
6840
|
}[];
|
|
6557
6841
|
}
|
|
6558
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
|
+
|
|
6559
6884
|
/* Excluded from this release type: TickManager */
|
|
6560
6885
|
|
|
6561
6886
|
/**
|
|
@@ -6574,12 +6899,23 @@ export declare type TiptapNode = Node_2;
|
|
|
6574
6899
|
/** @public */
|
|
6575
6900
|
export declare type TLAdjacentDirection = 'down' | 'left' | 'next' | 'prev' | 'right' | 'up';
|
|
6576
6901
|
|
|
6902
|
+
/** @public */
|
|
6903
|
+
export declare type TLAnyAssetUtilConstructor = TLAssetUtilConstructor<any>;
|
|
6904
|
+
|
|
6577
6905
|
/** @public */
|
|
6578
6906
|
export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
6579
6907
|
|
|
6580
6908
|
/** @public */
|
|
6581
6909
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
6582
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
|
+
|
|
6583
6919
|
/** @public */
|
|
6584
6920
|
export declare type TLBaseBoxShape = ExtractShapeByProps<{
|
|
6585
6921
|
h: number;
|
|
@@ -6801,6 +7137,7 @@ export declare interface TLContent {
|
|
|
6801
7137
|
rootShapeIds: TLShapeId[];
|
|
6802
7138
|
assets: TLAsset[];
|
|
6803
7139
|
schema: SerializedSchema;
|
|
7140
|
+
users?: TLUser[];
|
|
6804
7141
|
}
|
|
6805
7142
|
|
|
6806
7143
|
/**
|
|
@@ -6822,6 +7159,12 @@ export declare interface TLCropInfo<T extends TLShape> {
|
|
|
6822
7159
|
aspectRatioLocked?: boolean;
|
|
6823
7160
|
}
|
|
6824
7161
|
|
|
7162
|
+
/** @public */
|
|
7163
|
+
export declare interface TLCurrentUser {
|
|
7164
|
+
readonly userPreferences: Signal<TLUserPreferences>;
|
|
7165
|
+
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7166
|
+
}
|
|
7167
|
+
|
|
6825
7168
|
/** @public */
|
|
6826
7169
|
export declare interface TLCursorProps {
|
|
6827
7170
|
userId: string;
|
|
@@ -6922,6 +7265,10 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6922
7265
|
* An array of binding utils to use in the editor.
|
|
6923
7266
|
*/
|
|
6924
7267
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
7268
|
+
/**
|
|
7269
|
+
* An array of asset utils to use in the editor.
|
|
7270
|
+
*/
|
|
7271
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
6925
7272
|
/**
|
|
6926
7273
|
* An array of tools to add to the editor's state chart.
|
|
6927
7274
|
*/
|
|
@@ -6949,11 +7296,23 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6949
7296
|
/**
|
|
6950
7297
|
* The user interacting with the editor.
|
|
6951
7298
|
*/
|
|
6952
|
-
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';
|
|
7308
|
+
/**
|
|
7309
|
+
* Named themes for the editor.
|
|
7310
|
+
*/
|
|
7311
|
+
themes?: Partial<TLThemes>;
|
|
6953
7312
|
/**
|
|
6954
|
-
*
|
|
7313
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
6955
7314
|
*/
|
|
6956
|
-
|
|
7315
|
+
initialTheme?: TLThemeId;
|
|
6957
7316
|
/**
|
|
6958
7317
|
* Camera options for the editor.
|
|
6959
7318
|
*
|
|
@@ -7346,18 +7705,17 @@ export declare interface TLEditorOptions {
|
|
|
7346
7705
|
*/
|
|
7347
7706
|
bindingUtils: readonly TLAnyBindingUtilConstructor[];
|
|
7348
7707
|
/**
|
|
7349
|
-
* An array of
|
|
7708
|
+
* An array of asset utils to use in the editor. These will be used to handle asset-type-specific behavior.
|
|
7350
7709
|
*/
|
|
7351
|
-
|
|
7710
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
7352
7711
|
/**
|
|
7353
|
-
*
|
|
7354
|
-
* 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.
|
|
7355
7713
|
*/
|
|
7356
|
-
|
|
7714
|
+
tools: readonly TLStateNodeConstructor[];
|
|
7357
7715
|
/**
|
|
7358
7716
|
* A user defined externally to replace the default user.
|
|
7359
7717
|
*/
|
|
7360
|
-
user?:
|
|
7718
|
+
user?: TLCurrentUser;
|
|
7361
7719
|
/**
|
|
7362
7720
|
* The editor's initial active tool (or other state node id).
|
|
7363
7721
|
*/
|
|
@@ -7366,27 +7724,15 @@ export declare interface TLEditorOptions {
|
|
|
7366
7724
|
* Whether to automatically focus the editor when it mounts.
|
|
7367
7725
|
*/
|
|
7368
7726
|
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
7727
|
licenseKey?: string;
|
|
7387
7728
|
fontAssetUrls?: {
|
|
7388
7729
|
[key: string]: string | undefined;
|
|
7389
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;
|
|
7390
7736
|
/**
|
|
7391
7737
|
* Provides a way to hide shapes.
|
|
7392
7738
|
*
|
|
@@ -7403,6 +7749,40 @@ export declare interface TLEditorOptions {
|
|
|
7403
7749
|
* @param editor - The editor instance.
|
|
7404
7750
|
*/
|
|
7405
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;
|
|
7406
7786
|
}
|
|
7407
7787
|
|
|
7408
7788
|
/**
|
|
@@ -7461,6 +7841,7 @@ export declare const tlenv: {
|
|
|
7461
7841
|
*/
|
|
7462
7842
|
export declare const tlenvReactive: Atom< {
|
|
7463
7843
|
isCoarsePointer: boolean;
|
|
7844
|
+
supportsP3ColorSpace: boolean;
|
|
7464
7845
|
}, unknown>;
|
|
7465
7846
|
|
|
7466
7847
|
/** @public */
|
|
@@ -7589,6 +7970,7 @@ export declare interface TLFileReplaceExternalContent extends TLBaseExternalCont
|
|
|
7589
7970
|
type: 'file-replace';
|
|
7590
7971
|
file: File;
|
|
7591
7972
|
shapeId: TLShapeId;
|
|
7973
|
+
/** @deprecated This field is no longer used by the default handler. It may be removed in a future version. */
|
|
7592
7974
|
isImage: boolean;
|
|
7593
7975
|
}
|
|
7594
7976
|
|
|
@@ -7599,72 +7981,6 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
|
7599
7981
|
ignoreParent?: boolean;
|
|
7600
7982
|
}
|
|
7601
7983
|
|
|
7602
|
-
/**
|
|
7603
|
-
* A font face that can be used in the editor. The properties of this are largely the same as the
|
|
7604
|
-
* ones in the
|
|
7605
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.
|
|
7606
|
-
* @public
|
|
7607
|
-
*/
|
|
7608
|
-
export declare interface TLFontFace {
|
|
7609
|
-
/**
|
|
7610
|
-
* How this font can be referred to in CSS.
|
|
7611
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family | `font-family`}.
|
|
7612
|
-
*/
|
|
7613
|
-
readonly family: string;
|
|
7614
|
-
/**
|
|
7615
|
-
* The source of the font. This
|
|
7616
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`}.
|
|
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;
|
|
7666
|
-
}
|
|
7667
|
-
|
|
7668
7984
|
/** Additional options for the {@link ShapeUtil.getGeometry} method.
|
|
7669
7985
|
*
|
|
7670
7986
|
* @public
|
|
@@ -8298,6 +8614,7 @@ export declare interface TLShapeUtilConstructor<T extends TLShape, U extends Sha
|
|
|
8298
8614
|
type: T['type'];
|
|
8299
8615
|
props?: RecordProps<T>;
|
|
8300
8616
|
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
8617
|
+
handledAssetTypes?: readonly string[];
|
|
8301
8618
|
}
|
|
8302
8619
|
|
|
8303
8620
|
/** @public */
|
|
@@ -8337,6 +8654,14 @@ export declare interface TLStoreBaseOptions {
|
|
|
8337
8654
|
defaultName?: string;
|
|
8338
8655
|
/** How should this store upload & resolve assets? */
|
|
8339
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;
|
|
8340
8665
|
/** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
|
|
8341
8666
|
onMount?(editor: Editor): (() => void) | void;
|
|
8342
8667
|
}
|
|
@@ -8356,6 +8681,7 @@ export declare type TLStoreOptions = TLStoreBaseOptions & {
|
|
|
8356
8681
|
|
|
8357
8682
|
/** @public */
|
|
8358
8683
|
export declare type TLStoreSchemaOptions = {
|
|
8684
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
8359
8685
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
8360
8686
|
migrations?: readonly MigrationSequence[];
|
|
8361
8687
|
records?: Record<string, CustomRecordInfo>;
|
|
@@ -8524,12 +8850,6 @@ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
|
|
|
8524
8850
|
url: string;
|
|
8525
8851
|
}
|
|
8526
8852
|
|
|
8527
|
-
/** @public */
|
|
8528
|
-
export declare interface TLUser {
|
|
8529
|
-
readonly userPreferences: Signal<TLUserPreferences>;
|
|
8530
|
-
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
8531
|
-
}
|
|
8532
|
-
|
|
8533
8853
|
/**
|
|
8534
8854
|
* A user of tldraw
|
|
8535
8855
|
*
|
|
@@ -8630,6 +8950,9 @@ export declare function uniq<T>(array: {
|
|
|
8630
8950
|
readonly length: number;
|
|
8631
8951
|
} | null | undefined): T[];
|
|
8632
8952
|
|
|
8953
|
+
/** @public */
|
|
8954
|
+
export declare function useColorMode(): 'dark' | 'light';
|
|
8955
|
+
|
|
8633
8956
|
/** @public */
|
|
8634
8957
|
export declare function useContainer(): HTMLElement;
|
|
8635
8958
|
|
|
@@ -8668,9 +8991,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
|
|
|
8668
8991
|
/** @public */
|
|
8669
8992
|
export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
8670
8993
|
|
|
8671
|
-
/** @public */
|
|
8672
|
-
export declare function useIsDarkMode(): boolean;
|
|
8673
|
-
|
|
8674
8994
|
/** @public */
|
|
8675
8995
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
8676
8996
|
|
|
@@ -8708,11 +9028,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
|
|
|
8708
9028
|
/** @public */
|
|
8709
9029
|
export declare class UserPreferencesManager {
|
|
8710
9030
|
private readonly user;
|
|
8711
|
-
private readonly
|
|
9031
|
+
private readonly colorScheme;
|
|
8712
9032
|
systemColorScheme: Atom<"dark" | "light", unknown>;
|
|
8713
9033
|
disposables: Set<() => void>;
|
|
8714
9034
|
dispose(): void;
|
|
8715
|
-
constructor(user:
|
|
9035
|
+
constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
|
|
8716
9036
|
updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
|
|
8717
9037
|
getUserPreferences(): {
|
|
8718
9038
|
animationSpeed: number;
|
|
@@ -8783,10 +9103,10 @@ export declare function useSvgExportContext(): null | SvgExportContext;
|
|
|
8783
9103
|
/**
|
|
8784
9104
|
* @public
|
|
8785
9105
|
*/
|
|
8786
|
-
export declare function
|
|
9106
|
+
export declare function useTldrawCurrentUser(opts: {
|
|
8787
9107
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void;
|
|
8788
9108
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences;
|
|
8789
|
-
}):
|
|
9109
|
+
}): TLCurrentUser;
|
|
8790
9110
|
|
|
8791
9111
|
/** @public */
|
|
8792
9112
|
export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreSchema<TLRecord, TLStoreProps>;
|