@tldraw/editor 4.6.0-canary.7cb931b72e36 → 4.6.0-canary.7effedd9627e

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.
Files changed (98) hide show
  1. package/dist-cjs/index.d.ts +244 -98
  2. package/dist-cjs/index.js +10 -3
  3. package/dist-cjs/index.js.map +3 -3
  4. package/dist-cjs/lib/TldrawEditor.js +48 -12
  5. package/dist-cjs/lib/TldrawEditor.js.map +3 -3
  6. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +3 -3
  7. package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +2 -2
  8. package/dist-cjs/lib/config/createTLStore.js +5 -0
  9. package/dist-cjs/lib/config/createTLStore.js.map +2 -2
  10. package/dist-cjs/lib/editor/Editor.js +134 -5
  11. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  12. package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
  13. package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +106 -0
  14. package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
  15. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +586 -0
  16. package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
  17. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +6 -4
  18. package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
  19. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +1 -1
  20. package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
  21. package/dist-cjs/lib/exports/getSvgJsx.js +12 -7
  22. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  23. package/dist-cjs/lib/globals/environment.js +18 -1
  24. package/dist-cjs/lib/globals/environment.js.map +2 -2
  25. package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
  26. package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
  27. package/dist-cjs/lib/hooks/useCursor.js +3 -7
  28. package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
  29. package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
  30. package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
  31. package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
  32. package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
  33. package/dist-cjs/lib/utils/richText.js.map +2 -2
  34. package/dist-cjs/version.js +3 -3
  35. package/dist-cjs/version.js.map +1 -1
  36. package/dist-esm/index.d.mts +244 -98
  37. package/dist-esm/index.mjs +11 -6
  38. package/dist-esm/index.mjs.map +2 -2
  39. package/dist-esm/lib/TldrawEditor.mjs +51 -12
  40. package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
  41. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +3 -3
  42. package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +2 -2
  43. package/dist-esm/lib/config/createTLStore.mjs +8 -1
  44. package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
  45. package/dist-esm/lib/editor/Editor.mjs +134 -5
  46. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  47. package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
  48. package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +88 -0
  49. package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
  50. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +568 -0
  51. package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
  52. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +6 -4
  53. package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
  54. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +1 -1
  55. package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
  56. package/dist-esm/lib/exports/getSvgJsx.mjs +12 -10
  57. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  58. package/dist-esm/lib/globals/environment.mjs +18 -1
  59. package/dist-esm/lib/globals/environment.mjs.map +2 -2
  60. package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
  61. package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
  62. package/dist-esm/lib/hooks/useCursor.mjs +3 -7
  63. package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
  64. package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
  65. package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
  66. package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
  67. package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
  68. package/dist-esm/lib/utils/richText.mjs.map +2 -2
  69. package/dist-esm/version.mjs +3 -3
  70. package/dist-esm/version.mjs.map +1 -1
  71. package/editor.css +0 -33
  72. package/package.json +8 -9
  73. package/src/index.ts +6 -6
  74. package/src/lib/TldrawEditor.tsx +74 -10
  75. package/src/lib/components/default-components/CanvasShapeIndicators.tsx +3 -3
  76. package/src/lib/config/createTLStore.ts +15 -0
  77. package/src/lib/editor/Editor.ts +197 -27
  78. package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
  79. package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
  80. package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
  81. package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +605 -0
  82. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +24 -30
  83. package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +6 -4
  84. package/src/lib/editor/shapes/ShapeUtil.ts +1 -1
  85. package/src/lib/editor/types/SvgExportContext.tsx +5 -0
  86. package/src/lib/exports/getSvgJsx.tsx +21 -15
  87. package/src/lib/globals/environment.ts +18 -0
  88. package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
  89. package/src/lib/hooks/useCursor.ts +3 -7
  90. package/src/lib/hooks/useDarkMode.ts +4 -4
  91. package/src/lib/hooks/useGestureEvents.ts +240 -168
  92. package/src/lib/primitives/Box.test.ts +30 -0
  93. package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
  94. package/src/lib/utils/richText.ts +1 -1
  95. package/src/version.ts +3 -3
  96. package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
  97. package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
  98. package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
@@ -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,6 +84,10 @@ 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';
86
93
  import { TLUser } from '@tldraw/tlschema';
@@ -743,7 +750,7 @@ export declare function createTLSchemaFromUtils(opts: TLStoreSchemaOptions): Sto
743
750
  *
744
751
  * @public
745
752
  */
746
- export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, ...rest }?: TLStoreOptions): TLStore;
753
+ export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, themes, ...rest }?: TLStoreOptions): TLStore;
747
754
 
748
755
  /** @public */
749
756
  export declare class CubicBezier2d extends Polyline2d {
@@ -818,6 +825,13 @@ export declare interface DebugFlagDefaults<T> {
818
825
 
819
826
  /* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
820
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
+
821
835
  /** @public @react */
822
836
  export declare function DefaultBackground(): JSX.Element;
823
837
 
@@ -1043,7 +1057,7 @@ export declare class EdgeScrollManager {
1043
1057
  /** @public */
1044
1058
  export declare class Editor extends EventEmitter<TLEventMap> {
1045
1059
  readonly id: string;
1046
- constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus, inferDarkMode, options: _options, textOptions: _textOptions, getShapeVisibility, fontAssetUrls }: TLEditorOptions);
1060
+ constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
1047
1061
  private readonly _getShapeVisibility?;
1048
1062
  private getIsShapeHiddenCache;
1049
1063
  isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
@@ -1106,7 +1120,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1106
1120
  * @public
1107
1121
  */
1108
1122
  readonly snaps: SnapManager;
1109
- private readonly _spatialIndex;
1123
+ /* Excluded from this release type: _spatialIndex */
1110
1124
  /**
1111
1125
  * A manager for the any asynchronous events and making sure they're
1112
1126
  * cleaned up upon disposal.
@@ -1125,6 +1139,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1125
1139
  * @public
1126
1140
  */
1127
1141
  readonly user: UserPreferencesManager;
1142
+ /* Excluded from this release type: _themeManager */
1128
1143
  /**
1129
1144
  * A helper for measuring text.
1130
1145
  *
@@ -1175,6 +1190,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1175
1190
  * @public
1176
1191
  */
1177
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;
1178
1270
  /**
1179
1271
  * A map of shape utility classes (TLShapeUtils) by shape type.
1180
1272
  *
@@ -4394,6 +4486,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
4394
4486
  */
4395
4487
  export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
4396
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
+
4397
4518
  /** @public */
4398
4519
  export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
4399
4520
 
@@ -5400,6 +5521,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
5400
5521
  y: number;
5401
5522
  };
5402
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
+
5403
5534
  /** @public */
5404
5535
  export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
5405
5536
 
@@ -6525,6 +6656,10 @@ export declare interface SvgExportContext {
6525
6656
  * Whether the export should be in dark mode.
6526
6657
  */
6527
6658
  readonly isDarkMode: boolean;
6659
+ /**
6660
+ * The color mode to use for this export.
6661
+ */
6662
+ readonly colorMode: 'dark' | 'light';
6528
6663
  /**
6529
6664
  * The scale of the export - how much CSS pixels will be scaled up/down by.
6530
6665
  */
@@ -6595,6 +6730,47 @@ export declare class TextManager {
6595
6730
  }[];
6596
6731
  }
6597
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
+
6598
6774
  /* Excluded from this release type: TickManager */
6599
6775
 
6600
6776
  /**
@@ -6997,9 +7173,21 @@ export declare interface TldrawEditorBaseProps {
6997
7173
  */
6998
7174
  user?: TLCurrentUser;
6999
7175
  /**
7000
- * Whether to infer dark mode from the user's OS. Defaults to false.
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>;
7187
+ /**
7188
+ * The id of the initially active theme. Defaults to `'default'`.
7001
7189
  */
7002
- inferDarkMode?: boolean;
7190
+ initialTheme?: TLThemeId;
7003
7191
  /**
7004
7192
  * Camera options for the editor.
7005
7193
  *
@@ -7395,11 +7583,6 @@ export declare interface TLEditorOptions {
7395
7583
  * An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
7396
7584
  */
7397
7585
  tools: readonly TLStateNodeConstructor[];
7398
- /**
7399
- * Should return a containing html element which has all the styles applied to the editor. If not
7400
- * given, the body element will be used.
7401
- */
7402
- getContainer(): HTMLElement;
7403
7586
  /**
7404
7587
  * A user defined externally to replace the default user.
7405
7588
  */
@@ -7412,27 +7595,15 @@ export declare interface TLEditorOptions {
7412
7595
  * Whether to automatically focus the editor when it mounts.
7413
7596
  */
7414
7597
  autoFocus?: boolean;
7415
- /**
7416
- * Whether to infer dark mode from the user's system preferences. Defaults to false.
7417
- */
7418
- inferDarkMode?: boolean;
7419
- /**
7420
- * Options for the editor's camera.
7421
- *
7422
- * @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
7423
- */
7424
- cameraOptions?: Partial<TLCameraOptions>;
7425
- options?: Partial<TldrawOptions>;
7426
- /**
7427
- * Text options for the editor.
7428
- *
7429
- * @deprecated Use `options.text` instead. This prop will be removed in a future release.
7430
- */
7431
- textOptions?: TLTextOptions;
7432
7598
  licenseKey?: string;
7433
7599
  fontAssetUrls?: {
7434
7600
  [key: string]: string | undefined;
7435
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;
7436
7607
  /**
7437
7608
  * Provides a way to hide shapes.
7438
7609
  *
@@ -7449,6 +7620,40 @@ export declare interface TLEditorOptions {
7449
7620
  * @param editor - The editor instance.
7450
7621
  */
7451
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;
7452
7657
  }
7453
7658
 
7454
7659
  /**
@@ -7507,6 +7712,7 @@ export declare const tlenv: {
7507
7712
  */
7508
7713
  export declare const tlenvReactive: Atom< {
7509
7714
  isCoarsePointer: boolean;
7715
+ supportsP3ColorSpace: boolean;
7510
7716
  }, unknown>;
7511
7717
 
7512
7718
  /** @public */
@@ -7645,72 +7851,6 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
7645
7851
  ignoreParent?: boolean;
7646
7852
  }
7647
7853
 
7648
- /**
7649
- * A font face that can be used in the editor. The properties of this are largely the same as the
7650
- * ones in the
7651
- * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.
7652
- * @public
7653
- */
7654
- export declare interface TLFontFace {
7655
- /**
7656
- * How this font can be referred to in CSS.
7657
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family | `font-family`}.
7658
- */
7659
- readonly family: string;
7660
- /**
7661
- * The source of the font. This
7662
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`}.
7663
- */
7664
- readonly src: TLFontFaceSource;
7665
- /**
7666
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.
7667
- */
7668
- readonly ascentOverride?: string;
7669
- /**
7670
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.
7671
- */
7672
- readonly descentOverride?: string;
7673
- /**
7674
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.
7675
- */
7676
- readonly stretch?: string;
7677
- /**
7678
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.
7679
- */
7680
- readonly style?: string;
7681
- /**
7682
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.
7683
- */
7684
- readonly weight?: string;
7685
- /**
7686
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.
7687
- */
7688
- readonly featureSettings?: string;
7689
- /**
7690
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.
7691
- */
7692
- readonly lineGapOverride?: string;
7693
- /**
7694
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.
7695
- */
7696
- readonly unicodeRange?: string;
7697
- }
7698
-
7699
- /**
7700
- * Represents the `src` property of a {@link TLFontFace}.
7701
- * See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.
7702
- * @public
7703
- */
7704
- export declare interface TLFontFaceSource {
7705
- /**
7706
- * A URL from which to load the font. If the value here is a key in
7707
- * {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.
7708
- */
7709
- url: string;
7710
- format?: string;
7711
- tech?: string;
7712
- }
7713
-
7714
7854
  /** Additional options for the {@link ShapeUtil.getGeometry} method.
7715
7855
  *
7716
7856
  * @public
@@ -8383,6 +8523,12 @@ export declare interface TLStoreBaseOptions {
8383
8523
  defaultName?: string;
8384
8524
  /** How should this store upload & resolve assets? */
8385
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>;
8386
8532
  /** How should this store resolve users for attribution? */
8387
8533
  users?: TLUserStore;
8388
8534
  /** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
@@ -8672,6 +8818,9 @@ export declare function uniq<T>(array: {
8672
8818
  readonly length: number;
8673
8819
  } | null | undefined): T[];
8674
8820
 
8821
+ /** @public */
8822
+ export declare function useColorMode(): 'dark' | 'light';
8823
+
8675
8824
  /** @public */
8676
8825
  export declare function useContainer(): HTMLElement;
8677
8826
 
@@ -8710,9 +8859,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
8710
8859
  /** @public */
8711
8860
  export declare function useIsCropping(shapeId: TLShapeId): boolean;
8712
8861
 
8713
- /** @public */
8714
- export declare function useIsDarkMode(): boolean;
8715
-
8716
8862
  /** @public */
8717
8863
  export declare function useIsEditing(shapeId: TLShapeId): boolean;
8718
8864
 
@@ -8750,11 +8896,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
8750
8896
  /** @public */
8751
8897
  export declare class UserPreferencesManager {
8752
8898
  private readonly user;
8753
- private readonly inferDarkMode;
8899
+ private readonly colorScheme;
8754
8900
  systemColorScheme: Atom<"dark" | "light", unknown>;
8755
8901
  disposables: Set<() => void>;
8756
8902
  dispose(): void;
8757
- constructor(user: TLCurrentUser, inferDarkMode: boolean);
8903
+ constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
8758
8904
  updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
8759
8905
  getUserPreferences(): {
8760
8906
  animationSpeed: number;
package/dist-cjs/index.js CHANGED
@@ -32,6 +32,7 @@ __export(index_exports, {
32
32
  CubicSpline2d: () => import_CubicSpline2d.CubicSpline2d,
33
33
  DEFAULT_ANIMATION_OPTIONS: () => import_constants.DEFAULT_ANIMATION_OPTIONS,
34
34
  DEFAULT_CAMERA_OPTIONS: () => import_constants.DEFAULT_CAMERA_OPTIONS,
35
+ DEFAULT_THEME: () => import_defaultThemes.DEFAULT_THEME,
35
36
  DefaultBackground: () => import_DefaultBackground.DefaultBackground,
36
37
  DefaultBrush: () => import_DefaultBrush.DefaultBrush,
37
38
  DefaultCanvas: () => import_DefaultCanvas.DefaultCanvas,
@@ -99,6 +100,7 @@ __export(index_exports, {
99
100
  TAB_ID: () => import_TLSessionStateSnapshot.TAB_ID,
100
101
  Table: () => import_LocalIndexedDb.Table,
101
102
  TextManager: () => import_TextManager.TextManager,
103
+ ThemeManager: () => import_ThemeManager.ThemeManager,
102
104
  TickManager: () => import_TickManager.TickManager,
103
105
  TldrawEditor: () => import_TldrawEditor.TldrawEditor,
104
106
  TransformedGeometry2d: () => import_Geometry2d.TransformedGeometry2d,
@@ -135,6 +137,7 @@ __export(index_exports, {
135
137
  extractSessionStateFromLegacySnapshot: () => import_TLSessionStateSnapshot.extractSessionStateFromLegacySnapshot,
136
138
  featureFlags: () => import_debug_flags.featureFlags,
137
139
  getArcMeasure: () => import_utils2.getArcMeasure,
140
+ getColorValue: () => import_defaultThemes2.getColorValue,
138
141
  getCursor: () => import_useCursor.getCursor,
139
142
  getDefaultCdnBaseUrl: () => import_assets.getDefaultCdnBaseUrl,
140
143
  getDroppedShapesToNewParents: () => import_reparenting.getDroppedShapesToNewParents,
@@ -192,6 +195,7 @@ __export(index_exports, {
192
195
  releasePointerCapture: () => import_dom.releasePointerCapture,
193
196
  resizeBox: () => import_resizeBox.resizeBox,
194
197
  resizeScaled: () => import_resizeScaled.resizeScaled,
198
+ resolveThemes: () => import_ThemeManager.resolveThemes,
195
199
  rotateSelectionHandle: () => import_Box.rotateSelectionHandle,
196
200
  runtime: () => import_runtime.runtime,
197
201
  sanitizeId: () => import_useSafeId.sanitizeId,
@@ -210,6 +214,7 @@ __export(index_exports, {
210
214
  toFixed: () => import_utils2.toFixed,
211
215
  toPrecision: () => import_utils2.toPrecision,
212
216
  uniq: () => import_uniq.uniq,
217
+ useColorMode: () => import_useColorMode.useColorMode,
213
218
  useContainer: () => import_useContainer.useContainer,
214
219
  useContainerIfExists: () => import_useContainer.useContainerIfExists,
215
220
  useDelaySvgExport: () => import_SvgExportContext.useDelaySvgExport,
@@ -218,7 +223,6 @@ __export(index_exports, {
218
223
  useEvent: () => import_useEvent.useEvent,
219
224
  useGlobalMenuIsOpen: () => import_useGlobalMenuIsOpen.useGlobalMenuIsOpen,
220
225
  useIsCropping: () => import_useIsCropping.useIsCropping,
221
- useIsDarkMode: () => import_useIsDarkMode.useIsDarkMode,
222
226
  useIsEditing: () => import_useIsEditing.useIsEditing,
223
227
  useLocalStore: () => import_useLocalStore.useLocalStore,
224
228
  useMaybeEditor: () => import_useEditor.useMaybeEditor,
@@ -292,6 +296,8 @@ var import_HandleSnaps = require("./lib/editor/managers/SnapManager/HandleSnaps"
292
296
  var import_SnapManager = require("./lib/editor/managers/SnapManager/SnapManager");
293
297
  var import_SpatialIndexManager = require("./lib/editor/managers/SpatialIndexManager/SpatialIndexManager");
294
298
  var import_TextManager = require("./lib/editor/managers/TextManager/TextManager");
299
+ var import_defaultThemes = require("./lib/editor/managers/ThemeManager/defaultThemes");
300
+ var import_ThemeManager = require("./lib/editor/managers/ThemeManager/ThemeManager");
295
301
  var import_TickManager = require("./lib/editor/managers/TickManager/TickManager");
296
302
  var import_UserPreferencesManager = require("./lib/editor/managers/UserPreferencesManager/UserPreferencesManager");
297
303
  var import_BaseBoxShapeUtil = require("./lib/editor/shapes/BaseBoxShapeUtil");
@@ -311,6 +317,7 @@ var import_environment = require("./lib/globals/environment");
311
317
  var import_menus = require("./lib/globals/menus");
312
318
  var import_time = require("./lib/globals/time");
313
319
  var import_useContainer = require("./lib/hooks/useContainer");
320
+ var import_useColorMode = require("./lib/hooks/useColorMode");
314
321
  var import_useCursor = require("./lib/hooks/useCursor");
315
322
  var import_useEditor = require("./lib/hooks/useEditor");
316
323
  var import_useEditorComponents = require("./lib/hooks/useEditorComponents");
@@ -318,7 +325,6 @@ var import_useEvent = require("./lib/hooks/useEvent");
318
325
  var import_useGlobalMenuIsOpen = require("./lib/hooks/useGlobalMenuIsOpen");
319
326
  var import_useIdentity = require("./lib/hooks/useIdentity");
320
327
  var import_useIsCropping = require("./lib/hooks/useIsCropping");
321
- var import_useIsDarkMode = require("./lib/hooks/useIsDarkMode");
322
328
  var import_useIsEditing = require("./lib/hooks/useIsEditing");
323
329
  var import_useLocalStore = require("./lib/hooks/useLocalStore");
324
330
  var import_usePassThroughMouseOverEvents = require("./lib/hooks/usePassThroughMouseOverEvents");
@@ -374,9 +380,10 @@ var import_SharedStylesMap = require("./lib/utils/SharedStylesMap");
374
380
  var import_hardReset = require("./lib/utils/sync/hardReset");
375
381
  var import_LocalIndexedDb = require("./lib/utils/sync/LocalIndexedDb");
376
382
  var import_uniq = require("./lib/utils/uniq");
383
+ var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
377
384
  (0, import_utils.registerTldrawLibraryVersion)(
378
385
  "@tldraw/editor",
379
- "4.6.0-canary.7cb931b72e36",
386
+ "4.6.0-canary.7effedd9627e",
380
387
  "cjs"
381
388
  );
382
389
  //# sourceMappingURL=index.js.map