@tldraw/editor 3.16.0-canary.aa1aff3ffe55 → 3.16.0-canary.cf24aedcd577
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 +6 -0
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/TldrawEditor.js +1 -1
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +0 -5
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/config/TLUserPreferences.js +8 -2
- package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +17 -14
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +8 -3
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +1 -2
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +24 -20
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/options.js +1 -0
- package/dist-cjs/lib/options.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 +6 -0
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/TldrawEditor.mjs +1 -1
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +0 -5
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs +8 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +17 -14
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +8 -3
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.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 +25 -21
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +1 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +2 -0
- package/package.json +7 -7
- package/src/lib/TldrawEditor.tsx +5 -5
- package/src/lib/components/MenuClickCapture.tsx +0 -8
- package/src/lib/config/TLUserPreferences.ts +7 -0
- package/src/lib/editor/Editor.ts +26 -19
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +13 -0
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +5 -0
- package/src/lib/exports/getSvgJsx.tsx +2 -2
- package/src/lib/hooks/useCanvasEvents.ts +39 -32
- package/src/lib/options.ts +2 -0
- package/src/version.ts +3 -3
|
@@ -25,6 +25,7 @@ describe('UserPreferencesManager', () => {
|
|
|
25
25
|
locale: 'en',
|
|
26
26
|
animationSpeed: 1,
|
|
27
27
|
areKeyboardShortcutsEnabled: true,
|
|
28
|
+
showUiLabels: false,
|
|
28
29
|
edgeScrollSpeed: 1,
|
|
29
30
|
colorScheme: 'light',
|
|
30
31
|
isSnapMode: false,
|
|
@@ -231,6 +232,7 @@ describe('UserPreferencesManager', () => {
|
|
|
231
232
|
color: mockUserPreferences.color,
|
|
232
233
|
animationSpeed: mockUserPreferences.animationSpeed,
|
|
233
234
|
areKeyboardShortcutsEnabled: mockUserPreferences.areKeyboardShortcutsEnabled,
|
|
235
|
+
showUiLabels: mockUserPreferences.showUiLabels,
|
|
234
236
|
isSnapMode: mockUserPreferences.isSnapMode,
|
|
235
237
|
colorScheme: mockUserPreferences.colorScheme,
|
|
236
238
|
isDarkMode: false, // light mode
|
|
@@ -379,6 +381,17 @@ describe('UserPreferencesManager', () => {
|
|
|
379
381
|
})
|
|
380
382
|
})
|
|
381
383
|
|
|
384
|
+
describe('getShowUiLabels', () => {
|
|
385
|
+
it('should return user show ui labels setting', () => {
|
|
386
|
+
expect(userPreferencesManager.getShowUiLabels()).toBe(mockUserPreferences.showUiLabels)
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
it('should return default show ui labels when null', () => {
|
|
390
|
+
userPreferencesAtom.set({ ...mockUserPreferences, showUiLabels: null })
|
|
391
|
+
expect(userPreferencesManager.getShowUiLabels()).toBe(defaultUserPreferences.showUiLabels)
|
|
392
|
+
})
|
|
393
|
+
})
|
|
394
|
+
|
|
382
395
|
describe('getEdgeScrollSpeed', () => {
|
|
383
396
|
it('should return user edge scroll speed', () => {
|
|
384
397
|
expect(userPreferencesManager.getEdgeScrollSpeed()).toBe(
|
|
@@ -49,6 +49,7 @@ export class UserPreferencesManager {
|
|
|
49
49
|
isDarkMode: this.getIsDarkMode(),
|
|
50
50
|
isWrapMode: this.getIsWrapMode(),
|
|
51
51
|
isDynamicResizeMode: this.getIsDynamicResizeMode(),
|
|
52
|
+
showUiLabels: this.getShowUiLabels(),
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -119,4 +120,8 @@ export class UserPreferencesManager {
|
|
|
119
120
|
defaultUserPreferences.isPasteAtCursorMode
|
|
120
121
|
)
|
|
121
122
|
}
|
|
123
|
+
|
|
124
|
+
@computed getShowUiLabels() {
|
|
125
|
+
return this.user.userPreferences.get().showUiLabels ?? defaultUserPreferences.showUiLabels
|
|
126
|
+
}
|
|
122
127
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
TLGroupShape,
|
|
5
5
|
TLShape,
|
|
6
6
|
TLShapeId,
|
|
7
|
+
getColorValue,
|
|
7
8
|
getDefaultColorTheme,
|
|
8
9
|
} from '@tldraw/tlschema'
|
|
9
10
|
import { hasOwnProperty, promiseWithResolve, uniqueId } from '@tldraw/utils'
|
|
@@ -373,8 +374,7 @@ function SvgExport({
|
|
|
373
374
|
| { options: { showColors: boolean } }
|
|
374
375
|
if (frameShapeUtil?.options.showColors) {
|
|
375
376
|
const shape = editor.getShape(singleFrameShapeId)! as TLFrameShape
|
|
376
|
-
|
|
377
|
-
backgroundColor = color.frame.fill
|
|
377
|
+
backgroundColor = getColorValue(theme, shape.props.color, 'frameFill')
|
|
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, { useMemo } from 'react'
|
|
2
|
+
import React, { useEffect, useMemo } from 'react'
|
|
3
3
|
import { RIGHT_MOUSE_BUTTON } from '../constants'
|
|
4
4
|
import {
|
|
5
5
|
preventDefault,
|
|
@@ -16,9 +16,6 @@ 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
|
-
|
|
22
19
|
function onPointerDown(e: React.PointerEvent) {
|
|
23
20
|
if ((e as any).isKilled) return
|
|
24
21
|
|
|
@@ -44,35 +41,9 @@ export function useCanvasEvents() {
|
|
|
44
41
|
})
|
|
45
42
|
}
|
|
46
43
|
|
|
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
|
-
|
|
71
44
|
function onPointerUp(e: React.PointerEvent) {
|
|
72
45
|
if ((e as any).isKilled) return
|
|
73
46
|
if (e.button !== 0 && e.button !== 1 && e.button !== 2 && e.button !== 5) return
|
|
74
|
-
lastX = e.clientX
|
|
75
|
-
lastY = e.clientY
|
|
76
47
|
|
|
77
48
|
releasePointerCapture(e.currentTarget, e)
|
|
78
49
|
|
|
@@ -158,7 +129,6 @@ export function useCanvasEvents() {
|
|
|
158
129
|
|
|
159
130
|
return {
|
|
160
131
|
onPointerDown,
|
|
161
|
-
onPointerMove,
|
|
162
132
|
onPointerUp,
|
|
163
133
|
onPointerEnter,
|
|
164
134
|
onPointerLeave,
|
|
@@ -169,8 +139,45 @@ export function useCanvasEvents() {
|
|
|
169
139
|
onClick,
|
|
170
140
|
}
|
|
171
141
|
},
|
|
172
|
-
[editor
|
|
142
|
+
[editor]
|
|
173
143
|
)
|
|
174
144
|
|
|
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
|
+
|
|
175
182
|
return events
|
|
176
183
|
}
|
package/src/lib/options.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface TldrawOptions {
|
|
|
53
53
|
readonly flattenImageBoundsPadding: number
|
|
54
54
|
readonly laserDelayMs: number
|
|
55
55
|
readonly maxExportDelayMs: number
|
|
56
|
+
readonly tooltipDelayMs: number
|
|
56
57
|
/**
|
|
57
58
|
* How long should previews created by {@link Editor.createTemporaryAssetPreview} last before
|
|
58
59
|
* they expire? Defaults to 3 minutes.
|
|
@@ -124,6 +125,7 @@ export const defaultTldrawOptions = {
|
|
|
124
125
|
flattenImageBoundsPadding: 16,
|
|
125
126
|
laserDelayMs: 1200,
|
|
126
127
|
maxExportDelayMs: 5000,
|
|
128
|
+
tooltipDelayMs: 700,
|
|
127
129
|
temporaryAssetPreviewLifetimeMs: 180000,
|
|
128
130
|
actionShortcutsLocation: 'swap',
|
|
129
131
|
createTextOnCanvasDoubleClick: true,
|
package/src/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '3.16.0-canary.
|
|
4
|
+
export const version = '3.16.0-canary.cf24aedcd577'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-08-
|
|
8
|
-
patch: '2025-08-
|
|
7
|
+
minor: '2025-08-11T15:30:09.531Z',
|
|
8
|
+
patch: '2025-08-11T15:30:09.531Z',
|
|
9
9
|
}
|