tldraw 3.15.0-next.f1dfcef63951 → 3.16.0-next.c30b1b5e551a
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 +161 -95
- package/dist-cjs/index.js +42 -31
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +5 -2
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- 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/defaultExternalContentHandlers.js +1 -0
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +22 -36
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +16 -4
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +3 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.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/line/LineShapeUtil.js +15 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.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/styles.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +43 -22
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +2 -15
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +5 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +51 -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/Spinner.js +2 -25
- package/dist-cjs/lib/ui/components/Spinner.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/Toolbar/ToggleToolLockedButton.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/Button/TldrawUiButtonIcon.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/TldrawUiIcon.js +35 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +6 -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/components/primitives/menus/TldrawUiMenuCheckboxItem.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 +42 -8
- 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/menu-hooks.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/useTools.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 +8 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +2 -1
- package/dist-cjs/lib/ui/kbd-utils.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-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +3 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +161 -95
- package/dist-esm/index.mjs +154 -135
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +5 -2
- package/dist-esm/lib/TldrawImage.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/defaultExternalContentHandlers.mjs +1 -0
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +24 -36
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +19 -5
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +3 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.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/line/LineShapeUtil.mjs +15 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.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/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +43 -22
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +2 -15
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +5 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +51 -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/Spinner.mjs +3 -26
- package/dist-esm/lib/ui/components/Spinner.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/Toolbar/ToggleToolLockedButton.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/Button/TldrawUiButtonIcon.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/TldrawUiIcon.mjs +36 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +6 -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/components/primitives/menus/TldrawUiMenuCheckboxItem.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 +42 -8
- 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/menu-hooks.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/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +8 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +2 -1
- package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +3 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +4 -3
- package/src/index.ts +174 -160
- package/src/lib/TldrawImage.tsx +6 -2
- package/src/lib/canvas/TldrawCropHandles.tsx +3 -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/defaultExternalContentHandlers.ts +2 -1
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +5 -5
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +25 -39
- package/src/lib/shapes/arrow/arrowLabel.ts +23 -3
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +3 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +5 -7
- package/src/lib/shapes/line/LineShapeUtil.tsx +19 -2
- 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/styles.tsx +3 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +54 -30
- package/src/lib/tools/SelectTool/childStates/Idle.ts +2 -24
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +7 -0
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +12 -1
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +11 -0
- package/src/lib/tools/SelectTool/childStates/Translating.ts +11 -0
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -0
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +40 -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/Spinner.tsx +2 -24
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +1 -0
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +3 -1
- package/src/lib/ui/components/menu-items.tsx +17 -0
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +41 -3
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +6 -1
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +4 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +3 -4
- package/src/lib/ui/context/actions.tsx +44 -9
- package/src/lib/ui/context/events.tsx +4 -2
- package/src/lib/ui/hooks/menu-hooks.ts +1 -0
- package/src/lib/ui/hooks/useClipboardEvents.ts +31 -10
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +3 -2
- package/src/lib/ui/hooks/useTools.tsx +2 -1
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +8 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +8 -0
- package/src/lib/ui/kbd-utils.ts +2 -1
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +8 -22
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +16 -2
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +24 -3
- package/src/lib/utils/tldr/buildFromV1Document.ts +2 -1
- package/src/test/Editor.test.tsx +68 -1
- package/src/test/SelectTool.test.ts +37 -11
- package/src/test/commands/clipboard.test.ts +1 -1
- package/src/test/commands/deletePage.test.ts +84 -1
- package/src/test/navigation.test.ts +254 -0
- package/src/test/shapeutils.test.ts +394 -45
- package/tldraw.css +29 -49
- package/src/test/editor.test.ts +0 -77
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor,
|
|
3
|
-
Group2d,
|
|
4
3
|
StateNode,
|
|
5
4
|
TLAdjacentDirection,
|
|
6
|
-
TLArrowShape,
|
|
7
5
|
TLClickEventInfo,
|
|
8
6
|
TLGroupShape,
|
|
9
7
|
TLKeyboardEventInfo,
|
|
@@ -18,6 +16,7 @@ import {
|
|
|
18
16
|
pointInPolygon,
|
|
19
17
|
toRichText,
|
|
20
18
|
} from '@tldraw/editor'
|
|
19
|
+
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
21
20
|
import { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'
|
|
22
21
|
import { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'
|
|
23
22
|
import { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'
|
|
@@ -98,12 +97,6 @@ export class Idle extends StateNode {
|
|
|
98
97
|
case 'shape': {
|
|
99
98
|
const { shape } = info
|
|
100
99
|
|
|
101
|
-
if (this.isOverArrowLabelTest(shape)) {
|
|
102
|
-
// We're moving the label on a shape.
|
|
103
|
-
this.parent.transition('pointing_arrow_label', info)
|
|
104
|
-
break
|
|
105
|
-
}
|
|
106
|
-
|
|
107
100
|
if (this.editor.isShapeOrAncestorLocked(shape)) {
|
|
108
101
|
this.parent.transition('pointing_canvas', info)
|
|
109
102
|
break
|
|
@@ -595,22 +588,7 @@ export class Idle extends StateNode {
|
|
|
595
588
|
isOverArrowLabelTest(shape: TLShape | undefined) {
|
|
596
589
|
if (!shape) return false
|
|
597
590
|
|
|
598
|
-
|
|
599
|
-
if (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {
|
|
600
|
-
const pointInShapeSpace = this.editor.getPointInShapeSpace(
|
|
601
|
-
shape,
|
|
602
|
-
this.editor.inputs.currentPagePoint
|
|
603
|
-
)
|
|
604
|
-
// How should we handle multiple labels? Do shapes ever have multiple labels?
|
|
605
|
-
const labelGeometry = this.editor.getShapeGeometry<Group2d>(shape).children[1]
|
|
606
|
-
// Knowing what we know about arrows... if the shape has no text in its label,
|
|
607
|
-
// then the label geometry should not be there.
|
|
608
|
-
if (labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)) {
|
|
609
|
-
return true
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return false
|
|
591
|
+
return isOverArrowLabel(this.editor, shape)
|
|
614
592
|
}
|
|
615
593
|
|
|
616
594
|
handleDoubleClickOnCanvas(info: TLClickEventInfo) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'
|
|
2
|
+
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
2
3
|
import { getTextLabels } from '../../../utils/shapes/shapes'
|
|
3
4
|
|
|
4
5
|
export class PointingShape extends StateNode {
|
|
@@ -210,6 +211,12 @@ export class PointingShape extends StateNode {
|
|
|
210
211
|
|
|
211
212
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
212
213
|
if (this.editor.inputs.isDragging) {
|
|
214
|
+
if (isOverArrowLabel(this.editor, this.hitShape)) {
|
|
215
|
+
// We're moving the label on a shape.
|
|
216
|
+
this.parent.transition('pointing_arrow_label', { ...info, shape: this.hitShape })
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
|
|
213
220
|
if (this.didCtrlOnEnter) {
|
|
214
221
|
this.parent.transition('brushing', info)
|
|
215
222
|
} else {
|
|
@@ -122,8 +122,19 @@ export class Resizing extends StateNode {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
private cancel() {
|
|
125
|
-
//
|
|
125
|
+
// Call onResizeCancel callback before resetting
|
|
126
|
+
const { shapeSnapshots } = this.snapshot
|
|
127
|
+
|
|
128
|
+
shapeSnapshots.forEach(({ shape }) => {
|
|
129
|
+
const current = this.editor.getShape(shape.id)
|
|
130
|
+
if (current) {
|
|
131
|
+
const util = this.editor.getShapeUtil(shape)
|
|
132
|
+
util.onResizeCancel?.(shape, current)
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
|
|
126
136
|
this.editor.bailToMark(this.markId)
|
|
137
|
+
|
|
127
138
|
if (this.info.onInteractionEnd) {
|
|
128
139
|
this.editor.setCurrentTool(this.info.onInteractionEnd, {})
|
|
129
140
|
} else {
|
|
@@ -109,6 +109,17 @@ export class Rotating extends StateNode {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
private cancel() {
|
|
112
|
+
// Call onRotateCancel callback before bailing to mark
|
|
113
|
+
const { shapeSnapshots } = this.snapshot
|
|
114
|
+
|
|
115
|
+
shapeSnapshots.forEach(({ shape }) => {
|
|
116
|
+
const current = this.editor.getShape(shape.id)
|
|
117
|
+
if (current) {
|
|
118
|
+
const util = this.editor.getShapeUtil(shape)
|
|
119
|
+
util.onRotateCancel?.(shape, current)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
112
123
|
this.editor.bailToMark(this.markId)
|
|
113
124
|
if (this.info.onInteractionEnd) {
|
|
114
125
|
this.editor.setCurrentTool(this.info.onInteractionEnd, this.info)
|
|
@@ -203,6 +203,17 @@ export class Translating extends StateNode {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
private cancel() {
|
|
206
|
+
// Call onTranslateCancel callback before resetting
|
|
207
|
+
const { movingShapes } = this.snapshot
|
|
208
|
+
|
|
209
|
+
movingShapes.forEach((shape) => {
|
|
210
|
+
const current = this.editor.getShape(shape.id)
|
|
211
|
+
if (current) {
|
|
212
|
+
const util = this.editor.getShapeUtil(shape)
|
|
213
|
+
util.onTranslateCancel?.(shape, current)
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
|
|
206
217
|
this.reset()
|
|
207
218
|
if (this.info.onInteractionEnd) {
|
|
208
219
|
this.editor.setCurrentTool(this.info.onInteractionEnd)
|
package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx
CHANGED
|
@@ -210,9 +210,49 @@ export function DefaultKeyboardShortcutsDialogContent() {
|
|
|
210
210
|
/* do nothing */
|
|
211
211
|
}}
|
|
212
212
|
/>
|
|
213
|
+
<TldrawUiMenuItem
|
|
214
|
+
id="a11y-rotate-shape-cw"
|
|
215
|
+
label="a11y.rotate-shape-cw"
|
|
216
|
+
kbd="shift+﹥"
|
|
217
|
+
onSelect={() => {
|
|
218
|
+
/* do nothing */
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
<TldrawUiMenuItem
|
|
222
|
+
id="a11y-rotate-shape-cw-fine"
|
|
223
|
+
label="a11y.rotate-shape-cw-fine"
|
|
224
|
+
kbd="shift+alt+﹥"
|
|
225
|
+
onSelect={() => {
|
|
226
|
+
/* do nothing */
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
<TldrawUiMenuItem
|
|
230
|
+
id="a11y-rotate-shape-ccw"
|
|
231
|
+
label="a11y.rotate-shape-ccw"
|
|
232
|
+
kbd="shift+﹤"
|
|
233
|
+
onSelect={() => {
|
|
234
|
+
/* do nothing */
|
|
235
|
+
}}
|
|
236
|
+
/>
|
|
237
|
+
<TldrawUiMenuItem
|
|
238
|
+
id="a11y-rotate-shape-ccw-fine"
|
|
239
|
+
label="a11y.rotate-shape-ccw-fine"
|
|
240
|
+
kbd="shift+alt+﹤"
|
|
241
|
+
onSelect={() => {
|
|
242
|
+
/* do nothing */
|
|
243
|
+
}}
|
|
244
|
+
/>
|
|
213
245
|
<TldrawUiMenuActionItem actionId="enlarge-shapes" />
|
|
214
246
|
<TldrawUiMenuActionItem actionId="shrink-shapes" />
|
|
215
247
|
<TldrawUiMenuActionItem actionId="a11y-repeat-shape-announce" />
|
|
248
|
+
<TldrawUiMenuItem
|
|
249
|
+
id="a11y-open-keyboard-shortcuts"
|
|
250
|
+
label="a11y.open-keyboard-shortcuts"
|
|
251
|
+
kbd="cmd+alt+/"
|
|
252
|
+
onSelect={() => {
|
|
253
|
+
/* do nothing */
|
|
254
|
+
}}
|
|
255
|
+
/>
|
|
216
256
|
</TldrawUiMenuGroup>
|
|
217
257
|
{showCollaborationUi && (
|
|
218
258
|
<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
|
</>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultSpinner } from '@tldraw/editor'
|
|
1
2
|
import React from 'react'
|
|
2
3
|
import { useTranslation } from '../hooks/useTranslation/useTranslation'
|
|
3
4
|
|
|
@@ -5,28 +6,5 @@ import { useTranslation } from '../hooks/useTranslation/useTranslation'
|
|
|
5
6
|
export function Spinner(props: React.SVGProps<SVGSVGElement>) {
|
|
6
7
|
const msg = useTranslation()
|
|
7
8
|
|
|
8
|
-
return (
|
|
9
|
-
<svg
|
|
10
|
-
width={16}
|
|
11
|
-
height={16}
|
|
12
|
-
viewBox="0 0 16 16"
|
|
13
|
-
{...props}
|
|
14
|
-
aria-label={msg('app.loading')}
|
|
15
|
-
aria-hidden="false"
|
|
16
|
-
>
|
|
17
|
-
<g strokeWidth={2} fill="none" fillRule="evenodd">
|
|
18
|
-
<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke="currentColor" />
|
|
19
|
-
<path strokeLinecap="round" d="M15 8c0-4.5-4.5-7-7-7" stroke="currentColor">
|
|
20
|
-
<animateTransform
|
|
21
|
-
attributeName="transform"
|
|
22
|
-
type="rotate"
|
|
23
|
-
from="0 8 8"
|
|
24
|
-
to="360 8 8"
|
|
25
|
-
dur="1s"
|
|
26
|
-
repeatCount="indefinite"
|
|
27
|
-
/>
|
|
28
|
-
</path>
|
|
29
|
-
</g>
|
|
30
|
-
</svg>
|
|
31
|
-
)
|
|
9
|
+
return <DefaultSpinner aria-label={msg('app.loading')} {...props} />
|
|
32
10
|
}
|
|
@@ -6,10 +6,12 @@ import { useTranslation } from '../../hooks/useTranslation/useTranslation'
|
|
|
6
6
|
import { TldrawUiButton } from '../primitives/Button/TldrawUiButton'
|
|
7
7
|
import { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/** @public */
|
|
10
|
+
export interface ToggleToolLockedButtonProps {
|
|
10
11
|
activeToolId?: string
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
/** @public @react */
|
|
13
15
|
export function ToggleToolLockedButton({ activeToolId }: ToggleToolLockedButtonProps) {
|
|
14
16
|
const editor = useEditor()
|
|
15
17
|
const breakpoint = useBreakpoint()
|
|
@@ -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
|
)
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import classNames from 'classnames'
|
|
2
|
-
import { memo, useLayoutEffect, useRef } from 'react'
|
|
2
|
+
import { cloneElement, memo, ReactElement, useLayoutEffect, useRef } from 'react'
|
|
3
3
|
import { useAssetUrls } from '../../context/asset-urls'
|
|
4
4
|
import { TLUiIconType } from '../../icon-types'
|
|
5
5
|
|
|
6
|
+
/** @public */
|
|
7
|
+
export type TLUiIconJsx = ReactElement<React.HTMLAttributes<HTMLDivElement>>
|
|
8
|
+
|
|
6
9
|
/** @public */
|
|
7
10
|
export interface TLUiIconProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
icon: TLUiIconType | Exclude<string, TLUiIconType>
|
|
11
|
+
icon: TLUiIconType | Exclude<string, TLUiIconType> | TLUiIconJsx
|
|
9
12
|
label: string
|
|
10
13
|
small?: boolean
|
|
11
14
|
color?: string
|
|
@@ -24,6 +27,41 @@ export const TldrawUiIcon = memo(function TldrawUiIcon({
|
|
|
24
27
|
className,
|
|
25
28
|
...props
|
|
26
29
|
}: TLUiIconProps) {
|
|
30
|
+
if (typeof icon === 'string') {
|
|
31
|
+
return (
|
|
32
|
+
<TldrawUIIconInner
|
|
33
|
+
label={label}
|
|
34
|
+
small={small}
|
|
35
|
+
invertIcon={invertIcon}
|
|
36
|
+
icon={icon}
|
|
37
|
+
color={color}
|
|
38
|
+
className={className}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return cloneElement(icon, {
|
|
45
|
+
...props,
|
|
46
|
+
className: classNames({ 'tlui-icon__small': small }, className, icon.props.className),
|
|
47
|
+
'aria-label': label,
|
|
48
|
+
style: {
|
|
49
|
+
color,
|
|
50
|
+
transform: invertIcon ? 'scale(-1, 1)' : undefined,
|
|
51
|
+
...icon.props.style,
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
function TldrawUIIconInner({
|
|
57
|
+
label,
|
|
58
|
+
small,
|
|
59
|
+
invertIcon,
|
|
60
|
+
icon,
|
|
61
|
+
color,
|
|
62
|
+
className,
|
|
63
|
+
...props
|
|
64
|
+
}: TLUiIconProps & { icon: TLUiIconType | Exclude<string, TLUiIconType> }) {
|
|
27
65
|
const assetUrls = useAssetUrls()
|
|
28
66
|
const asset = assetUrls.icons[icon as TLUiIconType] ?? assetUrls.icons['question-mark-circle']
|
|
29
67
|
const ref = useRef<HTMLDivElement>(null)
|
|
@@ -69,4 +107,4 @@ export const TldrawUiIcon = memo(function TldrawUiIcon({
|
|
|
69
107
|
}}
|
|
70
108
|
/>
|
|
71
109
|
)
|
|
72
|
-
}
|
|
110
|
+
}
|
|
@@ -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,10 @@ 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}
|
|
89
|
+
aria-label={title + ' — ' + msg(label as TLUiTranslationKey)}
|
|
85
90
|
className="tlui-slider__thumb"
|
|
86
91
|
dir="ltr"
|
|
87
92
|
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}
|
|
@@ -5,7 +5,7 @@ import { TLUiEventSource } from '../../../context/events'
|
|
|
5
5
|
import { useReadonly } from '../../../hooks/useReadonly'
|
|
6
6
|
import { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'
|
|
7
7
|
import { useTranslation } from '../../../hooks/useTranslation/useTranslation'
|
|
8
|
-
import { TldrawUiIcon } from '../TldrawUiIcon'
|
|
8
|
+
import { TldrawUiIcon, TLUiIconJsx } from '../TldrawUiIcon'
|
|
9
9
|
import { TldrawUiKbd } from '../TldrawUiKbd'
|
|
10
10
|
import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ export interface TLUiMenuCheckboxItemProps<
|
|
|
14
14
|
TranslationKey extends string = string,
|
|
15
15
|
IconType extends string = string,
|
|
16
16
|
> {
|
|
17
|
-
icon?: IconType
|
|
17
|
+
icon?: IconType | TLUiIconJsx
|
|
18
18
|
id: string
|
|
19
19
|
kbd?: string
|
|
20
20
|
title?: string
|
|
@@ -12,6 +12,7 @@ import { TldrawUiButton } from '../Button/TldrawUiButton'
|
|
|
12
12
|
import { TldrawUiButtonIcon } from '../Button/TldrawUiButtonIcon'
|
|
13
13
|
import { TldrawUiButtonLabel } from '../Button/TldrawUiButtonLabel'
|
|
14
14
|
import { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'
|
|
15
|
+
import { TLUiIconJsx } from '../TldrawUiIcon'
|
|
15
16
|
import { TldrawUiKbd } from '../TldrawUiKbd'
|
|
16
17
|
import { TldrawUiToolbarButton } from '../TldrawUiToolbar'
|
|
17
18
|
import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
|
|
@@ -25,11 +26,11 @@ export interface TLUiMenuItemProps<
|
|
|
25
26
|
/**
|
|
26
27
|
* The icon to display on the item. Icons are only shown in certain menu types.
|
|
27
28
|
*/
|
|
28
|
-
icon?: IconType
|
|
29
|
+
icon?: IconType | TLUiIconJsx
|
|
29
30
|
/**
|
|
30
31
|
* An icon to display to the left of the menu item.
|
|
31
32
|
*/
|
|
32
|
-
iconLeft?: IconType
|
|
33
|
+
iconLeft?: IconType | TLUiIconJsx
|
|
33
34
|
/**
|
|
34
35
|
* The keyboard shortcut to display on the item.
|
|
35
36
|
*/
|
|
@@ -218,7 +219,6 @@ export function TldrawUiMenuItem<
|
|
|
218
219
|
preventDefault(e)
|
|
219
220
|
onSelect('toolbar')
|
|
220
221
|
}}
|
|
221
|
-
role="option"
|
|
222
222
|
title={titleStr}
|
|
223
223
|
type="tool"
|
|
224
224
|
>
|
|
@@ -237,7 +237,6 @@ export function TldrawUiMenuItem<
|
|
|
237
237
|
data-value={id}
|
|
238
238
|
disabled={disabled}
|
|
239
239
|
onClick={() => onSelect('toolbar')}
|
|
240
|
-
role="option"
|
|
241
240
|
title={titleStr}
|
|
242
241
|
type="icon"
|
|
243
242
|
>
|
|
@@ -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'
|
|
@@ -42,12 +43,13 @@ export interface TLUiActionItem<
|
|
|
42
43
|
TransationKey extends string = string,
|
|
43
44
|
IconType extends string = string,
|
|
44
45
|
> {
|
|
45
|
-
icon?: IconType
|
|
46
|
+
icon?: IconType | React.ReactElement
|
|
46
47
|
id: string
|
|
47
48
|
kbd?: string
|
|
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
|
|
|
@@ -1027,17 +1037,20 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1027
1037
|
id: 'rotate-cw',
|
|
1028
1038
|
label: 'action.rotate-cw',
|
|
1029
1039
|
icon: 'rotate-cw',
|
|
1040
|
+
kbd: 'shift+.,shift+alt+.',
|
|
1030
1041
|
onSelect(source) {
|
|
1031
1042
|
if (!canApplySelectionAction()) return
|
|
1032
1043
|
if (mustGoBackToSelectToolFirst()) return
|
|
1033
1044
|
|
|
1034
|
-
|
|
1045
|
+
const isFine = editor.inputs.altKey
|
|
1046
|
+
trackEvent('rotate-cw', { source, fine: isFine })
|
|
1035
1047
|
editor.markHistoryStoppingPoint('rotate-cw')
|
|
1036
1048
|
editor.run(() => {
|
|
1037
|
-
const
|
|
1038
|
-
const
|
|
1049
|
+
const rotation = HALF_PI / (isFine ? 96 : 6)
|
|
1050
|
+
const offset = editor.getSelectionRotation() % rotation
|
|
1051
|
+
const dontUseOffset = approximately(offset, 0) || approximately(offset, rotation)
|
|
1039
1052
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
1040
|
-
editor.rotateShapesBy(selectedShapeIds,
|
|
1053
|
+
editor.rotateShapesBy(selectedShapeIds, rotation - (dontUseOffset ? 0 : offset))
|
|
1041
1054
|
kickoutOccludedShapes(editor, selectedShapeIds)
|
|
1042
1055
|
})
|
|
1043
1056
|
},
|
|
@@ -1046,17 +1059,21 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1046
1059
|
id: 'rotate-ccw',
|
|
1047
1060
|
label: 'action.rotate-ccw',
|
|
1048
1061
|
icon: 'rotate-ccw',
|
|
1062
|
+
// omg double comma
|
|
1063
|
+
kbd: 'shift+,,shift+alt+,',
|
|
1049
1064
|
onSelect(source) {
|
|
1050
1065
|
if (!canApplySelectionAction()) return
|
|
1051
1066
|
if (mustGoBackToSelectToolFirst()) return
|
|
1052
1067
|
|
|
1053
|
-
|
|
1068
|
+
const isFine = editor.inputs.altKey
|
|
1069
|
+
trackEvent('rotate-ccw', { source, fine: isFine })
|
|
1054
1070
|
editor.markHistoryStoppingPoint('rotate-ccw')
|
|
1055
1071
|
editor.run(() => {
|
|
1056
|
-
const
|
|
1072
|
+
const rotation = HALF_PI / (isFine ? 96 : 6)
|
|
1073
|
+
const offset = editor.getSelectionRotation() % rotation
|
|
1057
1074
|
const offsetCloseToZero = approximately(offset, 0)
|
|
1058
1075
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
1059
|
-
editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -
|
|
1076
|
+
editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -rotation : -offset)
|
|
1060
1077
|
kickoutOccludedShapes(editor, selectedShapeIds)
|
|
1061
1078
|
})
|
|
1062
1079
|
},
|
|
@@ -1234,6 +1251,21 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1234
1251
|
},
|
|
1235
1252
|
checkbox: true,
|
|
1236
1253
|
},
|
|
1254
|
+
{
|
|
1255
|
+
id: 'toggle-keyboard-shortcuts',
|
|
1256
|
+
label: {
|
|
1257
|
+
default: 'action.toggle-keyboard-shortcuts',
|
|
1258
|
+
menu: 'action.toggle-keyboard-shortcuts.menu',
|
|
1259
|
+
},
|
|
1260
|
+
readonlyOk: true,
|
|
1261
|
+
onSelect(source) {
|
|
1262
|
+
trackEvent('toggle-keyboard-shortcuts', { source })
|
|
1263
|
+
editor.user.updateUserPreferences({
|
|
1264
|
+
areKeyboardShortcutsEnabled: !editor.user.getAreKeyboardShortcutsEnabled(),
|
|
1265
|
+
})
|
|
1266
|
+
},
|
|
1267
|
+
checkbox: true,
|
|
1268
|
+
},
|
|
1237
1269
|
{
|
|
1238
1270
|
id: 'toggle-edge-scrolling',
|
|
1239
1271
|
label: {
|
|
@@ -1530,6 +1562,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1530
1562
|
id: 'adjust-shape-styles',
|
|
1531
1563
|
label: 'a11y.adjust-shape-styles',
|
|
1532
1564
|
kbd: 'cmd+Enter,ctrl+Enter',
|
|
1565
|
+
isRequiredA11yAction: true,
|
|
1533
1566
|
onSelect: async (source) => {
|
|
1534
1567
|
if (!canApplySelectionAction()) return
|
|
1535
1568
|
|
|
@@ -1543,6 +1576,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1543
1576
|
{
|
|
1544
1577
|
id: 'a11y-open-context-menu',
|
|
1545
1578
|
kbd: 'cmd+shift+Enter,ctrl+shift+Enter',
|
|
1579
|
+
isRequiredA11yAction: true,
|
|
1546
1580
|
readonlyOk: true,
|
|
1547
1581
|
onSelect: async (source) => {
|
|
1548
1582
|
if (!canApplySelectionAction()) return
|
|
@@ -1595,6 +1629,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1595
1629
|
id: 'a11y-repeat-shape-announce',
|
|
1596
1630
|
kbd: 'alt+r',
|
|
1597
1631
|
label: 'a11y.repeat-shape',
|
|
1632
|
+
isRequiredA11yAction: true,
|
|
1598
1633
|
readonlyOk: true,
|
|
1599
1634
|
onSelect: async (source) => {
|
|
1600
1635
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
@@ -76,8 +76,8 @@ export interface TLUiEventMap {
|
|
|
76
76
|
'delete-shapes': null
|
|
77
77
|
'select-all-shapes': null
|
|
78
78
|
'select-none-shapes': null
|
|
79
|
-
'rotate-ccw':
|
|
80
|
-
'rotate-cw':
|
|
79
|
+
'rotate-ccw': { fine: boolean }
|
|
80
|
+
'rotate-cw': { fine: boolean }
|
|
81
81
|
'zoom-in': { towardsCursor: boolean }
|
|
82
82
|
'zoom-out': { towardsCursor: boolean }
|
|
83
83
|
'zoom-to-fit': null
|
|
@@ -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'
|