@tldraw/editor 4.6.0-canary.f9c762eafbc3 → 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 +426 -120
- 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/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.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 +29 -1
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/config/defaultShapes.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +703 -362
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +25 -64
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +1 -1
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +14 -53
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +71 -112
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +21 -56
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +11 -52
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +19 -56
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +4 -4
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +102 -30
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +106 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +586 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +16 -55
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +63 -72
- 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/ExportDelay.js +12 -53
- package/dist-cjs/lib/exports/ExportDelay.js.map +1 -1
- package/dist-cjs/lib/exports/FontEmbedder.js +14 -57
- package/dist-cjs/lib/exports/FontEmbedder.js.map +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +12 -7
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/globals/environment.js +18 -1
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
- package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
- package/dist-cjs/lib/hooks/useCursor.js +3 -7
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
- package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
- package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
- package/dist-cjs/lib/options.js +3 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +26 -26
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +1 -1
- package/dist-cjs/lib/primitives/Vec.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +3 -3
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +10 -9
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
- package/dist-cjs/lib/utils/SharedStylesMap.js +1 -1
- package/dist-cjs/lib/utils/SharedStylesMap.js.map +1 -1
- package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +426 -120
- package/dist-esm/index.mjs +22 -10
- 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/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.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 +35 -2
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/config/defaultShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +706 -364
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +25 -64
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +14 -53
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +71 -112
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +21 -56
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +11 -52
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +19 -56
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +4 -4
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +102 -30
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +88 -0
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +568 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +16 -55
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +63 -72
- 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/ExportDelay.mjs +12 -53
- package/dist-esm/lib/exports/ExportDelay.mjs.map +1 -1
- package/dist-esm/lib/exports/FontEmbedder.mjs +14 -57
- package/dist-esm/lib/exports/FontEmbedder.mjs.map +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +12 -10
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +18 -1
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
- package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
- package/dist-esm/lib/hooks/useCursor.mjs +3 -7
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
- package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
- package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +3 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +26 -26
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +1 -1
- package/dist-esm/lib/primitives/Vec.mjs.map +1 -1
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +1 -1
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +3 -3
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +10 -9
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
- package/dist-esm/lib/utils/SharedStylesMap.mjs +1 -1
- package/dist-esm/lib/utils/SharedStylesMap.mjs.map +1 -1
- package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +13 -33
- package/package.json +7 -8
- package/src/index.ts +27 -14
- package/src/lib/TldrawEditor.tsx +83 -17
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +3 -3
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -0
- package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
- package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +9 -9
- package/src/lib/config/createTLStore.ts +51 -2
- package/src/lib/config/defaultShapes.ts +1 -1
- package/src/lib/editor/Editor.ts +338 -36
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
- package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +30 -30
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +1 -1
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
- package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
- package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +605 -0
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +25 -31
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +7 -5
- package/src/lib/editor/shapes/ShapeUtil.ts +14 -3
- package/src/lib/editor/types/SvgExportContext.tsx +5 -0
- package/src/lib/editor/types/clipboard-types.ts +2 -1
- package/src/lib/exports/StyleEmbedder.ts +1 -1
- package/src/lib/exports/getSvgJsx.tsx +22 -16
- package/src/lib/globals/environment.ts +18 -0
- package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
- package/src/lib/hooks/useCursor.ts +3 -7
- package/src/lib/hooks/useDarkMode.ts +4 -4
- package/src/lib/hooks/useEditorComponents.tsx +1 -1
- package/src/lib/hooks/useGestureEvents.ts +240 -168
- package/src/lib/hooks/useLocalStore.ts +1 -1
- package/src/lib/options.ts +108 -0
- package/src/lib/primitives/Box.test.ts +30 -0
- package/src/lib/primitives/Box.ts +26 -26
- package/src/lib/primitives/Vec.ts +1 -1
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/CubicSpline2d.ts +1 -1
- package/src/lib/primitives/geometry/Ellipse2d.ts +3 -3
- package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +10 -9
- package/src/lib/primitives/geometry/Polyline2d.ts +2 -2
- package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
- package/src/lib/utils/SharedStylesMap.ts +1 -1
- package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
- package/src/lib/utils/richText.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +2 -1
- package/src/version.ts +3 -3
- package/dist-cjs/lib/config/createTLUser.js.map +0 -7
- package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
- package/dist-esm/lib/config/createTLUser.mjs.map +0 -7
- package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
- package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
package/dist-cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Atom } from '@tldraw/state';
|
|
2
2
|
import { AtomSet } from '@tldraw/store';
|
|
3
|
+
import { Awaitable } from '@tldraw/utils';
|
|
3
4
|
import { BoxModel } from '@tldraw/tlschema';
|
|
4
5
|
import { ComponentType } from 'react';
|
|
5
6
|
import { Computed } from '@tldraw/state';
|
|
@@ -56,9 +57,12 @@ import { TLCamera } from '@tldraw/tlschema';
|
|
|
56
57
|
import { TLCreateShapePartial } from '@tldraw/tlschema';
|
|
57
58
|
import { TLCursor } from '@tldraw/tlschema';
|
|
58
59
|
import { TLCursorType } from '@tldraw/tlschema';
|
|
60
|
+
import { TLDefaultColor } from '@tldraw/tlschema';
|
|
61
|
+
import { TLDefaultColorStyle } from '@tldraw/tlschema';
|
|
59
62
|
import { TLDefaultDashStyle } from '@tldraw/tlschema';
|
|
60
63
|
import { TLDefaultHorizontalAlignStyle } from '@tldraw/tlschema';
|
|
61
64
|
import { TLDocument } from '@tldraw/tlschema';
|
|
65
|
+
import { TLFontFace } from '@tldraw/tlschema';
|
|
62
66
|
import { TLGroupShape } from '@tldraw/tlschema';
|
|
63
67
|
import { TLHandle } from '@tldraw/tlschema';
|
|
64
68
|
import { TLImageAsset } from '@tldraw/tlschema';
|
|
@@ -80,8 +84,14 @@ import { TLStore } from '@tldraw/tlschema';
|
|
|
80
84
|
import { TLStoreProps } from '@tldraw/tlschema';
|
|
81
85
|
import { TLStoreSchema } from '@tldraw/tlschema';
|
|
82
86
|
import { TLStoreSnapshot } from '@tldraw/tlschema';
|
|
87
|
+
import { TLTheme } from '@tldraw/tlschema';
|
|
88
|
+
import { TLThemeColors } from '@tldraw/tlschema';
|
|
89
|
+
import { TLThemeId } from '@tldraw/tlschema';
|
|
90
|
+
import { TLThemes } from '@tldraw/tlschema';
|
|
83
91
|
import { TLUnknownBinding } from '@tldraw/tlschema';
|
|
84
92
|
import { TLUnknownShape } from '@tldraw/tlschema';
|
|
93
|
+
import { TLUser } from '@tldraw/tlschema';
|
|
94
|
+
import { TLUserStore } from '@tldraw/tlschema';
|
|
85
95
|
import { TLVideoAsset } from '@tldraw/tlschema';
|
|
86
96
|
import { UnknownRecord } from '@tldraw/store';
|
|
87
97
|
import { VecModel } from '@tldraw/tlschema';
|
|
@@ -164,6 +174,12 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
164
174
|
getInterpolatedProps(startShape: Shape, endShape: Shape, t: number): Shape['props'];
|
|
165
175
|
}
|
|
166
176
|
|
|
177
|
+
/** @public */
|
|
178
|
+
export declare interface BatchMeasurementRequest {
|
|
179
|
+
html: string;
|
|
180
|
+
opts: TLMeasureTextOpts;
|
|
181
|
+
}
|
|
182
|
+
|
|
167
183
|
/**
|
|
168
184
|
* Options passed to {@link BindingUtil.onBeforeChange} and {@link BindingUtil.onAfterChange},
|
|
169
185
|
* describing the data associated with a binding being changed.
|
|
@@ -711,6 +727,12 @@ export declare function createDeepLinkString(deepLink: TLDeepLink): string;
|
|
|
711
727
|
*/
|
|
712
728
|
export declare function createSessionStateSnapshotSignal(store: TLStore): Signal<null | TLSessionStateSnapshot>;
|
|
713
729
|
|
|
730
|
+
/** @public */
|
|
731
|
+
export declare function createTLCurrentUser(opts?: {
|
|
732
|
+
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
733
|
+
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
734
|
+
}): TLCurrentUser;
|
|
735
|
+
|
|
714
736
|
/**
|
|
715
737
|
* A helper for creating a TLStore schema from either an object with shapeUtils, bindingUtils, and
|
|
716
738
|
* migrations, or a schema.
|
|
@@ -728,13 +750,7 @@ export declare function createTLSchemaFromUtils(opts: TLStoreSchemaOptions): Sto
|
|
|
728
750
|
*
|
|
729
751
|
* @public
|
|
730
752
|
*/
|
|
731
|
-
export declare function createTLStore({ initialData, defaultName, id, assets, onMount, collaboration, ...rest }?: TLStoreOptions): TLStore;
|
|
732
|
-
|
|
733
|
-
/** @public */
|
|
734
|
-
export declare function createTLUser(opts?: {
|
|
735
|
-
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
736
|
-
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
737
|
-
}): TLUser;
|
|
753
|
+
export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, themes, ...rest }?: TLStoreOptions): TLStore;
|
|
738
754
|
|
|
739
755
|
/** @public */
|
|
740
756
|
export declare class CubicBezier2d extends Polyline2d {
|
|
@@ -809,6 +825,13 @@ export declare interface DebugFlagDefaults<T> {
|
|
|
809
825
|
|
|
810
826
|
/* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
|
|
811
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
|
+
|
|
812
835
|
/** @public @react */
|
|
813
836
|
export declare function DefaultBackground(): JSX.Element;
|
|
814
837
|
|
|
@@ -923,6 +946,9 @@ export declare const defaultTldrawOptions: {
|
|
|
923
946
|
readonly maxShapesPerPage: 4000;
|
|
924
947
|
readonly multiClickDurationMs: 200;
|
|
925
948
|
readonly nonce: undefined;
|
|
949
|
+
readonly onBeforeCopyToClipboard: undefined;
|
|
950
|
+
readonly onBeforePasteFromClipboard: undefined;
|
|
951
|
+
readonly onClipboardPasteRaw: undefined;
|
|
926
952
|
readonly quickZoomPreservesScreenBounds: true;
|
|
927
953
|
readonly snapThreshold: 8;
|
|
928
954
|
readonly spacebarPanning: true;
|
|
@@ -953,6 +979,9 @@ export declare const defaultUserPreferences: Readonly<{
|
|
|
953
979
|
name: "";
|
|
954
980
|
}>;
|
|
955
981
|
|
|
982
|
+
/** @public */
|
|
983
|
+
export declare const defaultUserStore: TLUserStore;
|
|
984
|
+
|
|
956
985
|
/**
|
|
957
986
|
* Convert degrees to radians.
|
|
958
987
|
*
|
|
@@ -1028,7 +1057,7 @@ export declare class EdgeScrollManager {
|
|
|
1028
1057
|
/** @public */
|
|
1029
1058
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1030
1059
|
readonly id: string;
|
|
1031
|
-
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);
|
|
1032
1061
|
private readonly _getShapeVisibility?;
|
|
1033
1062
|
private getIsShapeHiddenCache;
|
|
1034
1063
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1091,7 +1120,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1091
1120
|
* @public
|
|
1092
1121
|
*/
|
|
1093
1122
|
readonly snaps: SnapManager;
|
|
1094
|
-
|
|
1123
|
+
/* Excluded from this release type: _spatialIndex */
|
|
1095
1124
|
/**
|
|
1096
1125
|
* A manager for the any asynchronous events and making sure they're
|
|
1097
1126
|
* cleaned up upon disposal.
|
|
@@ -1110,6 +1139,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1110
1139
|
* @public
|
|
1111
1140
|
*/
|
|
1112
1141
|
readonly user: UserPreferencesManager;
|
|
1142
|
+
/* Excluded from this release type: _themeManager */
|
|
1113
1143
|
/**
|
|
1114
1144
|
* A helper for measuring text.
|
|
1115
1145
|
*
|
|
@@ -1160,6 +1190,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1160
1190
|
* @public
|
|
1161
1191
|
*/
|
|
1162
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;
|
|
1163
1270
|
/**
|
|
1164
1271
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1165
1272
|
*
|
|
@@ -2259,6 +2366,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2259
2366
|
* @public
|
|
2260
2367
|
*/
|
|
2261
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 */
|
|
2262
2395
|
private _isLockedOnFollowingUser;
|
|
2263
2396
|
/**
|
|
2264
2397
|
* Start viewport-following a user.
|
|
@@ -4353,6 +4486,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
|
|
|
4353
4486
|
*/
|
|
4354
4487
|
export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
|
|
4355
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
|
+
|
|
4356
4518
|
/** @public */
|
|
4357
4519
|
export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
|
|
4358
4520
|
|
|
@@ -5359,6 +5521,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
|
|
|
5359
5521
|
y: number;
|
|
5360
5522
|
};
|
|
5361
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
|
+
|
|
5362
5534
|
/** @public */
|
|
5363
5535
|
export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
|
|
5364
5536
|
|
|
@@ -5947,6 +6119,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5947
6119
|
*/
|
|
5948
6120
|
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
|
|
5949
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[];
|
|
5950
6130
|
getAriaDescriptor(shape: Shape): string | undefined;
|
|
5951
6131
|
/**
|
|
5952
6132
|
* A callback called just before a shape is created. This method provides a last chance to modify
|
|
@@ -6476,6 +6656,10 @@ export declare interface SvgExportContext {
|
|
|
6476
6656
|
* Whether the export should be in dark mode.
|
|
6477
6657
|
*/
|
|
6478
6658
|
readonly isDarkMode: boolean;
|
|
6659
|
+
/**
|
|
6660
|
+
* The color mode to use for this export.
|
|
6661
|
+
*/
|
|
6662
|
+
readonly colorMode: 'dark' | 'light';
|
|
6479
6663
|
/**
|
|
6480
6664
|
* The scale of the export - how much CSS pixels will be scaled up/down by.
|
|
6481
6665
|
*/
|
|
@@ -6507,15 +6691,18 @@ export declare const TAB_ID: string;
|
|
|
6507
6691
|
export declare class TextManager {
|
|
6508
6692
|
editor: Editor;
|
|
6509
6693
|
private elm;
|
|
6694
|
+
private poolElms;
|
|
6510
6695
|
constructor(editor: Editor);
|
|
6696
|
+
private createMeasurementEl;
|
|
6697
|
+
private resetElementStyles;
|
|
6511
6698
|
private setElementStyles;
|
|
6699
|
+
private getMeasureStyles;
|
|
6512
6700
|
dispose(): void;
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
};
|
|
6701
|
+
private ensurePoolSize;
|
|
6702
|
+
private getPoolItem;
|
|
6703
|
+
measureHtmlBatch(requests: BatchMeasurementRequest[]): TLMeasuredTextSize[];
|
|
6704
|
+
measureText(textToMeasure: string, opts: TLMeasureTextOpts): TLMeasuredTextSize;
|
|
6705
|
+
measureHtml(html: string, opts: TLMeasureTextOpts): TLMeasuredTextSize;
|
|
6519
6706
|
/**
|
|
6520
6707
|
* Given an html element, measure the position of each span of unbroken
|
|
6521
6708
|
* word/white-space characters within any text nodes it contains.
|
|
@@ -6543,6 +6730,47 @@ export declare class TextManager {
|
|
|
6543
6730
|
}[];
|
|
6544
6731
|
}
|
|
6545
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
|
+
|
|
6546
6774
|
/* Excluded from this release type: TickManager */
|
|
6547
6775
|
|
|
6548
6776
|
/**
|
|
@@ -6727,6 +6955,40 @@ export declare type TLCLickEventName = 'double_click' | 'quadruple_click' | 'tri
|
|
|
6727
6955
|
/** @public */
|
|
6728
6956
|
export declare type TLClickState = 'idle' | 'overflow' | 'pendingDouble' | 'pendingOverflow' | 'pendingQuadruple' | 'pendingTriple';
|
|
6729
6957
|
|
|
6958
|
+
/**
|
|
6959
|
+
* Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.
|
|
6960
|
+
*
|
|
6961
|
+
* - `native-event`: from the `paste` event — `clipboardData` is available synchronously (unlike async
|
|
6962
|
+
* `navigator.clipboard.read()`).
|
|
6963
|
+
* - `clipboard-read`: from an explicit `navigator.clipboard.read()` call — only `ClipboardItem[]`
|
|
6964
|
+
* exists
|
|
6965
|
+
* (no `DataTransfer`).
|
|
6966
|
+
*
|
|
6967
|
+
* @public
|
|
6968
|
+
*/
|
|
6969
|
+
export declare type TLClipboardPasteRawInfo = {
|
|
6970
|
+
readonly clipboardData: DataTransfer | null;
|
|
6971
|
+
readonly editor: Editor;
|
|
6972
|
+
readonly event: ClipboardEvent;
|
|
6973
|
+
readonly point: undefined | VecLike;
|
|
6974
|
+
readonly source: 'native-event';
|
|
6975
|
+
} | {
|
|
6976
|
+
readonly clipboardItems: readonly ClipboardItem[];
|
|
6977
|
+
readonly editor: Editor;
|
|
6978
|
+
readonly point: undefined | VecLike;
|
|
6979
|
+
readonly source: 'clipboard-read';
|
|
6980
|
+
};
|
|
6981
|
+
|
|
6982
|
+
/**
|
|
6983
|
+
* Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).
|
|
6984
|
+
*
|
|
6985
|
+
* @public
|
|
6986
|
+
*/
|
|
6987
|
+
export declare interface TLClipboardWriteInfo {
|
|
6988
|
+
readonly operation: 'copy' | 'cut';
|
|
6989
|
+
readonly source: 'menu' | 'native';
|
|
6990
|
+
}
|
|
6991
|
+
|
|
6730
6992
|
/** @public */
|
|
6731
6993
|
export declare interface TLCollaboratorHintProps {
|
|
6732
6994
|
userId: string;
|
|
@@ -6754,6 +7016,7 @@ export declare interface TLContent {
|
|
|
6754
7016
|
rootShapeIds: TLShapeId[];
|
|
6755
7017
|
assets: TLAsset[];
|
|
6756
7018
|
schema: SerializedSchema;
|
|
7019
|
+
users?: TLUser[];
|
|
6757
7020
|
}
|
|
6758
7021
|
|
|
6759
7022
|
/**
|
|
@@ -6775,6 +7038,12 @@ export declare interface TLCropInfo<T extends TLShape> {
|
|
|
6775
7038
|
aspectRatioLocked?: boolean;
|
|
6776
7039
|
}
|
|
6777
7040
|
|
|
7041
|
+
/** @public */
|
|
7042
|
+
export declare interface TLCurrentUser {
|
|
7043
|
+
readonly userPreferences: Signal<TLUserPreferences>;
|
|
7044
|
+
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7045
|
+
}
|
|
7046
|
+
|
|
6778
7047
|
/** @public */
|
|
6779
7048
|
export declare interface TLCursorProps {
|
|
6780
7049
|
userId: string;
|
|
@@ -6902,11 +7171,23 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6902
7171
|
/**
|
|
6903
7172
|
* The user interacting with the editor.
|
|
6904
7173
|
*/
|
|
6905
|
-
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';
|
|
6906
7183
|
/**
|
|
6907
|
-
*
|
|
7184
|
+
* Named themes for the editor.
|
|
6908
7185
|
*/
|
|
6909
|
-
|
|
7186
|
+
themes?: Partial<TLThemes>;
|
|
7187
|
+
/**
|
|
7188
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7189
|
+
*/
|
|
7190
|
+
initialTheme?: TLThemeId;
|
|
6910
7191
|
/**
|
|
6911
7192
|
* Camera options for the editor.
|
|
6912
7193
|
*
|
|
@@ -7166,6 +7447,72 @@ export declare interface TldrawOptions {
|
|
|
7166
7447
|
* viewport's page dimensions regardless of overview zoom changes.
|
|
7167
7448
|
*/
|
|
7168
7449
|
readonly quickZoomPreservesScreenBounds: boolean;
|
|
7450
|
+
/**
|
|
7451
|
+
* Called before content is written to the clipboard during a copy or cut operation.
|
|
7452
|
+
* Receives the serialized content (shapes, bindings, assets) and can filter or transform
|
|
7453
|
+
* it before it reaches the clipboard.
|
|
7454
|
+
*
|
|
7455
|
+
* Return a modified `TLContent` object to change what is copied or cut. Return `false` to
|
|
7456
|
+
* cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`
|
|
7457
|
+
* (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if
|
|
7458
|
+
* the hook is async.
|
|
7459
|
+
*
|
|
7460
|
+
* @example
|
|
7461
|
+
* ```tsx
|
|
7462
|
+
* // Filter out "locked" shapes from copy
|
|
7463
|
+
* onBeforeCopyToClipboard({ content, operation }) {
|
|
7464
|
+
* return {
|
|
7465
|
+
* ...content,
|
|
7466
|
+
* shapes: content.shapes.filter(s => !s.meta.locked),
|
|
7467
|
+
* rootShapeIds: content.rootShapeIds.filter(id =>
|
|
7468
|
+
* content.shapes.find(s => s.id === id && !s.meta.locked)
|
|
7469
|
+
* ),
|
|
7470
|
+
* }
|
|
7471
|
+
* }
|
|
7472
|
+
* ```
|
|
7473
|
+
*/
|
|
7474
|
+
onBeforeCopyToClipboard?(info: {
|
|
7475
|
+
content: TLContent;
|
|
7476
|
+
editor: Editor;
|
|
7477
|
+
} & TLClipboardWriteInfo): Awaitable<false | TLContent | void>;
|
|
7478
|
+
/**
|
|
7479
|
+
* Called before pasted content is processed and shapes are created. Receives the parsed
|
|
7480
|
+
* external content from the clipboard and can filter, transform, or cancel it.
|
|
7481
|
+
*
|
|
7482
|
+
* Return `false` to cancel the paste. Return a modified content object to transform it.
|
|
7483
|
+
* Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of
|
|
7484
|
+
* those values if the hook is async.
|
|
7485
|
+
*
|
|
7486
|
+
* This only fires for clipboard paste operations (keyboard shortcuts and menu actions),
|
|
7487
|
+
* not for file drops or programmatic `putExternalContent` calls.
|
|
7488
|
+
*
|
|
7489
|
+
* @example
|
|
7490
|
+
* ```tsx
|
|
7491
|
+
* // Block pasting of image files
|
|
7492
|
+
* onBeforePasteFromClipboard({ content }) {
|
|
7493
|
+
* if (content.type === 'files') {
|
|
7494
|
+
* const nonImages = content.files.filter(f => !f.type.startsWith('image/'))
|
|
7495
|
+
* if (nonImages.length === 0) return false
|
|
7496
|
+
* return { ...content, files: nonImages }
|
|
7497
|
+
* }
|
|
7498
|
+
* }
|
|
7499
|
+
* ```
|
|
7500
|
+
*/
|
|
7501
|
+
onBeforePasteFromClipboard?(info: {
|
|
7502
|
+
content: TLExternalContent<unknown>;
|
|
7503
|
+
editor: Editor;
|
|
7504
|
+
point?: VecLike;
|
|
7505
|
+
source: 'clipboard-read' | 'native-event';
|
|
7506
|
+
}): Awaitable<false | TLExternalContent<unknown> | void>;
|
|
7507
|
+
/**
|
|
7508
|
+
* Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data
|
|
7509
|
+
* (and before {@link TldrawOptions.onBeforePasteFromClipboard}).
|
|
7510
|
+
*
|
|
7511
|
+
* Return `false` to cancel tldraw's default paste handling for this gesture (same convention as
|
|
7512
|
+
* {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from
|
|
7513
|
+
* raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.
|
|
7514
|
+
*/
|
|
7515
|
+
onClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void;
|
|
7169
7516
|
/**
|
|
7170
7517
|
* Called when content is dropped on the canvas. Provides the page position
|
|
7171
7518
|
* where the drop occurred and the underlying drag event object.
|
|
@@ -7236,15 +7583,10 @@ export declare interface TLEditorOptions {
|
|
|
7236
7583
|
* An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
|
|
7237
7584
|
*/
|
|
7238
7585
|
tools: readonly TLStateNodeConstructor[];
|
|
7239
|
-
/**
|
|
7240
|
-
* Should return a containing html element which has all the styles applied to the editor. If not
|
|
7241
|
-
* given, the body element will be used.
|
|
7242
|
-
*/
|
|
7243
|
-
getContainer(): HTMLElement;
|
|
7244
7586
|
/**
|
|
7245
7587
|
* A user defined externally to replace the default user.
|
|
7246
7588
|
*/
|
|
7247
|
-
user?:
|
|
7589
|
+
user?: TLCurrentUser;
|
|
7248
7590
|
/**
|
|
7249
7591
|
* The editor's initial active tool (or other state node id).
|
|
7250
7592
|
*/
|
|
@@ -7253,27 +7595,15 @@ export declare interface TLEditorOptions {
|
|
|
7253
7595
|
* Whether to automatically focus the editor when it mounts.
|
|
7254
7596
|
*/
|
|
7255
7597
|
autoFocus?: boolean;
|
|
7256
|
-
/**
|
|
7257
|
-
* Whether to infer dark mode from the user's system preferences. Defaults to false.
|
|
7258
|
-
*/
|
|
7259
|
-
inferDarkMode?: boolean;
|
|
7260
|
-
/**
|
|
7261
|
-
* Options for the editor's camera.
|
|
7262
|
-
*
|
|
7263
|
-
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7264
|
-
*/
|
|
7265
|
-
cameraOptions?: Partial<TLCameraOptions>;
|
|
7266
|
-
options?: Partial<TldrawOptions>;
|
|
7267
|
-
/**
|
|
7268
|
-
* Text options for the editor.
|
|
7269
|
-
*
|
|
7270
|
-
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7271
|
-
*/
|
|
7272
|
-
textOptions?: TLTextOptions;
|
|
7273
7598
|
licenseKey?: string;
|
|
7274
7599
|
fontAssetUrls?: {
|
|
7275
7600
|
[key: string]: string | undefined;
|
|
7276
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;
|
|
7277
7607
|
/**
|
|
7278
7608
|
* Provides a way to hide shapes.
|
|
7279
7609
|
*
|
|
@@ -7290,6 +7620,40 @@ export declare interface TLEditorOptions {
|
|
|
7290
7620
|
* @param editor - The editor instance.
|
|
7291
7621
|
*/
|
|
7292
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;
|
|
7293
7657
|
}
|
|
7294
7658
|
|
|
7295
7659
|
/**
|
|
@@ -7348,6 +7712,7 @@ export declare const tlenv: {
|
|
|
7348
7712
|
*/
|
|
7349
7713
|
export declare const tlenvReactive: Atom< {
|
|
7350
7714
|
isCoarsePointer: boolean;
|
|
7715
|
+
supportsP3ColorSpace: boolean;
|
|
7351
7716
|
}, unknown>;
|
|
7352
7717
|
|
|
7353
7718
|
/** @public */
|
|
@@ -7486,72 +7851,6 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
|
7486
7851
|
ignoreParent?: boolean;
|
|
7487
7852
|
}
|
|
7488
7853
|
|
|
7489
|
-
/**
|
|
7490
|
-
* A font face that can be used in the editor. The properties of this are largely the same as the
|
|
7491
|
-
* ones in the
|
|
7492
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.
|
|
7493
|
-
* @public
|
|
7494
|
-
*/
|
|
7495
|
-
export declare interface TLFontFace {
|
|
7496
|
-
/**
|
|
7497
|
-
* How this font can be referred to in CSS.
|
|
7498
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-family | `font-family`}.
|
|
7499
|
-
*/
|
|
7500
|
-
readonly family: string;
|
|
7501
|
-
/**
|
|
7502
|
-
* The source of the font. This
|
|
7503
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`}.
|
|
7504
|
-
*/
|
|
7505
|
-
readonly src: TLFontFaceSource;
|
|
7506
|
-
/**
|
|
7507
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.
|
|
7508
|
-
*/
|
|
7509
|
-
readonly ascentOverride?: string;
|
|
7510
|
-
/**
|
|
7511
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.
|
|
7512
|
-
*/
|
|
7513
|
-
readonly descentOverride?: string;
|
|
7514
|
-
/**
|
|
7515
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.
|
|
7516
|
-
*/
|
|
7517
|
-
readonly stretch?: string;
|
|
7518
|
-
/**
|
|
7519
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.
|
|
7520
|
-
*/
|
|
7521
|
-
readonly style?: string;
|
|
7522
|
-
/**
|
|
7523
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.
|
|
7524
|
-
*/
|
|
7525
|
-
readonly weight?: string;
|
|
7526
|
-
/**
|
|
7527
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.
|
|
7528
|
-
*/
|
|
7529
|
-
readonly featureSettings?: string;
|
|
7530
|
-
/**
|
|
7531
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.
|
|
7532
|
-
*/
|
|
7533
|
-
readonly lineGapOverride?: string;
|
|
7534
|
-
/**
|
|
7535
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.
|
|
7536
|
-
*/
|
|
7537
|
-
readonly unicodeRange?: string;
|
|
7538
|
-
}
|
|
7539
|
-
|
|
7540
|
-
/**
|
|
7541
|
-
* Represents the `src` property of a {@link TLFontFace}.
|
|
7542
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.
|
|
7543
|
-
* @public
|
|
7544
|
-
*/
|
|
7545
|
-
export declare interface TLFontFaceSource {
|
|
7546
|
-
/**
|
|
7547
|
-
* A URL from which to load the font. If the value here is a key in
|
|
7548
|
-
* {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.
|
|
7549
|
-
*/
|
|
7550
|
-
url: string;
|
|
7551
|
-
format?: string;
|
|
7552
|
-
tech?: string;
|
|
7553
|
-
}
|
|
7554
|
-
|
|
7555
7854
|
/** Additional options for the {@link ShapeUtil.getGeometry} method.
|
|
7556
7855
|
*
|
|
7557
7856
|
* @public
|
|
@@ -7743,6 +8042,11 @@ export declare interface TLLoadSnapshotOptions {
|
|
|
7743
8042
|
forceOverwriteSessionState?: boolean;
|
|
7744
8043
|
}
|
|
7745
8044
|
|
|
8045
|
+
/** @public */
|
|
8046
|
+
export declare type TLMeasuredTextSize = BoxModel & {
|
|
8047
|
+
scrollWidth: number;
|
|
8048
|
+
};
|
|
8049
|
+
|
|
7746
8050
|
/** @public */
|
|
7747
8051
|
export declare interface TLMeasureTextOpts {
|
|
7748
8052
|
fontStyle: string;
|
|
@@ -8219,6 +8523,14 @@ export declare interface TLStoreBaseOptions {
|
|
|
8219
8523
|
defaultName?: string;
|
|
8220
8524
|
/** How should this store upload & resolve assets? */
|
|
8221
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;
|
|
8222
8534
|
/** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
|
|
8223
8535
|
onMount?(editor: Editor): (() => void) | void;
|
|
8224
8536
|
}
|
|
@@ -8406,12 +8718,6 @@ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
|
|
|
8406
8718
|
url: string;
|
|
8407
8719
|
}
|
|
8408
8720
|
|
|
8409
|
-
/** @public */
|
|
8410
|
-
export declare interface TLUser {
|
|
8411
|
-
readonly userPreferences: Signal<TLUserPreferences>;
|
|
8412
|
-
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
8413
|
-
}
|
|
8414
|
-
|
|
8415
8721
|
/**
|
|
8416
8722
|
* A user of tldraw
|
|
8417
8723
|
*
|
|
@@ -8512,6 +8818,9 @@ export declare function uniq<T>(array: {
|
|
|
8512
8818
|
readonly length: number;
|
|
8513
8819
|
} | null | undefined): T[];
|
|
8514
8820
|
|
|
8821
|
+
/** @public */
|
|
8822
|
+
export declare function useColorMode(): 'dark' | 'light';
|
|
8823
|
+
|
|
8515
8824
|
/** @public */
|
|
8516
8825
|
export declare function useContainer(): HTMLElement;
|
|
8517
8826
|
|
|
@@ -8550,9 +8859,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
|
|
|
8550
8859
|
/** @public */
|
|
8551
8860
|
export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
8552
8861
|
|
|
8553
|
-
/** @public */
|
|
8554
|
-
export declare function useIsDarkMode(): boolean;
|
|
8555
|
-
|
|
8556
8862
|
/** @public */
|
|
8557
8863
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
8558
8864
|
|
|
@@ -8590,11 +8896,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
|
|
|
8590
8896
|
/** @public */
|
|
8591
8897
|
export declare class UserPreferencesManager {
|
|
8592
8898
|
private readonly user;
|
|
8593
|
-
private readonly
|
|
8899
|
+
private readonly colorScheme;
|
|
8594
8900
|
systemColorScheme: Atom<"dark" | "light", unknown>;
|
|
8595
8901
|
disposables: Set<() => void>;
|
|
8596
8902
|
dispose(): void;
|
|
8597
|
-
constructor(user:
|
|
8903
|
+
constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
|
|
8598
8904
|
updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
|
|
8599
8905
|
getUserPreferences(): {
|
|
8600
8906
|
animationSpeed: number;
|
|
@@ -8665,10 +8971,10 @@ export declare function useSvgExportContext(): null | SvgExportContext;
|
|
|
8665
8971
|
/**
|
|
8666
8972
|
* @public
|
|
8667
8973
|
*/
|
|
8668
|
-
export declare function
|
|
8974
|
+
export declare function useTldrawCurrentUser(opts: {
|
|
8669
8975
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void;
|
|
8670
8976
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences;
|
|
8671
|
-
}):
|
|
8977
|
+
}): TLCurrentUser;
|
|
8672
8978
|
|
|
8673
8979
|
/** @public */
|
|
8674
8980
|
export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreSchema<TLRecord, TLStoreProps>;
|