tldraw 3.15.0-canary.cc3205a8ac6d → 3.15.0-canary.d251cd98b4e1
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 +77 -84
- package/dist-cjs/index.js +31 -30
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -11
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +11 -1
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +1 -0
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +16 -0
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +0 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +28 -1
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +4 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-esm/index.d.mts +77 -84
- package/dist-esm/index.mjs +134 -132
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -11
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +11 -1
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +2 -0
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +16 -0
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +0 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +28 -1
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +4 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +159 -158
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -12
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +8 -0
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -0
- package/src/lib/ui/components/menu-items.tsx +17 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +0 -2
- package/src/lib/ui/context/actions.tsx +29 -1
- package/src/lib/ui/context/events.tsx +2 -0
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +3 -2
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +4 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +4 -0
- package/src/lib/ui/version.ts +3 -3
- package/src/test/Editor.test.tsx +68 -1
- package/src/test/commands/clipboard.test.ts +1 -1
- package/src/test/editor.test.ts +0 -77
|
@@ -107,6 +107,7 @@ export interface TLUiEventMap {
|
|
|
107
107
|
'toggle-paste-at-cursor': null
|
|
108
108
|
'toggle-lock': null
|
|
109
109
|
'toggle-reduce-motion': null
|
|
110
|
+
'toggle-keyboard-shortcuts': null
|
|
110
111
|
'toggle-edge-scrolling': null
|
|
111
112
|
'color-scheme': { value: string }
|
|
112
113
|
'exit-pen-mode': null
|
|
@@ -127,6 +128,7 @@ export interface TLUiEventMap {
|
|
|
127
128
|
'copy-link': null
|
|
128
129
|
'image-replace': null
|
|
129
130
|
'video-replace': null
|
|
131
|
+
'open-kbd-shortcuts': null
|
|
130
132
|
'rich-text': {
|
|
131
133
|
operation:
|
|
132
134
|
| 'bold'
|
|
@@ -61,7 +61,7 @@ export function useKeyboardShortcuts() {
|
|
|
61
61
|
if (SKIP_KBDS.includes(action.id)) continue
|
|
62
62
|
|
|
63
63
|
hot(getHotkeysStringFromKbd(action.kbd), (event) => {
|
|
64
|
-
if (areShortcutsDisabled(editor)) return
|
|
64
|
+
if (areShortcutsDisabled(editor) && !action.isRequiredA11yAction) return
|
|
65
65
|
preventDefault(event)
|
|
66
66
|
action.onSelect('kbd')
|
|
67
67
|
})
|
|
@@ -149,7 +149,8 @@ export function areShortcutsDisabled(editor: Editor) {
|
|
|
149
149
|
return (
|
|
150
150
|
editor.menus.hasAnyOpenMenus() ||
|
|
151
151
|
editor.getEditingShapeId() !== null ||
|
|
152
|
-
editor.getCrashingError()
|
|
152
|
+
editor.getCrashingError() ||
|
|
153
|
+
!editor.user.getAreKeyboardShortcutsEnabled()
|
|
153
154
|
)
|
|
154
155
|
}
|
|
155
156
|
|
|
@@ -55,6 +55,7 @@ export type TLUiTranslationKey =
|
|
|
55
55
|
| 'action.new-project'
|
|
56
56
|
| 'action.new-shared-project'
|
|
57
57
|
| 'action.open-cursor-chat'
|
|
58
|
+
| 'action.open-kbd-shortcuts'
|
|
58
59
|
| 'action.open-file'
|
|
59
60
|
| 'action.pack'
|
|
60
61
|
| 'action.paste'
|
|
@@ -90,6 +91,8 @@ export type TLUiTranslationKey =
|
|
|
90
91
|
| 'action.toggle-wrap-mode'
|
|
91
92
|
| 'action.toggle-reduce-motion.menu'
|
|
92
93
|
| 'action.toggle-reduce-motion'
|
|
94
|
+
| 'action.toggle-keyboard-shortcuts.menu'
|
|
95
|
+
| 'action.toggle-keyboard-shortcuts'
|
|
93
96
|
| 'action.toggle-edge-scrolling.menu'
|
|
94
97
|
| 'action.toggle-edge-scrolling'
|
|
95
98
|
| 'action.toggle-debug-mode.menu'
|
|
@@ -288,6 +291,7 @@ export type TLUiTranslationKey =
|
|
|
288
291
|
| 'a11y.pan-camera'
|
|
289
292
|
| 'a11y.adjust-shape-styles'
|
|
290
293
|
| 'a11y.open-context-menu'
|
|
294
|
+
| 'a11y.open-keyboard-shortcuts'
|
|
291
295
|
| 'menu.title'
|
|
292
296
|
| 'menu.theme'
|
|
293
297
|
| 'menu.copy-as'
|
|
@@ -55,6 +55,7 @@ export const DEFAULT_TRANSLATION = {
|
|
|
55
55
|
'action.new-project': 'New project',
|
|
56
56
|
'action.new-shared-project': 'New shared project',
|
|
57
57
|
'action.open-cursor-chat': 'Cursor chat',
|
|
58
|
+
'action.open-kbd-shortcuts': 'Open keyboard shortcuts',
|
|
58
59
|
'action.open-file': 'Open file',
|
|
59
60
|
'action.pack': 'Pack',
|
|
60
61
|
'action.paste': 'Paste',
|
|
@@ -91,6 +92,8 @@ export const DEFAULT_TRANSLATION = {
|
|
|
91
92
|
'action.toggle-wrap-mode': 'Toggle Select on wrap',
|
|
92
93
|
'action.toggle-reduce-motion.menu': 'Reduce motion',
|
|
93
94
|
'action.toggle-reduce-motion': 'Toggle reduce motion',
|
|
95
|
+
'action.toggle-keyboard-shortcuts.menu': 'Keyboard shortcuts',
|
|
96
|
+
'action.toggle-keyboard-shortcuts': 'Toggle keyboard shortcuts',
|
|
94
97
|
'action.toggle-edge-scrolling.menu': 'Edge scrolling',
|
|
95
98
|
'action.toggle-edge-scrolling': 'Toggle edge scrolling',
|
|
96
99
|
'action.toggle-debug-mode.menu': 'Debug mode',
|
|
@@ -289,6 +292,7 @@ export const DEFAULT_TRANSLATION = {
|
|
|
289
292
|
'a11y.pan-camera': 'Pan camera',
|
|
290
293
|
'a11y.adjust-shape-styles': 'Adjust shape styles',
|
|
291
294
|
'a11y.open-context-menu': 'Open context menu',
|
|
295
|
+
'a11y.open-keyboard-shortcuts': 'Open keyboard shortcuts',
|
|
292
296
|
'menu.title': 'Menu',
|
|
293
297
|
'menu.theme': 'Theme',
|
|
294
298
|
'menu.copy-as': 'Copy as',
|
package/src/lib/ui/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.15.0-canary.
|
|
4
|
+
export const version = '3.15.0-canary.d251cd98b4e1'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-07-
|
|
8
|
-
patch: '2025-07-
|
|
7
|
+
minor: '2025-07-09T14:00:46.148Z',
|
|
8
|
+
patch: '2025-07-09T14:00:46.148Z',
|
|
9
9
|
}
|
package/src/test/Editor.test.tsx
CHANGED
|
@@ -49,7 +49,7 @@ beforeEach(() => {
|
|
|
49
49
|
})
|
|
50
50
|
|
|
51
51
|
const moveShapesToPage2 = () => {
|
|
52
|
-
// directly
|
|
52
|
+
// directly manipulate parentId like would happen in multiplayer situations
|
|
53
53
|
|
|
54
54
|
editor.updateShapes([
|
|
55
55
|
{ id: ids.box1, type: 'geo', parentId: ids.page2 },
|
|
@@ -899,3 +899,70 @@ describe('the geometry cache', () => {
|
|
|
899
899
|
expect(editor.getShapePageBounds(A)!.width).toBe(200)
|
|
900
900
|
})
|
|
901
901
|
})
|
|
902
|
+
describe('editor.getShapePageBounds', () => {
|
|
903
|
+
it('calculates axis aligned bounds correctly', () => {
|
|
904
|
+
editor.createShape({
|
|
905
|
+
type: 'geo',
|
|
906
|
+
x: 99,
|
|
907
|
+
y: 88,
|
|
908
|
+
props: {
|
|
909
|
+
w: 199,
|
|
910
|
+
h: 188,
|
|
911
|
+
},
|
|
912
|
+
})
|
|
913
|
+
const shape = editor.getLastCreatedShape()
|
|
914
|
+
expect(editor.getShapePageBounds(shape)!).toMatchInlineSnapshot(`
|
|
915
|
+
Box {
|
|
916
|
+
"h": 188,
|
|
917
|
+
"w": 199,
|
|
918
|
+
"x": 99,
|
|
919
|
+
"y": 88,
|
|
920
|
+
}
|
|
921
|
+
`)
|
|
922
|
+
})
|
|
923
|
+
|
|
924
|
+
it('calculates rotated bounds correctly', () => {
|
|
925
|
+
editor.createShape({
|
|
926
|
+
type: 'geo',
|
|
927
|
+
x: 99,
|
|
928
|
+
y: 88,
|
|
929
|
+
rotation: Math.PI / 4,
|
|
930
|
+
props: {
|
|
931
|
+
w: 199,
|
|
932
|
+
h: 188,
|
|
933
|
+
},
|
|
934
|
+
})
|
|
935
|
+
const shape = editor.getLastCreatedShape()
|
|
936
|
+
expect(editor.getShapePageBounds(shape)!).toMatchInlineSnapshot(`
|
|
937
|
+
Box {
|
|
938
|
+
"h": 273.65032431919394,
|
|
939
|
+
"w": 273.6503243191939,
|
|
940
|
+
"x": -33.93607486307093,
|
|
941
|
+
"y": 88,
|
|
942
|
+
}
|
|
943
|
+
`)
|
|
944
|
+
})
|
|
945
|
+
|
|
946
|
+
it('calculates bounds based on vertices, not corners', () => {
|
|
947
|
+
editor.createShape({
|
|
948
|
+
type: 'geo',
|
|
949
|
+
x: 99,
|
|
950
|
+
y: 88,
|
|
951
|
+
rotation: Math.PI / 4,
|
|
952
|
+
props: {
|
|
953
|
+
geo: 'ellipse',
|
|
954
|
+
w: 199,
|
|
955
|
+
h: 188,
|
|
956
|
+
},
|
|
957
|
+
})
|
|
958
|
+
const shape = editor.getLastCreatedShape()
|
|
959
|
+
expect(editor.getShapePageBounds(shape)!).toMatchInlineSnapshot(`
|
|
960
|
+
Box {
|
|
961
|
+
"h": 193.49999999999997,
|
|
962
|
+
"w": 193.50000000000003,
|
|
963
|
+
"x": 6.139087296526014,
|
|
964
|
+
"y": 128.07516215959694,
|
|
965
|
+
}
|
|
966
|
+
`)
|
|
967
|
+
})
|
|
968
|
+
})
|
package/src/test/editor.test.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { TestEditor } from './TestEditor'
|
|
2
|
-
|
|
3
|
-
describe('editor', () => {
|
|
4
|
-
let editor: TestEditor
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
editor = new TestEditor()
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
describe('editor.getShapePageBounds', () => {
|
|
11
|
-
it('calculates axis aligned bounds correctly', () => {
|
|
12
|
-
editor.createShape({
|
|
13
|
-
type: 'geo',
|
|
14
|
-
x: 99,
|
|
15
|
-
y: 88,
|
|
16
|
-
props: {
|
|
17
|
-
w: 199,
|
|
18
|
-
h: 188,
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
const shape = editor.getLastCreatedShape()
|
|
22
|
-
expect(editor.getShapePageBounds(shape)!).toMatchInlineSnapshot(`
|
|
23
|
-
Box {
|
|
24
|
-
"h": 188,
|
|
25
|
-
"w": 199,
|
|
26
|
-
"x": 99,
|
|
27
|
-
"y": 88,
|
|
28
|
-
}
|
|
29
|
-
`)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('calculates rotated bounds correctly', () => {
|
|
33
|
-
editor.createShape({
|
|
34
|
-
type: 'geo',
|
|
35
|
-
x: 99,
|
|
36
|
-
y: 88,
|
|
37
|
-
rotation: Math.PI / 4,
|
|
38
|
-
props: {
|
|
39
|
-
w: 199,
|
|
40
|
-
h: 188,
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
const shape = editor.getLastCreatedShape()
|
|
44
|
-
expect(editor.getShapePageBounds(shape)!).toMatchInlineSnapshot(`
|
|
45
|
-
Box {
|
|
46
|
-
"h": 273.65032431919394,
|
|
47
|
-
"w": 273.6503243191939,
|
|
48
|
-
"x": -33.93607486307093,
|
|
49
|
-
"y": 88,
|
|
50
|
-
}
|
|
51
|
-
`)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('calculates bounds based on vertices, not corners', () => {
|
|
55
|
-
editor.createShape({
|
|
56
|
-
type: 'geo',
|
|
57
|
-
x: 99,
|
|
58
|
-
y: 88,
|
|
59
|
-
rotation: Math.PI / 4,
|
|
60
|
-
props: {
|
|
61
|
-
geo: 'ellipse',
|
|
62
|
-
w: 199,
|
|
63
|
-
h: 188,
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
const shape = editor.getLastCreatedShape()
|
|
67
|
-
expect(editor.getShapePageBounds(shape)!).toMatchInlineSnapshot(`
|
|
68
|
-
Box {
|
|
69
|
-
"h": 193.49999999999997,
|
|
70
|
-
"w": 193.50000000000003,
|
|
71
|
-
"x": 6.139087296526014,
|
|
72
|
-
"y": 128.07516215959694,
|
|
73
|
-
}
|
|
74
|
-
`)
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
})
|