tldraw 3.15.0-canary.db14db4f5395 → 3.15.0-canary.ee0606e7631e
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 +82 -84
- package/dist-cjs/index.js +32 -30
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +279 -271
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -5
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +21 -3
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -0
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +1 -0
- package/dist-cjs/lib/shapes/shared/RichTextLabel.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/NavigationPanel/DefaultNavigationPanel.js +3 -4
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +2 -1
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.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/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +5 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +1 -0
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.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/useClipboardEvents.js +24 -7
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.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 +82 -84
- package/dist-esm/index.mjs +136 -132
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +279 -271
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +22 -3
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -0
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +1 -0
- package/dist-esm/lib/shapes/shared/RichTextLabel.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/NavigationPanel/DefaultNavigationPanel.mjs +3 -4
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +2 -1
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.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/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +5 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +1 -0
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.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/useClipboardEvents.mjs +24 -7
- package/dist-esm/lib/ui/hooks/useClipboardEvents.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 +160 -158
- package/src/lib/canvas/TldrawCropHandles.tsx +1 -1
- package/src/lib/canvas/TldrawHandles.tsx +5 -1
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +5 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +5 -7
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +35 -1
- package/src/lib/shapes/shared/PlainTextLabel.tsx +1 -0
- package/src/lib/shapes/shared/RichTextLabel.tsx +1 -0
- 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/NavigationPanel/DefaultNavigationPanel.tsx +3 -4
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +1 -0
- package/src/lib/ui/components/menu-items.tsx +17 -0
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +5 -1
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +4 -0
- package/src/lib/ui/context/actions.tsx +29 -1
- package/src/lib/ui/context/events.tsx +2 -0
- package/src/lib/ui/hooks/useClipboardEvents.ts +31 -10
- 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/lib/ui.css +0 -14
- package/src/test/Editor.test.tsx +68 -1
- package/src/test/commands/clipboard.test.ts +1 -1
- package/tldraw.css +2 -16
- package/src/test/editor.test.ts +0 -77
|
@@ -303,33 +303,26 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
function getTextSize(editor: Editor, props: TLTextShape['props']) {
|
|
306
|
-
const { font, richText,
|
|
306
|
+
const { font, richText, size, w } = props
|
|
307
307
|
|
|
308
|
-
const minWidth =
|
|
308
|
+
const minWidth = 16
|
|
309
309
|
const fontSize = FONT_SIZES[size]
|
|
310
310
|
|
|
311
|
-
const
|
|
312
|
-
? null
|
|
313
|
-
: // `measureText` floors the number so we need to do the same here to avoid issues.
|
|
314
|
-
Math.floor(Math.max(minWidth, w))
|
|
311
|
+
const maybeFixedWidth = props.autoSize ? null : Math.max(minWidth, Math.floor(w))
|
|
315
312
|
|
|
316
313
|
const html = renderHtmlFromRichTextForMeasurement(editor, richText)
|
|
317
314
|
const result = editor.textMeasure.measureHtml(html, {
|
|
318
315
|
...TEXT_PROPS,
|
|
319
316
|
fontFamily: FONT_FAMILIES[font],
|
|
320
317
|
fontSize: fontSize,
|
|
321
|
-
maxWidth:
|
|
318
|
+
maxWidth: maybeFixedWidth,
|
|
322
319
|
})
|
|
323
320
|
|
|
324
321
|
// If we're autosizing the measureText will essentially `Math.floor`
|
|
325
322
|
// the numbers so `19` rather than `19.3`, this means we must +1 to
|
|
326
323
|
// whatever we get to avoid wrapping.
|
|
327
|
-
if (autoSize) {
|
|
328
|
-
result.w += 1
|
|
329
|
-
}
|
|
330
|
-
|
|
331
324
|
return {
|
|
332
|
-
width: Math.max(minWidth, result.w),
|
|
325
|
+
width: maybeFixedWidth ?? Math.max(minWidth, result.w + 1),
|
|
333
326
|
height: Math.max(fontSize, result.h),
|
|
334
327
|
}
|
|
335
328
|
}
|
package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx
CHANGED
|
@@ -213,6 +213,14 @@ export function DefaultKeyboardShortcutsDialogContent() {
|
|
|
213
213
|
<TldrawUiMenuActionItem actionId="enlarge-shapes" />
|
|
214
214
|
<TldrawUiMenuActionItem actionId="shrink-shapes" />
|
|
215
215
|
<TldrawUiMenuActionItem actionId="a11y-repeat-shape-announce" />
|
|
216
|
+
<TldrawUiMenuItem
|
|
217
|
+
id="a11y-open-keyboard-shortcuts"
|
|
218
|
+
label="a11y.open-keyboard-shortcuts"
|
|
219
|
+
kbd="cmd+alt+/"
|
|
220
|
+
onSelect={() => {
|
|
221
|
+
/* do nothing */
|
|
222
|
+
}}
|
|
223
|
+
/>
|
|
216
224
|
</TldrawUiMenuGroup>
|
|
217
225
|
{showCollaborationUi && (
|
|
218
226
|
<TldrawUiMenuGroup label="shortcuts-dialog.collaboration" id="collaboration">
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ToggleEdgeScrollingItem,
|
|
20
20
|
ToggleFocusModeItem,
|
|
21
21
|
ToggleGridItem,
|
|
22
|
+
ToggleKeyboardShortcutsItem,
|
|
22
23
|
ToggleLockMenuItem,
|
|
23
24
|
TogglePasteAtCursorItem,
|
|
24
25
|
ToggleReduceMotionItem,
|
|
@@ -161,6 +162,7 @@ export function PreferencesGroup() {
|
|
|
161
162
|
<ToggleFocusModeItem />
|
|
162
163
|
<ToggleEdgeScrollingItem />
|
|
163
164
|
<ToggleReduceMotionItem />
|
|
165
|
+
<ToggleKeyboardShortcutsItem />
|
|
164
166
|
<ToggleDynamicSizeModeItem />
|
|
165
167
|
<TogglePasteAtCursorItem />
|
|
166
168
|
<ToggleDebugModeItem />
|
|
@@ -45,7 +45,7 @@ export const DefaultNavigationPanel = memo(function DefaultNavigationPanel() {
|
|
|
45
45
|
title={`${msg(unwrapLabel(actions['zoom-out'].label))} ${kbdStr(actions['zoom-out'].kbd!)}`}
|
|
46
46
|
onClick={() => actions['zoom-out'].onSelect('navigation-zone')}
|
|
47
47
|
>
|
|
48
|
-
<TldrawUiButtonIcon icon="minus" />
|
|
48
|
+
<TldrawUiButtonIcon small icon="minus" />
|
|
49
49
|
</TldrawUiToolbarButton>
|
|
50
50
|
)}
|
|
51
51
|
{ZoomMenu && <ZoomMenu key="zoom-menu" />}
|
|
@@ -56,7 +56,7 @@ export const DefaultNavigationPanel = memo(function DefaultNavigationPanel() {
|
|
|
56
56
|
title={`${msg(unwrapLabel(actions['zoom-in'].label))} ${kbdStr(actions['zoom-in'].kbd!)}`}
|
|
57
57
|
onClick={() => actions['zoom-in'].onSelect('navigation-zone')}
|
|
58
58
|
>
|
|
59
|
-
<TldrawUiButtonIcon icon="plus" />
|
|
59
|
+
<TldrawUiButtonIcon small icon="plus" />
|
|
60
60
|
</TldrawUiToolbarButton>
|
|
61
61
|
)}
|
|
62
62
|
{Minimap && (
|
|
@@ -64,10 +64,9 @@ export const DefaultNavigationPanel = memo(function DefaultNavigationPanel() {
|
|
|
64
64
|
type="icon"
|
|
65
65
|
data-testid="minimap.toggle-button"
|
|
66
66
|
title={msg('navigation-zone.toggle-minimap')}
|
|
67
|
-
className="tlui-navigation-panel__toggle"
|
|
68
67
|
onClick={toggleMinimap}
|
|
69
68
|
>
|
|
70
|
-
<TldrawUiButtonIcon icon={collapsed ? '
|
|
69
|
+
<TldrawUiButtonIcon small icon={collapsed ? 'chevron-right' : 'chevron-left'} />
|
|
71
70
|
</TldrawUiToolbarButton>
|
|
72
71
|
)}
|
|
73
72
|
</>
|
|
@@ -634,6 +634,23 @@ export function ToggleReduceMotionItem() {
|
|
|
634
634
|
)
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
+
/** @public @react */
|
|
638
|
+
export function ToggleKeyboardShortcutsItem() {
|
|
639
|
+
const editor = useEditor()
|
|
640
|
+
const keyboardShortcuts = useValue(
|
|
641
|
+
'keyboardShortcuts',
|
|
642
|
+
() => editor.user.getAreKeyboardShortcutsEnabled(),
|
|
643
|
+
[editor]
|
|
644
|
+
)
|
|
645
|
+
|
|
646
|
+
return (
|
|
647
|
+
<TldrawUiMenuActionCheckboxItem
|
|
648
|
+
actionId="toggle-keyboard-shortcuts"
|
|
649
|
+
checked={keyboardShortcuts}
|
|
650
|
+
/>
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
|
|
637
654
|
/** @public @react */
|
|
638
655
|
export function ToggleDebugModeItem() {
|
|
639
656
|
const editor = useEditor()
|
|
@@ -65,7 +65,7 @@ export interface TLUiDialogBodyProps {
|
|
|
65
65
|
/** @public @react */
|
|
66
66
|
export function TldrawUiDialogBody({ className, children, style }: TLUiDialogBodyProps) {
|
|
67
67
|
return (
|
|
68
|
-
<div className={classNames('tlui-dialog__body', className)} style={style}>
|
|
68
|
+
<div className={classNames('tlui-dialog__body', className)} style={style} tabIndex={0}>
|
|
69
69
|
{children}
|
|
70
70
|
</div>
|
|
71
71
|
)
|
|
@@ -13,6 +13,7 @@ export interface TLUiSliderProps {
|
|
|
13
13
|
onValueChange(value: number): void
|
|
14
14
|
onHistoryMark(id: string): void
|
|
15
15
|
'data-testid'?: string
|
|
16
|
+
ariaValueModifier?: number
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/** @public @react */
|
|
@@ -26,6 +27,7 @@ export const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(
|
|
|
26
27
|
label,
|
|
27
28
|
onValueChange,
|
|
28
29
|
['data-testid']: testId,
|
|
30
|
+
ariaValueModifier = 1,
|
|
29
31
|
}: TLUiSliderProps,
|
|
30
32
|
ref
|
|
31
33
|
) {
|
|
@@ -81,7 +83,9 @@ export const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(
|
|
|
81
83
|
</_Slider.Track>
|
|
82
84
|
{value !== null && (
|
|
83
85
|
<_Slider.Thumb
|
|
84
|
-
aria-
|
|
86
|
+
aria-valuemin={(min ?? 0) * ariaValueModifier}
|
|
87
|
+
aria-valuenow={value * ariaValueModifier}
|
|
88
|
+
aria-valuemax={steps * ariaValueModifier}
|
|
85
89
|
className="tlui-slider__thumb"
|
|
86
90
|
dir="ltr"
|
|
87
91
|
ref={ref}
|
|
@@ -76,6 +76,10 @@ export const TldrawUiToolbarToggleGroup = ({
|
|
|
76
76
|
<_Toolbar.ToggleGroup
|
|
77
77
|
type={type}
|
|
78
78
|
{...props}
|
|
79
|
+
// TODO: this fixes a bug in Radix until they fix it.
|
|
80
|
+
// https://github.com/radix-ui/primitives/issues/3188
|
|
81
|
+
// https://github.com/radix-ui/primitives/pull/3189
|
|
82
|
+
role="radiogroup"
|
|
79
83
|
className={classnames('tlui-toolbar-toggle-group', className)}
|
|
80
84
|
>
|
|
81
85
|
{children}
|
|
@@ -28,6 +28,7 @@ import { fitFrameToContent, removeFrame } from '../../utils/frames/frames'
|
|
|
28
28
|
import { generateShapeAnnouncementMessage } from '../components/A11y'
|
|
29
29
|
import { EditLinkDialog } from '../components/EditLinkDialog'
|
|
30
30
|
import { EmbedDialog } from '../components/EmbedDialog'
|
|
31
|
+
import { DefaultKeyboardShortcutsDialog } from '../components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialog'
|
|
31
32
|
import { useShowCollaborationUi } from '../hooks/useCollaborationStatus'
|
|
32
33
|
import { flattenShapesToImages } from '../hooks/useFlatten'
|
|
33
34
|
import { TLUiTranslationKey } from '../hooks/useTranslation/TLUiTranslationKey'
|
|
@@ -48,6 +49,7 @@ export interface TLUiActionItem<
|
|
|
48
49
|
label?: TransationKey | { [key: string]: TransationKey }
|
|
49
50
|
readonlyOk?: boolean
|
|
50
51
|
checkbox?: boolean
|
|
52
|
+
isRequiredA11yAction?: boolean
|
|
51
53
|
onSelect(source: TLUiEventSource): Promise<void> | void
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -168,6 +170,15 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
168
170
|
helpers.addDialog({ component: EmbedDialog })
|
|
169
171
|
},
|
|
170
172
|
},
|
|
173
|
+
{
|
|
174
|
+
id: 'open-kbd-shortcuts',
|
|
175
|
+
label: 'action.open-kbd-shortcuts',
|
|
176
|
+
kbd: 'cmd+alt+/,ctrl+alt+/',
|
|
177
|
+
onSelect(source) {
|
|
178
|
+
trackEvent('open-kbd-shortcuts', { source })
|
|
179
|
+
helpers.addDialog({ component: DefaultKeyboardShortcutsDialog })
|
|
180
|
+
},
|
|
181
|
+
},
|
|
171
182
|
{
|
|
172
183
|
id: 'insert-media',
|
|
173
184
|
label: 'action.insert-media',
|
|
@@ -502,7 +513,6 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
502
513
|
}
|
|
503
514
|
}
|
|
504
515
|
|
|
505
|
-
if (!editor.canCreateShapes(ids)) return
|
|
506
516
|
editor.markHistoryStoppingPoint('duplicate shapes')
|
|
507
517
|
editor.duplicateShapes(ids, offset)
|
|
508
518
|
|
|
@@ -1234,6 +1244,21 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1234
1244
|
},
|
|
1235
1245
|
checkbox: true,
|
|
1236
1246
|
},
|
|
1247
|
+
{
|
|
1248
|
+
id: 'toggle-keyboard-shortcuts',
|
|
1249
|
+
label: {
|
|
1250
|
+
default: 'action.toggle-keyboard-shortcuts',
|
|
1251
|
+
menu: 'action.toggle-keyboard-shortcuts.menu',
|
|
1252
|
+
},
|
|
1253
|
+
readonlyOk: true,
|
|
1254
|
+
onSelect(source) {
|
|
1255
|
+
trackEvent('toggle-keyboard-shortcuts', { source })
|
|
1256
|
+
editor.user.updateUserPreferences({
|
|
1257
|
+
areKeyboardShortcutsEnabled: !editor.user.getAreKeyboardShortcutsEnabled(),
|
|
1258
|
+
})
|
|
1259
|
+
},
|
|
1260
|
+
checkbox: true,
|
|
1261
|
+
},
|
|
1237
1262
|
{
|
|
1238
1263
|
id: 'toggle-edge-scrolling',
|
|
1239
1264
|
label: {
|
|
@@ -1530,6 +1555,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1530
1555
|
id: 'adjust-shape-styles',
|
|
1531
1556
|
label: 'a11y.adjust-shape-styles',
|
|
1532
1557
|
kbd: 'cmd+Enter,ctrl+Enter',
|
|
1558
|
+
isRequiredA11yAction: true,
|
|
1533
1559
|
onSelect: async (source) => {
|
|
1534
1560
|
if (!canApplySelectionAction()) return
|
|
1535
1561
|
|
|
@@ -1543,6 +1569,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1543
1569
|
{
|
|
1544
1570
|
id: 'a11y-open-context-menu',
|
|
1545
1571
|
kbd: 'cmd+shift+Enter,ctrl+shift+Enter',
|
|
1572
|
+
isRequiredA11yAction: true,
|
|
1546
1573
|
readonlyOk: true,
|
|
1547
1574
|
onSelect: async (source) => {
|
|
1548
1575
|
if (!canApplySelectionAction()) return
|
|
@@ -1595,6 +1622,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1595
1622
|
id: 'a11y-repeat-shape-announce',
|
|
1596
1623
|
kbd: 'alt+r',
|
|
1597
1624
|
label: 'a11y.repeat-shape',
|
|
1625
|
+
isRequiredA11yAction: true,
|
|
1598
1626
|
readonlyOk: true,
|
|
1599
1627
|
onSelect: async (source) => {
|
|
1600
1628
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
@@ -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'
|
|
@@ -352,7 +352,7 @@ async function handleClipboardThings(editor: Editor, things: ClipboardThing[], p
|
|
|
352
352
|
|
|
353
353
|
if (tldrawHtmlComment) {
|
|
354
354
|
try {
|
|
355
|
-
// First try parsing as plain JSON (version 2
|
|
355
|
+
// First try parsing as plain JSON (version 2/3 formats)
|
|
356
356
|
let json
|
|
357
357
|
try {
|
|
358
358
|
json = JSON.parse(tldrawHtmlComment)
|
|
@@ -380,19 +380,32 @@ async function handleClipboardThings(editor: Editor, things: ClipboardThing[], p
|
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
// Handle versioned clipboard format
|
|
383
|
-
if (json.version ===
|
|
384
|
-
// Version
|
|
383
|
+
if (json.version === 3) {
|
|
384
|
+
// Version 3: Assets are plain, decompress only other data
|
|
385
385
|
try {
|
|
386
|
-
|
|
386
|
+
const otherData = JSON.parse(
|
|
387
|
+
lz.decompressFromBase64(json.data.otherCompressed) || '{}'
|
|
388
|
+
)
|
|
389
|
+
const reconstructedData = {
|
|
390
|
+
assets: json.data.assets || [],
|
|
391
|
+
...otherData,
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
r({ type: 'tldraw', data: reconstructedData })
|
|
387
395
|
return
|
|
388
396
|
} catch (error) {
|
|
389
397
|
r({
|
|
390
398
|
type: 'error',
|
|
391
399
|
data: json,
|
|
392
|
-
reason: `failed to
|
|
400
|
+
reason: `failed to decompress version 2 clipboard data: ${error}`,
|
|
393
401
|
})
|
|
394
402
|
return
|
|
395
403
|
}
|
|
404
|
+
}
|
|
405
|
+
if (json.version === 2) {
|
|
406
|
+
// Version 2: Everything is plain, this had issues with encoding... :-/
|
|
407
|
+
// TODO: nix this support after some time.
|
|
408
|
+
r({ type: 'tldraw', data: json.data })
|
|
396
409
|
} else {
|
|
397
410
|
// Version 1 or no version: Legacy format
|
|
398
411
|
if (typeof json.data === 'string') {
|
|
@@ -584,13 +597,21 @@ const handleNativeOrMenuCopy = async (editor: Editor) => {
|
|
|
584
597
|
return
|
|
585
598
|
}
|
|
586
599
|
|
|
587
|
-
//
|
|
588
|
-
|
|
600
|
+
// Use versioned clipboard format for better compression
|
|
601
|
+
// Version 3: Don't compress assets, only compress other data
|
|
602
|
+
const { assets, ...otherData } = content
|
|
603
|
+
const clipboardData = {
|
|
589
604
|
type: 'application/tldraw',
|
|
590
605
|
kind: 'content',
|
|
591
|
-
version:
|
|
592
|
-
data:
|
|
593
|
-
|
|
606
|
+
version: 3,
|
|
607
|
+
data: {
|
|
608
|
+
assets: assets || [], // Plain JSON, no compression
|
|
609
|
+
otherCompressed: lz.compressToBase64(JSON.stringify(otherData)), // Only compress non-asset data
|
|
610
|
+
},
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// Don't compress the final structure - just use plain JSON
|
|
614
|
+
const stringifiedClipboard = JSON.stringify(clipboardData)
|
|
594
615
|
|
|
595
616
|
if (typeof navigator === 'undefined') {
|
|
596
617
|
return
|
|
@@ -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.ee0606e7631e'
|
|
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-14T15:28:44.028Z',
|
|
8
|
+
patch: '2025-07-14T15:28:44.028Z',
|
|
9
9
|
}
|
package/src/lib/ui.css
CHANGED
|
@@ -1108,20 +1108,6 @@
|
|
|
1108
1108
|
display: none;
|
|
1109
1109
|
}
|
|
1110
1110
|
|
|
1111
|
-
.tlui-navigation-panel__toggle .tlui-icon {
|
|
1112
|
-
opacity: 0.24;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
.tlui-navigation-panel__toggle:active .tlui-icon {
|
|
1116
|
-
opacity: 1;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
@media (hover: hover) {
|
|
1120
|
-
.tlui-navigation-panel__toggle:hover .tlui-icon {
|
|
1121
|
-
opacity: 1;
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
1111
|
/* Minimap */
|
|
1126
1112
|
|
|
1127
1113
|
.tlui-minimap {
|
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/tldraw.css
CHANGED
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
--color-text: hsl(0, 0%, 0%);
|
|
172
172
|
--color-text-0: hsl(0, 0%, 11%);
|
|
173
173
|
--color-text-1: hsl(0, 0%, 18%);
|
|
174
|
-
--color-text-3: hsl(
|
|
174
|
+
--color-text-3: hsl(204, 4%, 45%);
|
|
175
175
|
--color-text-shadow: hsl(0, 0%, 100%);
|
|
176
176
|
--color-text-highlight: hsl(52, 100%, 50%);
|
|
177
177
|
--color-text-highlight-p3: color(display-p3 0.972 0.8205 0.05);
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
--color-text: hsl(210, 17%, 98%);
|
|
227
227
|
--color-text-0: hsl(0, 9%, 94%);
|
|
228
228
|
--color-text-1: hsl(0, 0%, 85%);
|
|
229
|
-
--color-text-3: hsl(
|
|
229
|
+
--color-text-3: hsl(204, 4%, 75%);
|
|
230
230
|
--color-text-shadow: hsl(210, 13%, 18%);
|
|
231
231
|
--color-text-highlight: hsl(52, 100%, 41%);
|
|
232
232
|
--color-text-highlight-p3: color(display-p3 0.8078 0.6225 0.0312);
|
|
@@ -2892,20 +2892,6 @@ it from receiving any pointer events or affecting the cursor. */
|
|
|
2892
2892
|
display: none;
|
|
2893
2893
|
}
|
|
2894
2894
|
|
|
2895
|
-
.tlui-navigation-panel__toggle .tlui-icon {
|
|
2896
|
-
opacity: 0.24;
|
|
2897
|
-
}
|
|
2898
|
-
|
|
2899
|
-
.tlui-navigation-panel__toggle:active .tlui-icon {
|
|
2900
|
-
opacity: 1;
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
@media (hover: hover) {
|
|
2904
|
-
.tlui-navigation-panel__toggle:hover .tlui-icon {
|
|
2905
|
-
opacity: 1;
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
|
-
|
|
2909
2895
|
/* Minimap */
|
|
2910
2896
|
|
|
2911
2897
|
.tlui-minimap {
|
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
|
-
})
|