@tldraw/editor 4.6.0-canary.f354288a547b → 4.6.0-canary.fc83e96f57ca
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 +302 -114
- package/dist-cjs/index.js +14 -6
- package/dist-cjs/index.js.map +3 -3
- package/dist-cjs/lib/TldrawEditor.js +52 -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 +28 -0
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +240 -8
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.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/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 +10 -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/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/primitives/geometry/Geometry2d.js +2 -1
- package/dist-cjs/lib/primitives/geometry/Geometry2d.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 +302 -114
- package/dist-esm/index.mjs +19 -9
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +55 -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 +34 -1
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +242 -8
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/managers/FontManager/FontManager.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/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 +10 -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/primitives/geometry/Geometry2d.mjs +2 -1
- package/dist-esm/lib/primitives/geometry/Geometry2d.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 +12 -7
- package/src/lib/TldrawEditor.tsx +82 -16
- 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 +50 -1
- package/src/lib/editor/Editor.ts +330 -29
- 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/SpatialIndexManager/SpatialIndexManager.ts +4 -4
- 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 +12 -1
- package/src/lib/editor/types/SvgExportContext.tsx +5 -0
- package/src/lib/editor/types/clipboard-types.ts +2 -1
- 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/primitives/geometry/Geometry2d.ts +2 -1
- 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,14 @@ 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';
|
|
84
91
|
import { TLUnknownBinding } from '@tldraw/tlschema';
|
|
85
92
|
import { TLUnknownShape } from '@tldraw/tlschema';
|
|
93
|
+
import { TLUser } from '@tldraw/tlschema';
|
|
94
|
+
import { TLUserStore } from '@tldraw/tlschema';
|
|
86
95
|
import { TLVideoAsset } from '@tldraw/tlschema';
|
|
87
96
|
import { UnknownRecord } from '@tldraw/store';
|
|
88
97
|
import { VecModel } from '@tldraw/tlschema';
|
|
@@ -718,6 +727,12 @@ export declare function createDeepLinkString(deepLink: TLDeepLink): string;
|
|
|
718
727
|
*/
|
|
719
728
|
export declare function createSessionStateSnapshotSignal(store: TLStore): Signal<null | TLSessionStateSnapshot>;
|
|
720
729
|
|
|
730
|
+
/** @public */
|
|
731
|
+
export declare function createTLCurrentUser(opts?: {
|
|
732
|
+
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
733
|
+
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
734
|
+
}): TLCurrentUser;
|
|
735
|
+
|
|
721
736
|
/**
|
|
722
737
|
* A helper for creating a TLStore schema from either an object with shapeUtils, bindingUtils, and
|
|
723
738
|
* migrations, or a schema.
|
|
@@ -735,13 +750,7 @@ export declare function createTLSchemaFromUtils(opts: TLStoreSchemaOptions): Sto
|
|
|
735
750
|
*
|
|
736
751
|
* @public
|
|
737
752
|
*/
|
|
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;
|
|
753
|
+
export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, themes, ...rest }?: TLStoreOptions): TLStore;
|
|
745
754
|
|
|
746
755
|
/** @public */
|
|
747
756
|
export declare class CubicBezier2d extends Polyline2d {
|
|
@@ -816,6 +825,13 @@ export declare interface DebugFlagDefaults<T> {
|
|
|
816
825
|
|
|
817
826
|
/* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
|
|
818
827
|
|
|
828
|
+
/**
|
|
829
|
+
* The default theme definition containing color palettes for both light and dark modes.
|
|
830
|
+
*
|
|
831
|
+
* @public
|
|
832
|
+
*/
|
|
833
|
+
export declare const DEFAULT_THEME: TLTheme;
|
|
834
|
+
|
|
819
835
|
/** @public @react */
|
|
820
836
|
export declare function DefaultBackground(): JSX.Element;
|
|
821
837
|
|
|
@@ -963,6 +979,9 @@ export declare const defaultUserPreferences: Readonly<{
|
|
|
963
979
|
name: "";
|
|
964
980
|
}>;
|
|
965
981
|
|
|
982
|
+
/** @public */
|
|
983
|
+
export declare const defaultUserStore: TLUserStore;
|
|
984
|
+
|
|
966
985
|
/**
|
|
967
986
|
* Convert degrees to radians.
|
|
968
987
|
*
|
|
@@ -1038,7 +1057,7 @@ export declare class EdgeScrollManager {
|
|
|
1038
1057
|
/** @public */
|
|
1039
1058
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1040
1059
|
readonly id: string;
|
|
1041
|
-
constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus,
|
|
1060
|
+
constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
|
|
1042
1061
|
private readonly _getShapeVisibility?;
|
|
1043
1062
|
private getIsShapeHiddenCache;
|
|
1044
1063
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1101,7 +1120,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1101
1120
|
* @public
|
|
1102
1121
|
*/
|
|
1103
1122
|
readonly snaps: SnapManager;
|
|
1104
|
-
|
|
1123
|
+
/* Excluded from this release type: _spatialIndex */
|
|
1105
1124
|
/**
|
|
1106
1125
|
* A manager for the any asynchronous events and making sure they're
|
|
1107
1126
|
* cleaned up upon disposal.
|
|
@@ -1120,6 +1139,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1120
1139
|
* @public
|
|
1121
1140
|
*/
|
|
1122
1141
|
readonly user: UserPreferencesManager;
|
|
1142
|
+
/* Excluded from this release type: _themeManager */
|
|
1123
1143
|
/**
|
|
1124
1144
|
* A helper for measuring text.
|
|
1125
1145
|
*
|
|
@@ -1170,6 +1190,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1170
1190
|
* @public
|
|
1171
1191
|
*/
|
|
1172
1192
|
dispose(): void;
|
|
1193
|
+
/**
|
|
1194
|
+
* Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
|
|
1195
|
+
*
|
|
1196
|
+
* @public
|
|
1197
|
+
*/
|
|
1198
|
+
getColorMode(): 'dark' | 'light';
|
|
1199
|
+
/**
|
|
1200
|
+
* Set the color mode. Note that this is a convenience method that passes the mode to
|
|
1201
|
+
* `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
|
|
1202
|
+
*
|
|
1203
|
+
* @public
|
|
1204
|
+
*/
|
|
1205
|
+
setColorMode(mode: 'dark' | 'light'): this;
|
|
1206
|
+
/**
|
|
1207
|
+
* Get the id of the current theme.
|
|
1208
|
+
*
|
|
1209
|
+
* @public
|
|
1210
|
+
*/
|
|
1211
|
+
getCurrentThemeId(): TLThemeId;
|
|
1212
|
+
/**
|
|
1213
|
+
* Get the current theme definition.
|
|
1214
|
+
*
|
|
1215
|
+
* @public
|
|
1216
|
+
*/
|
|
1217
|
+
getCurrentTheme(): TLTheme;
|
|
1218
|
+
/**
|
|
1219
|
+
* Set the current theme by id.
|
|
1220
|
+
*
|
|
1221
|
+
* @public
|
|
1222
|
+
*/
|
|
1223
|
+
setCurrentTheme(id: TLThemeId): this;
|
|
1224
|
+
/**
|
|
1225
|
+
* Get all registered theme definitions.
|
|
1226
|
+
*
|
|
1227
|
+
* @public
|
|
1228
|
+
*/
|
|
1229
|
+
getThemes(): TLThemes;
|
|
1230
|
+
/**
|
|
1231
|
+
* Get a single theme definition by id.
|
|
1232
|
+
*
|
|
1233
|
+
* @public
|
|
1234
|
+
*/
|
|
1235
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
1236
|
+
/**
|
|
1237
|
+
* Replace all theme definitions, or update them via a callback that receives a deep copy.
|
|
1238
|
+
* The `'default'` theme must always be present in the result.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```ts
|
|
1242
|
+
* // Replace all themes
|
|
1243
|
+
* editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
|
|
1244
|
+
*
|
|
1245
|
+
* // Update via callback
|
|
1246
|
+
* editor.updateThemes((themes) => {
|
|
1247
|
+
* delete themes.ocean
|
|
1248
|
+
* return themes
|
|
1249
|
+
* })
|
|
1250
|
+
* ```
|
|
1251
|
+
*
|
|
1252
|
+
* @public
|
|
1253
|
+
*/
|
|
1254
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): this;
|
|
1255
|
+
/**
|
|
1256
|
+
* Register or update a single theme definition. The theme is keyed by its `id` property.
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* // Override a property on the default theme
|
|
1261
|
+
* editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
|
|
1262
|
+
*
|
|
1263
|
+
* // Register a new theme
|
|
1264
|
+
* editor.updateTheme({ id: 'ocean', ...myOceanTheme })
|
|
1265
|
+
* ```
|
|
1266
|
+
*
|
|
1267
|
+
* @public
|
|
1268
|
+
*/
|
|
1269
|
+
updateTheme(theme: TLTheme): this;
|
|
1173
1270
|
/**
|
|
1174
1271
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1175
1272
|
*
|
|
@@ -2269,6 +2366,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2269
2366
|
* @public
|
|
2270
2367
|
*/
|
|
2271
2368
|
getCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
2369
|
+
/**
|
|
2370
|
+
* Get the current user's ID for attribution purposes.
|
|
2371
|
+
* Also ensures a `user:` record exists in the store for the current user.
|
|
2372
|
+
* Returns `null` when the user store has no current user.
|
|
2373
|
+
*
|
|
2374
|
+
* @public
|
|
2375
|
+
*/
|
|
2376
|
+
getAttributionUserId(): null | string;
|
|
2377
|
+
/* Excluded from this release type: _ensureUserRecord */
|
|
2378
|
+
/**
|
|
2379
|
+
* Resolve a display name for a user ID. Asks the
|
|
2380
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2381
|
+
* falling back to the `user:` record in the store.
|
|
2382
|
+
*
|
|
2383
|
+
* @public
|
|
2384
|
+
*/
|
|
2385
|
+
getAttributionDisplayName(userId: null | string): null | string;
|
|
2386
|
+
/**
|
|
2387
|
+
* Resolve a user record by ID. Asks the
|
|
2388
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2389
|
+
* falling back to the `user:` record in the store.
|
|
2390
|
+
*
|
|
2391
|
+
* @public
|
|
2392
|
+
*/
|
|
2393
|
+
getAttributionUser(userId: null | string): null | TLUser;
|
|
2394
|
+
/* Excluded from this release type: _getReferencedUserIds */
|
|
2272
2395
|
private _isLockedOnFollowingUser;
|
|
2273
2396
|
/**
|
|
2274
2397
|
* Start viewport-following a user.
|
|
@@ -4363,6 +4486,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
|
|
|
4363
4486
|
*/
|
|
4364
4487
|
export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
|
|
4365
4488
|
|
|
4489
|
+
/**
|
|
4490
|
+
* Resolves a color style value to its actual CSS color string for a given theme and variant.
|
|
4491
|
+
* If the color is not a default theme color, returns the color value as-is.
|
|
4492
|
+
*
|
|
4493
|
+
* @param colors - The color palette for the current color mode (e.g. `theme.colors[colorMode]`)
|
|
4494
|
+
* @param color - The color style value to resolve
|
|
4495
|
+
* @param variant - Which variant of the color to return (solid, fill, pattern, etc.)
|
|
4496
|
+
* @returns The CSS color string for the specified color and variant
|
|
4497
|
+
*
|
|
4498
|
+
* @example
|
|
4499
|
+
* ```ts
|
|
4500
|
+
* import { getColorValue } from 'tldraw'
|
|
4501
|
+
*
|
|
4502
|
+
* const colors = editor.getCurrentTheme().colors[editor.getColorMode()]
|
|
4503
|
+
*
|
|
4504
|
+
* // Get the solid variant of red
|
|
4505
|
+
* const redSolid = getColorValue(colors, 'red', 'solid') // '#e03131'
|
|
4506
|
+
*
|
|
4507
|
+
* // Get the fill variant of blue
|
|
4508
|
+
* const blueFill = getColorValue(colors, 'blue', 'fill') // '#4465e9'
|
|
4509
|
+
*
|
|
4510
|
+
* // Custom color passes through unchanged
|
|
4511
|
+
* const customColor = getColorValue(colors, '#ff0000', 'solid') // '#ff0000'
|
|
4512
|
+
* ```
|
|
4513
|
+
*
|
|
4514
|
+
* @public
|
|
4515
|
+
*/
|
|
4516
|
+
export declare function getColorValue(colors: TLThemeColors, color: string | TLDefaultColorStyle, variant: keyof TLDefaultColor): string;
|
|
4517
|
+
|
|
4366
4518
|
/** @public */
|
|
4367
4519
|
export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
|
|
4368
4520
|
|
|
@@ -5369,6 +5521,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
|
|
|
5369
5521
|
y: number;
|
|
5370
5522
|
};
|
|
5371
5523
|
|
|
5524
|
+
/**
|
|
5525
|
+
* Resolve a partial set of user-provided themes into a complete `TLThemes`
|
|
5526
|
+
* record by merging with `DEFAULT_THEME`. The result is suitable for passing to
|
|
5527
|
+
* `registerColorsFromThemes`, `registerFontsFromThemes`, and the
|
|
5528
|
+
* `ThemeManager` constructor.
|
|
5529
|
+
*
|
|
5530
|
+
* @public
|
|
5531
|
+
*/
|
|
5532
|
+
export declare function resolveThemes(themes?: Partial<TLThemes>): TLThemes;
|
|
5533
|
+
|
|
5372
5534
|
/** @public */
|
|
5373
5535
|
export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
|
|
5374
5536
|
|
|
@@ -5957,6 +6119,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5957
6119
|
*/
|
|
5958
6120
|
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
|
|
5959
6121
|
getText(shape: Shape): string | undefined;
|
|
6122
|
+
/**
|
|
6123
|
+
* Return user IDs referenced in shape-specific props.
|
|
6124
|
+
* Used when copying shapes to include referenced users on the clipboard.
|
|
6125
|
+
* Override this if your shape stores user IDs in custom props.
|
|
6126
|
+
*
|
|
6127
|
+
* @public
|
|
6128
|
+
*/
|
|
6129
|
+
getReferencedUserIds(shape: Shape): string[];
|
|
5960
6130
|
getAriaDescriptor(shape: Shape): string | undefined;
|
|
5961
6131
|
/**
|
|
5962
6132
|
* A callback called just before a shape is created. This method provides a last chance to modify
|
|
@@ -6486,6 +6656,10 @@ export declare interface SvgExportContext {
|
|
|
6486
6656
|
* Whether the export should be in dark mode.
|
|
6487
6657
|
*/
|
|
6488
6658
|
readonly isDarkMode: boolean;
|
|
6659
|
+
/**
|
|
6660
|
+
* The color mode to use for this export.
|
|
6661
|
+
*/
|
|
6662
|
+
readonly colorMode: 'dark' | 'light';
|
|
6489
6663
|
/**
|
|
6490
6664
|
* The scale of the export - how much CSS pixels will be scaled up/down by.
|
|
6491
6665
|
*/
|
|
@@ -6556,6 +6730,47 @@ export declare class TextManager {
|
|
|
6556
6730
|
}[];
|
|
6557
6731
|
}
|
|
6558
6732
|
|
|
6733
|
+
/**
|
|
6734
|
+
* Manages the editor's color themes.
|
|
6735
|
+
*
|
|
6736
|
+
* Stores named theme definitions (each containing light and dark color palettes
|
|
6737
|
+
* alongside shared properties like font size). The current theme is resolved by
|
|
6738
|
+
* combining the current theme name with the user's color mode preference.
|
|
6739
|
+
*
|
|
6740
|
+
* **Terminology:**
|
|
6741
|
+
* - **Theme** (`TLTheme`): A named set of colors and typographic values for both light and dark modes.
|
|
6742
|
+
* - **Color mode** (`'light' | 'dark'`): The resolved appearance mode, derived from the user's
|
|
6743
|
+
* `colorScheme` preference (`'light' | 'dark' | 'system'`). Access via `getColorMode()`.
|
|
6744
|
+
*
|
|
6745
|
+
* @public
|
|
6746
|
+
*/
|
|
6747
|
+
export declare class ThemeManager {
|
|
6748
|
+
private readonly editor;
|
|
6749
|
+
private readonly _themes;
|
|
6750
|
+
private readonly _currentThemeId;
|
|
6751
|
+
constructor(editor: Editor, options: {
|
|
6752
|
+
initial: TLThemeId;
|
|
6753
|
+
themes: TLThemes;
|
|
6754
|
+
});
|
|
6755
|
+
/** Get the current color mode based on the user's dark mode preference. */
|
|
6756
|
+
getColorMode(): 'dark' | 'light';
|
|
6757
|
+
/** Get all registered theme definitions. */
|
|
6758
|
+
getThemes(): TLThemes;
|
|
6759
|
+
/** Get a single theme definition by id. */
|
|
6760
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
6761
|
+
/** Get the id of the current theme. */
|
|
6762
|
+
getCurrentThemeId(): TLThemeId;
|
|
6763
|
+
getCurrentTheme(): TLTheme;
|
|
6764
|
+
/** Set the current theme by id. The theme must have been previously registered. */
|
|
6765
|
+
setCurrentTheme(id: TLThemeId): void;
|
|
6766
|
+
/** Replace all theme definitions, or update them via a callback that receives a deep copy. */
|
|
6767
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): void;
|
|
6768
|
+
/** Register or update a named theme definition. */
|
|
6769
|
+
updateTheme(theme: TLTheme): void;
|
|
6770
|
+
/** Clean up any resources held by the manager. */
|
|
6771
|
+
dispose(): void;
|
|
6772
|
+
}
|
|
6773
|
+
|
|
6559
6774
|
/* Excluded from this release type: TickManager */
|
|
6560
6775
|
|
|
6561
6776
|
/**
|
|
@@ -6801,6 +7016,7 @@ export declare interface TLContent {
|
|
|
6801
7016
|
rootShapeIds: TLShapeId[];
|
|
6802
7017
|
assets: TLAsset[];
|
|
6803
7018
|
schema: SerializedSchema;
|
|
7019
|
+
users?: TLUser[];
|
|
6804
7020
|
}
|
|
6805
7021
|
|
|
6806
7022
|
/**
|
|
@@ -6822,6 +7038,12 @@ export declare interface TLCropInfo<T extends TLShape> {
|
|
|
6822
7038
|
aspectRatioLocked?: boolean;
|
|
6823
7039
|
}
|
|
6824
7040
|
|
|
7041
|
+
/** @public */
|
|
7042
|
+
export declare interface TLCurrentUser {
|
|
7043
|
+
readonly userPreferences: Signal<TLUserPreferences>;
|
|
7044
|
+
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7045
|
+
}
|
|
7046
|
+
|
|
6825
7047
|
/** @public */
|
|
6826
7048
|
export declare interface TLCursorProps {
|
|
6827
7049
|
userId: string;
|
|
@@ -6949,11 +7171,23 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6949
7171
|
/**
|
|
6950
7172
|
* The user interacting with the editor.
|
|
6951
7173
|
*/
|
|
6952
|
-
user?:
|
|
7174
|
+
user?: TLCurrentUser;
|
|
7175
|
+
/**
|
|
7176
|
+
* The editor's color scheme. Defaults to `'light'`.
|
|
7177
|
+
*
|
|
7178
|
+
* - `'light'` - Always use light mode.
|
|
7179
|
+
* - `'dark'` - Always use dark mode.
|
|
7180
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7181
|
+
*/
|
|
7182
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7183
|
+
/**
|
|
7184
|
+
* Named themes for the editor.
|
|
7185
|
+
*/
|
|
7186
|
+
themes?: Partial<TLThemes>;
|
|
6953
7187
|
/**
|
|
6954
|
-
*
|
|
7188
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
6955
7189
|
*/
|
|
6956
|
-
|
|
7190
|
+
initialTheme?: TLThemeId;
|
|
6957
7191
|
/**
|
|
6958
7192
|
* Camera options for the editor.
|
|
6959
7193
|
*
|
|
@@ -7349,15 +7583,10 @@ export declare interface TLEditorOptions {
|
|
|
7349
7583
|
* An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
|
|
7350
7584
|
*/
|
|
7351
7585
|
tools: readonly TLStateNodeConstructor[];
|
|
7352
|
-
/**
|
|
7353
|
-
* Should return a containing html element which has all the styles applied to the editor. If not
|
|
7354
|
-
* given, the body element will be used.
|
|
7355
|
-
*/
|
|
7356
|
-
getContainer(): HTMLElement;
|
|
7357
7586
|
/**
|
|
7358
7587
|
* A user defined externally to replace the default user.
|
|
7359
7588
|
*/
|
|
7360
|
-
user?:
|
|
7589
|
+
user?: TLCurrentUser;
|
|
7361
7590
|
/**
|
|
7362
7591
|
* The editor's initial active tool (or other state node id).
|
|
7363
7592
|
*/
|
|
@@ -7366,27 +7595,15 @@ export declare interface TLEditorOptions {
|
|
|
7366
7595
|
* Whether to automatically focus the editor when it mounts.
|
|
7367
7596
|
*/
|
|
7368
7597
|
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
7598
|
licenseKey?: string;
|
|
7387
7599
|
fontAssetUrls?: {
|
|
7388
7600
|
[key: string]: string | undefined;
|
|
7389
7601
|
};
|
|
7602
|
+
/**
|
|
7603
|
+
* Should return a containing html element which has all the styles applied to the editor. If not
|
|
7604
|
+
* given, the body element will be used.
|
|
7605
|
+
*/
|
|
7606
|
+
getContainer(): HTMLElement;
|
|
7390
7607
|
/**
|
|
7391
7608
|
* Provides a way to hide shapes.
|
|
7392
7609
|
*
|
|
@@ -7403,6 +7620,40 @@ export declare interface TLEditorOptions {
|
|
|
7403
7620
|
* @param editor - The editor instance.
|
|
7404
7621
|
*/
|
|
7405
7622
|
getShapeVisibility?(shape: TLShape, editor: Editor): 'hidden' | 'inherit' | 'visible' | null | undefined;
|
|
7623
|
+
/**
|
|
7624
|
+
* Named theme definitions for the editor. Each theme contains shared
|
|
7625
|
+
* properties (font size, line height, stroke width) and color palettes
|
|
7626
|
+
* for both light and dark modes.
|
|
7627
|
+
*/
|
|
7628
|
+
themes?: Partial<TLThemes>;
|
|
7629
|
+
/**
|
|
7630
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7631
|
+
*/
|
|
7632
|
+
initialTheme?: TLThemeId;
|
|
7633
|
+
/**
|
|
7634
|
+
* The editor's color scheme preference, controls the default color mode. Defaults to `'light'`.
|
|
7635
|
+
*
|
|
7636
|
+
* - `'light'` - Always use light mode.
|
|
7637
|
+
* - `'dark'` - Always use dark mode.
|
|
7638
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7639
|
+
*/
|
|
7640
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7641
|
+
/**
|
|
7642
|
+
* Additional configuration options for the tldraw editor.
|
|
7643
|
+
*/
|
|
7644
|
+
options?: Partial<TldrawOptions>;
|
|
7645
|
+
/**
|
|
7646
|
+
* Options for the editor's camera.
|
|
7647
|
+
*
|
|
7648
|
+
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7649
|
+
*/
|
|
7650
|
+
cameraOptions?: Partial<TLCameraOptions>;
|
|
7651
|
+
/**
|
|
7652
|
+
* Text options for the editor.
|
|
7653
|
+
*
|
|
7654
|
+
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7655
|
+
*/
|
|
7656
|
+
textOptions?: TLTextOptions;
|
|
7406
7657
|
}
|
|
7407
7658
|
|
|
7408
7659
|
/**
|
|
@@ -7461,6 +7712,7 @@ export declare const tlenv: {
|
|
|
7461
7712
|
*/
|
|
7462
7713
|
export declare const tlenvReactive: Atom< {
|
|
7463
7714
|
isCoarsePointer: boolean;
|
|
7715
|
+
supportsP3ColorSpace: boolean;
|
|
7464
7716
|
}, unknown>;
|
|
7465
7717
|
|
|
7466
7718
|
/** @public */
|
|
@@ -7599,72 +7851,6 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
|
7599
7851
|
ignoreParent?: boolean;
|
|
7600
7852
|
}
|
|
7601
7853
|
|
|
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
7854
|
/** Additional options for the {@link ShapeUtil.getGeometry} method.
|
|
7669
7855
|
*
|
|
7670
7856
|
* @public
|
|
@@ -8337,6 +8523,14 @@ export declare interface TLStoreBaseOptions {
|
|
|
8337
8523
|
defaultName?: string;
|
|
8338
8524
|
/** How should this store upload & resolve assets? */
|
|
8339
8525
|
assets?: TLAssetStore;
|
|
8526
|
+
/**
|
|
8527
|
+
* Named theme definitions. When provided, custom color names are automatically
|
|
8528
|
+
* registered before the store is constructed so persisted data with those
|
|
8529
|
+
* colors passes validation on load.
|
|
8530
|
+
*/
|
|
8531
|
+
themes?: Partial<TLThemes>;
|
|
8532
|
+
/** How should this store resolve users for attribution? */
|
|
8533
|
+
users?: TLUserStore;
|
|
8340
8534
|
/** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
|
|
8341
8535
|
onMount?(editor: Editor): (() => void) | void;
|
|
8342
8536
|
}
|
|
@@ -8524,12 +8718,6 @@ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
|
|
|
8524
8718
|
url: string;
|
|
8525
8719
|
}
|
|
8526
8720
|
|
|
8527
|
-
/** @public */
|
|
8528
|
-
export declare interface TLUser {
|
|
8529
|
-
readonly userPreferences: Signal<TLUserPreferences>;
|
|
8530
|
-
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
8531
|
-
}
|
|
8532
|
-
|
|
8533
8721
|
/**
|
|
8534
8722
|
* A user of tldraw
|
|
8535
8723
|
*
|
|
@@ -8630,6 +8818,9 @@ export declare function uniq<T>(array: {
|
|
|
8630
8818
|
readonly length: number;
|
|
8631
8819
|
} | null | undefined): T[];
|
|
8632
8820
|
|
|
8821
|
+
/** @public */
|
|
8822
|
+
export declare function useColorMode(): 'dark' | 'light';
|
|
8823
|
+
|
|
8633
8824
|
/** @public */
|
|
8634
8825
|
export declare function useContainer(): HTMLElement;
|
|
8635
8826
|
|
|
@@ -8668,9 +8859,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
|
|
|
8668
8859
|
/** @public */
|
|
8669
8860
|
export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
8670
8861
|
|
|
8671
|
-
/** @public */
|
|
8672
|
-
export declare function useIsDarkMode(): boolean;
|
|
8673
|
-
|
|
8674
8862
|
/** @public */
|
|
8675
8863
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
8676
8864
|
|
|
@@ -8708,11 +8896,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
|
|
|
8708
8896
|
/** @public */
|
|
8709
8897
|
export declare class UserPreferencesManager {
|
|
8710
8898
|
private readonly user;
|
|
8711
|
-
private readonly
|
|
8899
|
+
private readonly colorScheme;
|
|
8712
8900
|
systemColorScheme: Atom<"dark" | "light", unknown>;
|
|
8713
8901
|
disposables: Set<() => void>;
|
|
8714
8902
|
dispose(): void;
|
|
8715
|
-
constructor(user:
|
|
8903
|
+
constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
|
|
8716
8904
|
updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
|
|
8717
8905
|
getUserPreferences(): {
|
|
8718
8906
|
animationSpeed: number;
|
|
@@ -8783,10 +8971,10 @@ export declare function useSvgExportContext(): null | SvgExportContext;
|
|
|
8783
8971
|
/**
|
|
8784
8972
|
* @public
|
|
8785
8973
|
*/
|
|
8786
|
-
export declare function
|
|
8974
|
+
export declare function useTldrawCurrentUser(opts: {
|
|
8787
8975
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void;
|
|
8788
8976
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences;
|
|
8789
|
-
}):
|
|
8977
|
+
}): TLCurrentUser;
|
|
8790
8978
|
|
|
8791
8979
|
/** @public */
|
|
8792
8980
|
export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreSchema<TLRecord, TLStoreProps>;
|