fix: add letter shortcuts to some shapes

This commit is contained in:
Peng Xiao
2022-12-06 12:42:08 +08:00
committed by Tienson Qin
parent feb6c2687b
commit 6ee380e3fc
8 changed files with 9 additions and 8 deletions

View File

@@ -24,9 +24,9 @@ export const ToolButton = observer(({ id, icon, title, ...props }: ToolButtonPro
// Tool must exist
const Tool = [...app.Tools, TLSelectTool, TLMoveTool]?.find(T => T.id === id)
const shortcut = ((Tool as any)['shortcut'] as string[])?.[0]
const shortcut = ((Tool as any)['shortcut'] as string[])?.join(', ').toUpperCase()
const titleWithShortcut = shortcut ? `${title} (${shortcut})` : title
const titleWithShortcut = shortcut ? `${title} - ${shortcut}` : title
return (
<Button
{...props}

View File

@@ -4,6 +4,6 @@ import { BoxShape, type Shape } from '../shapes'
export class BoxTool extends TLBoxTool<BoxShape, Shape, TLReactEventMap> {
static id = 'box'
static shortcut = ['7']
static shortcut = ['7', 'r']
Shape = BoxShape
}

View File

@@ -4,5 +4,6 @@ import { EllipseShape, type Shape } from '../shapes'
export class EllipseTool extends TLBoxTool<EllipseShape, Shape, TLReactEventMap> {
static id = 'ellipse'
static shortcut = ['o']
Shape = EllipseShape
}

View File

@@ -4,5 +4,5 @@ import type { Shape } from '../shapes'
export class NuEraseTool extends TLEraseTool<Shape, TLReactEventMap> {
static id = 'erase'
static shortcut = ['4']
static shortcut = ['4', 'e']
}

View File

@@ -4,7 +4,7 @@ import { HighlighterShape, type Shape } from '../shapes'
export class HighlighterTool extends TLDrawTool<HighlighterShape, Shape, TLReactEventMap> {
static id = 'highlighter'
static shortcut = ['3']
static shortcut = ['3', 'h']
Shape = HighlighterShape
simplify = true
simplifyTolerance = 0.618

View File

@@ -4,6 +4,6 @@ import { TextShape, type Shape } from '../shapes'
export class TextTool extends TLTextTool<TextShape, Shape, TLReactEventMap> {
static id = 'text'
static shortcut = ['6']
static shortcut = ['6', 't']
Shape = TextShape
}

View File

@@ -10,7 +10,7 @@ export class TLMoveTool<
R extends TLApp<S, K> = TLApp<S, K>
> extends TLTool<S, K, R> {
static id = 'move'
static shortcut = ['9']
static shortcut = ['m', '9']
static states = [IdleState, IdleHoldState, PanningState, PinchingState]

View File

@@ -33,7 +33,7 @@ export class TLSelectTool<
static initial = 'idle'
static shortcut = ['8']
static shortcut = ['s', '8']
static states = [
IdleState,