@tldraw/editor 3.16.0-internal.51e99e128bd4 → 3.16.0-internal.a478398270c6
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 +16 -217
- package/dist-cjs/index.js +1 -8
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +1 -3
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +5 -0
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/SVGContainer.js +1 -1
- package/dist-cjs/lib/components/SVGContainer.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +26 -4
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultBrush.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultBrush.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 +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCursor.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultGrid.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultGrid.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultHandles.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultScribble.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +1 -9
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +15 -27
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
- package/dist-cjs/lib/config/TLUserPreferences.js +3 -15
- package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +67 -134
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +4 -14
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +1 -20
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js +2 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +20 -24
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditor.js +4 -1
- package/dist-cjs/lib/hooks/useEditor.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +0 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +8 -8
- package/dist-cjs/lib/license/Watermark.js.map +2 -2
- package/dist-cjs/lib/options.js +0 -7
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +1 -3
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/geometry-constants.js +2 -2
- package/dist-cjs/lib/primitives/geometry/geometry-constants.js.map +2 -2
- package/dist-cjs/lib/primitives/intersect.js +4 -4
- package/dist-cjs/lib/primitives/intersect.js.map +2 -2
- package/dist-cjs/lib/primitives/utils.js +0 -4
- package/dist-cjs/lib/primitives/utils.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +1 -0
- 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 +16 -217
- package/dist-esm/index.mjs +2 -16
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +1 -3
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +5 -0
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/SVGContainer.mjs +1 -1
- package/dist-esm/lib/components/SVGContainer.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +26 -4
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultBrush.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 +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultGrid.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultGrid.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +1 -9
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +15 -17
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs +3 -15
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +67 -134
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +4 -14
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +1 -20
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +21 -25
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditor.mjs +4 -1
- package/dist-esm/lib/hooks/useEditor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -4
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +8 -8
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +0 -7
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +1 -3
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/geometry-constants.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/geometry-constants.mjs.map +2 -2
- package/dist-esm/lib/primitives/intersect.mjs +5 -5
- package/dist-esm/lib/primitives/intersect.mjs.map +2 -2
- package/dist-esm/lib/primitives/utils.mjs +0 -4
- package/dist-esm/lib/primitives/utils.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +1 -0
- 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 +313 -312
- package/package.json +38 -16
- package/src/index.ts +1 -15
- package/src/lib/TldrawEditor.tsx +5 -7
- package/src/lib/components/MenuClickCapture.tsx +8 -0
- package/src/lib/components/SVGContainer.tsx +1 -1
- package/src/lib/components/Shape.tsx +21 -6
- package/src/lib/components/default-components/DefaultBrush.tsx +1 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +2 -2
- package/src/lib/components/default-components/DefaultCursor.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -1
- package/src/lib/components/default-components/DefaultGrid.tsx +1 -1
- package/src/lib/components/default-components/DefaultHandles.tsx +1 -5
- package/src/lib/components/default-components/DefaultScribble.tsx +1 -1
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +2 -6
- package/src/lib/components/default-components/DefaultSnapIndictor.tsx +1 -1
- package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
- package/src/lib/config/TLUserPreferences.ts +1 -15
- package/src/lib/editor/Editor.test.ts +8 -416
- package/src/lib/editor/Editor.ts +92 -177
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +14 -15
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +15 -16
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +48 -49
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +23 -24
- package/src/lib/editor/managers/HistoryManager/HistoryManager.test.ts +6 -7
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +11 -12
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +50 -57
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +26 -51
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +13 -14
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +26 -55
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +1 -14
- package/src/lib/editor/shapes/ShapeUtil.ts +0 -57
- package/src/lib/editor/tools/StateNode.ts +1 -27
- package/src/lib/editor/types/misc-types.ts +1 -73
- package/src/lib/exports/getSvgJsx.tsx +2 -2
- package/src/lib/hooks/useCanvasEvents.ts +32 -39
- package/src/lib/hooks/useEditor.tsx +5 -6
- package/src/lib/hooks/useEditorComponents.tsx +2 -8
- package/src/lib/license/LicenseManager.test.ts +1 -3
- package/src/lib/license/Watermark.test.tsx +1 -2
- package/src/lib/license/Watermark.tsx +8 -8
- package/src/lib/options.ts +0 -8
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/CubicBezier2d.ts +1 -4
- package/src/lib/primitives/geometry/Ellipse2d.ts +2 -2
- package/src/lib/primitives/geometry/geometry-constants.ts +1 -2
- package/src/lib/primitives/intersect.ts +5 -12
- package/src/lib/primitives/utils.ts +0 -11
- package/src/lib/test/currentToolIdMask.test.ts +49 -0
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +1 -2
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +15 -15
- package/src/lib/utils/sync/TLLocalSyncClient.ts +1 -0
- package/src/version.ts +3 -3
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js +0 -53
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js.map +0 -7
- package/dist-cjs/lib/hooks/useStateAttribute.js +0 -35
- package/dist-cjs/lib/hooks/useStateAttribute.js.map +0 -7
- package/dist-cjs/lib/utils/EditorAtom.js +0 -45
- package/dist-cjs/lib/utils/EditorAtom.js.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs +0 -23
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs.map +0 -7
- package/dist-esm/lib/hooks/useStateAttribute.mjs +0 -15
- package/dist-esm/lib/hooks/useStateAttribute.mjs.map +0 -7
- package/dist-esm/lib/utils/EditorAtom.mjs +0 -25
- package/dist-esm/lib/utils/EditorAtom.mjs.map +0 -7
- package/src/lib/components/default-components/DefaultShapeWrapper.tsx +0 -35
- package/src/lib/editor/tools/StateNode.test.ts +0 -285
- package/src/lib/hooks/useStateAttribute.ts +0 -15
- package/src/lib/primitives/intersect.test.ts +0 -946
- package/src/lib/utils/EditorAtom.ts +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxModel
|
|
1
|
+
import { BoxModel } from '@tldraw/tlschema'
|
|
2
2
|
import { Box } from '../../primitives/Box'
|
|
3
3
|
import { VecLike } from '../../primitives/Vec'
|
|
4
4
|
|
|
@@ -187,75 +187,3 @@ export interface TLCameraConstraints {
|
|
|
187
187
|
y: 'free' | 'fixed' | 'inside' | 'outside' | 'contain'
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
/** @public */
|
|
192
|
-
export interface TLUpdatePointerOptions {
|
|
193
|
-
/** Whether to update the pointer immediately, rather than on the next tick. */
|
|
194
|
-
immediate?: boolean
|
|
195
|
-
/**
|
|
196
|
-
* The point, in screen-space, to update the pointer to. Defaults to the position of the last
|
|
197
|
-
* pointer event.
|
|
198
|
-
*/
|
|
199
|
-
point?: VecLike
|
|
200
|
-
pointerId?: number
|
|
201
|
-
ctrlKey?: boolean
|
|
202
|
-
altKey?: boolean
|
|
203
|
-
shiftKey?: boolean
|
|
204
|
-
metaKey?: boolean
|
|
205
|
-
accelKey?: boolean
|
|
206
|
-
isPen?: boolean
|
|
207
|
-
button?: number
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Options to {@link Editor.getShapeAtPoint}.
|
|
212
|
-
*
|
|
213
|
-
* @public
|
|
214
|
-
*/
|
|
215
|
-
export interface TLGetShapeAtPointOptions {
|
|
216
|
-
/**
|
|
217
|
-
* The margin to apply to the shape.
|
|
218
|
-
* If a number, it will be applied to both the inside and outside of the shape.
|
|
219
|
-
* If an array, the first element will be applied to the inside of the shape, and the second element will be applied to the outside.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```ts
|
|
223
|
-
* // Get the shape at the center of the screen
|
|
224
|
-
* const shape = editor.getShapeAtProps({
|
|
225
|
-
* margin: 10,
|
|
226
|
-
* })
|
|
227
|
-
*
|
|
228
|
-
* // Get the shape at the center of the screen with a 10px inner margin and a 5px outer margin
|
|
229
|
-
* const shape = editor.getShapeAtProps({
|
|
230
|
-
* margin: [10, 5],
|
|
231
|
-
* })
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
margin?: number | [number, number]
|
|
235
|
-
/**
|
|
236
|
-
* Whether to register hits inside of shapes (beyond the margin), such as the inside of a solid shape.
|
|
237
|
-
*/
|
|
238
|
-
hitInside?: boolean
|
|
239
|
-
/**
|
|
240
|
-
* Whether to register hits on locked shapes.
|
|
241
|
-
*/
|
|
242
|
-
hitLocked?: boolean
|
|
243
|
-
/**
|
|
244
|
-
* Whether to register hits on labels.
|
|
245
|
-
*/
|
|
246
|
-
hitLabels?: boolean
|
|
247
|
-
/**
|
|
248
|
-
* Whether to only return hits on shapes that are currently being rendered.
|
|
249
|
-
* todo: rename this to hitCulled or hitNotRendering
|
|
250
|
-
*/
|
|
251
|
-
renderingOnly?: boolean
|
|
252
|
-
/**
|
|
253
|
-
* Whether to register hits on the inside of frame shapes.
|
|
254
|
-
* todo: rename this to hitInsideFrames
|
|
255
|
-
*/
|
|
256
|
-
hitFrameInside?: boolean
|
|
257
|
-
/**
|
|
258
|
-
* A filter function to apply to the shapes.
|
|
259
|
-
*/
|
|
260
|
-
filter?(shape: TLShape): boolean
|
|
261
|
-
}
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
TLGroupShape,
|
|
5
5
|
TLShape,
|
|
6
6
|
TLShapeId,
|
|
7
|
-
getColorValue,
|
|
8
7
|
getDefaultColorTheme,
|
|
9
8
|
} from '@tldraw/tlschema'
|
|
10
9
|
import { hasOwnProperty, promiseWithResolve, uniqueId } from '@tldraw/utils'
|
|
@@ -374,7 +373,8 @@ function SvgExport({
|
|
|
374
373
|
| { options: { showColors: boolean } }
|
|
375
374
|
if (frameShapeUtil?.options.showColors) {
|
|
376
375
|
const shape = editor.getShape(singleFrameShapeId)! as TLFrameShape
|
|
377
|
-
|
|
376
|
+
const color = theme[shape.props.color]
|
|
377
|
+
backgroundColor = color.frame.fill
|
|
378
378
|
} else {
|
|
379
379
|
backgroundColor = theme.solid
|
|
380
380
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useValue } from '@tldraw/state-react'
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useMemo } from 'react'
|
|
3
3
|
import { RIGHT_MOUSE_BUTTON } from '../constants'
|
|
4
4
|
import {
|
|
5
5
|
preventDefault,
|
|
@@ -16,6 +16,9 @@ export function useCanvasEvents() {
|
|
|
16
16
|
|
|
17
17
|
const events = useMemo(
|
|
18
18
|
function canvasEvents() {
|
|
19
|
+
// Track the last screen point
|
|
20
|
+
let lastX: number, lastY: number
|
|
21
|
+
|
|
19
22
|
function onPointerDown(e: React.PointerEvent) {
|
|
20
23
|
if ((e as any).isKilled) return
|
|
21
24
|
|
|
@@ -41,9 +44,35 @@ export function useCanvasEvents() {
|
|
|
41
44
|
})
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
function onPointerMove(e: React.PointerEvent) {
|
|
48
|
+
if ((e as any).isKilled) return
|
|
49
|
+
|
|
50
|
+
if (e.clientX === lastX && e.clientY === lastY) return
|
|
51
|
+
lastX = e.clientX
|
|
52
|
+
lastY = e.clientY
|
|
53
|
+
|
|
54
|
+
// For tools that benefit from a higher fidelity of events,
|
|
55
|
+
// we dispatch the coalesced events.
|
|
56
|
+
// N.B. Sometimes getCoalescedEvents isn't present on iOS, ugh.
|
|
57
|
+
const events =
|
|
58
|
+
currentTool.useCoalescedEvents && e.nativeEvent.getCoalescedEvents
|
|
59
|
+
? e.nativeEvent.getCoalescedEvents()
|
|
60
|
+
: [e]
|
|
61
|
+
for (const singleEvent of events) {
|
|
62
|
+
editor.dispatch({
|
|
63
|
+
type: 'pointer',
|
|
64
|
+
target: 'canvas',
|
|
65
|
+
name: 'pointer_move',
|
|
66
|
+
...getPointerInfo(singleEvent),
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
44
71
|
function onPointerUp(e: React.PointerEvent) {
|
|
45
72
|
if ((e as any).isKilled) return
|
|
46
73
|
if (e.button !== 0 && e.button !== 1 && e.button !== 2 && e.button !== 5) return
|
|
74
|
+
lastX = e.clientX
|
|
75
|
+
lastY = e.clientY
|
|
47
76
|
|
|
48
77
|
releasePointerCapture(e.currentTarget, e)
|
|
49
78
|
|
|
@@ -129,6 +158,7 @@ export function useCanvasEvents() {
|
|
|
129
158
|
|
|
130
159
|
return {
|
|
131
160
|
onPointerDown,
|
|
161
|
+
onPointerMove,
|
|
132
162
|
onPointerUp,
|
|
133
163
|
onPointerEnter,
|
|
134
164
|
onPointerLeave,
|
|
@@ -139,45 +169,8 @@ export function useCanvasEvents() {
|
|
|
139
169
|
onClick,
|
|
140
170
|
}
|
|
141
171
|
},
|
|
142
|
-
[editor]
|
|
172
|
+
[editor, currentTool]
|
|
143
173
|
)
|
|
144
174
|
|
|
145
|
-
// onPointerMove is special: where we're only interested in the other events when they're
|
|
146
|
-
// happening _on_ the canvas (as opposed to outside of it, or on UI floating over it), we want
|
|
147
|
-
// the pointer position to be up to date regardless of whether it's over the tldraw canvas or
|
|
148
|
-
// not. So instead of returning a listener to be attached to the canvas, we directly attach a
|
|
149
|
-
// listener to the whole document instead.
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
let lastX: number, lastY: number
|
|
152
|
-
|
|
153
|
-
function onPointerMove(e: PointerEvent) {
|
|
154
|
-
if ((e as any).isKilled) return
|
|
155
|
-
;(e as any).isKilled = true
|
|
156
|
-
|
|
157
|
-
if (e.clientX === lastX && e.clientY === lastY) return
|
|
158
|
-
lastX = e.clientX
|
|
159
|
-
lastY = e.clientY
|
|
160
|
-
|
|
161
|
-
// For tools that benefit from a higher fidelity of events,
|
|
162
|
-
// we dispatch the coalesced events.
|
|
163
|
-
// N.B. Sometimes getCoalescedEvents isn't present on iOS, ugh.
|
|
164
|
-
const events =
|
|
165
|
-
currentTool.useCoalescedEvents && e.getCoalescedEvents ? e.getCoalescedEvents() : [e]
|
|
166
|
-
for (const singleEvent of events) {
|
|
167
|
-
editor.dispatch({
|
|
168
|
-
type: 'pointer',
|
|
169
|
-
target: 'canvas',
|
|
170
|
-
name: 'pointer_move',
|
|
171
|
-
...getPointerInfo(singleEvent),
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
document.body.addEventListener('pointermove', onPointerMove)
|
|
177
|
-
return () => {
|
|
178
|
-
document.body.removeEventListener('pointermove', onPointerMove)
|
|
179
|
-
}
|
|
180
|
-
}, [editor, currentTool])
|
|
181
|
-
|
|
182
175
|
return events
|
|
183
176
|
}
|
|
@@ -21,14 +21,13 @@ export function useMaybeEditor(): Editor | null {
|
|
|
21
21
|
return React.useContext(EditorContext)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
export function EditorProvider({
|
|
25
|
+
editor,
|
|
26
|
+
children,
|
|
27
|
+
}: {
|
|
26
28
|
editor: Editor
|
|
27
29
|
children: React.ReactNode
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** @public @react */
|
|
31
|
-
export function EditorProvider({ editor, children }: EditorProviderProps) {
|
|
30
|
+
}) {
|
|
32
31
|
return (
|
|
33
32
|
<EditorContext.Provider value={editor}>
|
|
34
33
|
<IdProvider>{children}</IdProvider>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType, ReactNode,
|
|
1
|
+
import { ComponentType, ReactNode, createContext, useContext, useMemo } from 'react'
|
|
2
2
|
import { DefaultBackground } from '../components/default-components/DefaultBackground'
|
|
3
3
|
import { DefaultBrush, TLBrushProps } from '../components/default-components/DefaultBrush'
|
|
4
4
|
import {
|
|
@@ -37,10 +37,6 @@ import {
|
|
|
37
37
|
TLShapeIndicatorErrorFallbackComponent,
|
|
38
38
|
} from '../components/default-components/DefaultShapeIndicatorErrorFallback'
|
|
39
39
|
import { DefaultShapeIndicators } from '../components/default-components/DefaultShapeIndicators'
|
|
40
|
-
import {
|
|
41
|
-
DefaultShapeWrapper,
|
|
42
|
-
TLShapeWrapperProps,
|
|
43
|
-
} from '../components/default-components/DefaultShapeWrapper'
|
|
44
40
|
import {
|
|
45
41
|
DefaultSnapIndicator,
|
|
46
42
|
TLSnapIndicatorProps,
|
|
@@ -72,9 +68,8 @@ export interface TLEditorComponents {
|
|
|
72
68
|
SelectionForeground?: ComponentType<TLSelectionForegroundProps> | null
|
|
73
69
|
ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null
|
|
74
70
|
ShapeIndicators?: ComponentType | null
|
|
75
|
-
ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null
|
|
76
71
|
SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null
|
|
77
|
-
Spinner?: ComponentType
|
|
72
|
+
Spinner?: ComponentType | null
|
|
78
73
|
SvgDefs?: ComponentType | null
|
|
79
74
|
ZoomBrush?: ComponentType<TLBrushProps> | null
|
|
80
75
|
|
|
@@ -119,7 +114,6 @@ export function EditorComponentsProvider({
|
|
|
119
114
|
SelectionForeground: DefaultSelectionForeground,
|
|
120
115
|
ShapeIndicator: DefaultShapeIndicator,
|
|
121
116
|
ShapeIndicators: DefaultShapeIndicators,
|
|
122
|
-
ShapeWrapper: DefaultShapeWrapper,
|
|
123
117
|
SnapIndicator: DefaultSnapIndicator,
|
|
124
118
|
Spinner: DefaultSpinner,
|
|
125
119
|
SvgDefs: DefaultSvgDefs,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import crypto from 'crypto'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { publishDates } from '../../version'
|
|
4
3
|
import { str2ab } from '../utils/licensing'
|
|
5
4
|
import {
|
|
@@ -10,9 +9,8 @@ import {
|
|
|
10
9
|
ValidLicenseKeyResult,
|
|
11
10
|
} from './LicenseManager'
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
jest.mock('../../version', () => {
|
|
14
13
|
return {
|
|
15
|
-
version: '3.15.1',
|
|
16
14
|
publishDates: {
|
|
17
15
|
major: '2024-06-28T10:56:07.893Z',
|
|
18
16
|
minor: '2024-07-02T16:49:50.397Z',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { act, render, waitFor } from '@testing-library/react'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TldrawEditor } from '../TldrawEditor'
|
|
4
3
|
import { LicenseManager } from './LicenseManager'
|
|
5
4
|
|
|
6
5
|
let mockLicenseState = 'unlicensed'
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
jest.mock('./useLicenseManagerState', () => ({
|
|
9
8
|
useLicenseManagerState: () => mockLicenseState,
|
|
10
9
|
}))
|
|
11
10
|
|
|
@@ -86,15 +86,15 @@ To remove the watermark, please purchase a license at tldraw.dev.
|
|
|
86
86
|
|
|
87
87
|
.${className} {
|
|
88
88
|
position: absolute;
|
|
89
|
-
bottom: var(--
|
|
90
|
-
right: var(--
|
|
89
|
+
bottom: var(--space-2);
|
|
90
|
+
right: var(--space-2);
|
|
91
91
|
width: 96px;
|
|
92
92
|
height: 32px;
|
|
93
93
|
display: flex;
|
|
94
94
|
align-items: center;
|
|
95
95
|
justify-content: center;
|
|
96
|
-
z-index: var(--
|
|
97
|
-
background-color: color-mix(in srgb, var(--
|
|
96
|
+
z-index: var(--layer-watermark) !important;
|
|
97
|
+
background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
|
|
98
98
|
opacity: 1;
|
|
99
99
|
border-radius: 5px;
|
|
100
100
|
pointer-events: all;
|
|
@@ -108,7 +108,7 @@ To remove the watermark, please purchase a license at tldraw.dev.
|
|
|
108
108
|
height: 32px;
|
|
109
109
|
pointer-events: all;
|
|
110
110
|
cursor: inherit;
|
|
111
|
-
color: var(--
|
|
111
|
+
color: var(--color-text);
|
|
112
112
|
opacity: .38;
|
|
113
113
|
border: 0;
|
|
114
114
|
padding: 0;
|
|
@@ -137,13 +137,13 @@ To remove the watermark, please purchase a license at tldraw.dev.
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
.${className}:hover {
|
|
140
|
-
background-color: var(--
|
|
140
|
+
background-color: var(--color-background);
|
|
141
141
|
transition: background-color 0.2s ease-in-out;
|
|
142
142
|
transition-delay: 0.32s;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
.${className}:hover > button {
|
|
146
|
-
animation:
|
|
146
|
+
animation: delayed_link 0.2s forwards ease-in-out;
|
|
147
147
|
animation-delay: 0.32s;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -153,7 +153,7 @@ To remove the watermark, please purchase a license at tldraw.dev.
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
|
|
156
|
-
@keyframes
|
|
156
|
+
@keyframes delayed_link {
|
|
157
157
|
0% {
|
|
158
158
|
cursor: inherit;
|
|
159
159
|
opacity: .38;
|
package/src/lib/options.ts
CHANGED
|
@@ -27,8 +27,6 @@ export interface TldrawOptions {
|
|
|
27
27
|
readonly multiClickDurationMs: number
|
|
28
28
|
readonly coarseDragDistanceSquared: number
|
|
29
29
|
readonly dragDistanceSquared: number
|
|
30
|
-
readonly uiDragDistanceSquared: number
|
|
31
|
-
readonly uiCoarseDragDistanceSquared: number
|
|
32
30
|
readonly defaultSvgPadding: number
|
|
33
31
|
readonly cameraSlideFriction: number
|
|
34
32
|
readonly gridSteps: readonly {
|
|
@@ -55,7 +53,6 @@ export interface TldrawOptions {
|
|
|
55
53
|
readonly flattenImageBoundsPadding: number
|
|
56
54
|
readonly laserDelayMs: number
|
|
57
55
|
readonly maxExportDelayMs: number
|
|
58
|
-
readonly tooltipDelayMs: number
|
|
59
56
|
/**
|
|
60
57
|
* How long should previews created by {@link Editor.createTemporaryAssetPreview} last before
|
|
61
58
|
* they expire? Defaults to 3 minutes.
|
|
@@ -100,10 +97,6 @@ export const defaultTldrawOptions = {
|
|
|
100
97
|
multiClickDurationMs: 200,
|
|
101
98
|
coarseDragDistanceSquared: 36, // 6 squared
|
|
102
99
|
dragDistanceSquared: 16, // 4 squared
|
|
103
|
-
uiDragDistanceSquared: 16, // 4 squared
|
|
104
|
-
// it's really easy to accidentally drag from the toolbar on mobile, so we use a much larger
|
|
105
|
-
// threshold than usual here to try and prevent accidental drags.
|
|
106
|
-
uiCoarseDragDistanceSquared: 625, // 25 squared
|
|
107
100
|
defaultSvgPadding: 32,
|
|
108
101
|
cameraSlideFriction: 0.09,
|
|
109
102
|
gridSteps: [
|
|
@@ -131,7 +124,6 @@ export const defaultTldrawOptions = {
|
|
|
131
124
|
flattenImageBoundsPadding: 16,
|
|
132
125
|
laserDelayMs: 1200,
|
|
133
126
|
maxExportDelayMs: 5000,
|
|
134
|
-
tooltipDelayMs: 700,
|
|
135
127
|
temporaryAssetPreviewLifetimeMs: 180000,
|
|
136
128
|
actionShortcutsLocation: 'swap',
|
|
137
129
|
createTextOnCanvasDoubleClick: true,
|
|
@@ -2,7 +2,7 @@ import { Vec, VecLike } from '../Vec'
|
|
|
2
2
|
import { intersectLineSegmentCircle } from '../intersect'
|
|
3
3
|
import { getArcMeasure, getPointInArcT, getPointOnCircle } from '../utils'
|
|
4
4
|
import { Geometry2d, Geometry2dOptions } from './Geometry2d'
|
|
5
|
-
import {
|
|
5
|
+
import { getVerticesCountForLength } from './geometry-constants'
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export class Arc2d extends Geometry2d {
|
|
@@ -94,7 +94,7 @@ export class Arc2d extends Geometry2d {
|
|
|
94
94
|
getVertices(): Vec[] {
|
|
95
95
|
const { _center, _measure: measure, length, _radius: radius, _angleStart: angleStart } = this
|
|
96
96
|
const vertices: Vec[] = []
|
|
97
|
-
for (let i = 0, n =
|
|
97
|
+
for (let i = 0, n = getVerticesCountForLength(Math.abs(length)); i < n + 1; i++) {
|
|
98
98
|
const t = (i / n) * measure
|
|
99
99
|
const angle = angleStart + t
|
|
100
100
|
vertices.push(getPointOnCircle(_center, radius, angle))
|
|
@@ -3,7 +3,7 @@ import { Vec, VecLike } from '../Vec'
|
|
|
3
3
|
import { intersectLineSegmentCircle } from '../intersect'
|
|
4
4
|
import { PI2, getPointOnCircle } from '../utils'
|
|
5
5
|
import { Geometry2d, Geometry2dOptions } from './Geometry2d'
|
|
6
|
-
import {
|
|
6
|
+
import { getVerticesCountForLength } from './geometry-constants'
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export class Circle2d extends Geometry2d {
|
|
@@ -36,7 +36,7 @@ export class Circle2d extends Geometry2d {
|
|
|
36
36
|
const { _center, _radius: radius } = this
|
|
37
37
|
const perimeter = PI2 * radius
|
|
38
38
|
const vertices: Vec[] = []
|
|
39
|
-
for (let i = 0, n =
|
|
39
|
+
for (let i = 0, n = getVerticesCountForLength(perimeter); i < n; i++) {
|
|
40
40
|
const angle = (i / n) * PI2
|
|
41
41
|
vertices.push(getPointOnCircle(_center, radius, angle))
|
|
42
42
|
}
|
|
@@ -8,7 +8,6 @@ export class CubicBezier2d extends Polyline2d {
|
|
|
8
8
|
private _b: Vec
|
|
9
9
|
private _c: Vec
|
|
10
10
|
private _d: Vec
|
|
11
|
-
private _resolution: number
|
|
12
11
|
|
|
13
12
|
constructor(
|
|
14
13
|
config: Omit<Geometry2dOptions, 'isFilled' | 'isClosed'> & {
|
|
@@ -16,7 +15,6 @@ export class CubicBezier2d extends Polyline2d {
|
|
|
16
15
|
cp1: Vec
|
|
17
16
|
cp2: Vec
|
|
18
17
|
end: Vec
|
|
19
|
-
resolution?: number
|
|
20
18
|
}
|
|
21
19
|
) {
|
|
22
20
|
const { start: a, cp1: b, cp2: c, end: d } = config
|
|
@@ -26,14 +24,13 @@ export class CubicBezier2d extends Polyline2d {
|
|
|
26
24
|
this._b = b
|
|
27
25
|
this._c = c
|
|
28
26
|
this._d = d
|
|
29
|
-
this._resolution = config.resolution ?? 10
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
override getVertices() {
|
|
33
30
|
const vertices = [] as Vec[]
|
|
34
31
|
const { _a: a, _b: b, _c: c, _d: d } = this
|
|
35
32
|
// we'll always use ten vertices for each bezier curve
|
|
36
|
-
for (let i = 0, n =
|
|
33
|
+
for (let i = 0, n = 10; i <= n; i++) {
|
|
37
34
|
const t = i / n
|
|
38
35
|
vertices.push(
|
|
39
36
|
new Vec(
|
|
@@ -3,7 +3,7 @@ import { Vec, VecLike } from '../Vec'
|
|
|
3
3
|
import { PI, PI2, clamp, perimeterOfEllipse } from '../utils'
|
|
4
4
|
import { Edge2d } from './Edge2d'
|
|
5
5
|
import { Geometry2d, Geometry2dOptions } from './Geometry2d'
|
|
6
|
-
import {
|
|
6
|
+
import { getVerticesCountForLength } from './geometry-constants'
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export class Ellipse2d extends Geometry2d {
|
|
@@ -47,7 +47,7 @@ export class Ellipse2d extends Geometry2d {
|
|
|
47
47
|
const q = Math.pow(cx - cy, 2) / Math.pow(cx + cy, 2)
|
|
48
48
|
const p = PI * (cx + cy) * (1 + (3 * q) / (10 + Math.sqrt(4 - 3 * q)))
|
|
49
49
|
// Number of points
|
|
50
|
-
const len =
|
|
50
|
+
const len = getVerticesCountForLength(p)
|
|
51
51
|
// Size of step
|
|
52
52
|
const step = PI2 / len
|
|
53
53
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const SPACING = 20
|
|
2
2
|
const MIN_COUNT = 8
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export function getVerticesCountForArcLength(length: number, spacing = SPACING) {
|
|
4
|
+
export function getVerticesCountForLength(length: number, spacing = SPACING) {
|
|
6
5
|
return Math.max(MIN_COUNT, Math.ceil(length / spacing))
|
|
7
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Box } from './Box'
|
|
2
|
-
import {
|
|
2
|
+
import { pointInPolygon } from './utils'
|
|
3
3
|
import { Vec, VecLike } from './Vec'
|
|
4
4
|
|
|
5
5
|
// need even more intersections? See https://gist.github.com/steveruizok/35c02d526c707003a5c79761bfb89a52
|
|
@@ -17,8 +17,7 @@ export function intersectLineSegmentLineSegment(
|
|
|
17
17
|
a1: VecLike,
|
|
18
18
|
a2: VecLike,
|
|
19
19
|
b1: VecLike,
|
|
20
|
-
b2: VecLike
|
|
21
|
-
precision = 1e-10
|
|
20
|
+
b2: VecLike
|
|
22
21
|
) {
|
|
23
22
|
const ABx = a1.x - b1.x
|
|
24
23
|
const ABy = a1.y - b1.y
|
|
@@ -30,19 +29,14 @@ export function intersectLineSegmentLineSegment(
|
|
|
30
29
|
const ub_t = AVx * ABy - AVy * ABx
|
|
31
30
|
const u_b = BVy * AVx - BVx * AVy
|
|
32
31
|
|
|
33
|
-
if (
|
|
32
|
+
if (ua_t === 0 || ub_t === 0) return null // coincident
|
|
34
33
|
|
|
35
|
-
if (
|
|
34
|
+
if (u_b === 0) return null // parallel
|
|
36
35
|
|
|
37
36
|
if (u_b !== 0) {
|
|
38
37
|
const ua = ua_t / u_b
|
|
39
38
|
const ub = ub_t / u_b
|
|
40
|
-
if (
|
|
41
|
-
approximatelyLte(0, ua, precision) &&
|
|
42
|
-
approximatelyLte(ua, 1, precision) &&
|
|
43
|
-
approximatelyLte(0, ub, precision) &&
|
|
44
|
-
approximatelyLte(ub, 1, precision)
|
|
45
|
-
) {
|
|
39
|
+
if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) {
|
|
46
40
|
return Vec.AddXY(a1, ua * AVx, ua * AVy)
|
|
47
41
|
}
|
|
48
42
|
}
|
|
@@ -131,7 +125,6 @@ export function intersectLineSegmentPolygon(a1: VecLike, a2: VecLike, points: Ve
|
|
|
131
125
|
points[i - 1],
|
|
132
126
|
points[i % points.length]
|
|
133
127
|
)
|
|
134
|
-
|
|
135
128
|
if (segmentIntersection) result.push(segmentIntersection)
|
|
136
129
|
}
|
|
137
130
|
|
|
@@ -77,17 +77,6 @@ export function approximately(a: number, b: number, precision = 0.000001) {
|
|
|
77
77
|
return Math.abs(a - b) <= precision
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
/**
|
|
81
|
-
* Whether a number is approximately less than or equal to another number.
|
|
82
|
-
*
|
|
83
|
-
* @param a - The first number.
|
|
84
|
-
* @param b - The second number.
|
|
85
|
-
* @public
|
|
86
|
-
*/
|
|
87
|
-
export function approximatelyLte(a: number, b: number, precision = 0.000001) {
|
|
88
|
-
return a < b || approximately(a, b, precision)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
80
|
/**
|
|
92
81
|
* Find the approximate perimeter of an ellipse.
|
|
93
82
|
*
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe } from 'node:test'
|
|
2
|
+
import { createTLStore } from '../config/createTLStore'
|
|
3
|
+
import { Editor } from '../editor/Editor'
|
|
4
|
+
import { StateNode } from '../editor/tools/StateNode'
|
|
5
|
+
|
|
6
|
+
let editor: Editor
|
|
7
|
+
|
|
8
|
+
class A extends StateNode {
|
|
9
|
+
static override id = 'A'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class B extends StateNode {
|
|
13
|
+
static override id = 'B'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class C extends StateNode {
|
|
17
|
+
static override id = 'C'
|
|
18
|
+
|
|
19
|
+
override onEnter() {
|
|
20
|
+
this.setCurrentToolIdMask('A')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
editor = new Editor({
|
|
26
|
+
initialState: 'A',
|
|
27
|
+
shapeUtils: [],
|
|
28
|
+
bindingUtils: [],
|
|
29
|
+
tools: [A, B, C],
|
|
30
|
+
store: createTLStore({ shapeUtils: [], bindingUtils: [] }),
|
|
31
|
+
getContainer: () => document.body,
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('current tool id mask', () => {
|
|
36
|
+
it('starts with the correct tool id', () => {
|
|
37
|
+
expect(editor.getCurrentToolId()).toBe('A')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('updates the current tool id', () => {
|
|
41
|
+
editor.setCurrentTool('B')
|
|
42
|
+
expect(editor.getCurrentToolId()).toBe('B')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('masks the current tool id', () => {
|
|
46
|
+
editor.setCurrentTool('C')
|
|
47
|
+
expect(editor.getCurrentToolId()).toBe('A')
|
|
48
|
+
})
|
|
49
|
+
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createTLSchema } from '@tldraw/tlschema'
|
|
2
2
|
import { openDB } from 'idb'
|
|
3
|
-
import { vi } from 'vitest'
|
|
4
3
|
import { hardReset } from './hardReset'
|
|
5
4
|
import { getAllIndexDbNames, LocalIndexedDb } from './LocalIndexedDb'
|
|
6
5
|
|
|
7
6
|
const schema = createTLSchema({ shapes: {}, bindings: {} })
|
|
8
7
|
describe('LocalIndexedDb', () => {
|
|
9
8
|
beforeEach(() => {
|
|
10
|
-
|
|
9
|
+
jest.useRealTimers()
|
|
11
10
|
})
|
|
12
11
|
afterEach(async () => {
|
|
13
12
|
await hardReset({ shouldReload: false })
|